Handler¶
-
class
secsgem.secs.handler.
SecsHandler
(address, port, active, session_id, name, custom_connection_handler=None)[source]¶ Bases:
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
- custom_connection_handler (
secsgem.hsms.connections.HsmsMultiPassiveServer
) – object for connection handling (ie multi server)
-
register_stream_function
(stream, function, callback)[source]¶ 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
-
unregister_stream_function
(stream, function)[source]¶ Unregister the function callback for stream and function.
Parameters: - stream (integer) – stream to unregister callback for
- function (integer) – function to register callback for
-
collection_events
¶ Dictionary of available collection events
Example:
>>> handler = SecsHandler("127.0.0.1", 5000, False, 0, "test") >>> handler.collection_events[123] = {'name': 'collectionEventName', 'dvids': [1, 5] }
Key
Id of the collection event (integer)
Data
Dictionary with the following fields
- name
- Name of the collection event (string)
- dvids
- Data values for the collection event (list of integers)
-
data_values
¶ Dictionary of available data values
Example:
>>> handler = SecsHandler("127.0.0.1", 5000, False, 0, "test") >>> handler.data_values[5] = {'name': 'dataValueName', 'ceid': 123 }
Key
Id of the data value (integer)
Data
Dictionary with the following fields
- name
- Name of the data value (string)
- ceid
- Collection event the data value is used for (integer)
-
alarms
¶ Dictionary of available alarms
Example:
>>> handler = SecsHandler("127.0.0.1", 5000, True, 0, "test") >>> handler.alarms[137] = {'ceidon': 1371, 'ceidoff': 1372}
Key
Id of the alarm (integer)
Data
Dictionary with the following fields
- ceidon
- Collection event id for alarm on (integer)
- ceidoff
- Collection event id for alarm off (integer)
-
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)
-
list_svs
(svs=None)[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
(ecs=None)[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
-
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
-
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
-
callbacks
¶ Property for callback handling
-
disable
()¶ Disables the connection
-
enable
()¶ Enables the connection
-
events
¶ Property for event handling
-
get_next_system_counter
()¶ Returns the next System.
Returns: System for the next command Return type: integer
-
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
-
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