2021-06-02 20:46:46 +02:00

34 lines
931 B
Python

import time
import requests
from devices.traffic_light import TrafficLight, SWITCHING_TIME
from devices.vehicle import Vehicle
"""
USED AS ENTRYPOINT FOR DOCKERFILE
Start all vehicles / traffic lights here
"""
if __name__ == '__main__':
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
response = requests.get(ENTITY_IDENT_URL + 'cars')
cars = response.json()
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
traffic_lights = response.json()
print('Traffic lights', traffic_lights['cursor'])
for traffic_light in traffic_lights['cursor']:
print(traffic_light)
TrafficLight(tlid=traffic_light['id'],
switching_time=traffic_light['switchingTime']).start()
time.sleep(1)
print('Cars', cars['cursor'])
for car in cars['cursor']:
print(car)
Vehicle(vin=car['vin']).start_driving()
time.sleep(0.5)