HostHandler¶
-
class
secsgem.gem.hosthandler.
GemHostHandler
(connection: secsgem.common.protocol.Protocol)[source]¶ Bases:
secsgem.gem.handler.GemHandler
Baseclass for creating host models. Inherit from this class and override required functions.
-
subscribe_collection_event
(ceid: Union[int, str], dvs: List[Union[str, int]], report_id: Union[int, str, None] = 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: Union[int, str], params: List[str])[source]¶ Send a remote command.
Parameters: - rcmd (string) – Name of command
- params (list of strings) – DV IDs to add for collection event
-
delete_process_programs
(ppids: List[Union[str, int]])[source]¶ Delete a list of process program.
Parameters: ppids (list of strings) – Process programs to delete
-
get_process_program_list
() → secsgem.secs.functions.base.SecsStreamFunction[source]¶ Get process program list.
-
enable_alarm
(alid: Union[int, str])[source]¶ Enable alarm.
Parameters: alid ( secsgem.secs.dataitems.ALID
) – alarm id to enable
-
disable_alarm
(alid: Union[int, str])[source]¶ Disable alarm.
Parameters: alid ( secsgem.secs.dataitems.ALID
) – alarm id to disable
-
list_alarms
(alids: Optional[List[Union[str, int]]] = None)[source]¶ List alarms.
Parameters: alids (array of int/str) – alarms to list details for
-
alarms
¶ Get available alarms.
Example:
>>> handler = SecsHandler.hsms("127.0.0.1", 5000, False, 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)
-
are_you_there
()¶ Check if remote is still replying.
-
callbacks
¶ Property for callback handling.
-
collection_events
¶ Get available collection events.
Example:
>>> handler = SecsHandler.hsms("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)
-
communication_state
¶ Get the communication state model.
-
data_values
¶ Get available data values.
Example:
>>> handler = SecsHandler.hsms("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)
-
disable
() → None¶ Disable the connection.
-
disable_ceid_reports
()¶ Disable all Collection Event Reports.
-
disable_ceids
()¶ Disable all Collection Events.
-
enable
() → None¶ Enable the connection.
-
events
¶ Wrapper for connections events.
-
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
-
classmethod
hsms
(address, port, active, session_id, name, custom_connection_handler=None, **kwargs) → secsgem.secs.handler.SecsHandler¶ Initialize a secs handler using a hsms connection.
All arguments will be passed to the HSMS handler.
-
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
() → int¶ 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_closed
(connection)¶ Handle connection was closed event.
-
protocol
¶ Get the connection for the handler.
-
register_stream_function
(stream: int, function: int, 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
¶ Get available remote commands.
Example:
>>> handler = SecsHandler.hsms("127.0.0.1", 5000, False, 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_id)¶ Request contents of one Equipment Constant.
Parameters: ec_id (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: Union[int, str]) → Tuple[Union[int, str], str]¶ Request a process program.
Parameters: ppid (string) – Transferred process programs ID
-
request_sv
(sv_id)¶ Request contents of one Service Variable.
Parameters: sv_id (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.common.Packet
) – packet to get object forReturns: matching stream and function object Return type: secsSxFx object
-
send_and_waitfor_response
(*args, **kwargs)¶ Wrapper for connections send_and_waitfor_response function.
-
send_equipment_terminal
(terminal_id, text)¶ Set text to equipment terminal.
Parameters: - terminal_id (int) – ID of terminal
- text (string) – text to send
-
send_process_program
(ppid: Union[int, str], ppbody: str)¶ Send a process program.
Parameters: - ppid (string) – Transferred process programs ID
- ppbody (string) – Content of process program
-
send_response
(*args, **kwargs)¶ Wrapper for connections send_response function.
-
send_stream_function
(*args, **kwargs)¶ Wrapper for connections send_stream_function function.
-
serialize_data
() → Dict[str, Any]¶ Get serialized data.
Returns: data to serialize for this object Return type: dict
-
set_ec
(ec_id, value)¶ Set contents of one Equipment Constant.
Parameters: - ec_id (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: Optional[float] = None) → bool¶ 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
-