From 75e84e5a135e1fdf8a7d1020b911aac8c162dbca Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Fri, 11 Jun 2021 17:12:27 +0200 Subject: [PATCH] update doc --- components/i_feed/devices/traffic_light.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/i_feed/devices/traffic_light.py b/components/i_feed/devices/traffic_light.py index 5c13adb..22e972b 100644 --- a/components/i_feed/devices/traffic_light.py +++ b/components/i_feed/devices/traffic_light.py @@ -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)))