Spaces:
Sleeping

taha454 commited on
Commit
e970125
·
1 Parent(s): 1acda01

modified queu length check , delete request after proces

Browse files
Files changed (2) hide show
  1. mqtt_manager.py +2 -1
  2. traffic_utils.py +1 -0
mqtt_manager.py CHANGED
@@ -27,7 +27,8 @@ def get_State(tl_id):
27
  return state.singlas_state.get(tl_id, "FREE")
28
 
29
  def checked_ql(ql):
30
- return True
 
31
  # ------------------ Listener ------------------ #
32
  def mqtt_listener():
33
  def on_message(client, userdata, message):
 
27
  return state.singlas_state.get(tl_id, "FREE")
28
 
29
  def checked_ql(ql):
30
+ max_queue_length = 16 # 15 # this is the maximum queue length for the road
31
+ return ql>max_queue_length # for now, always return True, can be improved later to check if the queue length is valid or not
32
  # ------------------ Listener ------------------ #
33
  def mqtt_listener():
34
  def on_message(client, userdata, message):
traffic_utils.py CHANGED
@@ -64,6 +64,7 @@ async def open_signal(tl_id,state_,duration,delay):
64
  if (state.request[tl_id]['accepted']== True):
65
 
66
  threading.Thread(target=handle_request_in_thread, args=(tl_id, state_, duration)).start()
 
67
  return "Request Accepted"
68
  else:
69
  state.delete_last_request(tl_id)
 
64
  if (state.request[tl_id]['accepted']== True):
65
 
66
  threading.Thread(target=handle_request_in_thread, args=(tl_id, state_, duration)).start()
67
+ state.delete_last_request(tl_id)
68
  return "Request Accepted"
69
  else:
70
  state.delete_last_request(tl_id)