-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
executable file
·58 lines (50 loc) · 1.44 KB
/
example.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
from realtime_subscriber.Realtime_subscriber_api import BCTWSConnection
import threading
import sys
stream = None
def getFrame():
while True:
print("Getting frame...")
data = stream.get_frame()
print("Frame: ")
print (data)
def getOccupancy():
while True:
print("Getting occupancy...")
data = stream.get_occupancy()
print("Occupancy: ")
print (data)
def getPhase():
while True:
print("Getting phase...")
data = stream.get_phase()
print("Phase: ")
print( data)
if __name__ == '__main__':
# Accept username as the first argument and password as the second argument
if len(sys.argv) != 3:
print("Usage: python example.py <username> <password>")
sys.exit(1)
username = sys.argv[1]
password = sys.argv[2]
print("Opening Blucity stream...")
stream = BCTWSConnection(
"BCT_3D_4G_0206001",
username,
password,
singleton=False,
subscriptions = [
BCTWSConnection.subscriptionOption.LOOP_CHANGE,
BCTWSConnection.subscriptionOption.PHASE_CHANGE,
BCTWSConnection.subscriptionOption.FRAME])
print("Stream opened")
frame_thread =threading.Thread(target=getFrame)
occupancy_thread= threading.Thread(target=getOccupancy)
phase_thread = threading.Thread(target=getPhase)
frame_thread.start()
phase_thread.start()
occupancy_thread.start()
frame_thread.join()
phase_thread.join()
occupancy_thread .join()