Skip to content

Commit

Permalink
added (time.time()-time_waiting_for_incoming_msg-threshold_of_time_qu…
Browse files Browse the repository at this point in the history
…ery)>(time_of_write-old_time_of_write): to balance tx and rx timing
  • Loading branch information
marco committed Dec 20, 2016
1 parent e61c8a4 commit 52a98ad
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
5 changes: 3 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,9 @@ versione4.53 iniziato ad usare pythonserial come libraria dopo test fatti con
Introduced a conditional delay in the node_query_handler.py to allow the radio nodes to transmit to onoscenter.
Introduced a conditional skipUartRxMsg that permits the serialnode to receive radio messages more often.
The radio node is working now also if is not stable.


The button on the node is not changing the object status correctly.
The system is not 100% secure to change the status.
There is some proble for onos to receive data from radio..


(110, 'Connection timed out');;;
Expand Down
24 changes: 12 additions & 12 deletions scripts_folder/config_files/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"WPlugAvx0008": {
"hwModelName": "WPlugAvx",
"nodeAddress": "254",
"nodeAddress": "003",
"node_serial_number": "WPlugAvx0008"
}
},
Expand Down Expand Up @@ -209,7 +209,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -352,7 +352,7 @@
],
"priority": 10,
"scenarios": [],
"status": 0,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -387,7 +387,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -528,7 +528,7 @@
],
"priority": 10,
"scenarios": [],
"status": 1,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -599,7 +599,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -705,7 +705,7 @@
],
"priority": 0,
"scenarios": [],
"status": 19,
"status": 20,
"styleDict": {
"0": "background-color:green;",
"1": "background-color:red;",
Expand Down Expand Up @@ -741,7 +741,7 @@
],
"priority": 0,
"scenarios": [],
"status": 81,
"status": 100,
"styleDict": {
"0": "background-color:green;",
"1": "background-color:red;",
Expand Down Expand Up @@ -831,7 +831,7 @@
"scenario4",
"scenario8"
],
"status": 21,
"status": 40,
"styleDict": {
"0": "background-color:green;",
"1": "background-color:red;",
Expand Down Expand Up @@ -974,7 +974,7 @@
],
"priority": 0,
"scenarios": [],
"status": "onoswait",
"status": "0",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -1044,7 +1044,7 @@
],
"priority": 0,
"scenarios": [],
"status": "onoswait",
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down Expand Up @@ -1190,7 +1190,7 @@
],
"priority": 0,
"scenarios": [],
"status": 0,
"status": "inactive",
"styleDict": {
"0": "background-color:#A9E2F3;",
"1": "background-color:#8181F7;",
Expand Down
30 changes: 22 additions & 8 deletions scripts_folder/node_query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def make_query_to_radio_node(serialCom,node_serial_number,query,number_of_retry_
"""

max_retry=1
max_retry=1
for m in range(0,max_retry): #retry n times to get the answer from node #retry n times to get the answer from node

# [S_001dw06001_#]
Expand Down Expand Up @@ -256,16 +256,26 @@ def handle_new_query_to_radio_node_thread(serialCom):
global nodeDict
node_query_radio_threads_executing=1

query_sent_before_delay=0 #after n query sent wait a moment to let the remote nodes starts the tranmissions
threshold_of_query=2
time_of_write=time.time() #after n query sent wait a moment to let the remote nodes starts the tranmissions
old_time_of_write=time.time()
time_waiting_for_incoming_msg=time.time()
threshold_of_time_query=0.1

while not queryToRadioNodeQueue.empty():
query_sent_before_delay=query_sent_before_delay+1
if query_sent_before_delay>threshold_of_query:
time.sleep(1) #need this to allow the serial node to pick up the messages from the radio nodes..
#query_sent_before_delay=query_sent_before_delay+1
time_of_write=time.time()
old_time_of_write=time_of_write
time_waiting_for_incoming_msg=time.time()


if (time.time()-time_waiting_for_incoming_msg-threshold_of_time_query)>(time_of_write-old_time_of_write):
time.sleep(0.01) #need this to allow the serial node to pick up the messages from the radio nodes..
old_time_of_write=time.time()
time_waiting_for_incoming_msg=time.time()
time_of_write=time.time()
print("wait to allow rx from radio nodes")
query_sent_before_delay=0

continue


currentRadioQueryPacket=queryToRadioNodeQueue.get() #get the tuple:
Expand Down Expand Up @@ -304,12 +314,16 @@ def handle_new_query_to_radio_node_thread(serialCom):
if priority==99: #if the priority is 99 then the query will be always retrayed infinites times.
query_order=time.time()+1 #make the query less important..to allow other queries to run
else:

number_of_retry_done=number_of_retry_done+1
if number_of_retry_done>15: #if greater that n don't repeat the query.
print ("i retried the query:"+query+"more than 15 times , I giveup")
errorQueue.put("i retried the query:"+query+"more than 15 times , I giveup")
continue

if (time.time()-query_time )>100:
#if more than n seconds has passed since the query was made the first time..don't repeat the query.
print ("i retried the query "+query+"more than 100 seconds , I giveup")
errorQueue.put("i retried the query:"+query+"more than 100 seconds , I giveup")
continue
query_order=time.time()+queryToRadioNodeQueue.qsize() #make the query less important..to allow other queries to run

Expand Down
Binary file modified scripts_folder/node_query_handler.pyc
Binary file not shown.

0 comments on commit 52a98ad

Please sign in to comment.