Skip to content

Commit

Permalink
Use EDSSharp.ConvertTo functions instead of the default c# ones as mi…
Browse files Browse the repository at this point in the history
…ne are number base aware

and the default value that comes from an EDS may be in decimal,hex or octal as per the CanOpen EDS
specification. Fixes #41
  • Loading branch information
robincornelius committed Dec 12, 2016
1 parent 133a62c commit 9df069d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions EDSTest/DeviceODView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ private void addSubItemToolStripMenuItem_Click(object sender, EventArgs e)
newsub.subindex = (UInt16)od.parent.subobjects.Count;
od.parent.subobjects.Add((UInt16)(od.parent.subobjects.Count), newsub);

UInt16 def = Convert.ToUInt16(od.parent.subobjects[0].defaultvalue,16);
UInt16 def = EDSsharp.ConvertToUInt16(od.parent.subobjects[0].defaultvalue);

def++;
od.parent.subobjects[0].defaultvalue = def.ToString();

Expand All @@ -855,7 +856,7 @@ private void addSubItemToolStripMenuItem_Click(object sender, EventArgs e)

od.parent.subobjects.Add((UInt16)(od.parent.subobjects.Count), newsub);

UInt16 def = Convert.ToUInt16(od.parent.subobjects[0].defaultvalue,16);
UInt16 def = EDSsharp.ConvertToUInt16(od.parent.subobjects[0].defaultvalue);
def++;
od.parent.subobjects[0].defaultvalue = def.ToString();
}
Expand All @@ -876,7 +877,7 @@ private void removeSubItemToolStripMenuItem_Click(object sender, EventArgs e)

if (od.parent.objecttype == ObjectType.ARRAY)
{
UInt16 count = Convert.ToUInt16(od.parent.subobjects[0].defaultvalue);
UInt16 count = EDSsharp.ConvertToUInt16(od.parent.subobjects[0].defaultvalue);
if (count > 0)
count--;
od.parent.subobjects[0].defaultvalue = count.ToString();
Expand Down

0 comments on commit 9df069d

Please sign in to comment.