Wait for connection to entityident
This commit is contained in:
parent
c36a3e1d85
commit
8b0a60d9ab
@ -19,23 +19,26 @@ Start all vehicles / traffic lights here
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
||||||
try:
|
available = False
|
||||||
response = requests.get(ENTITY_IDENT_URL + 'cars')
|
while not available:
|
||||||
cars = response.json()
|
try:
|
||||||
|
response = requests.get(ENTITY_IDENT_URL + 'cars')
|
||||||
|
cars = response.json()
|
||||||
|
|
||||||
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
|
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
|
||||||
traffic_lights = response.json()
|
traffic_lights = response.json()
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
print("Is the entity_ident_server running and reachable?")
|
print("Is the entity_ident_server running and reachable?")
|
||||||
raise e
|
continue
|
||||||
|
available = True
|
||||||
|
|
||||||
for traffic_light in traffic_lights['cursor']:
|
for traffic_light in traffic_lights['cursor']:
|
||||||
print(traffic_light)
|
print(traffic_light)
|
||||||
TrafficLight(tlid=traffic_light['id'],
|
TrafficLight(tlid=traffic_light['id'],
|
||||||
switching_time=traffic_light['switchingTime']).start()
|
switching_time=traffic_light['switchingTime']).start()
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
|
|
||||||
for car in cars['cursor']:
|
for car in cars['cursor']:
|
||||||
print(car)
|
print(car)
|
||||||
Vehicle(vin=car['vin']).start_driving()
|
Vehicle(vin=car['vin']).start_driving()
|
||||||
time.sleep(10)
|
time.sleep(15)
|
||||||
|
|||||||
@ -21,6 +21,8 @@ sys.modules['target_velocity'] = target_velocity
|
|||||||
|
|
||||||
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
||||||
|
|
||||||
|
SCALING = 1
|
||||||
|
|
||||||
|
|
||||||
class Orchestrator:
|
class Orchestrator:
|
||||||
# vehicle ids
|
# vehicle ids
|
||||||
@ -38,15 +40,18 @@ class Orchestrator:
|
|||||||
# re-use http session, is faster then request.ing everytime
|
# re-use http session, is faster then request.ing everytime
|
||||||
self._session = requests.Session()
|
self._session = requests.Session()
|
||||||
|
|
||||||
try:
|
available = False
|
||||||
response = self._session.get(ENTITY_IDENT_URL + 'cars')
|
while not available:
|
||||||
cars = response.json()
|
try:
|
||||||
|
response = self._session.get(ENTITY_IDENT_URL + 'cars')
|
||||||
|
cars = response.json()
|
||||||
|
|
||||||
response = self._session.get(ENTITY_IDENT_URL + 'traffic_lights')
|
response = self._session.get(ENTITY_IDENT_URL + 'traffic_lights')
|
||||||
traffic_lights = response.json()
|
traffic_lights = response.json()
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
print("Is the entity_ident_server running and reachable?")
|
print("Is the entity_ident_server running and reachable?")
|
||||||
raise e
|
continue
|
||||||
|
available = True
|
||||||
|
|
||||||
for car in cars['cursor']:
|
for car in cars['cursor']:
|
||||||
self.vins.append(car['vin'])
|
self.vins.append(car['vin'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user