Skip to content

Commit eaf0b5e

Browse files
Add in dummy object support and allow PDO configuration tabs to be able to select dummy entries
1 parent 3d8cb8a commit eaf0b5e

File tree

4 files changed

+140
-32
lines changed

4 files changed

+140
-32
lines changed

‎EDSTest/DevicePDOView.cs‎

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ public void updatePDOinfo()
6161

6262
TXchoices.Add(String.Format("empty"));
6363

64+
//TXchoices.Add(string.Format("Dummy Bool")); //not sure how this works at all for a bit???
65+
66+
TXchoices.Add(string.Format("0x002/00/Dummy Int8"));
67+
TXchoices.Add(string.Format("0x003/00/Dummy Int16"));
68+
TXchoices.Add(string.Format("0x004/00/Dummy Int32"));
69+
TXchoices.Add(string.Format("0x005/00/Dummy UInt8"));
70+
TXchoices.Add(string.Format("0x006/00/Dummy UInt16"));
71+
TXchoices.Add(string.Format("0x007/00/Dummy UInt32"));
72+
6473

6574
listView_TXPDO.BeginUpdate();
6675

@@ -209,7 +218,7 @@ void updatePDOTXslot(ODentry od , int row)
209218
if (sub.defaultvalue != "")
210219
data = Convert.ToUInt32(sub.defaultvalue, EDSsharp.getbase(sub.defaultvalue));
211220

212-
if (data == 0) //FIX ME also include dummy usage here
221+
if (data == 0)
213222
{
214223
listView_TXCOBmap.AddComboBoxCell(row, byteoff + 2, TXchoices);
215224
listView_TXCOBmap.Items[row].SubItems[byteoff + 2].Text = "empty";
@@ -222,34 +231,77 @@ void updatePDOTXslot(ODentry od , int row)
222231
UInt16 pdoindex = (UInt16)((data >> 16) & 0x0000FFFF);
223232
byte pdosub = (byte)((data >> 8) & 0x000000FF);
224233

225-
//fixme sanity checking here please
226-
if (!eds.ods.ContainsKey(pdoindex))
227-
continue;
234+
String target = "";
235+
int PDOdatasize = 0;
228236

229-
ODentry targetod = eds.ods[pdoindex];
237+
//dummy objects
238+
if (pdoindex>=0x0002 && pdoindex<=0x007)
239+
{
240+
//the dummy objects
241+
switch (pdoindex)
242+
{
243+
case 0x002:
244+
target = "0x0002/00/Dummy Int8";
245+
PDOdatasize = 1;
246+
break;
247+
case 0x003:
248+
target = "0x0002/00/Dummy Int16";
249+
PDOdatasize = 2;
250+
break;
251+
case 0x004:
252+
target = "0x0002/00/Dummy Int32";
253+
PDOdatasize = 4;
254+
break;
255+
case 0x005:
256+
target = "0x0002/00/Dummy UInt8";
257+
PDOdatasize = 1;
258+
break;
259+
case 0x006:
260+
target = "0x0002/00/Dummy UInt16";
261+
PDOdatasize = 2;
262+
break;
263+
case 0x007:
264+
target = "0x0002/00/Dummy UInt32";
265+
PDOdatasize = 4;
266+
break;
267+
}
230268

231-
if(pdosub!=0)
269+
if (PDOdatasize == 0)
270+
continue;
271+
272+
}
273+
else
232274
{
233-
targetod = targetod.subobjects[pdosub];
275+
//fixme sanity checking here please
276+
if (!eds.ods.ContainsKey(pdoindex))
277+
continue;
278+
279+
ODentry targetod = eds.ods[pdoindex];
280+
281+
if (pdosub != 0)
282+
{
283+
//FIXME direct sub array access, unprotected and will fault with holes in range
284+
targetod = targetod.subobjects[pdosub];
285+
}
286+
287+
target = String.Format("0x{0:x4}/{1:x2}/", targetod.index, targetod.subindex) + targetod.parameter_name;
288+
PDOdatasize = targetod.sizeofdatatype();
234289
}
290+
235291

236292
listView_TXCOBmap.AddComboBoxCell(row, byteoff+2, TXchoices);
237-
238-
String target = String.Format("0x{0:x4}/{1:x2}/", targetod.index, targetod.subindex) + targetod.parameter_name;
239293
listView_TXCOBmap.Items[row].SubItems[byteoff+2].Text = target;
240294

241-
int PDOdatasize = targetod.sizeofdatatype();
242-
243-
while (PDOdatasize != 1)
295+
int oldPDOdatasize = PDOdatasize;
296+
297+
while (oldPDOdatasize != 1)
244298
{
245-
listView_TXCOBmap.Items[row].SubItems[byteoff + PDOdatasize+1].Text = " - ";
246-
PDOdatasize--;
299+
listView_TXCOBmap.Items[row].SubItems[byteoff + oldPDOdatasize + 1].Text = " - ";
300+
oldPDOdatasize--;
247301

248302
}
249303

250-
byteoff += targetod.sizeofdatatype();
251-
252-
304+
byteoff += PDOdatasize;
253305

254306
}
255307
}
@@ -286,14 +338,48 @@ void listView_TXCOBmap_onComboBoxIndexChanged(int row, int col, string Text)
286338
UInt16 index = Convert.ToUInt16(bits[0], 16);
287339
Byte sub = Convert.ToByte(bits[1], 16);
288340

