PDOs

class ingenialink.pdo.PDOMap(is_dirty: bool = True)[source]

Abstract class that contains PDO mapping information.

add_item(item: PDOMapItem) None[source]

Append a new item.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:

item – Item to be added.

Raises:

ValueError – If the item is not of the expected type.

add_registers(registers: EthercatRegister | CanopenRegister | list[EthercatRegister | CanopenRegister]) None[source]

Add a register or a list of registers in bulk.

It creates a new item for each register and adds it the items attribute.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:

registers – Register object or list of Registers.

clear() None[source]

Clear all items.

create_item(register: EthercatRegister | CanopenRegister, size_bits: int | None = None) PDOMapItem[source]

Create a new PDOMapItem.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:
  • register – Register object.

  • size_bits – Register size in bits.

Returns:

PDO Map item.

static create_item_from_register_uid(uid: str, dictionary: Dictionary, axis: int | None = None, value: int | float | None = None) RPDOMapItem | TPDOMapItem[source]

Create a PDOMapItem from a register uid.

Parameters:
  • uid – register uid to be mapped.

  • dictionary – servo dictionary to retrieve the registers.

  • axis – servo axis. Defaults to None. Should be specified if multiaxis, None otherwise.

  • value – Initial value for an RPDO register.

Returns:

PDOMapItem instance.

Raises:
  • ValueError – If there is a type mismatch retrieving the register object.

  • ValueError – if the pdo access type is not supported.

  • AttributeError – If an initial value is not provided for an RPDO register.

classmethod from_pdo_items(items: PDO_MAP_ITEM_TYPE | list[PDO_MAP_ITEM_TYPE]) PDO_MAP_TYPE[source]

Create a PDOMap from a list of PDOMapItems.

Parameters:
  • items – List of PDOMapItems.

  • dictionary – Canopen dictionary to retrieve the registers.

Returns:

PDOMap instance.

Raises:

ValueError – If the items are not of the expected type.

classmethod from_pdo_value(value: bytes, map_obj: CanOpenObject, dictionary: CanopenDictionary, is_dirty: bool) PDO_MAP_TYPE[source]

Create a PDOMap from the full pdo value (accessed via complete access).

Parameters:
  • value – Value of the pdo mapping in bytes.

  • map_obj – Mapping Canopen object.

  • dictionary – Canopen dictionary to retrieve the registers.

  • is_dirty – If the map has been modified since last read and not written to the slave.

Returns:

PDOMap instance.

get_item_bits() bitarray[source]

Return the concatenated items raw data (in bits).

Raises:
  • ILError – Raw data is empty.

  • ILError – If the length of the bit array is incorrect.

Returns:

Concatenated items raw data in bits.

get_item_bytes() bytes[source]

Return the concatenated items raw data (in bytes).

Returns:

Concatenated items raw data in bytes.

get_text_representation(item_space: int = 40) str[source]

Get a text representation of the map.

Returns:

Text representation of the map.

Return type:

str

map_register_values() dict[CanopenRegister, int | None][source]

Returns a dictionary with the mapping of the register items.

Associates which pdo mapping value will have each map register Unused mapping registers will return as None.

This method does not write the mapping to the slave, or express what the mapping on the slave should be. Use PDOMap.write_to_slave method instead

Raises:

ValueError – If the map_object is None. The map_object must be set before calling this method.

Returns:

dictionary with mapping register as keys and mapping value or None as values.

set_item_bytes(data_bytes: bytes) None[source]

Set the items raw data from a byte array.

Parameters:

data_bytes – Byte array.

Raises:

ILError – If the length of the received data does not coincide.

subscribe_to_process_data_event(callback: Callable[[], None]) None[source]

Subscribe to process data notifications.

Parameters:

callback – Subscribed callback function.

Raises:

ValueError – If a callback has already been set.

to_pdo_value() bytes[source]

Convert the PDOMap to the full pdo value (accessed via complete access).

Returns:

Value of the pdo mapping in bytes.

unsubscribe_to_process_data_event() None[source]

Unsubscribe from process data notifications.

