EquipmentHandler

class secsgem.gem.GemEquipmentHandler(settings, initial_control_state='ATTEMPT_ONLINE', initial_online_control_state='REMOTE')[source]

Baseclass for creating equipment models. Inherit from this class and override required functions.

on_connection_closed(connection)[source]

Handle connection was closed event.

property alarms: dict[int | str, Alarm]

Get the list of the alarms.

Returns:

Alarms list

are_you_there()

Check if remote is still replying.

Return type:

Message | None

property callbacks: CallbackHandler

Property for callback handling.

clear_alarm(alid)

Clear the list of the alarms.

Parameters:

alid (int | str) – Alarm id

property collection_events: dict[int | str | CollectionEventId, CollectionEvent]

Get list of the collection events.

Returns:

Collection event list

property communication_state: CommunicationStateMachine

Get the communication state model.

property control_state: ControlStateMachine

Get control state.

control_switch_offline()

Operator switches to offline control state.

control_switch_online()

Operator switches to online control state.

control_switch_online_local()

Operator switches to the local online control state.

control_switch_online_remote()

Operator switches to the local online control state.

property data_items: DataItems

Get data item container.

Returns:

data item container

property data_values: dict[int | str, DataValue]

Get list of the data values.

Returns:

Data value list

disable()

Disable the connection.

Return type:

None

disable_ceid_reports()

Disable all Collection Event Reports.

Return type:

Message | None

disable_ceids()

Disable all Collection Events.

Return type:

Message | None

enable()

Enable the connection.

Return type:

None

property equipment_constants: dict[int | str | EquipmentConstantId, EquipmentConstant]

The list of the equipments contstants.

Returns:

Equipment constant list

property events: EventProducer

Wrapper for connections events.

get_ceid_name(ceid)

Get the name of a collection event.

Parameters:

ceid (int | str) – ID of collection event

Return type:

str

Returns:

Name of the event or empty string if not found

list_ecs(ecs=None)

Get list of available Equipment Constants.

Parameters:

ecs (list[str | int] | None) – Equipment Constants to list

Return type:

SecsStreamFunction

Returns:

available Equipment Constants

list_svs(svs=None)

Get list of available Status Variables.

Parameters:

svs (list[str | int] | None) – Status Variables to list

Return type:

SecsStreamFunction

Returns:

available Status Variables

on_commack_requested()

Get the acknowledgement code for the connection request.

override to accept or deny connection request

Return type:

int

Returns:

0 when connection is accepted, 1 when connection is denied

on_dv_value_request(_data_value_id, data_value)

Get the data value depending on its configuation.

Override in inherited class to provide custom data value request handling.

Parameters:
  • data_value_id – Id of the data value encoded in the corresponding type

  • data_value (DataValue) – The data value requested

Return type:

Base

Returns:

The value encoded in the corresponding type

on_ec_value_request(_equipment_constant_id, equipment_constant)

Get the equipment constant value depending on its configuation.

Override in inherited class to provide custom equipment constant request handling.

Parameters:
  • equipment_constant_id – Id of the equipment constant encoded in the corresponding type

  • equipment_constant (EquipmentConstant) – The equipment constant requested

Return type:

Base

Returns:

The value encoded in the corresponding type

on_ec_value_update(_equipment_constant_id, equipment_constant, value)

Set the equipment constant value depending on its configuation.

Override in inherited class to provide custom equipment constant update handling.

Parameters:
  • equipment_constant_id – Id of the equipment constant encoded in the corresponding type

  • equipment_constant (EquipmentConstant) – The equipment constant to be updated

  • value (int | float) – The value encoded in the corresponding type

on_sv_value_request(_svid, status_variable)

Get the status variable value depending on its configuation.

Override in inherited class to provide custom status variable request handling.

Parameters:
  • svid – Id of the status variable encoded in the corresponding type

  • status_variable (StatusVariable) – The status variable requested

Return type:

Base

Returns:

The value encoded in the corresponding type

property protocol: Protocol

Get the connection for the handler.

register_stream_function(stream, function, callback)

Register the function callback for stream and function.

Parameters:
  • stream (int) – stream to register callback for

  • function (int) – function to register callback for

  • callback (Callable) – method to call when stream and functions is received

property registered_collection_events: dict[int | str, CollectionEventLink]

Get list of the subscribed collection events.

Returns:

Collection event list

property registered_reports: dict[int | str, CollectionEventReport]

