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() -