write_to_slave(max_pdo_items_for_padding: int | None = None, padding: bool = False) None[source]

Write the PDOMap to the slave.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:
  • max_pdo_items_for_padding – Maximum number of items for padding. If set, it will pad the PDOMap with empty items to reach this number. If None, no padding is done.

  • padding – If True, it will force to zero the unused items in the PDOMap.

Raises:

ValueError – If the slave is not set or the map_register_index is None.

property data_length_bits: int

Length of the map in bits.

Returns:

Length of the map in bits.

property data_length_bytes: int

Length of the map in bytes.

Returns:

Length of the map in bytes.

property is_dirty: bool

Check if the PDOMap has been modified since last read and not written to the slave.

Returns:

True if the PDOMap is dirty, False otherwise.

Return type:

bool

property is_editable: bool

Check if the PDOMap is editable.

Raises:

ValueError – If the map_object is None. The map_object must be set to check if the map is editable.

Returns:

True if the PDOMap is editable, False otherwise.

Return type:

bool

property items: tuple[PDOMapItem, ...]

Tuple of items (immutable).

Returns:

Tuple of items.

property items_mapping: bytearray

Returns all register item mappings concatenated.

Returns:

_description_

Return type:

int

property map_object: CanOpenObject | None

CanOpen object of the mapping register.

Returns:

CanOpen object of the mapping register.

property map_register_index: int | None

Index of the mapping register. None if it is not mapped in the slave.

Returns:

Index of the mapping register.

property map_register_index_bytes: bytes

Index of the mapping register in bytes.

Returns:

Index of the mapping register in bytes.

Raises:

ValueError – If map_register_index is None

property slave: PDOServo | None

Servo to which this PDO is mapped, None if it’s not mapped to any servo.

class ingenialink.pdo.PDOMapItem(register: None | EthercatRegister | CanopenRegister = None, size_bits: int | None = None)[source]

Abstract class to represent a register in the PDO mapping.

register

mapped register object. If None the item will padding.

size_bits

custom register size in bits.

Raises:
  • ValueError – If the register and size_bits are not provided.

  • ValueError – If the size_bits value is invalid. Only when the register

  • is set to None.

classmethod from_register_mapping(mapping: int, dictionary: CanopenDictionary) PDOMapItem[source]

Create a PDOMapItem from a register mapping.

Parameters:
  • mapping – Register mapping in bytes.

  • dictionary – Canopen dictionary to retrieve the registers.

Returns:

PDOMapItem instance.

ACCEPTED_CYCLICS: tuple[RegCyclicType, ...]

CYCLIC_TX, CYCLIC_RX, CYCLIC_SI, CYCLIC_SO, CYCLIC_SISO.

Type:

Accepted cyclic

property raw_data_bits: bitarray

Raw data in bits.

Returns:

Raw data in bits

Raises:

ILError – If the raw data is empty.

property raw_data_bytes: bytes

Raw data in bytes.

Returns:

Raw data in bytes

Raises:

ILError – If the raw data is empty.

property register_mapping: int

Arrange register information into PDO mapping format.

Returns:

PDO register mapping format.

property value: int | float | bool | bytes

Register value. Converts the raw data bytes into the register value.

Raises:
  • ILError – If the raw data is empty.

  • ILError – If the register type is not int or float.

Returns:

Register value.

class ingenialink.pdo.PDOServo(target: int | str, dictionary_path: str, servo_status_listener: bool = False, disconnect_callback: Callable[[Servo], None] | None = None)[source]

Abstract class to implement PDOs in a Servo class.

abstract check_servo_is_in_preoperational_state() None[source]

Checks if the servo is in preoperational state.

Raises:

ILEcatStateError – if servo is not in preoperational state.

generate_pdo_outputs() None[source]

Process the PDO outputs.

It should call _process_tpdo method using the received bytes as argument.

map_pdos(slave_index: int) None[source]

Map RPDO and TPDO register into the slave.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:

slave_index – salve index.

map_rpdos() None[source]

Map the RPDO registers into the servo slave.

