Skip to content

Commit 1bccfda

Browse files
author
Giannis Roussos
committed
FileVersion and FileRevision read correctly from XDD
1 parent 586e2a1 commit 1bccfda

5 files changed

Lines changed: 38 additions & 15 deletions

File tree

EDSEditorGUI/DeviceInfoView.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void populatedeviceinfo()
4747
textBox_revisionnumber.Text = eds.di.RevisionNumber.ToHexString();
4848
textBox_ordercode.Text = eds.di.OrderCode;
4949

50-
textBox_fileversion.Text = eds.fi.FileVersion.ToString();
50+
textBox_fileversion.Text = eds.fi.fileVersionString;
5151
textBox_di_description.Text = eds.fi.Description;
5252
textBox_create_datetime.Text = eds.fi.CreationDateTime.ToString();
5353
textBox_createdby.Text = eds.fi.CreatedBy;
@@ -139,13 +139,13 @@ private void update_devfile_info()
139139
try
140140
{
141141
eds.di.ProductName = textBox_productname.Text;
142-
eds.di.ProductNumber = UInt32.Parse(textBox_productnumber.Text);
142+
eds.di.ProductNumber = EDSsharp.U32Parse(textBox_productnumber.Text);
143143
eds.di.VendorName = textBox_vendorname.Text;
144-
eds.di.VendorNumber = UInt32.Parse(textBox_vendornumber.Text);
145-
eds.di.RevisionNumber = UInt32.Parse(textBox_revisionnumber.Text);
144+
eds.di.VendorNumber = EDSsharp.U32Parse(textBox_vendornumber.Text);
145+
eds.di.RevisionNumber = EDSsharp.U32Parse(textBox_revisionnumber.Text);
146146
eds.di.OrderCode = textBox_ordercode.Text;
147147

148-
eds.fi.FileVersion = Byte.Parse(textBox_fileversion.Text);
148+
eds.fi.fileVersionString = textBox_fileversion.Text;
149149
eds.fi.Description = textBox_di_description.Text;
150150
eds.fi.CreationDateTime = DateTime.Parse(textBox_create_datetime.Text);
151151
eds.fi.CreatedBy = textBox_createdby.Text;

libEDSsharp/CanOpenEDS.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,17 @@ void ApplycompactPDO(UInt16 index)
10251025
}
10261026
}
10271027
}
1028+
public static UInt32 U32Parse(string str)
1029+
{
1030+
if (str.Trim().ToLower().StartsWith("0x"))
1031+
{
1032+
return System.Convert.ToUInt32(str, 16);
1033+
}
1034+
else
1035+
{
1036+
return System.Convert.ToUInt32(str);
1037+
}
1038+
}
10281039

