ObjectDictionary Class¶
Thread-safe in-memory Object Dictionary keyed by (index, subindex) per CiA 301 §7.4.6
(FR-CO-001). Provides typed read/write accessors that enforce the declared
OdDataType; typed reads against an entry of the wrong data type throw
InvalidOperationException.
Inheritance Object → ObjectDictionary
Remarks¶
The dictionary is the single source of truth shared by the local application, the SDO server,
the PDO engine and — for the communication-profile objects the node manages (1005h,
1006h, 1014h, 1016h, 1017h, 100Ch, 100Dh, the SDO
and PDO parameter records) — the node's own runtime configuration. Every value the dictionary
accepts for one of those objects reaches the service it describes, whether it arrived over
SDO or through a local write here; the node's public methods (ConfigureTpdo,
StartHeartbeatProducer, …) are themselves writes to these objects.
All lookups take the internal lock briefly to avoid tearing when the SDO server writes concurrently with an application read; individual entry values are copied out under the lock so no reference leaks back to caller state. Writes to managed objects are validated before they are stored; a rejected local write throws ArgumentException whose message names the CiA 301 abort code the same write would have produced over SDO.
Storage is a System.Collections.Generic.Dictionary<> plus a single mutex, sized for the tens to hundreds of entries a device or tool node carries. If profiles grow into the thousands the storage can be swapped without changing the public surface.
Properties¶
ObjectDictionary.Count Property¶
Total number of registered (index, subindex) entries.
Property Value¶
Methods¶
ObjectDictionary.AddDomain(ushort, byte, byte[], OdAccess, bool) Method¶
Adds or replaces an Domain entry with the given initial bytes (may be empty; will be resized on later writes).
public CanKit.Pro.CANopen.OdEntry AddDomain(ushort index, byte subindex, byte[] value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddI16(ushort, byte, short, OdAccess, bool) Method¶
Adds or replaces an Integer16 entry.
public CanKit.Pro.CANopen.OdEntry AddI16(ushort index, byte subindex, short value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value Int16
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddI32(ushort, byte, int, OdAccess, bool) Method¶
Adds or replaces an Integer32 entry.
public CanKit.Pro.CANopen.OdEntry AddI32(ushort index, byte subindex, int value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value Int32
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddI8(ushort, byte, sbyte, OdAccess, bool) Method¶
Adds or replaces an Integer8 entry.
public CanKit.Pro.CANopen.OdEntry AddI8(ushort index, byte subindex, sbyte value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value SByte
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddRaw(ushort, byte, OdDataType, byte[], OdAccess, bool) Method¶
Adds or replaces an entry of any OdDataType from its raw little-endian bytes. Fixed-width types must be given exactly their width; the strings and Domain take any length (may be empty; resized on later writes).
public CanKit.Pro.CANopen.OdEntry AddRaw(ushort index, byte subindex, CanKit.Pro.CANopen.OdDataType dataType, byte[] value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
dataType OdDataType
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddU16(ushort, byte, ushort, OdAccess, bool) Method¶
Adds or replaces an Unsigned16 entry.
public CanKit.Pro.CANopen.OdEntry AddU16(ushort index, byte subindex, ushort value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value UInt16
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddU32(ushort, byte, uint, OdAccess, bool) Method¶
Adds or replaces an Unsigned32 entry.
public CanKit.Pro.CANopen.OdEntry AddU32(ushort index, byte subindex, uint value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value UInt32
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.AddU8(ushort, byte, byte, OdAccess, bool) Method¶
Adds or replaces an Unsigned8 entry.
public CanKit.Pro.CANopen.OdEntry AddU8(ushort index, byte subindex, byte value, CanKit.Pro.CANopen.OdAccess access=CanKit.Pro.CANopen.OdAccess.ReadWrite, bool pdoMappable=true);
Parameters¶
index UInt16
subindex Byte
value Byte
access OdAccess
pdoMappable Boolean
Returns¶
ObjectDictionary.ContainsIndex(ushort) Method¶
Whether any sub-index of index exists. Distinguishes "object does not
exist" (SDO abort 0602 0000h) from "sub-index does not exist" (0609 0011h).
Parameters¶
index UInt16
Returns¶
ObjectDictionary.ReadRaw(ushort, byte) Method¶
Reads an entry's raw little-endian byte value.
Parameters¶
index UInt16
subindex Byte
Returns¶
Exceptions¶
KeyNotFoundException
Thrown when the entry does not exist.
ObjectDictionary.ReadSigned(ushort, byte) Method¶
Reads a fixed-width signed entry as Int32 (upcasts I8/I16/I32). Throws when the declared type is not one of those three.
Parameters¶
index UInt16
subindex Byte
Returns¶
ObjectDictionary.ReadUnsigned(ushort, byte) Method¶
Reads a fixed-width unsigned entry as UInt32 (upcasts U8/U16/U32). Throws when the declared type is not one of those three.
Parameters¶
index UInt16
subindex Byte
Returns¶
ObjectDictionary.TryGet(ushort, byte, OdEntry) Method¶
Attempts to look up the entry for index/subindex.
Parameters¶
index UInt16
subindex Byte
entry OdEntry
Returns¶
ObjectDictionary.TryReadRaw(ushort, byte, byte[]) Method¶
Attempts to atomically snapshot the raw little-endian bytes of an entry under the OD's internal lock. Preferred over TryGet(ushort, byte, OdEntry) + GetRawValue() for the SDO server and TPDO hot paths: a concurrent WriteRaw(ushort, byte, byte[]) from another thread cannot tear a snapshot taken under the lock, so readers see either the entire pre-write value or the entire post-write value — never a mix. Returns false when the entry does not exist (mirrors TryGet(ushort, byte, OdEntry)).
Parameters¶
index UInt16
subindex Byte
Returns¶
ObjectDictionary.TryReadUnsigned(ushort, byte, uint) Method¶
Attempts to read a fixed-width unsigned entry (U8/U16/U32) as UInt32. Returns false when the entry does not exist or has another data type.
Parameters¶
index UInt16
subindex Byte
value UInt32
Returns¶
ObjectDictionary.WriteRaw(ushort, byte, byte[]) Method¶
Writes raw bytes to an entry; used both by application code and by the SDO server. Enforces size-consistency for fixed-width data types and — for the communication-profile objects the node manages — the CiA 301 value rules for that object.
Parameters¶
index UInt16
subindex Byte
Exceptions¶
KeyNotFoundException
Thrown when the entry does not exist.
InvalidOperationException
Thrown when value's length
does not match the entry's declared size.
ArgumentException
Thrown when the value is rejected for a managed
communication object; the message carries the SDO abort code the same write would
have produced on the bus.
ObjectDictionary.WriteUnsigned(ushort, byte, uint) Method¶
Writes a fixed-width unsigned value into an entry, enforcing the declared type width. Throws when the target entry is not U8/U16/U32, and ArgumentException when a managed communication object rejects the value (see WriteRaw(ushort, byte, byte[])).
Parameters¶
index UInt16
subindex Byte
value UInt32