Browse Source

Update gateway node v1.1

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

21
gatewayNode/parking.py

@ -28,8 +28,9 @@ if json_data != "" and json_data != None:
timeout=1
)
counter=0
prev_status = ser.readline()
ser.readline()
prev_status = "-1"
while 1:
park_status = ser.readline()
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\'', '')
try:
if park_status != 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")
if parkingStatus != prev_status:
data = """{"no":""" + parkingCode + ""","status":""" + parkingStatus + """}"""
r = requests.post(url = API_ENDPOINT, data = data)
except NameError:
print("**Not already prev variable.\n")
prev_status = park_status
if parkingStatus == "0":
print("parking reserved. RESPONSE :", r.status_code, "\n")
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:
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
v)MEw)73 push origin

Loading…
Cancel
Save