Handler¶
Handler for SECS commands. Used in combination with secsgem.HsmsHandler.HsmsConnectionManager
-
class
secsgem.secs.handler.
SecsHandler
(address, port, active, session_id, name, event_handler=None, custom_connection_handler=None)[source]¶ Bases:
secsgem.common.StreamFunctionCallbackHandler
,secsgem.hsms.handler.HsmsHandler
Baseclass for creating Host/Equipment models. This layer contains the SECS functionality. 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
- event_handler (
secsgem.common.EventHandler
) – object for event handling - custom_connection_handler (
secsgem.hsms.connections.HsmsMultiPassiveServer
) – object for connection handling (ie multi server)
-
ceids
= {}¶ Dictionary of available collection events, CEID is the key
Parameters: - name (string) – Name of the data value
- CEID (integer) – Collection event the data value is used for
-
dvs
= {}¶ Dictionary of available data values, DVID is the key
Parameters: - name (string) – Name of the collection event
- dv (list of integers) – Data values available for collection event
-
alarms
= {}¶ Dictionary of available alarms, ALID is the key
Parameters: - alarmText (string) – Description of the alarm
- ceidOn (integer) – Collection event for activated alarm
- ceidOff (integer) – Collection event for deactivated alarm
-
rcmds
= {}¶ Dictionary of available remote commands, command is the key
Parameters: - params (list of dictionary) – description of the parameters
- CEID (list of integers) – Collection events the remote command uses
-
secsStreamsFunctionsHost
= {0: {0: <class 'secsgem.secs.functions.SecsS00F00'>}, 1: {0: <class 'secsgem.secs.functions.SecsS01F00'>, 1: <class 'secsgem.secs.functions.SecsS01F01'>, 2: <class 'secsgem.secs.functions.SecsS01F02H'>, 3: <class 'secsgem.secs.functions.SecsS01F03'>, 4: <class 'secsgem.secs.functions.SecsS01F04'>, 11: <class 'secsgem.secs.functions.SecsS01F11'>, 12: <class 'secsgem.secs.functions.SecsS01F12'>, 13: <class 'secsgem.secs.functions.SecsS01F13H'>, 14: <class 'secsgem.secs.functions.SecsS01F14H'>}, 2: {0: <class 'secsgem.secs.functions.SecsS02F00'>, 33: <class 'secsgem.secs.functions.SecsS02F33'>, 34: <class 'secsgem.secs.functions.SecsS02F34'>, 35: <class 'secsgem.secs.functions.SecsS02F35'>, 36: <class 'secsgem.secs.functions.SecsS02F36'>, 37: <class 'secsgem.secs.functions.SecsS02F37'>, 38: <class 'secsgem.secs.functions.SecsS02F38'>, 41: <class 'secsgem.secs.functions.SecsS02F41'>, 42: <class 'secsgem.secs.functions.SecsS02F42'>, 13: <class 'secsgem.secs.functions.SecsS02F13'>, 14: <class 'secsgem.secs.functions.SecsS02F14'>, 15: <class 'secsgem.secs.functions.SecsS02F15'>, 16: <class 'secsgem.secs.functions.SecsS02F16'>, 29: <class 'secsgem.secs.functions.SecsS02F29'>, 30: <class 'secsgem.secs.functions.SecsS02F30'>}, 5: {0: <class 'secsgem.secs.functions.SecsS05F00'>, 1: <class 'secsgem.secs.functions.SecsS05F01'>, 2: <class 'secsgem.secs.functions.SecsS05F02'>}, 6: {0: <class 'secsgem.secs.functions.SecsS06F00'>, 11: <class 'secsgem.secs.functions.SecsS06F11'>, 12: <class 'secsgem.secs.functions.SecsS06F12'>}, 7: {1: <class 'secsgem.secs.functions.SecsS07F01'>, 2: <class 'secsgem.secs.functions.SecsS07F02'>, 3: <class 'secsgem.secs.functions.SecsS07F03'>, 4: <class 'secsgem.secs.functions.SecsS07F04'>, 5: <class 'secsgem.secs.functions.SecsS07F05'>, 6: <class 'secsgem.secs.functions.SecsS07F06'>, 17: <class 'secsgem.secs.functions.SecsS07F17'>, 18: <class 'secsgem.secs.functions.SecsS07F18'>, 19: <class 'secsgem.secs.functions.SecsS07F19'>, 20: <class 'secsgem.secs.functions.SecsS07F20'>}, 9: {0: <class 'secsgem.secs.functions.SecsS09F00'>, 1: <class 'secsgem.secs.functions.SecsS09F01'>, 3: <class 'secsgem.secs.functions.SecsS09F03'>, 5: <class 'secsgem.secs.functions.SecsS09F05'>, 7: <class 'secsgem.secs.functions.SecsS09F07'>, 9: <class 'secsgem.secs.functions.SecsS09F09'>, 11: <class 'secsgem.secs.functions.SecsS09F11'>, 13: <class 'secsgem.secs.functions.SecsS09F13'>}, 10: {0: <class 'secsgem.secs.functions.SecsS10F00'>, 1: <class 'secsgem.secs.functions.SecsS10F01'>, 2: <class 'secsgem.secs.functions.SecsS10F02'>, 3: <class 'secsgem.secs.functions.SecsS10F03'>, 4: <class 'secsgem.secs.functions.SecsS10F04'>}, 12: {0: <class 'secsgem.secs.functions.SecsS12F00'>, 1: <class 'secsgem.secs.functions.SecsS12F01'>, 2: <class 'secsgem.secs.functions.SecsS12F02'>, 3: <class 'secsgem.secs.functions.SecsS12F03'>, 4: <class 'secsgem.secs.functions.SecsS12F04'>, 5: <class 'secsgem.secs.functions.SecsS12F05'>, 6: <class 'secsgem.secs.functions.SecsS12F06'>, 7: <class 'secsgem.secs.functions.SecsS12F07'>, 8: <class 'secsgem.secs.functions.SecsS12F08'>, 9: <class 'secsgem.secs.functions.SecsS12F09'>, 10: <class 'secsgem.secs.functions.SecsS12F10'>, 11: <class 'secsgem.secs.functions.SecsS12F11'>, 12: <class 'secsgem.secs.functions.SecsS12F12'>, 13: <class 'secsgem.secs.functions.SecsS12F13'>, 14: <class 'secsgem.secs.functions.SecsS12F14'>, 15: <class 'secsgem.secs.functions.SecsS12F15'>, 16: <class 'secsgem.secs.functions.SecsS12F16'>, 17: <class 'secsgem.secs.functions.SecsS12F17'>, 18: <class 'secsgem.secs.functions.SecsS12F18'>, 19: <class 'secsgem.secs.functions.SecsS12F19'>}}¶
-
secsStreamsFunctionsEquipment
= {0: {0: <class 'secsgem.secs.functions.SecsS00F00'>}, 1: {0: <class 'secsgem.secs.functions.SecsS01F00'>, 1: <class 'secsgem.secs.functions.SecsS01F01'>, 2: <class 'secsgem.secs.functions.SecsS01F02E'>, 3: <class 'secsgem.secs.functions.SecsS01F03'>, 4: <class 'secsgem.secs.functions.SecsS01F04'>, 11: <class 'secsgem.secs.functions.SecsS01F11'>, 12: <class 'secsgem.secs.functions.SecsS01F12'>, 13: <class 'secsgem.secs.functions.SecsS01F13E'>, 14: <class 'secsgem.secs.functions.SecsS01F14E'>}, 2: {0: <class 'secsgem.secs.functions.SecsS02F00'>, 33: <class 'secsgem.secs.functions.SecsS02F33'>, 34: <class 'secsgem.secs.functions.SecsS02F34'>, 35: <class 'secsgem.secs.functions.SecsS02F35'>, 36: <class 'secsgem.secs.functions.SecsS02F36'>, 37: <class 'secsgem.secs.functions.SecsS02F37'>, 38: <class 'secsgem.secs.functions.SecsS02F38'>, 41: <class 'secsgem.secs.functions.SecsS02F41'>, 42: <class 'secsgem.secs.functions.SecsS02F42'>, 13: <class 'secsgem.secs.functions.SecsS02F13'>, 14: <class 'secsgem.secs.functions.SecsS02F14'>, 15: <class 'secsgem.secs.functions.SecsS02F15'>, 16: <class 'secsgem.secs.functions.SecsS02F16'>, 29: <class 'secsgem.secs.functions.SecsS02F29'>, 30: <class 'secsgem.secs.functions.SecsS02F30'>}, 5: {0: <class 'secsgem.secs.functions.SecsS05F00'>, 1: <class 'secsgem.secs.functions.SecsS05F01'>, 2: <class 'secsgem.secs.functions.SecsS05F02'>}, 6: {0: <class 'secsgem.secs.functions.SecsS06F00'>, 11: <class 'secsgem.secs.functions.SecsS06F11'>, 12: <class 'secsgem.secs.functions.SecsS06F12'>}, 7: {1: <class 'secsgem.secs.functions.SecsS07F01'>, 2: <class 'secsgem.secs.functions.SecsS07F02'>, 3: <class 'secsgem.secs.functions.SecsS07F03'>, 4: <class 'secsgem.secs.functions.SecsS07F04'>, 5: <class 'secsgem.secs.functions.SecsS07F05'>, 6: <class 'secsgem.secs.functions.SecsS07F06'>, 17: <class 'secsgem.secs.functions.SecsS07F17'>, 18: <class 'secsgem.secs.functions.SecsS07F18'>, 19: <class 'secsgem.secs.functions.SecsS07F19'>, 20: <class 'secsgem.secs.functions.SecsS07F20'>}, 9: {0: <class 'secsgem.secs.functions.SecsS09F00'>, 1: <class 'secsgem.secs.functions.SecsS09F01'>, 3: <class 'secsgem.secs.functions.SecsS09F03'>, 5: <class 'secsgem.secs.functions.SecsS09F05'>, 7: <class 'secsgem.secs.functions.SecsS09F07'>, 9: <class 'secsgem.secs.functions.SecsS09F09'>, 11: <class 'secsgem.secs.functions.SecsS09F11'>, 13: <class 'secsgem.secs.functions.SecsS09F13'>}, 10: {0: <class 'secsgem.secs.functions.SecsS10F00'>, 1: <class 'secsgem.secs.functions.SecsS10F01'>, 2: <class 'secsgem.secs.functions.SecsS10F02'>, 3: <class 'secsgem.secs.functions.SecsS10F03'>, 4: <class 'secsgem.secs.functions.SecsS10F04'>}, 12: {0: <class 'secsgem.secs.functions.SecsS12F00'>, 1: <class 'secsgem.secs.functions.SecsS12F01'>, 2: <class 'secsgem.secs.functions.SecsS12F02'>, 3: <class 'secsgem.secs.functions.SecsS12F03'>, 4: <class 'secsgem.secs.functions.SecsS12F04'>, 5: <class 'secsgem.secs.functions.SecsS12F05'>, 6: <class 'secsgem.secs.functions.SecsS12F06'>, 7: <class 'secsgem.secs.functions.SecsS12F07'>, 8: <class 'secsgem.secs.functions.SecsS12F08'>, 9: <class 'secsgem.secs.functions.SecsS12F09'>, 10: <class 'secsgem.secs.functions.SecsS12F10'>, 11: <class 'secsgem.secs.functions.SecsS12F11'>, 12: <class 'secsgem.secs.functions.SecsS12F12'>, 13: <class 'secsgem.secs.functions.SecsS12F13'>, 14: <class 'secsgem.secs.functions.SecsS12F14'>, 15: <class 'secsgem.secs.functions.SecsS12F15'>, 16: <class 'secsgem.secs.functions.SecsS12F16'>, 17: <class 'secsgem.secs.functions.SecsS12F17'>, 18: <class 'secsgem.secs.functions.SecsS12F18'>, 19: <class 'secsgem.secs.functions.SecsS12F19'>}}¶
-
list_svs
()[source]¶ Get list of available Service Variables.
Returns: available Service Variables Return type: list
-
request_svs
(svs)[source]¶ Request contents of supplied Service Variables.
Parameters: svs (list) – Service Variables to request Returns: values of requested Service Variables Return type: list
-
request_sv
(sv)[source]¶ Request contents of one Service Variable.
Parameters: sv (int) – id of Service Variable Returns: value of requested Service Variable Return type: various
-
list_ecs
()[source]¶ Get list of available Equipment Constants.
Returns: available Equipment Constants Return type: list
-
request_ecs
(ecs)[source]¶ Request contents of supplied Equipment Constants.
Parameters: ecs (list) – Equipment Constants to request Returns: values of requested Equipment Constants Return type: list
-
request_ec
(ec)[source]¶ Request contents of one Equipment Constant.
Parameters: ec (int) – id of Equipment Constant Returns: value of requested Equipment Constant Return type: various
-
set_ecs
(ecs)[source]¶ Set contents of supplied Equipment Constants.
Parameters: ecs (list) – list containing list of id / value pairs
-
set_ec
(ec, value)[source]¶ Set contents of one Equipment Constant.
Parameters: - ec (int) – id of Equipment Constant
- value (various) – new content of Equipment Constant
-
send_equipment_terminal
(terminal_id, text)[source]¶ Set text to equipment terminal
Parameters: - terminal_id (int) – ID of terminal
- text (string) – text to send
-
get_ceid_name
(ceid)[source]¶ 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
-
disable
()¶ Disables the connection
-
enable
()¶ Enables the connection
-
fire_event
(event_name, data, async=False)¶ Fire an event
Parameters: - event_name (string) – event to fire
- data (dict) – parameters for event
-
get_dvid_name
(dvid)[source]¶ 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
-
on_connection_before_closed
(_)¶ Connection is about to be closed
-
on_connection_closed
(_)¶ Connection was 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_callback
(stream, function, callback)¶ Register the function callback for stream and function. Multiple callbacks can be registered for one 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
-
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_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_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
-
unregister_callback
(stream, function, callback)¶ Unregister the function callback for stream and function. Multiple callbacks can be registered for one function, only the supplied callback will be removed.
Parameters: - stream (integer) – stream to unregister callback for
- function (integer) – function to register callback for
- callback (def callback(connection)) – method to remove from callback list
-
waitfor_deselect_rsp
(system_id)¶ Wait for an incoming Deselect Response
Parameters: system_id (integer) – System of the request to reply for Returns: Packet that was received Return type: secsgem.hsms.packets.HsmsPacket
-
waitfor_linktest_rsp
(system_id)¶ Wait for an incoming Linktest Response
Parameters: system_id (integer) – System of the request to reply for Returns: Packet that was received Return type: secsgem.hsms.packets.HsmsPacket
-
waitfor_select_rsp
(system_id)¶ Wait for an incoming Select Response
Parameters: system_id (integer) – System of the request to reply for Returns: Packet that was received Return type: secsgem.hsms.packets.HsmsPacket
-
waitfor_stream_function
(stream, function, is_control=False)¶ Wait for an incoming stream and function and return the receive data
Parameters: - stream (integer) – number of stream to wait for
- function (integer) – number of function to wait for
- is_control (bool) – is it a control packet
Returns: Packet that was received
Return type:
-
waitfor_system
(system, is_control=False)¶ Wait for an message with supplied system
Parameters: system (integer) – number of system to wait for Returns: Packet that was received Return type: secsgem.hsms.packets.HsmsPacket
-
stream_function
(stream, function)[source]¶ 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
-
secs_decode
(packet)[source]¶ 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