Get list of the subscribed reports.

Returns:

Collection event report list

property remote_commands: dict[int | str | RemoteCommandId, RemoteCommand]

Get list of the remote commands.

Returns:

Remote command list

request_ec(ec_id)

Request contents of one Equipment Constant.

Parameters:

ec_id (int | str) – id of Equipment Constant

Return type:

SecsStreamFunction

Returns:

value of requested Equipment Constant

request_ecs(ecs)

Request contents of supplied Equipment Constants.

Parameters:

ecs (list[int | str]) – Equipment Constants to request

Return type:

SecsStreamFunction

Returns:

values of requested Equipment Constants

request_process_program(ppid)

Request a process program.

ppid: Transferred process programs ID

Return type:

tuple[int | str, str]

request_sv(sv_id)

Request contents of one Status Variable.

Parameters:

sv_id (int | str) – id of Status Variable

Return type:

int | str | None

Returns:

value of requested Status Variable

request_svs(svs)

Request contents of supplied Status Variables.

Parameters:

svs (list[str | int]) – Status Variables to request

Return type:

SecsStreamFunction

Returns:

values of requested Status Variables

send_and_waitfor_response(function)

Wrapper for connections send_and_waitfor_response function.

Return type:

Message | None

send_equipment_terminal(terminal_id, text)

Set text to equipment terminal.

Parameters:
  • terminal_id (int) – ID of terminal

  • text (str) – text to send

Return type:

Message | None

send_process_program(ppid, ppbody)

Send a process program.

Parameters:
  • ppid (int | str) – Transferred process programs ID

  • ppbody (str) – Content of process program

Return type:

int

Returns:

Send result

send_response(function, system)

Wrapper for connections send_response function.

Return type:

bool

send_stream_function(function)

Wrapper for connections send_stream_function function.

Return type:

bool

serialize_data()

Get serialized data.

Return type:

dict[str, Any]

Returns:

data to serialize for this object

set_alarm(alid)

Set the list of the alarms.

Parameters:

alid (int | str) – Alarm id

set_ec(ec_id, value)

Set contents of one Equipment Constant.

Parameters:
  • ec_id (int | str) – id of Equipment Constant

  • value (int | str | float) – new content of Equipment Constant

Return type:

int

set_ecs(ecs)

Set contents of supplied Equipment Constants.

Parameters:

ecs (list[list[str | int | float]]) – list containing list of id / value pairs

Return type:

int

property settings: Settings

Get the setting object.

property status_variables: dict[int | str, StatusVariable]

Get list of the status variables.

Returns:

Status variable list

stream_function(stream, function)

Get class for stream and function.

Parameters:
  • stream (int) – stream to get class for

  • function (int) – function to get class for

Return type:

type[SecsStreamFunction]

Returns:

class for function

trigger_collection_events(ceids)

Triggers the supplied collection events.

Parameters:

ceids (list[int | str | CollectionEventId]) – List of collection events

unregister_stream_function(stream, function)

Unregister the function callback for stream and function.

Parameters:
  • stream (int) – stream to unregister callback for

  • function (int) – function to register callback for

waitfor_communicating(timeout=None)

Wait until connection gets into communicating state. Returns immediately if state is communicating.

Parameters:

timeout (float | None) – seconds to wait before aborting

Return type:

bool

Returns:

True if state is communicating, False if timed out

class secsgem.gem.DataValue(dvid, name, value_type, use_callback=True, **kwargs)[source]

Data value definition.

property dvid: int | str

Get the data value id.

property name: str

Get the data value name.

property value_type: type[Base]

Get the data value type.

property use_callback: bool

Get if data value uses callback.

property id_type: type[Base]

Get the data value id type.

class secsgem.gem.StatusVariable(svid, name, unit, value_type, use_callback=True, **kwargs)[source]

Status variable definition.

class secsgem.gem.CollectionEvent(ceid, name, data_values, **kwargs)[source]

Collection event definition.

Representation for registered/linked collection event.

property collection_event: CollectionEvent

Get the associated collection event.

property reports: list[int | str]

Get list of the data values.

Returns:

List of linked reports

class secsgem.gem.CollectionEventReport(rptid, variables, **kwargs)[source]

Report definition for registered collection events.

class secsgem.gem.EquipmentConstant(ecid, name, min_value, max_value, default_value, unit, value_type, use_callback=True, **kwargs)[source]

Equipment constant definition.