Skip to content

API Reference

Dietmar Borgards edited this page Feb 28, 2026 · 3 revisions

API Reference

The public API surface of EdsDcfNet. All operations are available through the static CanOpenFile facade class plus extension methods on ObjectDictionary.


CanOpenFile — Main Entry Point

CanOpenFile is a static class with no state. Every method is self-contained.

using EdsDcfNet;

EDS Methods

ReadEds(string filePath)

Reads and parses an EDS file from disk.

ElectronicDataSheet ReadEds(string filePath)
Parameter Description
filePath Absolute or relative path to the .eds file

Returns: ElectronicDataSheet Throws: EdsParseException on parse errors, IOException on file access errors


ReadEdsFromString(string content)

Parses an EDS from a string (useful for unit testing or in-memory processing).

ElectronicDataSheet ReadEdsFromString(string content)

Returns: ElectronicDataSheet Throws: EdsParseException on parse errors


WriteEds(ElectronicDataSheet eds, string filePath)

Serializes an ElectronicDataSheet to an EDS file (UTF-8 without BOM).

void WriteEds(ElectronicDataSheet eds, string filePath)

Throws: EdsWriteException on serialization errors, IOException on file access errors


WriteEdsToString(ElectronicDataSheet eds)

Serializes an ElectronicDataSheet to a string.

string WriteEdsToString(ElectronicDataSheet eds)

Returns: The EDS file content as a string Throws: EdsWriteException on serialization errors


DCF Methods

ReadDcf(string filePath)

Reads and parses a DCF file from disk.

DeviceConfigurationFile ReadDcf(string filePath)

Returns: DeviceConfigurationFile Throws: EdsParseException on parse errors


ReadDcfFromString(string content)

Parses a DCF from a string.

DeviceConfigurationFile ReadDcfFromString(string content)

Returns: DeviceConfigurationFile Throws: EdsParseException on parse errors


WriteDcf(DeviceConfigurationFile dcf, string filePath)

Serializes a DeviceConfigurationFile to a file (UTF-8 without BOM).

void WriteDcf(DeviceConfigurationFile dcf, string filePath)

Throws: DcfWriteException on serialization errors, IOException on file access errors


WriteDcfToString(DeviceConfigurationFile dcf)

Serializes a DeviceConfigurationFile to a string.

string WriteDcfToString(DeviceConfigurationFile dcf)

Returns: The DCF file content as a string Throws: DcfWriteException on serialization errors


CPJ Methods

ReadCpj(string filePath)

Reads and parses a CPJ nodelist project file from disk.

NodelistProject ReadCpj(string filePath)

Returns: NodelistProject Throws: EdsParseException on parse errors


ReadCpjFromString(string content)

Parses a CPJ from a string.

NodelistProject ReadCpjFromString(string content)

Returns: NodelistProject Throws: EdsParseException on parse errors


WriteCpj(NodelistProject cpj, string filePath)

Serializes a NodelistProject to a file (UTF-8 without BOM).

void WriteCpj(NodelistProject cpj, string filePath)

Throws: IOException on file access errors


WriteCpjToString(NodelistProject cpj)

Serializes a NodelistProject to a string.

string WriteCpjToString(NodelistProject cpj)

Returns: The CPJ file content as a string


XDD Methods

ReadXdd(string filePath)

Reads and parses a CiA 311 XDD (XML Device Description) file.

ElectronicDataSheet ReadXdd(string filePath)

Returns: ElectronicDataSheet (same model as EDS; ApplicationProcess property populated when present) Throws: EdsParseException on parse errors, IOException on file access errors


ReadXddFromString(string content)

Parses an XDD from a string.

ElectronicDataSheet ReadXddFromString(string content)

Returns: ElectronicDataSheet Throws: EdsParseException on parse errors


WriteXdd(ElectronicDataSheet xdd, string filePath)

Serializes an ElectronicDataSheet to a CiA 311 XDD file.

void WriteXdd(ElectronicDataSheet xdd, string filePath)

WriteXddToString(ElectronicDataSheet xdd)

Serializes an ElectronicDataSheet to an XDD string.

string WriteXddToString(ElectronicDataSheet xdd)

Returns: The XDD file content as a string


XDC Methods

ReadXdc(string filePath)

Reads and parses a CiA 311 XDC (XML Device Configuration) file.

DeviceConfigurationFile ReadXdc(string filePath)

Returns: DeviceConfigurationFile (same model as DCF) Throws: EdsParseException on parse errors, IOException on file access errors


ReadXdcFromString(string content)

Parses an XDC from a string.

DeviceConfigurationFile ReadXdcFromString(string content)

Returns: DeviceConfigurationFile Throws: EdsParseException on parse errors


WriteXdc(DeviceConfigurationFile xdc, string filePath)

Serializes a DeviceConfigurationFile to a CiA 311 XDC file.

void WriteXdc(DeviceConfigurationFile xdc, string filePath)

WriteXdcToString(DeviceConfigurationFile xdc)

Serializes a DeviceConfigurationFile to an XDC string.

string WriteXdcToString(DeviceConfigurationFile xdc)

Returns: The XDC file content as a string


Conversion

EdsToDcf(ElectronicDataSheet eds, byte nodeId, ushort baudrate, string? nodeName)

Converts an EDS template to a configured DCF instance.

DeviceConfigurationFile EdsToDcf(
    ElectronicDataSheet eds,
    byte nodeId,
    ushort baudrate = 250,
    string? nodeName = null)
Parameter Type Default Description
eds ElectronicDataSheet Source EDS (not modified)
nodeId byte Node address, must be 1–127
baudrate ushort 250 Baud rate in kbit/s
nodeName string? null Human-readable node name

