ocd.heart_beat – Control the OCD main loop status and wait for connections¶
Heartbeat functionality
-
ocd.heart_beat.ENQUIRY_TOPIC= 'ocd.heartbeat.enquiry'¶ Topic sent when enquiring about heartbeat status
-
ocd.heart_beat.REPLY_TOPIC= 'ocd.heartbeat.reply'¶ Topic expected as a reply when enquiring about heartbeat status
-
class
ocd.heart_beat.HeartBeatQuery(*args, **kwargs)[source]¶ Bases:
ocd.utils.SendAndListenSpecialized version of
SendAndListento monitor if the OCD heart beats.Can also be used to check that a OCD subcommand is in contact with the OCD main loop (
ocd run).Parameters: - all : same as
SendAndListen
Attributes: - id_ : str
unique token associated with the current
HeartBeatQueryinstance. It is send as part of the event sent ({'id': id_}) and it is expected in the answer.
-
classmethod
from_addresses(server_address, listener_addresses, **kwargs)[source]¶ Same as
ocd.utils.SendAndListen.from_addresses(), but with the topic set toREPLY_TOPIC.
-
classmethod
from_names(server_name, listener_name, **kwargs)[source]¶ Same as
ocd.utils.SendAndListen.from_names(), but with the topic set toREPLY_TOPIC.
-
communicate(self)[source]¶ Send a
ENQUIRY_TOPICwith theid_in the event and expects aREPLY_TOPICwith the same id.Returns:
- all : same as
-
class
ocd.heart_beat.HeartBeatHandler(server)[source]¶ Bases:
objectThe
handle_event()handles events coming fromHeartBeatQueryand send out a reply.Parameters: - server :
tcs_lib.server.ZMQServer server to use to send out events
Attributes: - topics : list
topics handled by the state machine (
ENQUIRY_TOPIC)
-
classmethod
from_address(server_address)[source]¶ Initialize the class from the server address
Parameters: - server_address : string
url/path/… use to initialize the server
-
classmethod
from_name(server_name)[source]¶ Initialize the class from the server name. Uses
ocd.utils.get_zmq_server().Parameters: - server_name : string
name of the server as saved by
ocd.utils.init_zmq_servers()
-
handle_event(self, tcs_topic, tcs_event)[source]¶ Handle a TCS event with
topicsand re-emit the input event with topicREPLY_TOPICon the server passed to the constructor.Parameters: - tcs_topic : string
topic of the event
- tcs_event : dict
event to handle
Returns: - bool
Trueif the event has been correctly handled,Falseotherwise
- server :