Handler

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

Bases: secsgem.common.EventProducer

Baseclass for creating Host/Equipment models. This layer contains the HSMS 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)

Example:

import secsgem

def onConnect(event, data):
    print "Connected"

client = secsgem.HsmsHandler("10.211.55.33", 5000, True, 0, "test", event_handler=secsgem.EventHandler(events={'hsms_connected': onConnect}))

client.enable()

time.sleep(3)

client.disable()
on_connection_established(_)[source]

Connection was established

on_connection_before_closed(_)[source]

Connection is about to be closed

on_connection_closed(_)[source]

Connection was closed

on_connection_packet_received(_, packet)[source]

Packet received by connection

Parameters:packet (secsgem.hsms.packets.HsmsPacket) – received data packet
enable()[source]

Enables the connection

disable()[source]

Disables the connection

waitfor_stream_function(stream, function, is_control=False)[source]

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

send_stream_function(packet)[source]

Send the packet and wait for the response

Parameters:packet (secsgem.secs.functionbase.SecsStreamFunction) – packet to be sent
waitfor_system(system, is_control=False)[source]

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
send_and_waitfor_response(packet)[source]

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_response(function, system)[source]

Send response function for system

Parameters:
send_select_req()[source]

Send a Select Request to the remote host

Returns:System of the sent request
Return type:integer
send_select_rsp(system_id)[source]

Send a Select Response to the remote host

Parameters:system_id (integer) – System of the request to reply for
waitfor_select_rsp(system_id)[source]

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
send_linktest_req()[source]

Send a Linktest Request to the remote host

Returns:System of the sent request
Return type:integer
send_linktest_rsp(system_id)[source]

Send a Linktest Response to the remote host

Parameters:system_id (integer) – System of the request to reply for
waitfor_linktest_rsp(system_id)[source]

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
send_deselect_req()[source]

Send a Deselect Request to the remote host

Returns:System of the sent request
Return type:integer
send_deselect_rsp(system_id)[source]

Send a Deselect Response to the remote host

Parameters:system_id (integer) – System of the request to reply for
fire_event(event_name, data, async=False)

Fire an event

Parameters:
  • event_name (string) – event to fire
  • data (dict) – parameters for event
waitfor_deselect_rsp(system_id)[source]

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
send_reject_rsp(system_id, s_type, reason)[source]

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_separate_req()[source]

Send a Separate Request to the remote host