cpx_io.cpx_system package

Subpackages

Submodules

cpx_io.cpx_system.cpx_base module

CPX Base

exception cpx_io.cpx_system.cpx_base.CpxInitError(message='Module must be part of a Cpx class. Use add_module() to add it')

Bases: Exception

Error should be raised if a cpx-… module is instanciated without connecting it to a base module. Connect it to the cpx by adding it with add_module(<object instance>)

exception cpx_io.cpx_system.cpx_base.CpxRequestError(message='Request failed')

Bases: Exception

Error should be raised if a parameter or register request is denied

exception cpx_io.cpx_system.cpx_base.CpxConnectionError(message='Failed to connect to the CPX system.Check your connection and network configuration.')

Bases: Exception

Error should be raised when a connection to the CPX system fails.

class cpx_io.cpx_system.cpx_base.CpxBase(ip_address: str | None = None)

Bases: object

A class to connect to the Festo CPX system and read data from IO modules

Constructor of CpxBase class.

Parameters:

ip_address (str) – Required IP address as string e.g. (‘192.168.1.1’)

update_module_names()

Updates the module name list and attributes accordingly

shutdown()

Shutdown function

reconnect()

Shutdown modbus connection and reconnect

connected() bool

Returns information about connection status

check_connection_and_try_reconnect()

checks the modbus connection and tries to reconnect if the connection is timedout

read_device_info() dict

Reads device info from the CPX system and returns dict with containing values

return: Contains device information values rtype: dict

class BitwiseReg8

Bases: _BitwiseReg

Half Register

byte_size: int = 1
class BitwiseReg16

Bases: _BitwiseReg

Full Register

byte_size: int = 2
read_reg_data(register: int, length: int = 1) bytes

Reads and returns register(s) from Modbus server without interpreting the data

Parameters:
  • register (int) – adress of the first register to read

  • length (int) – number of registers to read (default: 1)

Returns:

Register(s) content

Return type:

bytes

write_reg_data(data: bytes, register: int) None

Write bytes object data to register(s).

Parameters:
  • data (bytes) – data to write to the register(s)

  • register (int) – adress of the first register to write

write_reg_data_with_single_cmds(data: bytes, register: int) None

Write bytes object data to register(s), with only single register writes. This is necessary for some firmware on particular addresses, where multiple register writes are not supported.

Parameters:
  • data (bytes) – data to write to the register(s)

  • register (int) – adress of the first register to write

static require_base(func)

For most module functions, a base is required that handles the registers, module numbering, etc.

cpx_io.cpx_system.cpx_dataclasses module

CPX SystemEntryRegisters dataclass

class cpx_io.cpx_system.cpx_dataclasses.SystemEntryRegisters(inputs: int | None = None, outputs: int | None = None, diagnosis: int | None = None)

Bases: object

Initial modbus registers of the AP system

inputs: int = None
outputs: int = None
diagnosis: int = None

cpx_io.cpx_system.cpx_module module

CpxModule

class cpx_io.cpx_system.cpx_module.CpxModule(name=None)

Bases: object

A class to connect to the Festo CPX system and read data from IO modules

property name

Property getter for name.

cpx_io.cpx_system.io_thread module

cpx_io - IOThread class for handling I/O transfers in a separate thread.

class cpx_io.cpx_system.io_thread.IOThread(perform_io=None, cycle_time: float = 0.01)

Bases: Thread

Class to handle I/O transfers in a separate thread.

Constructor of the IOThread class.

Parameters:
  • perform_io (function) – function that is called periodically (with interval cycle_time) and performs the I/O data transfer

  • cycle_time (float) – Cycle time that should be used for I/O transfers

run()

Method that needs to be implemented by child.

start()

Starts the thread.

stop()

Stops the thread.

Module contents