Spaces:
Sleeping
Sleeping
LapStore
commited on
Commit
·
da5366e
1
Parent(s):
618e662
debug mqtt
Browse files- mqtt_manager.py +1 -1
- state.py +1 -1
- traffic_utils.py +5 -4
mqtt_manager.py
CHANGED
|
@@ -66,7 +66,7 @@ def mqtt_publisher_loop(tl_id):
|
|
| 66 |
|
| 67 |
last_state = None
|
| 68 |
while True:
|
| 69 |
-
current_state = state.
|
| 70 |
'''
|
| 71 |
if current_state != last_state:
|
| 72 |
topic = topic_msg(tl_id)
|
|
|
|
| 66 |
|
| 67 |
last_state = None
|
| 68 |
while True:
|
| 69 |
+
current_state = state.singlas_state[tl_id]
|
| 70 |
'''
|
| 71 |
if current_state != last_state:
|
| 72 |
topic = topic_msg(tl_id)
|
state.py
CHANGED
|
@@ -9,7 +9,7 @@ singlas_state = {
|
|
| 9 |
"1698478721" :status_free,
|
| 10 |
"6082411793":status_free }
|
| 11 |
|
| 12 |
-
request = {
|
| 13 |
"1698478721":{
|
| 14 |
'State' : status_free,
|
| 15 |
'time' : None,
|
|
|
|
| 9 |
"1698478721" :status_free,
|
| 10 |
"6082411793":status_free }
|
| 11 |
|
| 12 |
+
request = { # only store info of current request ,not as updated as singlas_state
|
| 13 |
"1698478721":{
|
| 14 |
'State' : status_free,
|
| 15 |
'time' : None,
|
traffic_utils.py
CHANGED
|
@@ -37,13 +37,13 @@ def get_rectangle_container(coordinates):
|
|
| 37 |
async def wait_check_conection(tl_id,check_time):
|
| 38 |
start = time.time()
|
| 39 |
while time.time() - start < check_time:
|
| 40 |
-
if state.
|
| 41 |
break
|
| 42 |
await asyncio.sleep(0.2)
|
| 43 |
|
| 44 |
async def open_signal(tl_id,state_,duration,delay):
|
| 45 |
-
if (state.
|
| 46 |
-
request_type = "Accident to stop road " if (state.
|
| 47 |
return "Request Refused , Exist old request : \n"+ request_type
|
| 48 |
|
| 49 |
check_time = 4
|
|
@@ -59,10 +59,11 @@ async def open_signal(tl_id,state_,duration,delay):
|
|
| 59 |
|
| 60 |
if (state.request[tl_id]['accepted']== True):
|
| 61 |
state.singlas_state[tl_id] = state_
|
| 62 |
-
state.set_request(tl_id,state_,duration)
|
| 63 |
|
| 64 |
return "Request Accepted"
|
| 65 |
else:
|
|
|
|
| 66 |
state.delete_last_request(tl_id)
|
| 67 |
return "Request Refused , No Internet Connection or Very High Queue Length"
|
| 68 |
|
|
|
|
| 37 |
async def wait_check_conection(tl_id,check_time):
|
| 38 |
start = time.time()
|
| 39 |
while time.time() - start < check_time:
|
| 40 |
+
if state.singlas_state[tl_id] != state.status_chk:
|
| 41 |
break
|
| 42 |
await asyncio.sleep(0.2)
|
| 43 |
|
| 44 |
async def open_signal(tl_id,state_,duration,delay):
|
| 45 |
+
if (state.singlas_state[tl_id] != state.status_free): #exist old request
|
| 46 |
+
request_type = "Accident to stop road " if (state.singlas_state[tl_id] == state.status_acc) else "Exist Emergency request"
|
| 47 |
return "Request Refused , Exist old request : \n"+ request_type
|
| 48 |
|
| 49 |
check_time = 4
|
|
|
|
| 59 |
|
| 60 |
if (state.request[tl_id]['accepted']== True):
|
| 61 |
state.singlas_state[tl_id] = state_
|
| 62 |
+
state.set_request(tl_id,state_,duration)
|
| 63 |
|
| 64 |
return "Request Accepted"
|
| 65 |
else:
|
| 66 |
+
|
| 67 |
state.delete_last_request(tl_id)
|
| 68 |
return "Request Refused , No Internet Connection or Very High Queue Length"
|
| 69 |
|