Skip to content

Commit 1f9af8d

Browse files
author
Giannis Roussos
committed
Working on FileVersion & FileRevision
1 parent b4f6e3c commit 1f9af8d

File tree

6 files changed

+34
-33
lines changed

6 files changed

+34
-33
lines changed

EDSEditorGUI/DeviceInfoView.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public License
1717
Copyright(c) 2016 - 2019 Robin Cornelius <[email protected]>
1818
*/
1919

20-
using System;
21-
using System.Windows.Forms;
2220
using libEDSsharp;
21+
using System;
22+
using System.Drawing;
23+
using System.Globalization;
2324
using System.IO;
2425
using System.Runtime.CompilerServices;
25-
using System.Drawing;
26+
using System.Windows.Forms;
2627

2728
namespace ODEditor
2829
{
@@ -41,13 +42,13 @@ public void populatedeviceinfo()
4142
return;
4243

4344
textBox_productname.Text = eds.di.ProductName;
44-
textBox_productnumber.Text = eds.di.ProductNumber;
45+
textBox_productnumber.Text = eds.di.ProductNumber.ToHexString();
4546
textBox_vendorname.Text = eds.di.VendorName;
46-
textBox_vendornumber.Text = eds.di.VendorNumber;
47-
textBox_revisionnumber.Text = string.Format("0x{0:x8}", eds.di.RevisionNumber);
47+
textBox_vendornumber.Text = eds.di.VendorNumber.ToHexString();
48+
textBox_revisionnumber.Text = eds.di.RevisionNumber.ToHexString();
4849
textBox_ordercode.Text = eds.di.OrderCode;
4950

50-
textBox_fileversion.Text = eds.fi.FileVersion;
51+
textBox_fileversion.Text = eds.fi.FileVersion.ToString();
5152
textBox_di_description.Text = eds.fi.Description;
5253
textBox_create_datetime.Text = eds.fi.CreationDateTime.ToString();
5354
textBox_createdby.Text = eds.fi.CreatedBy;
@@ -139,13 +140,13 @@ private void update_devfile_info()
139140
try
140141
{
141142
eds.di.ProductName = textBox_productname.Text;
142-
eds.di.ProductNumber = textBox_productnumber.Text;
143+
eds.di.ProductNumber = UInt32.Parse(textBox_productnumber.Text);
143144
eds.di.VendorName = textBox_vendorname.Text;
144-
eds.di.VendorNumber = textBox_vendornumber.Text;
145-
eds.di.RevisionNumber = Convert.ToUInt32(textBox_revisionnumber.Text,16);
145+
eds.di.VendorNumber = UInt32.Parse(textBox_vendornumber.Text);
146+
eds.di.RevisionNumber = UInt32.Parse(textBox_revisionnumber.Text);
146147
eds.di.OrderCode = textBox_ordercode.Text;
147148

148-
eds.fi.FileVersion = textBox_fileversion.Text;
149+
eds.fi.FileVersion = Byte.Parse(textBox_fileversion.Text);
149150
eds.fi.Description = textBox_di_description.Text;
150151
eds.fi.CreationDateTime = DateTime.Parse(textBox_create_datetime.Text);
151152
eds.fi.CreatedBy = textBox_createdby.Text;

EDSEditorGUI/Form1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ private void openXDDfile(string path)
367367
}
368368
catch (Exception ex)
369369
{
370+
throw ex;
370371
Warnings.warning_list.Add(ex.ToString());
371372
}
372373

libEDSsharp/CanOpenXDD.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public ISO15745ProfileContainer convert(EDSsharp eds)
240240
device.DeviceIdentity.vendorName.readOnly = true;
241241

242242
device.DeviceIdentity.vendorID = new vendorID();
243-
device.DeviceIdentity.vendorID.Value = eds.di.VendorNumber;
243+
device.DeviceIdentity.vendorID.Value = eds.di.VendorNumber.ToHexString();
244244
device.DeviceIdentity.vendorID.readOnly = true;
245245

246246
device.DeviceIdentity.deviceFamily = new deviceFamily();
@@ -263,7 +263,7 @@ public ISO15745ProfileContainer convert(EDSsharp eds)
263263

264264
device.supportedLanguages = "en";
265265

266-
device.fileVersion = eds.fi.FileVersion;
266+
device.fileVersion = eds.fi.FileVersion.ToString();
267267

268268
device.fileName = Path.GetFileName(eds.projectFilename);
269269

@@ -277,7 +277,7 @@ public ISO15745ProfileContainer convert(EDSsharp eds)
277277
device.DeviceIdentity.productName.readOnly = true;
278278

279279
device.DeviceIdentity.productID = new productID();
280-
device.DeviceIdentity.productID.Value = eds.di.ProductNumber;
280+
device.DeviceIdentity.productID.Value = eds.di.ProductNumber.ToHexString();
281281
device.DeviceIdentity.productID.readOnly = true;
282282

283283
device.DeviceIdentity.productText = new productText();
@@ -401,7 +401,7 @@ public ISO15745ProfileContainer convert(EDSsharp eds)
401401
comnet.fileModificationTime = eds.fi.ModificationDateTime;
402402
comnet.fileModificationDateSpecified = true;
403403

404-
comnet.fileVersion = eds.fi.FileVersion;
404+
comnet.fileVersion = eds.fi.FileVersion.ToString();
405405

406406
comnet.supportedLanguages = "en";
407407

@@ -1157,9 +1157,9 @@ public EDSsharp convert(ISO15745ProfileContainer container)
11571157
if (obj.DeviceIdentity != null)
11581158
{
11591159
eds.di.ProductName = obj.DeviceIdentity.productName.Value;
1160-
eds.di.ProductNumber = obj.DeviceIdentity.productID.Value;
1160+
eds.di.ProductNumber = UInt32.Parse(obj.DeviceIdentity.productID.Value);
11611161
eds.di.VendorName = obj.DeviceIdentity.vendorName.Value;
1162-
eds.di.VendorNumber = obj.DeviceIdentity.vendorID.Value;
1162+
eds.di.VendorNumber = UInt32.Parse(obj.DeviceIdentity.vendorID.Value);
11631163

11641164
foreach (object o in obj.DeviceIdentity.productText.Items)
11651165
{
@@ -1184,12 +1184,11 @@ public EDSsharp convert(ISO15745ProfileContainer container)
11841184
eds.fi.EDSVersion = keyvalue[1];
11851185
break;
11861186
case "FileRevision":
1187-
eds.fi.FileVersion = keyvalue[1];
1187+
byte.TryParse(keyvalue[1], out eds.fi.FileVersion);
11881188
break;
11891189
case "RevisionNum":
1190-
byte.TryParse(keyvalue[1], out eds.fi.FileRevision); break;
1191-
1192-
1190+
byte.TryParse(keyvalue[1], out eds.fi.FileRevision);
1191+
break;
11931192
}
11941193
}
11951194
}

