Handler

Handler for GEM commands. Used in combination with secsgem.HsmsHandler.HsmsConnectionManager

class secsgem.gem.handler.GemHandler(address, port, active, session_id, name, event_handler=None, custom_connection_handler=None)[source]

Bases: secsgem.secs.handler.SecsHandler

Baseclass for creating Host/Equipment models. This layer contains GEM 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
enable()[source]

Enables the connection

disable()[source]

Disables the connection

on_connection_closed(connection)[source]

Connection was closed

clear_collection_events()[source]

Clear all collection events

subscribe_collection_event(ceid, dvs, report_id=None)[source]

Subscribe to a collection event

Parameters:
  • ceid (integer) – ID of the collection event
  • dvs (list of integers) – DV IDs to add for collection event
  • report_id (integer) – optional - ID for report, autonumbering if None
send_remote_command(rcmd, params)[source]

Send a remote command

Parameters:
  • rcmd (string) – Name of command
  • params (list of strings) – DV IDs to add for collection event
send_process_program(ppid, ppbody)[source]

Send a process program

Parameters:
  • ppid (string) – Transferred process programs ID
  • ppbody (string) – Content of process program
request_process_program(ppid)[source]

Request a process program

Parameters:ppid (string) – Transferred process programs ID
delete_process_programs(ppids)[source]

Delete a list of process program

Parameters:ppids (list of strings) – Process programs to delete
get_process_program_list()[source]

Get process program list

are_you_there()

Check if remote is still replying

disable_ceid_reports()

Disable all Collection Event Reports.

disable_ceids()

Disable all Collection Events.

fire_event(event_name, data, async=False)

Fire an event

Parameters:
  • event_name (string) – event to fire
  • data (dict) – parameters for event
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
list_ecs()

Get list of available Equipment Constants.

Returns:available Equipment Constants
Return type:list
list_svs()

Get list of available Service Variables.

Returns:available Service Variables
Return type:list
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_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
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_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
s01f01_handler(handler, packet)[source]

Callback handler for Stream 1, Function 1, Are You There

Parameters:
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'>}}
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'>}}
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 for
Returns: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 sent
Returns: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_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:
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_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:

secsgem.hsms.packets.HsmsPacket

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
s01f13_handler(handler, packet)[source]

Callback handler for Stream 1, Function 13, Establish Communication Request

Parameters:
s06f11_handler(handler, packet)[source]

Callback handler for Stream 6, Function 11, Establish Communication Request

Parameters:
s10f01_handler(handler, packet)[source]

Callback handler for Stream 10, Function 1, Terminal Request

Parameters: