update doc

This commit is contained in:
Marco Zeisler 2021-06-11 17:12:27 +02:00
parent b248c41963
commit 75e84e5a13

View File

@ -47,6 +47,10 @@ class TrafficLight:
self._tl_mb.setup_sender()
def start(self):
"""
Starts the traffic light by spawning a new thread. It toggles its state every self.switching_time / SCALING
seconds. When it switches, it notifies the orchestrator with self.send_status_update().
"""
self.running = True
def switcher():
@ -64,10 +68,17 @@ class TrafficLight:
self._t.start()
def stop(self):
"""
The running thread will stop its execution at the next evaluation of while self.running.
"""
self.running = False
@circuit(failure_threshold=10, expected_exception=AMQPConnectionError)
def send_status_update(self):
"""
Sends a status update containing an updated TrafficLightState object to the orchestrator.
This update contains the tlid, current_color and timestamp of the last switch.
"""
print(self.tlid, self.current_color, self.last_switch)
self._tl_mb.send(pickle.dumps(
TrafficLightState(tlid=self.tlid, color=self.current_color, last_switch=self.last_switch)))