Skip to content

Commit

Permalink
* Fix the sub index for the ODA/ODL defines, array and rec are off by…
Browse files Browse the repository at this point in the history
… one wrt each other
  • Loading branch information
robincornelius committed Jul 13, 2016
1 parent 7cfc9a3 commit 5d73cac
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions libEDSsharp/CanOpenNodeExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,16 @@ ALIASES FOR OBJECT DICTIONARY VARIABLES

ODAs.Add(ODA);


ODAout += (string.Format(" #define {0,-51}{1}\r\n", string.Format("ODA_{0}_{1}", make_cname(od.parameter_name), make_cname(sub.parameter_name)), sub.subindex));

//Arrays do not have a size in the raw CO objects, Records do
//so offset by one
if (od.objecttype == ObjectType.ARRAY)
{
ODAout += (string.Format(" #define {0,-51}{1}\r\n", string.Format("ODA_{0}_{1}", make_cname(od.parameter_name), make_cname(sub.parameter_name)), sub.subindex - 1));
}
else
{
ODAout += (string.Format(" #define {0,-51}{1}\r\n", string.Format("ODA_{0}_{1}", make_cname(od.parameter_name), make_cname(sub.parameter_name)), sub.subindex ));
}
}

file.Write(ODAout);
Expand Down Expand Up @@ -520,6 +527,9 @@ OBJECT DICTIONARY
file.WriteLine(@"] = {
");

bool arrayspecialcase = false;
int count = 0;

foreach (KeyValuePair<UInt16, ODentry> kvp in eds.ods)
{

Expand Down Expand Up @@ -552,8 +562,25 @@ OBJECT DICTIONARY
if (od.objecttype == ObjectType.ARRAY && od.nosubindexes > 0)
array = string.Format("[0]");


if(arrayspecial(od.index,true))
{
arrayspecialcase = true;
count = 0;
}

if(arrayspecialcase)
{
array = string.Format("[{0}]", count);
count++;
}

file.WriteLine(string.Format("{{0x{0:x4}, 0x{1:x2}, 0x{2:x2}, {3}, (void*)&{4}.{5}{6}}},", od.index, od.nosubindexes, flags, datasize, loc,make_cname(od.parameter_name), array));

if (arrayspecial(od.index, false))
{
arrayspecialcase = false;
}
}


Expand Down

0 comments on commit 5d73cac

Please sign in to comment.