Skip to content

Commit

Permalink
CanOpen.proto: change name "type" to more descriptive "dataType" and …
Browse files Browse the repository at this point in the history
…"objectType" (#150)
  • Loading branch information
CANopenNode authored Nov 29, 2024
1 parent b5820c6 commit c1071ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions libEDSsharp/CanOpenXDD_1_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ private Items1ChoiceType ConvertDataType(OdSubObject subEntry)
{
UInt32 byteLength;
bool signed = false;
var dt = subEntry.Type;
var dt = subEntry.DataType;

switch (dt)
{
Expand All @@ -474,7 +474,7 @@ private Items1ChoiceType ConvertDataType(OdSubObject subEntry)
return Items1ChoiceType.BITSTRING;

default:
subEntry.Type = LibCanOpen.OdSubObject.Types.DataType.Integer32;
subEntry.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer32;
return Items1ChoiceType.DINT;

// transform other non standard values to OCTET_STRING
Expand Down Expand Up @@ -508,7 +508,7 @@ private Items1ChoiceType ConvertDataType(OdSubObject subEntry)
bytes.Add(String.Format("{0:X2}", value & 0xFF));
value >>= 8;
}
subEntry.Type = LibCanOpen.OdSubObject.Types.DataType.OctetString;
subEntry.DataType = LibCanOpen.OdSubObject.Types.DataType.OctetString;
subEntry.DefaultValue = string.Join(" ", bytes);

return Items1ChoiceType.BITSTRING;
Expand All @@ -519,54 +519,54 @@ private void ConvertDataType(Items1ChoiceType choiceType, OdSubObject OdSubObjec
switch (choiceType)
{
case Items1ChoiceType.BOOL:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Boolean;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Boolean;
break;
case Items1ChoiceType.CHAR:
case Items1ChoiceType.SINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Integer8;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer8;
break;
case Items1ChoiceType.INT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Integer16;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer16;
break;
case Items1ChoiceType.DINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Integer32;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer32;
break;
case Items1ChoiceType.LINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Integer64;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer64;
break;
case Items1ChoiceType.BYTE:
case Items1ChoiceType.USINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Unsigned8;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Unsigned8;
break;
case Items1ChoiceType.WORD:
case Items1ChoiceType.UINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Unsigned16;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Unsigned16;
break;
case Items1ChoiceType.DWORD:
case Items1ChoiceType.UDINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Unsigned32;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Unsigned32;
break;
case Items1ChoiceType.LWORD:
case Items1ChoiceType.ULINT:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Unsigned64;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Unsigned64;
break;
case Items1ChoiceType.REAL:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Real32;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Real32;
break;
case Items1ChoiceType.LREAL:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Real64;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Real64;
break;
case Items1ChoiceType.STRING:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.VisibleString;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.VisibleString;
break;
case Items1ChoiceType.WSTRING:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.UnicodeString;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.UnicodeString;
break;
case Items1ChoiceType.BITSTRING:
OdSubObject.Type = OdSubObject.DefaultValue == "" ? LibCanOpen.OdSubObject.Types.DataType.Domain : LibCanOpen.OdSubObject.Types.DataType.OctetString;
OdSubObject.DataType = OdSubObject.DefaultValue == "" ? LibCanOpen.OdSubObject.Types.DataType.Domain : LibCanOpen.OdSubObject.Types.DataType.OctetString;
break;
default:
OdSubObject.Type = LibCanOpen.OdSubObject.Types.DataType.Integer32;
OdSubObject.DataType = LibCanOpen.OdSubObject.Types.DataType.Integer32;
break;
}
}
Expand Down Expand Up @@ -1758,12 +1758,12 @@ private CanOpenDevice ConvertToProtobuf(ISO15745ProfileContainer container)
{
Name = netObj.name ?? "",
Alias = netObj.denotation ?? "",
Type = objectType
ObjectType = objectType
};

OdSubObject subEntry0 = new OdSubObject()
{
Type = dataType,
DataType = dataType,
Sdo = accessSDO,
Pdo = accessPDO,
DefaultValue = netObj.defaultValue ?? "",
Expand Down Expand Up @@ -1851,7 +1851,7 @@ private CanOpenDevice ConvertToProtobuf(ISO15745ProfileContainer container)
{
Name = netSubObj.name ?? "",
Alias = netSubObj.denotation ?? "",
Type = subDataType,
DataType = subDataType,
Sdo = subAccessSDO,
Pdo = subAccessPDO,
DefaultValue = netSubObj.defaultValue ?? "",
Expand Down Expand Up @@ -1982,7 +1982,7 @@ private ISO15745ProfileContainer ConvertFromProtobuf(CanOpenDevice dev, string f
{
index = new byte[] { (byte)(indexInt >> 8), (byte)(indexInt & 0xFF) },
name = entry.Name,
objectType = (byte)entry.Type,
objectType = (byte)entry.ObjectType,
uniqueIDRef = "UID_OBJ_" + index
};
body_network_objectList.Add(netObj);
Expand All @@ -2006,7 +2006,7 @@ private ISO15745ProfileContainer ConvertFromProtobuf(CanOpenDevice dev, string f
}
body_device_parameterList.Add(devPar);

if (entry.Type == LibCanOpen.OdObject.Types.ObjectType.Var)
if (entry.ObjectType == LibCanOpen.OdObject.Types.ObjectType.Var)
{
if (entry.SubObjects.Count != 1)
{
Expand Down Expand Up @@ -2037,7 +2037,7 @@ private ISO15745ProfileContainer ConvertFromProtobuf(CanOpenDevice dev, string f
if (deviceCommissioning && subEntry0.ActualValue != null && subEntry0.ActualValue != "")
devPar.actualValue = new actualValue { value = subEntry0.ActualValue };
}
else if ((entry.Type == LibCanOpen.OdObject.Types.ObjectType.Array || entry.Type == LibCanOpen.OdObject.Types.ObjectType.Record) && entry.SubObjects != null && entry.SubObjects.Count > 0)
else if ((entry.ObjectType == LibCanOpen.OdObject.Types.ObjectType.Array || entry.ObjectType == LibCanOpen.OdObject.Types.ObjectType.Record) && entry.SubObjects != null && entry.SubObjects.Count > 0)
{
netObj.subNumber = (byte)entry.SubObjects.Count;
netObj.subNumberSpecified = true;
Expand Down Expand Up @@ -2103,7 +2103,7 @@ private ISO15745ProfileContainer ConvertFromProtobuf(CanOpenDevice dev, string f
if (deviceCommissioning && subEntry.ActualValue != null && subEntry.ActualValue != "")
devPar.actualValue = new actualValue { value = subEntry.ActualValue };

if (entry.Type == LibCanOpen.OdObject.Types.ObjectType.Record)
if (entry.ObjectType == LibCanOpen.OdObject.Types.ObjectType.Record)
{
devStructSubList.Add(new varDeclaration
{
Expand All @@ -2123,7 +2123,7 @@ private ISO15745ProfileContainer ConvertFromProtobuf(CanOpenDevice dev, string f
}

// add refference to data type definition and definition of array or struct data type (schema requirement)
if (entry.Type == LibCanOpen.OdObject.Types.ObjectType.Array)
if (entry.ObjectType == LibCanOpen.OdObject.Types.ObjectType.Array)
{
devPar.Items1 = new object[] { new dataTypeIDRef { uniqueIDRef = "UID_ARR_" + index } };
devPar.Items1ElementName = new Items1ChoiceType[] { Items1ChoiceType.dataTypeIDRef };
Expand Down
4 changes: 2 additions & 2 deletions libEDSsharp/proto/CanOpen.proto
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ message OdSubObject

string name = 1; // Name of the sub entry. If OdEntry is "VAR", this property is not relevant.
string alias = 2; // Additonal sub parameter name, for the actual device. If OdEntry is "VAR", this property is not relevant.
DataType type = 3; // CANopen data type
DataType dataType = 3; // CANopen data type
AccessSDO sdo = 4; // CANopen SDO access permissions
AccessPDO pdo = 5; // CANopen PDO access permissions
AccessSRDO srdo = 6; // CANopen SRDO access permissions.
Expand Down Expand Up @@ -146,7 +146,7 @@ message OdObject
// Description of the Entry.
string description = 4;
// CANopen Object Type.
ObjectType type = 5;
ObjectType objectType = 5;
// CanOpenNode OD exporter V4: it will generate a macro for each different CO_countLabel. For example, if four
// OD objects have "CO_countLabel" set to "TPDO", then macro "#define ODxyz_CNT_TPDO 4" will be generated by the OD exporter.
string countLabel = 101;
Expand Down

0 comments on commit c1071ab

Please sign in to comment.