hvl_ccb.dev.cube.base

Inheritance diagram of hvl_ccb.dev.cube.base

Classes for the BaseCube device.

class BaseCube(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

Base class for Cube variants.

OPC_MAX_YEAR = 2089
OPC_MIN_YEAR = 1990
active_alarms(human_readable: bool = True) List[Union[int, str]][source]

Displays all active alarms / messages.

Parameters

human_readableTrue for human readable message, False for corresponding integer

Returns

list with active alarms

property breakdown_detection_active: bool

Get the state of the breakdown detection functionality. Returns True if it is enabled, False otherwise.

Returns

state of the breakdown detection functionality

breakdown_detection_reset() None[source]

Reset the breakdown detection circuitry so that it is ready to detect breakdowns again.

property breakdown_detection_triggered: bool

See if breakdown detection unit has been triggered. Returns True if it is triggered, False otherwise.

Returns

trigger status of the breakdown detection unit

property cee16_socket

Read the on-state of the IEC CEE16 three-phase power socket.

Returns

the on-state of the CEE16 power socket

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

classmethod datetime_to_opc(time_dt: datetime.datetime) List[int][source]

Converts python datetime format into opc format (list of 8 integers) as defined in the following link: https://support.industry.siemens.com/cs/mdm/109798671?c=133950752267&lc=de-WW Each byte corresponds to one list entry. [yy, MM, dd, hh, mm, ss, milliseconds, weekday] Milliseconds and Weekday are not used, as this precision / information is not needed. The conversion of the numbers is special. Each decimal number is treated as it would be a hex-number and then converted back to decimal. This is tested with the used PLC in the BaseCube. yy: 0 to 99 (0 -> 2000, 89 -> 2089, 90 -> 1990, 99 -> 1999) MM: 1 to 12 dd: 1 to 31 hh: 0 to 23 mm: 0 to 59 ss: 0 to 59

Parameters

time_dt – time to be converted

Returns

time in opc list format

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

display_message_board() None[source]

Display 15 newest messages

display_status_board() None[source]

Display status board.

door_1_status

Get the status of a safety fence door. See constants.DoorStatus for possible returned door statuses.

door_2_status

Get the status of a safety fence door. See constants.DoorStatus for possible returned door statuses.

door_3_status

Get the status of a safety fence door. See constants.DoorStatus for possible returned door statuses.

earthing_rod_1_status

Get the status of a earthing rod. See constants.EarthingRodStatus for possible returned earthing rod statuses.

earthing_rod_2_status

Get the status of a earthing rod. See constants.EarthingRodStatus for possible returned earthing rod statuses.

earthing_rod_3_status

Get the status of a earthing rod. See constants.EarthingRodStatus for possible returned earthing rod statuses.

property operate: Optional[bool]

Indicates if ‘operate’ is activated. ‘operate’ means locket safety circuit, red lamps, high voltage on and locked safety switches.

Returns

True if operate is activated (RedOperate), False if ready is deactivated (RedReady), None otherwise

quit_error() None[source]

Quits errors that are active on the Cube.

read(node_id: str)[source]

Local wrapper for the OPC UA communication protocol read method.

Parameters

node_id – the id of the node to read.

Returns

the value of the variable

property ready: Optional[bool]

Indicates if ‘ready’ is activated. ‘ready’ means locket safety circuit, red lamps, but high voltage still off.

Returns

True if ready is activated (RedReady), False if ready is deactivated (GreenReady), None otherwise

set_message_board(msgs: List[str], display_board: bool = True) None[source]

Fills messages into message board that display that 15 newest messages with a timestamp.

Parameters
  • msgs – list of strings

  • display_board – display 15 newest messages if True (default)

Raises

ValueError – if there are too many messages or the positions indices are invalid.

set_status_board(msgs: List[str], pos: Optional[List[int]] = None, clear_board: bool = True, display_board: bool = True) None[source]

Sets and displays a status board. The messages and the position of the message can be defined.

Parameters
  • msgs – list of strings

  • pos – list of integers [0…14]

  • clear_board – clear unspecified lines if True (default), keep otherwise

  • display_board – display new status board if True (default)

Raises

ValueError – if there are too many messages or the positions indices are invalid.

start() None[source]

Starts the device. Sets the root node for all OPC read and write commands to the Siemens PLC object node which holds all our relevant objects and variables.

property status: hvl_ccb.dev.cube.constants.SafetyStatus

Get the safety circuit status of the Cube. This methods is for the user.

Returns

the safety status of the Cube’s state machine.

stop() None[source]

Stop the Cube device. Deactivates the remote control and closes the communication protocol.

Raises

CubeStopError – when the cube is not in the correct status to stop the operation

t13_socket_1

Set and get the state of a SEV T13 power socket.

t13_socket_2

Set and get the state of a SEV T13 power socket.

t13_socket_3

Set and get the state of a SEV T13 power socket.

write(node_id, value) None[source]

Local wrapper for the OPC UA communication protocol write method.

Parameters
  • node_id – the id of the node to write

  • value – the value to write to the variable

class BaseCubeConfiguration(namespace_index: int = 3, polling_delay_sec: Union[int, float] = 5.0, polling_interval_sec: Union[int, float] = 1.0, timeout_status_change: Union[int, float] = 6, timeout_interval: Union[int, float] = 0.1, noise_level_measurement_channel_1: Union[int, float] = 100, noise_level_measurement_channel_2: Union[int, float] = 100, noise_level_measurement_channel_3: Union[int, float] = 100, noise_level_measurement_channel_4: Union[int, float] = 100)[source]

Bases: object

Configuration dataclass for the BaseCube devices.

clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters
  • fieldname – name of the field

  • value – value to assign

is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns

a list of strings containing all keys.

namespace_index: int = 3

Namespace of the OPC variables, typically this is 3 (coming from Siemens)

noise_level_measurement_channel_1: Union[int, float] = 100
noise_level_measurement_channel_2: Union[int, float] = 100
noise_level_measurement_channel_3: Union[int, float] = 100
noise_level_measurement_channel_4: Union[int, float] = 100
classmethod optional_defaults() Dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns

a list of strings containing all optional keys.

polling_delay_sec: Union[int, float] = 5.0
polling_interval_sec: Union[int, float] = 1.0
classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns

a list of strings containing all required keys.

timeout_interval: Union[int, float] = 0.1
timeout_status_change: Union[int, float] = 6
class BaseCubeOpcUaCommunication(config)[source]

Bases: hvl_ccb.comm.opc.OpcUaCommunication

Communication protocol specification for BaseCube devices.

static config_cls()[source]

Return the default configdataclass class.

Returns

a reference to the default configdataclass class

class BaseCubeOpcUaCommunicationConfig(host: typing.Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address], endpoint_name: str = _CubeOpcEndpoint.BASE_CUBE, port: int = 4840, sub_handler: hvl_ccb.comm.opc.OpcUaSubHandler = <hvl_ccb.dev.cube.base._BaseCubeSubscriptionHandler object>, update_parameter: asyncua.ua.uaprotocol_auto.CreateSubscriptionParameters = CreateSubscriptionParameters(RequestedPublishingInterval=1000, RequestedLifetimeCount=300, RequestedMaxKeepAliveCount=22, MaxNotificationsPerPublish=10000, PublishingEnabled=True, Priority=0), wait_timeout_retry_sec: typing.Union[int, float] = 1, max_timeout_retry_nr: int = 5)[source]

Bases: hvl_ccb.comm.opc.OpcUaCommunicationConfig

Communication protocol configuration for OPC UA, specifications for the BaseCube devices.

endpoint_name: str = 'BaseCube'

Endpoint of the OPC server, this is a path like ‘OPCUA/SimulationServer’

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters
  • fieldname – name of the field

  • value – value to assign

classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns

a list of strings containing all keys.

classmethod optional_defaults() Dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns

a list of strings containing all optional keys.

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns

a list of strings containing all required keys.

sub_handler: hvl_ccb.comm.opc.OpcUaSubHandler = <hvl_ccb.dev.cube.base._BaseCubeSubscriptionHandler object>

Subscription handler for data change events