-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_LOCAL_3055.cpp
212 lines (160 loc) · 8.73 KB
/
main_LOCAL_3055.cpp
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#include <iostream>
#include <ctime>
#include "MotionSensor.h"
#include "GasSensor.h"
#include "SmokeSensor.h"
#include "Sensor.h"
#include "Component.h"
#include "Location.h"
#include "activation.h"
#include "main.h"
#include "EmergencyCenter.h"
#include "Alarm.h"
#include "Contact.h"
#include "mail.h"
using namespace std;
int main()
{
/*
************************************************************ SCENARIO 2 - Louise ************************************************************
*/
auto* instanceEmergencyCenter = EmergencyCenter::getInstance();
auto residentialArea = make_shared<Location>("Residential Area");
auto house1 = make_shared<Location>("House of John and Vicky");
auto shed = make_shared<Location>("Shed of John");
auto kitchen = make_shared<Location>("Kitchen of Vicky");
auto house2 = make_shared<Location>("House of Dave");
auto livingRoom = make_shared<Location>("Living room of Dave");
auto house3 = make_shared<Location>("House of Kaitlin");
auto lab = make_shared<Location>("Lab of Kaitlin");
//TODO: change the share pointer to the specific sensor it is.
//TODO: change the sensor classes to have a constructor that also includes the type of sensor
/*
* Initializing Sensors
*/
auto smokeSensor1 = std::make_shared<SmokeSensor>("Smokey", "John's shed");
auto motionSensor1 = std::make_shared<MotionSensor>("IcanCU", "John's shed");
auto smokeSensor2 = std::make_shared<SmokeSensor>("Smokey", "Vicky's kitchen");
auto motionSensor2 = std::make_shared<MotionSensor>("IcanCU", "Vicky's kitchen");
auto gasSensor1 = std::make_shared<GasSensor>("BreatheLabs", "Dave's living room");
auto smokeSensor3 = std::make_shared<SmokeSensor>("BurningInc", "Dave's living room");
auto gasSensor2 = std::make_shared<GasSensor>("TN2S", "Kaitlin's house");
auto motionSensor3 = std::make_shared<MotionSensor>("IcanCU", "Kaitlin's lab");
/*
* Configuring sensor actions
*/
auto houseAlarm1 = std::make_shared<Alarm>("the " + house1->getName());
auto messageFireDep = std::make_shared<Mail>("message", "fire department of the neighborhood");
smokeSensor1->addStrategy(houseAlarm1);
smokeSensor1->addStrategy(messageFireDep);
smokeSensor2->addStrategy(houseAlarm1);
smokeSensor2->addStrategy(messageFireDep);
auto activateLight = std::make_shared<Activation>("light");
auto activateAirConditioner = std::make_shared<Activation>("air conditioner");
motionSensor1->addStrategy(activateLight);
motionSensor1->addStrategy(activateAirConditioner);
motionSensor2->setStartTime(22.0, 0.0);
motionSensor2->setEndTime(7.0, 0.0);
auto messageVicky = std::make_shared<Mail>("email", "[email protected]");
motionSensor2->addStrategy(messageVicky);
auto activateSprinklers = std::make_shared<Activation>("sprinkler system");
auto houseAlarm2 = std::make_shared<Alarm>("the " + house2->getName());
smokeSensor3->addStrategy(activateSprinklers);
smokeSensor3->addStrategy(messageFireDep);
smokeSensor3->addStrategy(houseAlarm2);
auto houseAlarm3 = std::make_shared<Alarm>("the " + house3->getName());
gasSensor2->addStrategy(houseAlarm1);
gasSensor2->addStrategy(houseAlarm2);
gasSensor2->addStrategy(houseAlarm3);
auto emailKaitlin = std::make_shared<Mail>("email", "[email protected]");
motionSensor3->setStartTime(4.0, 40.0);
motionSensor3->setStartTime(9.0, 15.0);
motionSensor3->addStrategy(emailKaitlin);
/*
* Building the heirarchy - adding locations and sensors to a locations
*/
instanceEmergencyCenter->add(residentialArea);
instanceEmergencyCenter->addChildToParent(residentialArea, house1);
instanceEmergencyCenter->addChildToParent(house1, shed);
instanceEmergencyCenter->addChildToParent(shed, smokeSensor1);
instanceEmergencyCenter->addChildToParent(shed, motionSensor1);
instanceEmergencyCenter->addChildToParent(house1, kitchen);
instanceEmergencyCenter->addChildToParent(kitchen, smokeSensor2);
instanceEmergencyCenter->addChildToParent(kitchen, motionSensor2);
instanceEmergencyCenter->addChildToParent(residentialArea, house2);
instanceEmergencyCenter->addChildToParent(house2, livingRoom);
instanceEmergencyCenter->addChildToParent(livingRoom, gasSensor1);
instanceEmergencyCenter->addChildToParent(livingRoom, smokeSensor3);
instanceEmergencyCenter->addChildToParent(residentialArea, house3);
instanceEmergencyCenter->addChildToParent(house3, gasSensor2);
instanceEmergencyCenter->addChildToParent(house3, lab);
instanceEmergencyCenter->addChildToParent(lab, motionSensor3);
cout<< "------------------------ TEST 1: activate and test the smoke sensor in the shed -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocation("John's shed");
//--- Start of code to be tested ---
instanceEmergencyCenter->activateSpecificSensor(smokeSensor1->getSensorID());
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocation("John's shed");
cout<< "------------------------ TEST 2: activate and test all sensors in Vicky and John’s house -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(house1);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->activateAllByLocationPointer(house1);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(house1);
cout<< "------------------------ TEST 3: test all sensors in the neighborhood -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(residentialArea);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 4: activate all sensors using the ++ operator -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->activateAllComponents();
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 5: test the whole neighborhood -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(residentialArea);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 6: test the mad scientist’s house -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(house3);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 7: give an overview of all sensors ordered by id -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->overviewSensorsInVector(instanceEmergencyCenter->orderById(instanceEmergencyCenter->getSensorList()));
//--- End of code to be tested ---
cout<< "------------------------ END OF TESTS -----------------------" << endl;
//instanceEmergencyCenter->overviewSensorsInVector(instanceEmergencyCenter->orderByLocation(instanceEmergencyCenter->getSensorList()));
//instanceEmergencyCenter->deActivateAllByLocationPointer(house3);
instanceEmergencyCenter->deActivateSpecificSensor(3);
instanceEmergencyCenter->overviewSensors();
cout << "end of program" << endl;
return 0;
}
/*some random comment*/