Browse Source

Update gateway node v1.1

master
Evangelos Oulis 5 years ago
parent
commit
e83ffadada
  1. 19
      gatewayNode/parking.py
  2. 2
      git

19
gatewayNode/parking.py

@ -29,7 +29,8 @@ if json_data != "" and json_data != None:
) )
counter=0 counter=0
prev_status = ser.readline() ser.readline()
prev_status = "-1"
while 1: while 1:
park_status = ser.readline() park_status = ser.readline()
park_status_data = str(park_status).split("#") park_status_data = str(park_status).split("#")
@ -38,16 +39,16 @@ if json_data != "" and json_data != None:
parkingStatus = park_status_data[1].replace('\\r\\n\'', '') parkingStatus = park_status_data[1].replace('\\r\\n\'', '')
try: try:
if park_status != prev_status: if parkingStatus != prev_status:
if parkingStatus == "1":
print("parking reserved. RESPONSE :", r.status_code, "\n")
elif parkingStatus == "0":
print("parking not reserved. RESPONSE : ", r.status_code, "\n")
data = """{"no":""" + parkingCode + ""","status":""" + parkingStatus + """}""" data = """{"no":""" + parkingCode + ""","status":""" + parkingStatus + """}"""
r = requests.post(url = API_ENDPOINT, data = data) r = requests.post(url = API_ENDPOINT, data = data)
except NameError: if parkingStatus == "0":
print("**Not already prev variable.\n") print("parking reserved. RESPONSE :", r.status_code, "\n")
prev_status = park_status elif parkingStatus == "1":
print("parking not reserved. RESPONSE : ", r.status_code, "\n")
except NameError as e:
print("**Not already prev variable. <Error> : ", str(e), "\n")
prev_status = parkingStatus
else: else:
print("Create a *.json configuration like: {'ip' : 'xxx.xxx.xxx.xxx', 'port': 'xxxx'}") print("Create a *.json configuration like: {'ip' : 'xxx.xxx.xxx.xxx', 'port': 'xxxx'}")

2
git

@ -1,2 +1,4 @@
cs151051\nv)MEw)73 push origin cs151051\nv)MEw)73 push origin
cs151051\nv)MEw)73 push origin cs151051\nv)MEw)73 push origin
cs151051
v)MEw)73 push origin

Loading…
Cancel
Save