-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpi_interface.py
More file actions
29 lines (23 loc) · 967 Bytes
/
pi_interface.py
File metadata and controls
29 lines (23 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# sensors:
# - RFID for association of LCL + container
# - GPS for detecting LCL destination
# - A counter to start association/ loading session
#GPS is emulated using timer
#RFID tag is emulated using button press
#each loading session is represented by the counter
import requests
import time
listOfLCL = [1, 2, 3]
tagurl = 'https://lcl-enterprises.herokuapp.com/lcls/register'
arrivalurl = 'https://lcl-enterprises.herokuapp.com/lcls/arrived'
counter = 0;
while counter <= 2:
randLCL = randint(0, 2)
tagEmulate = input("Press a to emulate the tag: ")
if tagEmulate == 'a':
#container ID is unique to each microprocessor
r = requests.post(tagurl, data = {'container_id' : "GLFU2814428", 'lcl_id' : listOfLCL[randLCL]})
counter = counter + 1 #simulates each loading session
time.sleep(3)
#after 3 seconds have been elapsed (emulating arrival)
arrival = requests.post(arrivalurl, data = {'container_id' : "2"} )