EquipmentHandler¶
-
class
secsgem.gem.equipmenthandler.
GemEquipmentHandler
(address, port, active, session_id, name, custom_connection_handler=None, initial_control_state='ATTEMPT_ONLINE', initial_online_control_state='REMOTE')[source]¶ Bases:
secsgem.gem.handler.GemHandler
Baseclass for creating equipment models. Inherit from this class and override required functions.
Parameters: - address (string) – IP address of remote host
- port (integer) – TCP port of remote host
- active (boolean) – Is the connection active (True) or passive (False)
- session_id (integer) – session / device ID to use for connection
- name (string) – Name of the underlying configuration
- custom_connection_handler (
secsgem.hsms.connections.HsmsMultiPassiveServer
) – object for connection handling (ie multi server) - initial_control_state (string) – initial state for the control state model, one of [“EQUIPMENT_OFFLINE”, “ATTEMPT_ONLINE”, “HOST_OFFLINE”, “ONLINE”]
-
data_values
¶ The list of the data values
Returns: Data value list Return type: list of secsgem.gem.equipmenthandler.DataValue
-
on_dv_value_request
(dvid, dv)[source]¶ Get the data value depending on its configuation.
Override in inherited class to provide custom data value request handling.
Parameters: - dvid (
secsgem.secs.variables.SecsVar
) – Id of the data value encoded in the corresponding type - dv (
secsgem.gem.equipmenthandler.DataValue
) – The data value requested
Returns: The value encoded in the corresponding type
Return type: - dvid (
-
status_variables
¶ The list of the status variables
Returns: Status variable list Return type: list of secsgem.gem.equipmenthandler.StatusVariables
-
on_sv_value_request
(svid, sv)[source]¶ Get the status variable value depending on its configuation.
Override in inherited class to provide custom status variable request handling.
Parameters: - svid (
secsgem.secs.variables.SecsVar
) – Id of the status variable encoded in the corresponding type - sv (
secsgem.gem.equipmenthandler.StatusVariable
) – The status variable requested
Returns: The value encoded in the corresponding type
Return type: - svid (
-
collection_events
¶ The list of the collection events
Returns: Collection event list Return type: list of secsgem.gem.equipmenthandler.CollectionEvent
-
registered_reports
¶ The list of the subscribed reports
Returns: Collection event report list Return type: dictionary of subscribed reports
-
registered_collection_events
¶ The list of the subscribed collection events
Returns: Collection event list Return type: dictionary of secsgem.gem.equipmenthandler.CollectionEventLink
-
trigger_collection_events
(ceids)[source]¶ Triggers the supplied collection events
Parameters: ceids (list of various) – List of collection events
-
equipment_constants
¶ The list of the equipments contstants
Returns: Equipment constant list Return type: list of secsgem.gem.equipmenthandler.EquipmentConstant
-
on_ec_value_request
(ecid, ec)[source]¶ Get the equipment constant value depending on its configuation.
Override in inherited class to provide custom equipment constant request handling.
Parameters: - ecid (
secsgem.secs.variables.SecsVar
) – Id of the equipment constant encoded in the corresponding type - ec (
secsgem.gem.equipmenthandler.EquipmentConstant
) – The equipment constant requested
Returns: The value encoded in the corresponding type
Return type: - ecid (
-
on_ec_value_update
(ecid, ec, value)[source]¶ Set the equipment constant value depending on its configuation.
Override in inherited class to provide custom equipment constant update handling.
Parameters: - ecid (
secsgem.secs.variables.SecsVar
) – Id of the equipment constant encoded in the corresponding type - ec (
secsgem.gem.equipmenthandler.EquipmentConstant
) – The equipment constant to be updated - value (
secsgem.secs.variables.SecsVar
) – The value encoded in the corresponding type
- ecid (
-
alarms
¶ The list of the alarms
Returns: Alarms list Return type: list of secsgem.gem.equipmenthandler.Alarm
-
are_you_there
()¶ Check if remote is still replying
-
callbacks
¶ Property for callback handling
-
disable
()¶ Disables the connection
-
disable_ceid_reports
()¶ Disable all Collection Event Reports.
-
disable_ceids
()¶ Disable all Collection Events.
-
enable
()¶ Enables the connection
-
events
¶ Property for event handling
-
get_ceid_name
(ceid)¶ Get the name of a collection event
Parameters: ceid (integer) – ID of collection event Returns: Name of the event or empty string if not found Return type: string
-
get_dvid_name
(dvid)¶ Get the name of a data value
Parameters: dvid (integer) – ID of data value Returns: Name of the event or empty string if not found Return type: string
-
get_next_system_counter
()¶ Returns the next System.
Returns: System for the next command Return type: integer
-
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
Returns: 0 when connection is accepted, 1 when connection is denied Return type: integer
-
on_connection_before_closed
(_)¶ Connection is about to be closed
-
on_connection_established
(_)¶ Connection was established
-
on_connection_packet_received
(_, packet)¶ Packet received by connection
Parameters: packet ( secsgem.hsms.packets.HsmsPacket
) – received data packet
-
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
-
remote_commands
¶ Dictionary of available remote commands
Example:
>>> handler = SecsHandler("127.0.0.1", 5000, True, 0, "test") >>> handler.remote_commands["PP_SELECT"] = {'params': [{'name': 'PROGRAM', 'format': 'A'}], 'ceids': [200, 343]}
Key
Name of the remote command (string)
Data
Dictionary with the following fields
- params
Parameters for the remote command (list of dictionaries)
Parameters
The dictionaries have the following fields
- name
- name of the parameter (string)
- format
- format character of the parameter (string)
- ceids
- Collection events ids the remote command might return (list of integers)
-
request_ec
(ec)¶ Request contents of one Equipment Constant.
Parameters: ec (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
Parameters: ppid (string) – Transferred process programs ID
-
request_sv
(sv)¶ Request contents of one Service Variable.
Parameters: sv (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
-
secs_decode
(packet)¶ Get object of decoded stream and function class, or None if no class is available.
Parameters: packet ( secsgem.hsms.packets.HsmsPacket
) – packet to get object forReturns: matching stream and function object Return type: secsSxFx object
-
send_and_waitfor_response
(packet)¶ Send the packet and wait for the response
Parameters: packet ( secsgem.secs.functionbase.SecsStreamFunction
) – packet to be sentReturns: Packet that was received Return type: secsgem.hsms.packets.HsmsPacket
-
send_deselect_req
()¶ Send a Deselect Request to the remote host
Returns: System of the sent request Return type: integer
-
send_deselect_rsp
(system_id)¶ Send a Deselect Response to the remote host
Parameters: system_id (integer) – System of the request to reply for
-
send_equipment_terminal
(terminal_id, text)¶ Set text to equipment terminal
Parameters: - terminal_id (int) – ID of terminal
- text (string) – text to send
-
send_linktest_req
()¶ Send a Linktest Request to the remote host
Returns: System of the sent request Return type: integer
-
send_linktest_rsp
(system_id)¶ Send a Linktest Response to the remote host
Parameters: system_id (integer) – System of the request to reply for
-
send_process_program
(ppid, ppbody)¶ Send a process program
Parameters: - ppid (string) – Transferred process programs ID
- ppbody (string) – Content of process program
-
send_reject_rsp
(system_id, s_type, reason)¶ Send a Reject Response to the remote host
Parameters: - system_id (integer) – System of the request to reply for
- s_type (integer) – s_type of rejected message
- reason (integer) – reason for rejection
-
send_response
(function, system)¶ Send response function for system
Parameters: - function (
secsgem.secs.functionbase.SecsStreamFunction
) – function to be sent - system (integer) – system to reply to
- function (
-
send_select_req
()¶ Send a Select Request to the remote host
Returns: System of the sent request Return type: integer
-
send_select_rsp
(system_id)¶ Send a Select Response to the remote host
Parameters: system_id (integer) – System of the request to reply for
-
send_separate_req
()¶ Send a Separate Request to the remote host
-
send_stream_function
(packet)¶ Send the packet and wait for the response
Parameters: packet ( secsgem.secs.functionbase.SecsStreamFunction
) – packet to be sent
-
set_ec
(ec, value)¶ Set contents of one Equipment Constant.
Parameters: - ec (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
-
stream_function
(stream, function)¶ Get class for stream and function
Parameters: - stream (int) – stream to get function for
- function (int) – function to get
Returns: matching stream and function class
Return type: secsSxFx class
-
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) – seconds to wait before aborting Returns: True if state is communicating, False if timed out Return type: bool
-
class
secsgem.gem.equipmenthandler.
DataValue
(dvid, name, value_type, use_callback=True, **kwargs)[source]¶ Bases:
object
Data value definition
You can manually set the secs-type of the id with the ‘id_type’ keyword argument.
Custom parameters can be set with the keyword arguments, they will be passed to the GemEquipmentHandlers callback
secsgem.gem.equipmenthandler.GemEquipmentHandler.on_dv_value_request()
.If use_callbacks is disabled, you can set the value with the value property.
Parameters: - dvid (various) – ID of the data value
- name (string) – long name of the data value
- value_type (type of class inherited from
secsgem.secs.variables.SecsVar
) – type of the data value - use_callback (boolean) – use the GemEquipmentHandler callbacks to get variable (True) or use internal value
-
class
secsgem.gem.equipmenthandler.
StatusVariable
(svid, name, unit, value_type, use_callback=True, **kwargs)[source]¶ Bases:
object
Status variable definition
You can manually set the secs-type of the id with the ‘id_type’ keyword argument.
Custom parameters can be set with the keyword arguments, they will be passed to the GemEquipmentHandlers callback
secsgem.gem.equipmenthandler.GemEquipmentHandler.on_sv_value_request()
.If use_callbacks is disabled, you can set the value with the value property.
Parameters: - svid (various) – ID of the status variable
- name (string) – long name of the status variable
- unit (string) – unit (see SEMI E5, Units of Measure)
- value_type (type of class inherited from
secsgem.secs.variables.SecsVar
) – type of the status variable - use_callback (boolean) – use the GemEquipmentHandler callbacks to get variable (True) or use internal value
-
class
secsgem.gem.equipmenthandler.
CollectionEvent
(ceid, name, data_values, **kwargs)[source]¶ Bases:
object
Collection event definition
You can manually set the secs-type of the id with the ‘id_type’ keyword argument.
Custom parameters can be set with the keyword arguments, they will be passed to the GemEquipmentHandlers callback
secsgem.gem.equipmenthandler.GemEquipmentHandler.on_dv_value_request()
.If use_callbacks is disabled, you can set the value with the value property.
Parameters: - ceid (various) – ID of the collection event
- name (string) – long name of the collection event
- data_values (list of DVIDs) – data values available for this event
-
class
secsgem.gem.equipmenthandler.
CollectionEventLink
(ce, reports, **kwargs)[source]¶ Bases:
object
Representation for registered/linked collection event
Parameters: - ce (
secsgem.gem.equipmenthandler.CollectionEvent
) – ID of the collection event - reports (list of
secsgem.gem.equipmenthandler.CollectionEventReport
) – list of the linked reports
-
reports
¶ The list of the data values
Returns: List of linked reports Return type: list of secsgem.gem.equipmenthandler.CollectionEventReport
- ce (
-
class
secsgem.gem.equipmenthandler.
CollectionEventReport
(rptid, variables, **kwargs)[source]¶ Bases:
object
Report definition for registered collection events
You can manually set the secs-type of the id with the ‘id_type’ keyword argument.
Parameters: - rptid (various) – ID of the report
- vars (string) – long name of the collection event
-
class
secsgem.gem.equipmenthandler.
EquipmentConstant
(ecid, name, min_value, max_value, default_value, unit, value_type, use_callback=True, **kwargs)[source]¶ Bases:
object
Equipment constant definition
You can manually set the secs-type of the id with the ‘id_type’ keyword argument.
Custom parameters can be set with the keyword arguments, they will be passed to the GemEquipmentHandlers callbacks
secsgem.gem.equipmenthandler.GemEquipmentHandler.on_ec_value_request()
andsecsgem.gem.equipmenthandler.GemEquipmentHandler.on_ec_value_update()
.If use_callbacks is disabled, you can set the value with the value property.
Parameters: - svid (various) – ID of the equipment constant
- name (string) – long name
- min_value (various) – minimum value
- max_value (various) – maximum value
- default_value (various) – default value
- unit (string) – unit (see SEMI E5, Units of Measure)
- value_type (type of class inherited from
secsgem.secs.variables.SecsVar
) – type of the status variable - use_callback (boolean) – use the GemEquipmentHandler callbacks to get and set variable (True) or use internal value