diff --git a/components/entitiy_ident/mongo/traffic_lights.json b/components/entitiy_ident/mongo/traffic_lights.json index d9f41a3..dc3b4c4 100644 --- a/components/entitiy_ident/mongo/traffic_lights.json +++ b/components/entitiy_ident/mongo/traffic_lights.json @@ -2,16 +2,19 @@ { "id": "1", "location": [16.0, 48.0], - "range": 2000 + "range": 2000, + "switchingTime": 500 }, { "id": "2", "location": [16.0, 48.1], - "range": 800 + "range": 800, + "switchingTime": 240 }, { "id": "3", "location": [16.0, 48.2], - "range": 1000 + "range": 1000, + "switchingTime": 360 } ] \ No newline at end of file diff --git a/components/i_feed/i_feed.py b/components/i_feed/i_feed.py index 9be33a7..e60367f 100644 --- a/components/i_feed/i_feed.py +++ b/components/i_feed/i_feed.py @@ -1,4 +1,5 @@ import time +import requests from devices.traffic_light import TrafficLight, SWITCHING_TIME from devices.vehicle import Vehicle @@ -9,24 +10,22 @@ Start all vehicles / traffic lights here """ if __name__ == '__main__': - tl1 = TrafficLight(tlid='traffic-light-1', switching_time=SWITCHING_TIME) - tl1.start() - time.sleep(1) - tl2 = TrafficLight(tlid='traffic-light-2', switching_time=240) - tl2.start() + ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/' - time.sleep(1) - tl3 = TrafficLight(tlid='traffic-light-3', switching_time=360) - tl3.start() + response = requests.get(ENTITY_IDENT_URL + 'cars') + cars = response.json() - v1 = Vehicle(vin='SB164ABN1PE082000') - v1.start_driving() + response = requests.get(ENTITY_IDENT_URL + 'traffic_lights') + traffic_lights = response.json() - time.sleep(1) - v2 = Vehicle(vin='SB999ABN1PE082111') - v2.start_driving() + for traffic_light in traffic_lights['cursor']: + print(traffic_light) + TrafficLight(tlid=traffic_light['id'], + switching_time=traffic_light['switchingTime']).start() + time.sleep(1) - time.sleep(0.5) - v3 = Vehicle(vin='SB555ABN1PE082555') - v3.start_driving() + for car in cars['cursor']: + print(car) + Vehicle(vin=car['vin']).start_driving() + time.sleep(0.5) diff --git a/components/i_feed/requirements.txt b/components/i_feed/requirements.txt index 1cf2ae5..6fec3c0 100644 --- a/components/i_feed/requirements.txt +++ b/components/i_feed/requirements.txt @@ -1,2 +1,3 @@ circuitbreaker # fault tolerance geopy +requests \ No newline at end of file