Skip to content

Commit e51e4f5

Browse files
Add in Extra Device Info Fields to xml Fixes #48
Add in the extra fields to the xml, make the CharacteristicsList actualy a list of Characteristics and use it to store the various extra device info properties we have. This with the previous commit should complete the fix.
1 parent 0603ce3 commit e51e4f5

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

‎.vs/EDSEditor/v14/.suo‎

62 KB
Binary file not shown.

‎libEDSsharp/Bridge.cs‎

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@ public Device convert(EDSsharp eds)
187187
dev.Other.BaudRate.SupportedBaudRate.Add(baud);
188188

189189

190+
dev.Other.Capabilities = new Capabilities();
191+
dev.Other.Capabilities.CharacteristicsList = new CharacteristicsList();
192+
dev.Other.Capabilities.CharacteristicsList.Characteristic = new List<Characteristic>();
193+
194+
195+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("SimpleBootUpSlave", eds.di.SimpleBootUpSlave.ToString()));
196+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("SimpleBootUpMaster", eds.di.SimpleBootUpMaster.ToString()));
197+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("DynamicChannelsSupported", eds.di.DynamicChannelsSupported.ToString()));
198+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("CompactPDO", eds.di.CompactPDO.ToString()));
199+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("GroupMessaging", eds.di.GroupMessaging.ToString()));
200+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("LSS_Supported", eds.di.LSS_Supported.ToString()));
201+
202+
dev.Other.Capabilities.CharacteristicsList.Characteristic.Add(makecharcteristic("Granularity", eds.di.Granularity.ToString()));
203+
190204
dev.Other.DeviceIdentity = new DeviceIdentity();
191205
dev.Other.DeviceIdentity.ProductName = eds.di.ProductName;
192206
dev.Other.DeviceIdentity.ProductNumber = eds.di.ProductNumber;
@@ -222,6 +236,21 @@ public Device convert(EDSsharp eds)
222236
}
223237

224238

239+
public Characteristic makecharcteristic(string name,string content)
240+
{
241+
Characteristic cl = new Characteristic();
242+
243+
cl.CharacteristicName = new CharacteristicName();
244+
cl.CharacteristicContent = new CharacteristicContent();
245+
cl.CharacteristicContent.Label = new Label();
246+
cl.CharacteristicName.Label = new Label();
247+
248+
cl.CharacteristicName.Label.Text = name;
249+
cl.CharacteristicContent.Label.Text = content;
250+
251+
return cl;
252+
}
253+
225254
public EDSsharp convert(Device dev)
226255
{
227256
EDSsharp eds = new EDSsharp();
@@ -397,6 +426,44 @@ public EDSsharp convert(Device dev)
397426

398427
}
399428

429+
Dictionary<string, string> keypairs = new Dictionary<string, string>();
430+
431+
432+
if (dev.Other.Capabilities.CharacteristicsList != null)
433+
{
434+
foreach (Characteristic c in dev.Other.Capabilities.CharacteristicsList.Characteristic)
435+
{
436+
try
437+
{
438+
keypairs.Add(c.CharacteristicName.Label.Text, c.CharacteristicContent.Label.Text);
439+
}
440+
catch (Exception e)
441+
{
442+
// Warnings.warning_list.Add("Parsing characteristics failed " + e.ToString());
443+
}
444+
}
445+
}
446+
447+
448+
bool boolout;
449+
if (keypairs.ContainsKey("SimpleBootUpSlave") && bool.TryParse(keypairs["SimpleBootUpSlave"], out boolout))
450+
eds.di.SimpleBootUpSlave = boolout;
451+
if (keypairs.ContainsKey("SimpleBootUpMaster") && bool.TryParse(keypairs["SimpleBootUpMaster"], out boolout))
452+
eds.di.SimpleBootUpMaster = boolout;
453+
if (keypairs.ContainsKey("DynamicChannelsSupported") && bool.TryParse(keypairs["DynamicChannelsSupported"], out boolout))
454+
eds.di.DynamicChannelsSupported = boolout;
455+
if (keypairs.ContainsKey("CompactPDO") && bool.TryParse(keypairs["CompactPDO"], out boolout))
456+
eds.di.CompactPDO = boolout;
457+
if (keypairs.ContainsKey("GroupMessaging") && bool.TryParse(keypairs["GroupMessaging"], out boolout))
458+
eds.di.GroupMessaging = boolout;
459+
if (keypairs.ContainsKey("LSS_Supported") && bool.TryParse(keypairs["LSS_Supported"], out boolout))
460+
eds.di.LSS_Supported = boolout;
461+
462+
byte byteout;
463+
if (keypairs.ContainsKey("Granularity") && byte.TryParse(keypairs["Granularity"], out byteout))
464+
eds.di.Granularity = byteout;
465+
466+
400467
eds.di.ProductName = dev.Other.DeviceIdentity.ProductName;
401468
eds.di.ProductNumber = dev.Other.DeviceIdentity.ProductNumber;
402469

@@ -456,7 +523,17 @@ public EDSsharp convert(Device dev)
456523
catch (Exception e)
457524
{
458525
if (dev.Other.File != null)
459-
Warnings.warning_list.Add(String.Format("Unable to parse FileVersion\"{0}\" {1}", dev.Other.File.FileVersion,e.ToString()));
526+
{
527+
// CanOpenNode default project.xml conatins - for fileversion, its suspose to be a byte field according to DS306
528+
if (dev.Other.File.FileVersion == "-")
529+
{
530+
dev.Other.File.FileVersion = "0";
531+
}
532+
else
533+
{
534+
Warnings.warning_list.Add(String.Format("Unable to parse FileVersion\"{0}\" {1}", dev.Other.File.FileVersion, e.ToString()));
535+
}
536+
}
460537

461538
eds.fi.FileVersion = 0;
462539
}

‎libEDSsharp/CanOpenXML.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public class Characteristic {
257257
[XmlRoot(ElementName="characteristicsList")]
258258
public class CharacteristicsList {
259259
[XmlElement(ElementName="characteristic")]
260-
public Characteristic Characteristic { get; set; }
260+
public List<Characteristic> Characteristic { get; set; }
261261
}
262262

263263
[XmlRoot(ElementName="capabilities")]

0 commit comments

Comments
 (0)