From f581863e14d722a148205db813833f6931e81c9c Mon Sep 17 00:00:00 2001 From: Marco Zeisler Date: Mon, 17 May 2021 18:17:53 +0200 Subject: [PATCH] added traffic light id; --- components/i_feed/traffic_light.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/i_feed/traffic_light.py b/components/i_feed/traffic_light.py index c931103..d7b49d8 100644 --- a/components/i_feed/traffic_light.py +++ b/components/i_feed/traffic_light.py @@ -16,6 +16,8 @@ class TrafficLight: GREEN = 0 RED = 1 + # id of traffic light + tlid: str # time between switches in seconds switching_time: int # timestamp of last switch @@ -29,7 +31,11 @@ class TrafficLight: # stores runner thread _t: threading.Thread - def __init__(self, switching_time: int = SWITCHING_TIME, starting_color: Color = Color.RED): + def __init__(self, + tlid: str, + switching_time: int = SWITCHING_TIME, + starting_color: Color = Color.RED): + self.tlid = tlid self.switching_time = switching_time self._starting_color = starting_color @@ -56,10 +62,9 @@ class TrafficLight: @circuit(failure_threshold=10, expected_exception=ConnectionError) def send_status_update(self): # TODO inform the message broker about the current status - print(self.current_color, self.last_switch) + print(self.tlid, self.current_color, self.last_switch) if __name__ == '__main__': - tl1 = TrafficLight(3) + tl1 = TrafficLight(tlid='tl1') tl1.start() -