cpx_io.cpx_system.cpx_ap package
Subpackages
- cpx_io.cpx_system.cpx_ap.builder package
- Submodules
- cpx_io.cpx_system.cpx_ap.builder.ap_module_builder module
- cpx_io.cpx_system.cpx_ap.builder.apdd_information_builder module
- cpx_io.cpx_system.cpx_ap.builder.channel_builder module
- cpx_io.cpx_system.cpx_ap.builder.diagnosis_builder module
- cpx_io.cpx_system.cpx_ap.builder.parameter_builder module
- cpx_io.cpx_system.cpx_ap.builder.physical_quantity_builder module
- Module contents
- cpx_io.cpx_system.cpx_ap.dataclasses package
- Submodules
- cpx_io.cpx_system.cpx_ap.dataclasses.apdd_information module
- cpx_io.cpx_system.cpx_ap.dataclasses.channels module
- cpx_io.cpx_system.cpx_ap.dataclasses.module_diagnosis module
- cpx_io.cpx_system.cpx_ap.dataclasses.module_parameters module
ModuleParametersModuleParameters.fieldbus_serial_numberModuleParameters.product_keyModuleParameters.firmware_versionModuleParameters.module_codeModuleParameters.temp_asicModuleParameters.logic_voltageModuleParameters.load_voltageModuleParameters.hw_versionModuleParameters.io_link_variantModuleParameters.operating_supply
- cpx_io.cpx_system.cpx_ap.dataclasses.system_parameters module
SystemParametersSystemParameters.dhcp_enableSystemParameters.ip_addressSystemParameters.subnet_maskSystemParameters.gateway_addressSystemParameters.active_ip_addressSystemParameters.active_subnet_maskSystemParameters.active_gateway_addressSystemParameters.mac_addressSystemParameters.setup_monitoring_load_supply
- Module contents
Submodules
cpx_io.cpx_system.cpx_ap.ap_docu_generator module
Documentation generator for AP systems
- cpx_io.cpx_system.cpx_ap.ap_docu_generator.generate_system_information_file(ap_system) None
Saves a readable document that includes the system information in the apdd path
cpx_io.cpx_system.cpx_ap.ap_modbus_registers module
Modbus register definitions for CPX-AP
cpx_io.cpx_system.cpx_ap.ap_module module
Generic AP module implementation from APDD
- class cpx_io.cpx_system.cpx_ap.ap_module.ApModule(apdd_information: ApddInformation, channels: tuple, parameter_list: list, diagnosis_list: list, variant_list: list, variant_switch_parameter: int | None)
Bases:
CpxModuleGeneric AP module class. This includes all functions that are shared among the modules. To get an overview of your system and the supported functions of the individual modules, see the system documentation of the CpxAp object
- is_function_supported(func_name)
Returns False if function is not supported
- read_output_channels() list
Read only output channels from module and interpret them as the module intends.
For mixed IN/OUTput modules the outputs are numbered from 0..<number of output channels>, the inputs cannot be accessed this way.
- Returns:
List of values of the channels
- Return type:
list
- read_channels() list
Read all channels from module and interpret them as the module intends.
- Returns:
List of values of the channels
- Return type:
list
- read_output_channel(channel: int) Any
Read back the value of one output channel.
For mixed IN/OUTput modules the outputs are numbered from 0..<number of output channels>, the inputs cannot be accessed this way.
- Parameters:
channel (int) – Channel number, starting with 0
- Returns:
Value of the channel
- Return type:
bool
- read_channel(channel: int) Any
Read back the value of one channel.
- Parameters:
channel (int) – Channel number, starting with 0
- Returns:
Value of the channel
- Return type:
bool
- write_channels(data: list[Any]) None
Write all channels with a list of values. Length of the list must fit the output size of the module. Get the size first by reading the channels and using len().
- Parameters:
data (list) – list of values for each output channel. The type of the list elements must fit to the module type
- write_channel(channel: int, value: Any) None
Set one channel value. Value must be the correct type, typecheck is done by the function Get the correct type by reading out the channel first and using type() on the value.
- Parameters:
channel (int) – Channel number, starting with 0
- Value:
Value that should be written to the channel
- set_channel(channel: int) None
Set one channel to logic high level.
- Parameters:
channel (int) – Channel number, starting with 0
- reset_channel(channel: int) None
Set one channel to logic low level.
- Parameters:
channel (int) – Channel number, starting with 0
- toggle_channel(channel: int) None
Set one channel the inverted of current logic level.
- Parameters:
channel (int) – Channel number, starting with 0
- write_module_parameter(parameter: str | int, value: int | bool | str, instances: int | list = None) None
Write module parameter if available.
- Parameters:
parameter (str | int) – Parameter name or ID
value (int | bool | str) – Value to write to the parameter, type depending on parameter
instances – (optional) Index or list of instances of the parameter. If None, all instances will be written
- get_parameter_from_identifier(parameter_identifier: int | str)
helper function to get parameter object from identifier
- read_module_parameter(parameter: str | int, instances: int | list = None) Any
Read module parameter if available. Access either by ID (faster) or by Name.
- Parameters:
parameter (str | int) – Parameter name or ID
instances – (optional) Index or list of instances of the parameter. If None, all instances will be written
- Returns:
Value of the parameter. Type depends on the parameter
- Return type:
Any
- read_module_parameter_enum_str(parameter: str | int, instances: int | list = None) Any
Read enum name of module parameter if available. Access either by ID (faster) or by Name.
- Parameters:
parameter (str | int) – Parameter name or ID
instances – (optional) Index or list of instances of the parameter. If None, all instances will be written
- Returns:
Name of the enum value.
- Return type:
str
- read_diagnosis_code() int
Read the diagnosis code from the module
- Ret value:
Diagnosis code
- Return type:
tuple
- read_present_state() bool
Read the present state from the module
- Ret value:
Present state
- Return type:
bool
- read_diagnosis_information() ModuleDiagnosis
- Read the diagnosis information from the module. Contains:
diagnosis_id
name
description
guideline
- Ret value:
Diagnosis information
- Return type:
ModuleDiagnosis or None if no diagnosis is active
- read_system_parameters() SystemParameters
Read parameters from EP module.
- Returns:
Parameters object containing all r/w parameters
- Return type:
Parameters
- read_pqi(channel: int = None) dict | list[dict]
Returns Port Qualifier Information for each channel. If no channel is given, returns a list of PQI dict for all channels.
- Parameters:
channel (int) – Channel number, starting with 0, optional
- Returns:
PQI information as dict for one channel or as list of dicts for more channels
- Return type:
dict | list[dict] depending on param channel
- read_fieldbus_parameters() list[dict]
Read all fieldbus parameters (status/information) for all channels.
- Returns:
a dict of parameters for every channel.
- Return type:
list[dict]
- cast_channel_argument_to_list(channels: list[int] | int) list[int]
Checks if the given channel argument is a list and casts it to a list if not. Else the list stays as it is. Returns a list containing the channels.
- Parameters:
channels – list of channels or single channel number
- Type:
channels
- read_isdu(channels: list[int] | int, index: int, subindex: int = 0, data_type: str = 'raw') any
Read isdu (device parameter) from defined channel. Raises CpxRequestError when read failed.
- Parameters:
channels (list[int] | int) – list of channels or single channel number(s) which should be read, starting with 0
index (int) – io-link parameter index
subindex (int) – (optional) io-link parameter subindex, defaults to 0
data_type (str) – (optional) datatype for correct interpretation. Check ap_supported_datatypes.SUPPORTED_ISDU_DATATYPES for a list of supported datatypes
- Returns:
list of values or single value depending on the datatype for each channel
- Return type:
list[any] | any
- write_isdu(data: bytes | str | int | bool, channels: list[int] | int, index: int, subindex: int = 0) None
Write isdu (device parameter) to defined channel. Raises CpxRequestError when write failed.
- Parameters:
data (bytes|str|int|bool) – Data to write.
channels (list[int] | int) – list of channel numbers or single channel number which should be written, starting with 0
index (int) – io-link parameter index
subindex (int) – io-link parameter subindex
- change_variant(variant: int | str) None
Change the module variant if supported.
- Parameters:
variant (int | str) – Variant number or name to change to
cpx_io.cpx_system.cpx_ap.ap_parameter module
Contains functions which provide mapping of parameter types.
- class cpx_io.cpx_system.cpx_ap.ap_parameter.Parameter(parameter_id: int, parameter_instances: dict, is_writable: bool, array_size: int, data_type: str, default_value: int, description: str, name: str, unit: str = '', enums: dict | None = None)
Bases:
objectParameter dataclass
- parameter_id: int
- parameter_instances: dict
- is_writable: bool
- array_size: int
- data_type: str
- default_value: int
- description: str
- name: str
- unit: str = ''
- enums: dict = None
- class cpx_io.cpx_system.cpx_ap.ap_parameter.ParameterEnum(enum_id: int, bits: int, data_type: str, enum_values: Enum, ethercat_enum_id: int, name: str)
Bases:
objectParameterEnum dataclass
- enum_id: int
- bits: int
- data_type: str
- enum_values: Enum
- ethercat_enum_id: int
- name: str
- cpx_io.cpx_system.cpx_ap.ap_parameter.parameter_unpack(parameter: Parameter, raw: bytes, forced_format: str | None = None) Any
Unpacks a raw byte value to specific type. The type is determined by the parameters included in ParameterMap.
param parameter: Parameter that should be unpacked. type parameter: Parameter param raw: Raw bytes value that should be unpacked. type raw: bytes param forced_format: Optional format char (see struct) to force the unpacking strategy. type forced_format: str return: Unpacked value with determined type rtype: Any
- cpx_io.cpx_system.cpx_ap.ap_parameter.parameter_pack(parameter: Parameter, value: Any, forced_format: str | None = None) bytes
Packs a provided value to raw bytes object. The type is determined by the parameters included in ParameterMap.
param parameter: Parameter of value that should be unpacked. type parameter: Parameter param value: Value that should be packed. type value: Any param forced_format: Optional format char (see struct) to force the packing strategy. type forced_format: str
return: Packed value rtype: bytes
cpx_io.cpx_system.cpx_ap.ap_product_categories module
AP product categories ENUMS
- class cpx_io.cpx_system.cpx_ap.ap_product_categories.ProductCategory(value)
Bases:
EnumEnum for ProductCategory
- INTERFACE = 10
- ANALOG = 20
- DIGITAL = 30
- MOTION = 40
- SERVO_DRIVES = 50
- SAFETY = 60
- IO_LINK = 61
- INFRASTRUCTURE = 70
- MPA_L = 80
- MPA_S = 81
- VTSA = 82
- VTUG = 83
- VTUX = 84
- VTOM = 85
- CONTROLLERS = 100
cpx_io.cpx_system.cpx_ap.ap_supported_datatypes module
All implemented datatypes
cpx_io.cpx_system.cpx_ap.ap_supported_functions module
All supported functions
cpx_io.cpx_system.cpx_ap.cpx_ap module
CPX-AP module implementations
- class cpx_io.cpx_system.cpx_ap.cpx_ap.CpxAp(timeout: float | None = None, apdd_path: str | None = None, docu_path: str | None = None, generate_docu: bool = True, cycle_time: float = 0.01, **kwargs)
Bases:
CpxBaseCPX-AP base class
Constructor of the CpxAp class. This generates an individual documentation in the <docu_path>. This path is individual for each operating system. You can either set the path as a parameter or print <self.docu_path> to see the path for your system. CPX-AP systems will be setup automatically from the device description files (APDD) of the modules. If there is a change in the system a reconnect is always required and this will also update the documentation. The filename will always include the ip-address, so you can have multiple systems with individual documentations.
- Parameters:
timeout (float) – Modbus timeout (in s) that should be configured on the slave
apdd_path (str) – (optional) Path where the description files of the modules are saved
docu_path (str) – (optional) Path where the documentation files are saved
generate_docu (bool) – (optional) parameter to disable the generation of the documentation this is useful for big systems when the generation takes too long
cycle_time (float) – (optional) Cycle time (in s) for refreshing the connection automatically to avoid timeouts. If None, no automatic refresh is done.
- class ApInformation(module_code: int | None = None, module_class: int | None = None, communication_profiles: int | None = None, input_size: int | None = None, input_channels: int | None = None, output_size: int | None = None, output_channels: int | None = None, hw_version: int | None = None, fw_version: str | None = None, serial_number: str | None = None, product_key: str | None = None, order_text: str | None = None)
Bases:
objectInformation of AP Module
- module_code: int = None
- module_class: int = None
- communication_profiles: int = None
- input_size: int = None
- input_channels: int = None
- output_size: int = None
- output_channels: int = None
- hw_version: int = None
- fw_version: str = None
- serial_number: str = None
- product_key: str = None
- order_text: str = None
- class Diagnostics(degree_of_severity_information: bool, degree_of_severity_maintenance: bool, degree_of_severity_warning: bool, degree_of_severity_error: bool, _4: None, _5: None, module_present: bool, _7: None)
Bases:
BitwiseReg8Diagnostic information
- degree_of_severity_information: bool
- degree_of_severity_maintenance: bool
- degree_of_severity_warning: bool
- degree_of_severity_error: bool
- module_present: bool
- shutdown()
Shutdown function
- perform_io() None
This function is called periodically by the IOThread. It reads the current diagnosis status.
- delete_apdds() None
Delete all downloaded apdds in the apdds path. This forces a refresh when a new CPX-AP System is instantiated
- static create_apdd_path() str
Creates the apdd directory depending on the operating system and returns the path
- static create_docu_path() str
Creates the docu directory depending on the operating system and returns the path
- property apdd_path
getter function for private apdd_path property
- property docu_path
getter function for private docu_path property
- set_timeout(timeout_ms: int) None
Sets the modbus timeout to the provided value
- Parameters:
timeout_ms (int) – Modbus timeout in ms (milli-seconds)
- read_module_count() int
Reads and returns IO module count as integer
- Returns:
Number of the total amount of connected modules
- Return type:
int
- print_system_information() None
Prints all parameters from all modules
- print_system_state() None
Prints all parameters and channels from every module
- read_apdd_information(position: int) ApInformation
Reads and returns detailed information for a specific IO module
- Parameters:
position (int) – Module position index starting with 0
- Returns:
ApInformation object containing all the module information from the module
- Return type:
- read_diagnostic_status() list[Diagnostics]
Read the diagnostic status and return a Diagnostics object for each module
- Ret value:
Diagnostics status for every module
- Return type:
list[Diagnostics]
- read_global_diagnosis_state() dict
Read the global diagnosis state from the cpx system. Returns dict of module diagnosis state containing a logical OR over all modules errors. This will give you an overview about what state the system is in.
- Ret value:
Diagnosis state
- Return type:
dict
- read_active_diagnosis_count() int
Read count of currently active diagnosis from the cpx system
- Ret value:
Amount of active diagnosis
- Return type:
int
- read_latest_diagnosis_index() int
Read the index of the module with the latest diagnosis. If no diagnosis is available, returns None
- Ret value:
Modul index
- Return type:
int or None
- read_latest_diagnosis_code() int
Read the latest diagnosis code from the cpx system
- Ret value:
Diagnosis code
- Return type:
int
- write_parameter(position: int, parameter: Parameter, data: list[int] | int | bool, instance: int = 0) None
Write parameters via module position, param_id, instance (=channel) and data to write Data must be a list of (signed) 16 bit values or one 16 bit (signed) value or bool Raises “CpxRequestError” if request denied
- Parameters:
position (int) – Module position index starting with 0
parameter (Parameter) – AP Parameter
data (list | int | bool) – list of 16 bit signed integers, one signed 16 bit integer or bool to write
instance (int) – Parameter Instance (typically used to define the channel, see datasheet)
- read_parameter(position: int, parameter: Parameter, instance: int = 0) Any
Read parameter
- Parameters:
position (int) – Module position index starting with 0
parameter (Parameter) – AP Parameter
instance (int) – (optional) Parameter Instance (typically the channel, see datasheet)
- Returns:
Parameter value
- Return type:
Any