Skip to content

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.

public sealed class ObjectDictionary

Inheritance Object → ObjectDictionary

Remarks

The dictionary is the single source of truth shared by the local application, the SDO server and the PDO mapping layer. 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.

The MVP fixes storage to a System.Collections.Generic.Dictionary<> plus a single mutex. It is intended for tens of entries typical of an MVP node; 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.

public int Count { get; }

Property Value

Int32

Methods

ObjectDictionary.AddDomain(ushort, byte, byte[], OdAccess) 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);

Parameters

index UInt16

subindex Byte

value Byte[]

access OdAccess

Returns

OdEntry

ObjectDictionary.AddI16(ushort, byte, short, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value Int16

access OdAccess

Returns

OdEntry

ObjectDictionary.AddI32(ushort, byte, int, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value Int32

access OdAccess

Returns

OdEntry

ObjectDictionary.AddI8(ushort, byte, sbyte, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value SByte

access OdAccess

Returns

OdEntry

ObjectDictionary.AddU16(ushort, byte, ushort, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value UInt16

access OdAccess

Returns

OdEntry

ObjectDictionary.AddU32(ushort, byte, uint, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value UInt32

access OdAccess

Returns

OdEntry

ObjectDictionary.AddU8(ushort, byte, byte, OdAccess) 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);

Parameters

index UInt16

subindex Byte

value Byte

access OdAccess

Returns

OdEntry

ObjectDictionary.ReadRaw(ushort, byte) Method

Reads an entry's raw little-endian byte value.

public byte[] ReadRaw(ushort index, byte subindex);

Parameters

index UInt16

subindex Byte

Returns

Byte[]

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.

public int ReadSigned(ushort index, byte subindex);

Parameters

index UInt16

subindex Byte

Returns

Int32

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.

public uint ReadUnsigned(ushort index, byte subindex);

Parameters

index UInt16

subindex Byte

Returns

UInt32

ObjectDictionary.TryGet(ushort, byte, OdEntry) Method

Attempts to look up the entry for index/subindex.

public bool TryGet(ushort index, byte subindex, out CanKit.Pro.CANopen.OdEntry entry);

Parameters

index UInt16

subindex Byte

entry OdEntry

Returns

Boolean

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)).

public bool TryReadRaw(ushort index, byte subindex, out byte[] value);

Parameters

index UInt16

subindex Byte

value Byte[]

Returns

Boolean

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.

public void WriteRaw(ushort index, byte subindex, byte[] value);

Parameters

index UInt16

subindex Byte

value Byte[]

Exceptions

KeyNotFoundException
Thrown when the entry does not exist.

InvalidOperationException
Thrown when value's length does not match the entry's declared size.

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.

public void WriteUnsigned(ushort index, byte subindex, uint value);

Parameters

index UInt16

subindex Byte

value UInt32