10291040
/// <summary>
10301041
/// This function scans the PDO list and compares it to NrOfRXPDO and NrOfTXPDO
@@ -1064,7 +1075,15 @@ protected void ApplyimplicitPDO()
10641075
}
10651076
UpdatePDOcount();
10661077
}
1067-
1078+
private void GetEDSFileInfo()
1079+
{
1080+
string[] nums = fi.fileVersionString.Split('.');
1081+
if (nums.Length == 2)
1082+
{
1083+
byte.TryParse(nums[0], out fi.FileVersion);
1084+
byte.TryParse(nums[1], out fi.FileRevision);
1085+
}
1086+
}
10681087
public void Savefile(string filename, InfoSection.Filetype ft)
10691088
{
10701089
if (ft == InfoSection.Filetype.File_EDS)
@@ -1092,6 +1111,8 @@ public void Savefile(string filename, InfoSection.Filetype ft)
10921111
fi.EDSVersionMajor = 4;
10931112
fi.EDSVersionMinor = 0;
10941113

1114+
GetEDSFileInfo();
1115+
10951116
StreamWriter writer = System.IO.File.CreateText(filename);
10961117
writer.NewLine = "\n";
10971118
fi.Write(writer, ft);

libEDSsharp/CanOpenXDD_1_1.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ private ISO15745ProfileContainer Convert(EDSsharp eds, string fileName, bool dev
941941
body_device.fileCreationDate = eds.fi.CreationDateTime;
942942
body_device.fileCreationTime = eds.fi.CreationDateTime;
943943
body_device.fileCreationTimeSpecified = true;
944-
body_device.fileVersion = eds.fi.FileVersion.ToString();
944+
body_device.fileVersion = eds.fi.fileVersionString;
945945
body_device.fileModifiedBy = eds.fi.ModifiedBy;
946946
body_device.fileModificationDate = eds.fi.ModificationDateTime;
947947
body_device.fileModificationTime = eds.fi.ModificationDateTime;
@@ -1052,7 +1052,7 @@ private ISO15745ProfileContainer Convert(EDSsharp eds, string fileName, bool dev
10521052
body_network.fileCreationDate = eds.fi.CreationDateTime;
10531053
body_network.fileCreationTime = eds.fi.CreationDateTime;
10541054
body_network.fileCreationTimeSpecified = true;
1055-
body_network.fileVersion = eds.fi.FileVersion.ToString();
1055+
body_network.fileVersion = eds.fi.FileVersion.ToString() + "." + eds.fi.FileRevision.ToString();
10561056
body_network.fileModificationDate = eds.fi.ModificationDateTime;
10571057
body_network.fileModificationTime = eds.fi.ModificationDateTime;
10581058
body_network.fileModificationDateSpecified = true;
@@ -1213,7 +1213,6 @@ private string G_label_getDescription(object[] items) {
12131213
}
12141214
return "";
12151215
}
1216-
12171216
private EDSsharp Convert(ISO15745ProfileContainer container)
12181217
{
12191218
EDSsharp eds = new EDSsharp();
@@ -1234,7 +1233,7 @@ private EDSsharp Convert(ISO15745ProfileContainer container)
12341233
if (body_device != null)
12351234
{
12361235
eds.fi.FileName = body_device.fileName ?? "";
1237-
eds.fi.FileVersion = Byte.Parse(body_device.fileVersion ?? "0");
1236+
eds.fi.fileVersionString = body_device.fileVersion ?? "";
12381237
eds.fi.CreatedBy = body_device.fileCreator ?? "";
12391238
eds.fi.ModifiedBy = body_device.fileModifiedBy ?? "";
12401239

@@ -1257,15 +1256,15 @@ private EDSsharp Convert(ISO15745ProfileContainer container)
12571256
if (body_device.DeviceIdentity.vendorName != null)
12581257
eds.di.VendorName = body_device.DeviceIdentity.vendorName.Value ?? "";
12591258
if (body_device.DeviceIdentity.vendorID != null)
1260-
eds.di.VendorNumber = UInt32.Parse(body_device.DeviceIdentity.vendorID.Value ?? "0");
1259+
eds.di.VendorNumber = EDSsharp.U32Parse(body_device.DeviceIdentity.vendorID.Value ?? "0");
12611260
if (body_device.DeviceIdentity.revisionNumber != null)
12621261
eds.di.RevisionNumber = body_device.DeviceIdentity.revisionNumber.Value;
12631262
if (body_device.DeviceIdentity.orderCode != null)
12641263
eds.di.OrderCode = body_device.DeviceIdentity.orderCode.Value ?? "";
12651264
if (body_device.DeviceIdentity.productName != null)
12661265
eds.di.ProductName = body_device.DeviceIdentity.productName.Value ?? "";
12671266
if (body_device.DeviceIdentity.productID != null)
1268-
eds.di.ProductNumber = UInt32.Parse(body_device.DeviceIdentity.productID.Value ?? "0");
1267+
eds.di.ProductNumber = EDSsharp.U32Parse(body_device.DeviceIdentity.productID.Value ?? "0");
12691268
if (body_device.DeviceIdentity.productText != null)
12701269
eds.fi.Description = G_label_getDescription(body_device.DeviceIdentity.productText.Items);
12711270
}

libEDSsharp/eds.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ public FileInfo()
654654
{
655655
infoheader = "CAN OPEN FileInfo";
656656
edssection = "FileInfo";
657+
FileVersion = 1;
658+
FileRevision = 0;
657659
}
658660
}
659661

@@ -1822,9 +1824,6 @@ public EDSsharp()
18221824
fi.EDSVersionMajor = 4;
18231825
fi.EDSVersionMinor = 0;
18241826

1825-
fi.FileVersion = 1;
1826-
fi.FileRevision = 1;
1827-
18281827
fi.CreationDateTime = DateTime.Now;
18291828
fi.ModificationDateTime = DateTime.Now;
18301829

libEDSsharp/proto/CanOpen.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ message CanOpen_FileInfo
1919
message CanOpen_DeviceInfo
2020
{
2121
string vendorName = 1; // Vendor name.
22+
uint32 vendorID = 2; // Vendor ID
2223
string productName = 3; // Product name.
24+
uint32 productID = 4; // Product ID
25+
uint32 revisionNumber = 5; // Revision number
26+
string orderCode = 6; // Order code
2327
bool baudRate10 = 100; // Support of the baud rate 10 kbit/s.
2428
bool baudRate20 = 101; // Support of the baud rate 20 kbit/s.
2529
bool baudRate50 = 102; // Support of the baud rate 50 kbit/s.

0 commit comments

Comments
 (0)