Common functionality¶
Contains helper functions.
-
class
secsgem.common.
CallbackHandler
[source]¶ Bases:
object
Handler for callbacks for HSMS/SECS/GEM events.
This handler manages callbacks for events that can happen on a handler for a connection.
-
class
secsgem.common.
EventProducer
[source]¶ Bases:
object
Manages the consumers for the events and handles firing events.
-
fire
(event: str, data: Dict[str, Any])[source]¶ Fire a event.
calls all the available handlers for a specific event
Parameters: - event (string) – name of the event
- data (dict) – data connected to this event
-
targets
¶ Targets used as consumer for this producer.
-
-
secsgem.common.
format_hex
(text: bytes) → str[source]¶ Return byte arrays (string) formated as hex numbers.
Example:
>>> import secsgem.common >>> >>> data = b"asdfg" >>> secsgem.common.format_hex(data) '61:73:64:66:67'
Parameters: text (string) – byte array Returns: Formated text Return type: string
-
secsgem.common.
function_name
(function) → str[source]¶ Get name of function or method.
Returns: function/method name Return type: string
-
secsgem.common.
indent_block
(block: str, spaces: int = 2) → str[source]¶ Indent a multiline string by a number of spaces.
Parameters: - block (string) – input text
- spaces (integer) – number of spaces to prepend to each line
Returns: indented text
Return type: string
-
secsgem.common.
is_windows
() → bool[source]¶ Return True if running on windows.
Returns: Is windows system Return type: bool
-
secsgem.common.
is_errorcode_ewouldblock
(errorcode: int) → bool[source]¶ Check if the errorcode is a would-block error.
Parameters: errorcode – Code of the error Returns: True if blocking error code
-
class
secsgem.common.
Protocol
[source]¶ Bases:
abc.ABC
Abstract base class for a protocol.
-
events
¶ Property for event handling.
-
timeouts
¶ Property for timeout.
-
secs_decode
¶ Get secs decode.
-
send_stream_function
(function: SecsStreamFunction) → bool[source]¶ Send the packet and wait for the response.
Parameters: function ( secsgem.secs.functionbase.SecsStreamFunction
) – packet to be sent
-
send_and_waitfor_response
(function: SecsStreamFunction) → typing.Optional[Packet][source]¶ Send the packet and wait for the response.
Parameters: function ( secsgem.secs.functionbase.SecsStreamFunction
) – packet to be sentReturns: Packet that was received Return type: secsgem.common.Packet
-
-
class
secsgem.common.
Packet
[source]¶ Bases:
abc.ABC
Abstract base class for a packet.
-
header
¶ Get the header.
-