-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.py
175 lines (126 loc) · 6.02 KB
/
runner.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
from Sensors.ParkingLot.MatSensor import ParkingMatSensor
from Sensors.VenueSensors.QRCode import QRCode
from Sensors.Weather.Implementations.TemperatureSensor import TemperatureSensor
from Sensors.Weather.Implementations.HumiditySensor import HumiditySensor
from NdR.AccessibilityService.AccessibilityService import AccessibilityService
from NdR.AutomatedSystems.ParkingLots.Implementations.ParkingLotA import ParkingLotA
from NdR.AutomatedSystems.ParkingLots.Implementations.ParkingLotB import ParkingLotB
from NdR.AutomatedSystems.Venues.Implementations.VenueA import VenueA
from NdR.AutomatedSystems.Venues.Implementations.VenueB import VenueB
from NdR.AutomatedSystems.Venues.Implementations.VenueC import VenueC
from NdR.Participants.Visitor import Visitor
from NdR.VenueEvent.VenueEvent import VenueEvent
from NdR.VenueEvent.EventAdmin import EventAdmin
from NdR.BookingWindow.BookingWindow import BookingWindow
from EventBus.Implementations.User.Implementation.UserBus import UserBus
from EventBus.Implementations.Venue.VenueBus import VenueBus
from EventBus.Implementations.ParkingLot.ParkingLotBus import ParkingLotBus
from EventBus.Implementations.User.Implementation.WeatherBus import WeatherBus
from EventBus.Implementations.User.Implementation.UserNotifierBus import UserNotifierBus
from EventBus.Implementations.AccessibilityService.AccessibilityServiceBus import AccessibilityBus
from EventBus.Implementations.VenueEvents.EventAdminBus import EventAdminBus
import random
import time
# Initialize Event Buses to communicate with the system
userEventBus = UserBus()
usernotifierBus = UserNotifierBus()
venueEventBus = VenueBus()
parkingLotBus = ParkingLotBus()
weatherBus = WeatherBus()
acBus = AccessibilityBus()
# Initialize Sensors of temperature and humidity for the users
tempSensor = TemperatureSensor(
weatherbus = weatherBus
)
humSensor = HumiditySensor(
weatherbus = weatherBus
)
# Initialize the Parking Lots and the Parking Mat Sensors
parkingLotA = ParkingLotA(userbus = userEventBus)
parkingLotBus.addToBus(parkingLotA)
parkingMatSensorA = ParkingMatSensor(parkingLot = parkingLotA,
userbus = userEventBus,
parkbus = parkingLotBus)
parkingLotB = ParkingLotB(userbus = userEventBus)
parkingLotBus.addToBus(parkingLotB)
parkingMatSensorB = ParkingMatSensor(parkingLot = parkingLotB,
userbus = userEventBus,
parkbus = parkingLotBus)
# Initialize the Venues
venueA = VenueA(userbus = userEventBus)
venueEventBus.addToBus(venueA)
qrCodeA = QRCode(venue = venueA,
userbus = userEventBus,
venuebus = venueEventBus)
bookingWindowA = BookingWindow(venuebus = venueEventBus,
name_venue = venueA.getName())
venueB = VenueB(userbus = userEventBus)
venueEventBus.addToBus(venueB)
qrCodeB = QRCode(venue = venueB,
userbus = userEventBus,
venuebus = venueEventBus)
bookingWindowB = BookingWindow(venuebus = venueEventBus,
name_venue = venueB.getName())
venueC = VenueC(userbus = userEventBus)
venueEventBus.addToBus(venueC)
qrCodeC = QRCode(venue = venueC,
userbus = userEventBus,
venuebus = venueEventBus)
bookingWindowC = BookingWindow(venuebus = venueEventBus,
name_venue = venueC.getName())
# Accessibility Service
accessibilityService = AccessibilityService("blind")
acBus.addToBus(accessibilityService)
accessibilityService = AccessibilityService("deaf")
acBus.addToBus(accessibilityService)
visitors = []
i = 0
# Start the event!
venue_event = VenueEvent(name = "Lecture by Dr. SK",
type = "science",
venuebus = venueEventBus,
userbus = usernotifierBus)
types = ["science", "comedy", "game"]
while True:
# Every minute we try to create a new event
if i%12 == 0:
print("New event started!")
venue_event.endEvent()
venue_event = VenueEvent(name = "Henry Sir Lecture", type = "science", venuebus = venueEventBus,
userbus = usernotifierBus)
adminBus = EventAdminBus()
for iota in ['Harjin','Kaul','Yashdeep','Jakob']:
admin = EventAdmin(name = iota, event = venue_event.getName())
adminBus.addToBus(admin)
venue_event.startEvent(event_bus = adminBus)
venue_event.recommendEvent()
i += 1
# Someone visits and becomes a visitor with probability 0.4 per time
if random.random() < 0.4:
# Visitor name
name = input("Enter the name of the person: ")
index = int(input('Enter the index (0 based) you are interested in ["science", "comedy", "game"]: ') )
disability = input("Are you disabled?")
disability = {'yes' : True, 'no' : False}[disability]
if disability == True:
disability = list(input('Enter disabilties:').split())
ny = Visitor(name, types[index], disability = disability, acBus = acBus)
else:
ny = Visitor(name, types[index])
visitors.append(ny)
ny.addToBus(userEventBus)
ny.addToBus(weatherBus)
ny.addToBus(usernotifierBus)
n = int(input("Tickets:"))
bookingWindowA.bookTickets(demand = n)
if random.random() < 0.5:
if visitors != []:
visitors[-1].scanQRCode(qrCodeA)
if random.random() < 0.5:
if visitors != []:
visitors[-1].scanMatSensor(parkingMatSensorA)
parkingMatSensorA.sendValues()
# Weather Sensor sending values to the Users at the end of the iterations!
tempSensor.sendValues()
humSensor.sendValues()
time.sleep(1.0)