Returns: A fully independent DeviceConfigurationFile (deep copy of EDS) Throws: ArgumentException if nodeId is outside 1–127, EdsParseException on $NODEID formula errors


Data Models

ElectronicDataSheet

Property Type Description
FileInfo EdsFileInfo [FileInfo] section metadata
DeviceInfo DeviceInfo [DeviceInfo] section
ObjectDictionary ObjectDictionary All OD objects
Comments Comments? [Comments] section
SupportedModules List<ModuleInfo> Modular device modules
DynamicChannels DynamicChannels? CiA 302-4 dynamic channels
Tools List<ToolInfo> Tool sections
AdditionalSections Dictionary<string, Dictionary<string, string>> Unknown sections
ApplicationProcess ApplicationProcess? Typed CiA 311 §6.4.5 model; null for EDS files or when element is absent

DeviceConfigurationFile

All properties of ElectronicDataSheet, plus:

Property Type Description
DeviceCommissioning DeviceCommissioning [DeviceCommissioning] section
ConnectedModules List<int> Plugged-in module slots

DeviceCommissioning

Property Type Description
NodeId byte Node address (1–127)
NodeName string Human-readable name
Baudrate ushort Baud rate in kbit/s
NetNumber uint Network number
NetworkName string Network name
CANopenManager bool Is the node a CANopen manager?
LssSerialNumber uint? LSS serial number
NodeRefd string? Node reference (e.g., database ID)
NetRefd string? Network reference

DeviceInfo

Property Type Description
VendorName string Manufacturer name
VendorNumber uint Manufacturer ID (CiA assigned)
ProductName string Device name
ProductNumber uint Product code
RevisionNumber uint Firmware revision
OrderCode string Order/part number
SupportedBaudRates BaudRates Supported baud rates
SimpleBootUpMaster bool NMT master capability
SimpleBootUpSlave bool NMT slave capability
NrOfRxPdo ushort Number of RPDOs
NrOfTxPdo ushort Number of TPDOs
LssSupported bool LSS layer setting services
CANopenSafetySupported bool EN 50325-5 safety support

CanOpenObject

Property Type Description
Index ushort OD index (0x0000–0xFFFF)
ParameterName string Object name
ObjectType byte VAR=0x07, ARRAY=0x08, RECORD=0x09
DataType ushort? CiA data type code
AccessType AccessType ro / wo / rw / rwr / rww / const
DefaultValue string? EDS default value
ParameterValue string? DCF configured value
Denotation string? Optional label (DCF only)
LowLimit string? Minimum allowed value
HighLimit string? Maximum allowed value
PdoMapping bool Can be mapped to PDO
SrdoMapping bool Can be mapped to SRDO
SubObjects Dictionary<byte, CanOpenSubObject> Sub-objects (ARRAY/RECORD)
ObjectLinks List<ushort> Linked object indices
ObjFlags uint Object flags bitfield

NodelistProject

Property Type Description
Networks List<NetworkTopology> List of network topologies
AdditionalSections Dictionary<string, Dictionary<string, string>> Unknown sections

NetworkTopology

Property Type Description
NetName string? Network name
NetRefd string? Network reference
EdsBaseName string? Base path for EDS/DCF files
Nodes Dictionary<byte, NetworkNode> Nodes keyed by node ID

NetworkNode

Property Type Description
NodeId byte Node address (1–127)
Present bool Physically present in the network
Name string? Human-readable node name
Refd string? Node reference
DcfFileName string? Associated DCF file name

ApplicationProcess

Populated when reading XDD/XDC files that contain an ApplicationProcess element (CiA 311 §6.4.5).

Property Type Description
ParameterList List<ApParameter> Device parameters (mandatory when element present)
DataTypeList ApDataTypeList? Complex type definitions (arrays, structs, enums, derived)
FunctionTypeList List<ApFunctionType> Function type definitions
FunctionInstanceList ApFunctionInstanceList? Function instances
TemplateList ApTemplateList? Parameter and allowed-value templates
ParameterGroupList List<ApParameterGroup> Parameter groups for HMI classification

See Reading and Writing XDD/XDC Files for full usage examples.


Extension Methods (ObjectDictionaryExtensions)

using EdsDcfNet.Extensions;
Method Returns Description
GetObject(ushort index) CanOpenObject? Get object by index, null if not found
GetSubObject(ushort index, byte subIndex) CanOpenSubObject? Get sub-object, null if not found
SetParameterValue(ushort index, string value) bool Set VAR value; returns false if not found
SetParameterValue(ushort index, byte subIndex, string value) bool Set sub-object value; returns false if not found
GetParameterValue(ushort index) string? Get VAR ParameterValue
GetParameterValue(ushort index, byte subIndex) string? Get sub-object ParameterValue
GetObjectsByType(ObjectCategory category) IEnumerable<CanOpenObject> Filter by Mandatory/Optional/Manufacturer
GetPdoCommunicationParameters(bool transmit) IEnumerable<CanOpenObject> TPDO (0x1800–) or RPDO (0x1400–) com params
GetPdoMappingParameters(bool transmit) IEnumerable<CanOpenObject> TPDO (0x1A00–) or RPDO (0x1600–) mappings

Exceptions

Exception Namespace Description
EdsParseException EdsDcfNet.Exceptions Parse error with optional LineNumber and SectionName
EdsWriteException EdsDcfNet.Exceptions EDS write error with optional SectionName
DcfWriteException EdsDcfNet.Exceptions Write error with optional SectionName

See Also

Clone this wiki locally