-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloor.cpp
executable file
·131 lines (114 loc) · 3.03 KB
/
Floor.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
#include <iostream>
#include "Floor.h"
using namespace std;
floor::floor(int fno, int MainCorr, int SubCorr, int lights, int acs, int powerConsum)
{
floorNo = fno;
noOfMainCorr = MainCorr;
noOfSubCorr = SubCorr;
noLights = lights;
noAcs = acs;
powerConsumption = powerConsum;
movementOnSubCorridor = false;
}
void floor::initializeMainCorridors()
{
cout << " No of Main Corridors : " << noOfMainCorr << endl;
for(int i = 0; i < noOfMainCorr; i++)
{
//mainCorridor[i] = new Corridor(noLights, noAcs, MAIN);
mainCorridor.push_back( new Corridor(noLights, noAcs, MAIN));
mainCorridor[i]->initializeCorridorInsturments();
}
}
void floor::initializeSubCorridors()
{
cout << " No of Sub Corridors : " << noOfSubCorr << endl;
for(int i = 0; i < noOfSubCorr; i++)
{
//subCorridor[i] = new Corridor(noLights, noAcs, SUB);
subCorridor.push_back( new Corridor(noLights, noAcs, SUB));
subCorridor[i]->initializeCorridorInsturments();
}
}
void floor::initializeCorridors()
{
initializeMainCorridors();
initializeSubCorridors();
}
void floor::updateOnMovement(int subCorrNo)
{
if(isMovement())
{
//controller = new PowerControl;
/*for(int i = 0; i < noOfSubCorr; i++)
{
subCorridor[i]->switchOnLights();
}*/
if((unsigned int)(subCorrNo - 1) > subCorridor.size())
{
cout<<"Sub Corridor " << subCorrNo << " does not exist" << endl;
}
else
{
subCorridor[subCorrNo - 1]->switchOnLights();
}
}
}
void floor::getMainCorridorStatus()
{
for(unsigned int i = 0; i < mainCorridor.size(); i++)
{
cout<<" Main Corridor " << i + 1 << " Status" << endl;
mainCorridor[i]->getStatus();
}
}
void floor::getSubCorridorStatus()
{
for(unsigned int i = 0; i < subCorridor.size(); i++)
{
cout<<" Sub Corridor " << i + 1 << " Status" << endl;
subCorridor[i]->getStatus();
}
}
void floor::getStatus()
{
getMainCorridorStatus();
getSubCorridorStatus();
}
int floor::powerConsumptionAtMainCorr()
{
int powerConsumption = 0;
for(unsigned int i = 0; i < mainCorridor.size(); i++)
{
powerConsumption += mainCorridor[i]->powerConsumptionAtPresent();
}
cout<<"powerConsumptionAtMainCorr : " << powerConsumption << endl;
return powerConsumption;
}
int floor::powerConsumptionAtSubCorr()
{
int powerConsumption = 0;
for(unsigned int i = 0; i < subCorridor.size(); i++)
{
powerConsumption += subCorridor[i]->powerConsumptionAtPresent();
}
cout<<"powerConsumptionAtSubCorr : " << powerConsumption << endl;
return powerConsumption;
}
int floor::totalPowerConsumption()
{
return (powerConsumptionAtMainCorr() + powerConsumptionAtSubCorr());
}
void floor::AdjustPowerConsumption(int subCorrNo)
{
PowerUnitCfg * powerUnitCfgIns = PowerUnitCfg::getPowerUnitCfgIns(POWER_UNITS_PER_LIGHT, POWER_UNITS_PER_AC);
for(unsigned int i = 0;i < subCorridor.size(); i++)
{
subCorridor[i]->switchOffACs();
if(totalPowerConsumption() <= powerUnitCfgIns->maxPowerPerFloor(noOfMainCorr, noOfSubCorr))
{
break;
}
}
}