libEDSsharp/CanOpenXDD_1_1.cs

Lines changed: 7 additions & 7 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;
944+
body_device.fileVersion = eds.fi.FileVersion.ToString();
945945
body_device.fileModifiedBy = eds.fi.ModifiedBy;
946946
body_device.fileModificationDate = eds.fi.ModificationDateTime;
947947
body_device.fileModificationTime = eds.fi.ModificationDateTime;
@@ -953,11 +953,11 @@ private ISO15745ProfileContainer Convert(EDSsharp eds, string fileName, bool dev
953953
if (body_device.DeviceIdentity == null)
954954
body_device.DeviceIdentity = new DeviceIdentity();
955955
body_device.DeviceIdentity.vendorName = new vendorName { Value = eds.di.VendorName };
956-
body_device.DeviceIdentity.vendorID = new vendorID { Value = eds.di.VendorNumber };
956+
body_device.DeviceIdentity.vendorID = new vendorID { Value = eds.di.VendorNumber.ToHexString() };
957957
body_device.DeviceIdentity.revisionNumber = new revisionNumber { Value = eds.di.RevisionNumber };
958958
body_device.DeviceIdentity.orderCode = new orderCode { Value = eds.di.OrderCode };
959959
body_device.DeviceIdentity.productName = new productName { Value = eds.di.ProductName };
960-
body_device.DeviceIdentity.productID = new productID { Value = eds.di.ProductNumber };
960+
body_device.DeviceIdentity.productID = new productID { Value = eds.di.ProductNumber.ToHexString() };
961961
if (eds.fi.Description != null && eds.fi.Description != "")
962962
{
963963
body_device.DeviceIdentity.productText = new productText
@@ -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;
1055+
body_network.fileVersion = eds.fi.FileVersion.ToString();
10561056
body_network.fileModificationDate = eds.fi.ModificationDateTime;
10571057
body_network.fileModificationTime = eds.fi.ModificationDateTime;
10581058
body_network.fileModificationDateSpecified = true;
@@ -1234,7 +1234,7 @@ private EDSsharp Convert(ISO15745ProfileContainer container)
12341234
if (body_device != null)
12351235
{
12361236
eds.fi.FileName = body_device.fileName ?? "";
1237-
eds.fi.FileVersion = body_device.fileVersion ?? "";
1237+
eds.fi.FileVersion = Byte.Parse(body_device.fileVersion ?? "0");
12381238
eds.fi.CreatedBy = body_device.fileCreator ?? "";
12391239
eds.fi.ModifiedBy = body_device.fileModifiedBy ?? "";
12401240

@@ -1257,15 +1257,15 @@ private EDSsharp Convert(ISO15745ProfileContainer container)
12571257
if (body_device.DeviceIdentity.vendorName != null)
12581258
eds.di.VendorName = body_device.DeviceIdentity.vendorName.Value ?? "";
12591259
if (body_device.DeviceIdentity.vendorID != null)
1260-
eds.di.VendorNumber = body_device.DeviceIdentity.vendorID.Value ?? "";
1260+
eds.di.VendorNumber = UInt32.Parse(body_device.DeviceIdentity.vendorID.Value ?? "0");
12611261
if (body_device.DeviceIdentity.revisionNumber != null)
12621262
eds.di.RevisionNumber = body_device.DeviceIdentity.revisionNumber.Value;
12631263
if (body_device.DeviceIdentity.orderCode != null)
12641264
eds.di.OrderCode = body_device.DeviceIdentity.orderCode.Value ?? "";
12651265
if (body_device.DeviceIdentity.productName != null)
12661266
eds.di.ProductName = body_device.DeviceIdentity.productName.Value ?? "";
12671267
if (body_device.DeviceIdentity.productID != null)
1268-
eds.di.ProductNumber = body_device.DeviceIdentity.productID.Value ?? "";
1268+
eds.di.ProductNumber = UInt32.Parse(body_device.DeviceIdentity.productID.Value ?? "0");
12691269
if (body_device.DeviceIdentity.productText != null)
12701270
eds.fi.Description = G_label_getDescription(body_device.DeviceIdentity.productText.Items);
12711271
}

libEDSsharp/eds.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public partial class FileInfo : InfoSection
582582
/// indicate the actual file version (Unsigned8)
583583
/// </summary>
584584
[EdsExport]
585-
public string FileVersion="";
585+
public byte FileVersion;//=1;
586586
/// <summary>
587587
/// indicate the actual file revision (Unsigned8)
588588
/// </summary>
@@ -664,7 +664,7 @@ public partial class DeviceInfo : InfoSection
664664
/// unique vendor ID according to identity object sub-index 01h (Unsigned32)
665665
/// </summary>
666666
[EdsExport]
667-
public string VendorNumber="";
667+
public UInt32 VendorNumber;
668668
/// <summary>
669669
/// product name (max. 243 characters)
670670
/// </summary>
@@ -674,7 +674,7 @@ public partial class DeviceInfo : InfoSection
674674
/// product code according to identity object sub-index 02h (Unsigned32)
675675
/// </summary>
676676
[EdsExport]
677-
public string ProductNumber="";
677+
public UInt32 ProductNumber;
678678
/// <summary>
679679
/// product revision number according to identity object sub-index 03h (Unsigned32)
680680
/// </summary>
@@ -1815,7 +1815,7 @@ public EDSsharp()
18151815
fi.EDSVersionMajor = 4;
18161816
fi.EDSVersionMinor = 0;
18171817

1818-
fi.FileVersion = "1";
1818+
fi.FileVersion = 1;
18191819
fi.FileRevision = 1;
18201820

18211821
fi.CreationDateTime = DateTime.Now;

libEDSsharp/libEDSsharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@
6464
</ItemGroup>
6565
</Target>
6666

67-
</Project>
67+
</Project>

0 commit comments

Comments
 (0)