Configuration File

class ingenialink.configuration_file.ConfigRegister(uid: str, subnode: int, dtype: RegDtype, access: RegAccess, storage: float | int | str | bool, data: bytes | None = None)[source]

Register class for ConfigurationFile (XCF) class.

classmethod from_register(register: Register, value: float | int | str | bool) ConfigRegister[source]

Creates a ConfigRegister from a register, and its value.

Returns:

ConfigRegister instance filled with register data

Raises:

ValueError – Register has no an identifier

classmethod from_xcf(element: Element) ConfigRegister[source]

Creates a register from register XML element.

Returns:

ConfigRegister filled with XML element data

to_xcf() Element[source]

Creates a XML element from class data.

Returns:

XML register element filled with class data

class ingenialink.configuration_file.ConfigTable(uid: str, subnode: int, elements: list[TableElement] | None = None)[source]

Table class for ConfigurationFile (XCF) class.

classmethod from_xcf(element: Element) ConfigTable[source]

Creates a ConfigTable from XML element.

Parameters:

element – XML Table element.

Returns:

ConfigTable instance filled with XML element data.

Raises:

ValueError – Missing required attribute.

to_xcf() Element[source]

Creates an XML element with class data.

Returns:

XML table element filled with class data.

class ingenialink.configuration_file.ConfigurationFile(device: Device)[source]

Configuration file (XCF) class.

It can be generated from a XCF file or be exported to a XCF file.

add_config_register(config_register: ConfigRegister) None[source]

Add ConfigRegister to the XCF class.

Parameters:

config_register – register that will be added to the XCF

add_config_table(config_table: ConfigTable) None[source]

Add ConfigTable to the XCF class.

Parameters:

config_table – table that will be added to the XCF

add_register(register: Register, value: float | int | str | bool) None[source]

Add register to the XCF class.

Parameters:
  • register – register that will be added to the XCF

  • value – value that will be added to the register in te XCF

contains_node(subnode: int) bool[source]

Check of configuration file contains register of the target subnode.

Parameters:

subnode – target subnode number

Returns:

True if contains target subnode registers, else False

classmethod create_empty_configuration(interface: Interface, part_number: str | None, product_code: int | None, revision_number: int | None, firmware_version: str | None, node_id: int | None = None) ConfigurationFile[source]

Create an empty XCF with the device info.

Parameters:
  • interface – drive interface

  • part_number – drive part number

  • product_code – drive product code

  • revision_number – drive firmware revision number

  • firmware_version – drive firmware version

  • node_id – drive node id. Only for CANopen drives

Returns:

creates a XCF instance

classmethod from_dictionary_defaults(dictionary: DictionaryV3) ConfigurationFile[source]

Create a ConfigurationFile populated with default values from an XDF3 dictionary.

Iterates all registers in the dictionary, filters to those that are writable (RW) and stored in NVM (NVM_CFG or NVM address type), and populates each with its declared default value.

Tables are not included in the generated ConfigurationFile, as they have no default values declared in the dictionary.

Parameters:

dictionary – XDF3 dictionary to read defaults from.

Returns:

ConfigurationFile with all valid registers set to their default values.

Raises:

ValueError – If a qualifying register has no default value or a bytes default (DOMAIN dtype), which indicates the dictionary is not a valid XDF3 or the register default is missing.

classmethod load_from_xcf(xcf_path: str) ConfigurationFile[source]

Creates a XCF instance from a XCF file.

Parameters:

xcf_path – XCF file path

Returns:

XCF instance with XCF file data

Raises:
  • FileNotFoundError – xcf_path file not found

  • NotImplementedError – Configuration file version not supported

override_values(other: ConfigurationFile) None[source]

Overlay another ConfigurationFile’s values onto this one.

For each register and table in other:

  • If a matching entry (same subnode and uid) exists in self, it is replaced.

  • If no match is found the entry is appended to self. For registers a warning is logged (unexpected mismatch). For tables a debug message is logged instead, because tables have no default values in the dictionary and are therefore never present in a ConfigurationFile built with from_dictionary_defaults().

Parameters:

other – ConfigurationFile whose values will be applied on top of self.

save_to_xcf(xcf_path: str) None[source]

Save a file with the config file in the target path.

Parameters:

xcf_path – config file target path

Raises:

ValueError – the configuration has no registers

property device: Device

Configuration file device.

property registers: list[ConfigRegister]

Configuration file registers.

property tables: list[ConfigTable]

Configuration file tables.

property version: str

Version string.

class ingenialink.configuration_file.Device(interface: Interface, part_number: str | None, product_code: int | None, revision_number: int | None, firmware_version: str | None, node_id: int | None = None)[source]

Device data for ConfigurationFile (XCF) class.

classmethod from_xcf(element: Element) Device[source]

Creates a Device instance from XML element.

Returns:

Device instance filled with XML element data.

to_xcf() Element[source]

Creates an XML element with class data.

Returns:

XML element filled with class data

class ingenialink.configuration_file.TableElement(address: int, data: bytes)[source]

Table element for ConfigTable class.

Represents a single element value stored in a position of a table.

classmethod from_xcf(element: Element, table_uid: str = '') TableElement[source]

Creates a TableElement from XML element.

Parameters:
  • element – XML Element element.

  • table_uid – Parent table UID for error messages.

Returns:

TableElement instance filled with XML element data.

Raises:

ValueError – Missing required attribute.

to_xcf() Element[source]

Creates an XML element with class data.

Returns:

XML element filled with class data.