Connect entity ident service with ifeed
This commit is contained in:
parent
bc4f08add0
commit
16fa564e22
@ -2,16 +2,19 @@
|
|||||||
{
|
{
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"location": [16.0, 48.0],
|
"location": [16.0, 48.0],
|
||||||
"range": 2000
|
"range": 2000,
|
||||||
|
"switchingTime": 500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "2",
|
||||||
"location": [16.0, 48.1],
|
"location": [16.0, 48.1],
|
||||||
"range": 800
|
"range": 800,
|
||||||
|
"switchingTime": 240
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "3",
|
"id": "3",
|
||||||
"location": [16.0, 48.2],
|
"location": [16.0, 48.2],
|
||||||
"range": 1000
|
"range": 1000,
|
||||||
|
"switchingTime": 360
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
import requests
|
||||||
|
|
||||||
from devices.traffic_light import TrafficLight, SWITCHING_TIME
|
from devices.traffic_light import TrafficLight, SWITCHING_TIME
|
||||||
from devices.vehicle import Vehicle
|
from devices.vehicle import Vehicle
|
||||||
@ -9,24 +10,22 @@ Start all vehicles / traffic lights here
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
tl1 = TrafficLight(tlid='traffic-light-1', switching_time=SWITCHING_TIME)
|
|
||||||
tl1.start()
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
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(1)
|
||||||
tl2 = TrafficLight(tlid='traffic-light-2', switching_time=240)
|
|
||||||
tl2.start()
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
tl3 = TrafficLight(tlid='traffic-light-3', switching_time=360)
|
|
||||||
tl3.start()
|
|
||||||
|
|
||||||
v1 = Vehicle(vin='SB164ABN1PE082000')
|
|
||||||
v1.start_driving()
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
v2 = Vehicle(vin='SB999ABN1PE082111')
|
|
||||||
v2.start_driving()
|
|
||||||
|
|
||||||
|
for car in cars['cursor']:
|
||||||
|
print(car)
|
||||||
|
Vehicle(vin=car['vin']).start_driving()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
v3 = Vehicle(vin='SB555ABN1PE082555')
|
|
||||||
v3.start_driving()
|
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
circuitbreaker # fault tolerance
|
circuitbreaker # fault tolerance
|
||||||
geopy
|
geopy
|
||||||
|
requests
|
||||||
Loading…
x
Reference in New Issue
Block a user