289-
ODentry od = eds.ods[index];
290-
if(sub!=0)
291-
od = od.subobjects[sub];
292341

293-
//fixme for non basic types will this work?? i think
294-
//its not even allowed for PDO but need trap in code to
295-
//prevent this and throw error here
296-
int datalength = 8* od.sizeofdatatype();
342+
int datalength = 0;
343+
344+
if (index >= 0x002 && index <= 0x007)
345+
{
346+
//the dummy objects
347+
switch(index)
348+
{
349+
case 0x002:
350+
datalength = 8;
351+
break;
352+
case 0x003:
353+
datalength = 16;
354+
break;
355+
case 0x004:
356+
datalength = 32;
357+
break;
358+
case 0x005:
359+
datalength = 8;
360+
break;
361+
case 0x006:
362+
datalength = 16;
363+
break;
364+
case 0x007:
365+
datalength = 32;
366+
break;
367+
368+
}
369+
370+
}
371+
else
372+
{
373+
374+
ODentry od = eds.ods[index];
375+
if (sub != 0)
376+
od = od.subobjects[sub];
377+
378+
//fixme for non basic types will this work?? i think
379+
//its not even allowed for PDO but need trap in code to
380+
//prevent this and throw error here
381+
datalength = 8 * od.sizeofdatatype();
382+
}
297383

298384
totaldatalength += datalength;
299385

‎EDSTest/Form1.Designer.cs‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎libEDSsharp/NetworkPDOreport.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,14 @@ public void gennetpdodoc(string filepath, List<EDSsharp> network)
260260

261261
if (subindex2 == 0)
262262
{
263-
name2 = eds2.ods[index2].parameter_name;
263+
//fixme getobject could return null
264+
name2 = eds2.getobject(index2).parameter_name;
264265

265266
}
266267
else
267268
{
268-
name2 = eds2.ods[index2].getsubobject(subindex2).parameter_name;
269+
//fixme getobject could return null
270+
name2 = eds2.getobject(index2).getsubobject(subindex2).parameter_name;
269271
}
270272

271273
string sizemsg = "";

‎libEDSsharp/eds.cs‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,8 @@ public enum AccessType
960960

961961
Dictionary<string, Dictionary<string, string>> eds;
962962
public SortedDictionary<UInt16, ODentry> ods;
963+
public SortedDictionary<UInt16, ODentry> dummy_ods;
964+
963965
public FileInfo fi;
964966
public DeviceInfo di;
965967
public MandatoryObjects md;
@@ -977,6 +979,7 @@ public EDSsharp()
977979

978980
eds = new Dictionary<string, Dictionary<string, string>>();
979981
ods = new SortedDictionary<UInt16, ODentry>();
982+
dummy_ods = new SortedDictionary<UInt16, ODentry>();
980983

981984
fi = new FileInfo();
982985
di = new DeviceInfo();
@@ -1008,10 +1011,12 @@ public EDSsharp()
10081011

10091012
ODentry od = new ODentry();
10101013

1011-
1012-
1013-
1014-
1014+
dummy_ods.Add(2, new ODentry("Dummy Int8", 0x002, 0x00, DataType.INTEGER8, "0", AccessType.ro, PDOMappingType.optional));
1015+
dummy_ods.Add(3, new ODentry("Dummy Int16", 0x002, 0x00, DataType.INTEGER16, "0", AccessType.ro, PDOMappingType.optional));
1016+
dummy_ods.Add(4, new ODentry("Dummy Int32", 0x002, 0x00, DataType.INTEGER32, "0", AccessType.ro, PDOMappingType.optional));
1017+
dummy_ods.Add(5, new ODentry("Dummy UInt8", 0x002, 0x00, DataType.UNSIGNED8, "0", AccessType.ro, PDOMappingType.optional));
1018+
dummy_ods.Add(6, new ODentry("Dummy UInt16", 0x002, 0x00, DataType.UNSIGNED16, "0", AccessType.ro, PDOMappingType.optional));
1019+
dummy_ods.Add(7, new ODentry("Dummy UInt32", 0x002, 0x00, DataType.UNSIGNED32, "0", AccessType.ro, PDOMappingType.optional));
10151020

10161021
}
10171022

@@ -1558,8 +1563,23 @@ public bool createRXPDO(UInt16 index)
15581563
{
15591564
return createPDO(true, index);
15601565
}
1561-
15621566

1567+
public ODentry getobject(UInt16 no)
1568+
{
1569+
1570+
if(no>=0x002 && no<=0x007)
1571+
{
1572+
return dummy_ods[no];
1573+
}
1574+
1575+
if (ods.ContainsKey(no))
1576+
{
1577+
return ods[no];
1578+
}
1579+
1580+
return null;
1581+
1582+
}
15631583
}
15641584

15651585
public class ParameterException : Exception

0 commit comments

Comments
 (0)