Connect entity ident service with ifeed

This commit is contained in:
David Eder 2021-05-31 22:48:50 +02:00
parent bc4f08add0
commit 16fa564e22
3 changed files with 22 additions and 19 deletions

View File

@ -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
}
]

View File

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

View File

@ -1,2 +1,3 @@
circuitbreaker # fault tolerance
geopy
requests