It writes the RPDO maps into the slave, saves the RPDO maps in the _rpdo_maps attribute and adds them to the PDO Assign object.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Raises:

ILError – If there are no available PDOs.

map_tpdos() None[source]

Map the TPDO registers into the servo slave.

It writes the TPDO maps into the slave, saves the TPDO maps in the _tpdo_maps attribute and adds them to the PDO Assign object

WARNING: This operation can not be done if the servo is not in pre-operational state.

Raises:

ILError – If there are no available PDOs.

process_pdo_inputs() None[source]

Process the PDO inputs.

It should call _process_rpdo method to obtain the bytes to be sent to the slave.

remove_rpdo_map(rpdo_map: RPDOMap | None = None, rpdo_map_index: int | None = None) None[source]

Remove a RPDOMap from the RPDOMap list.

WARNING: This operation can not be done if the servo is not in pre-operational state.

Parameters:
  • rpdo_map – The RPDOMap instance to be removed.

  • rpdo_map_index – The map index of the RPDOMap list to be removed.

Raises:

ValueError – If the RPDOMap instance is not in the RPDOMap list.

remove_tpdo_map(tpdo_map: TPDOMap | None = None, tpdo_map_index: int | None = None) None[source]

Remove a TPDOMap from the TPDOMap list.

Parameters:
  • tpdo_map – The TPDOMap instance to be removed.

  • tpdo_map_index – The map index of the TPDOMap list to be removed.

Raises:

ValueError – If the TPDOMap instance is not in the TPDOMap list.

reset_pdo_mapping() None[source]

Reset the RPDO and TPDO mapping in the slave.

WARNING: This operation can not be done if the servo is not in pre-operational state.

reset_rpdo_mapping() None[source]

Delete the RPDO mapping stored in the servo slave.

WARNING: This operation can not be done if the servo is not in pre-operational state.

reset_tpdo_mapping() None[source]

Delete the TPDO mapping stored in the servo slave.

WARNING: This operation can not be done if the servo is not in pre-operational state.

set_pdo_map_to_slave(rpdo_maps: list[RPDOMap], tpdo_maps: list[TPDOMap]) None[source]

Callback called by the slave to configure the map.

Parameters:
  • rpdo_maps – List of RPDO maps.

  • tpdo_maps – List of TPDO maps.

property dictionary: CanopenDictionary

Canopen dictionary.

class ingenialink.pdo.RPDOMap(is_dirty: bool = True)[source]

Class to store RPDO mapping information.

class ingenialink.pdo.RPDOMapItem(register: None | EthercatRegister | CanopenRegister = None, size_bits: int | None = None)[source]

Class to represent RPDO mapping items.

ACCEPTED_CYCLICS: tuple[RegCyclicType, ...] = (RegCyclicType.RX, RegCyclicType.SAFETY_OUTPUT, RegCyclicType.SAFETY_INPUT_OUTPUT)

CYCLIC_TX, CYCLIC_RX, CYCLIC_SI, CYCLIC_SO, CYCLIC_SISO.

Type:

Accepted cyclic

property value: int | float | bytes

Register value. Converts the raw data bytes into the register value.

Raises:
  • ILError – If the raw data is empty.

  • ILError – If the register type is not int or float.

Returns:

Register value.

class ingenialink.pdo.TPDOMap(is_dirty: bool = True)[source]

Class to store TPDO mapping information.

class ingenialink.pdo.TPDOMapItem(register: None | EthercatRegister | CanopenRegister = None, size_bits: int | None = None)[source]

Class to represent TPDO mapping items.

ACCEPTED_CYCLICS: tuple[RegCyclicType, ...] = (RegCyclicType.TX, RegCyclicType.SAFETY_INPUT, RegCyclicType.SAFETY_INPUT_OUTPUT)

CYCLIC_TX, CYCLIC_RX, CYCLIC_SI, CYCLIC_SO, CYCLIC_SISO.

Type:

Accepted cyclic

ingenialink.pdo.MAP_REGISTER_BYTES = 4

Number of bytes used to store each mapping register information.