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.

property callbacks

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 | secsgem.gem.collection_event.CollectionEventId, secsgem.gem.collection_event.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 class for stream and function.

Parameters:
  • stream – stream to get class for

  • function – function to get class for

Returns:

class for function

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.

disable_ceids()

Disable all Collection Events.

enable()

Enable the connection.

Return type:

None

property equipment_constants: dict[int | str | secsgem.gem.equipment_constant.EquipmentConstantId, secsgem.gem.equipment_constant.EquipmentConstant]

The list of the equipments contstants.

Returns:

Equipment constant list

property events

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.

Returns:

available Equipment Constants

Return type:

list

list_svs(svs=None)

Get list of available Service Variables.

Returns:

available Service Variables

Return type:

list

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 (Base) – 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 (Base) – 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 (Base) – 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 (Base) – 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 (integer) – stream to register callback for

  • function (integer) – function to register callback for

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

property registered_collection_events: dict[int | str, secsgem.gem.collection_event_link.CollectionEventLink]

Get list of the subscribed collection events.

Returns:

Collection event list

property registered_reports: dict[int | str, secsgem.gem.collection_event_report.CollectionEventReport]

Get list of the subscribed reports.

Returns:

Collection event report list

property remote_commands: dict[int | str | secsgem.gem.remote_command.RemoteCommandId, secsgem.gem.remote_command.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) – id of Equipment Constant

Returns:

value of requested Equipment Constant

Return type:

various

request_ecs(ecs)

Request contents of supplied Equipment Constants.

Parameters:

ecs (list) – Equipment Constants to request

Returns:

values of requested Equipment Constants

Return type:

list

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 Service Variable.

Parameters:

sv_id (int) – id of Service Variable

Returns:

value of requested Service Variable

Return type:

various

request_svs(svs)

Request contents of supplied Service Variables.

Parameters:

svs (list) – Service Variables to request

Returns:

values of requested Service Variables

Return type:

list

send_and_waitfor_response(*args, **kwargs)

Wrapper for connections send_and_waitfor_response function.

send_equipment_terminal(terminal_id, text)

Set text to equipment terminal.

Parameters:
  • terminal_id (int) – ID of terminal

  • text (string) – text to send

send_process_program(ppid, ppbody)

Send a process program.

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

  • ppbody (str) – Content of process program

send_response(*args, **kwargs)

Wrapper for connections send_response function.

send_stream_function(*args, **kwargs)

Wrapper for connections send_stream_function function.

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) – id of Equipment Constant

  • value (various) – new content of Equipment Constant

set_ecs(ecs)

Set contents of supplied Equipment Constants.

Parameters:

ecs (list) – list containing list of id / value pairs

property settings: Settings

Get the setting object.

property status_variables: dict[int | str, secsgem.gem.status_variable.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 (integer) – stream to unregister callback for

  • function (integer) – 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[secsgem.secs.variables.base.Base]

Get the data value type.

property use_callback: bool

Get if data value uses callback.

property id_type: type[secsgem.secs.variables.base.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

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.