Skip to content

Commit 05a6a21

Browse files
chore: implement getter and setter for speed and status
1 parent cd78627 commit 05a6a21

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

room_control_unit/src/app/io/environment/VentilationSystem.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
VentilationSystem::VentilationSystem(const String id, const int ventilationPin): id(id), ventilationPin(ventilationPin), speedPercentage(0) {
1313
pinMode(this->ventilationPin, OUTPUT);
14-
14+
this->currentStatus = PowerStatus::OFF;
1515
this->turn(PowerStatus::OFF);
1616
}
1717

@@ -24,6 +24,7 @@ ActuatorType VentilationSystem::getType() {
2424
}
2525

2626
void VentilationSystem::turn(const PowerStatus status) {
27+
this->currentStatus = status;
2728
switch (status)
2829
{
2930
case PowerStatus::ON:
@@ -38,5 +39,16 @@ void VentilationSystem::turn(const PowerStatus status) {
3839

3940
void VentilationSystem::setSpeedPercentage(Percentage speedPercentage) {
4041
this->speedPercentage = speedPercentage;
42+
if(this->currentStatus == PowerStatus::ON) {
43+
this->turn(this->currentStatus);
44+
}
45+
}
46+
47+
Percentage VentilationSystem::getSpeedPercentage() {
48+
return this->speedPercentage;
49+
}
50+
51+
PowerStatus VentilationSystem::getStatus() {
52+
return this->currentStatus;
4153
}
4254

room_control_unit/src/app/io/environment/VentilationSystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ class VentilationSystem: public Ventilation {
2323
VentilationSystem(String id, int ventilationPin);
2424

2525
void turn(PowerStatus status);
26+
PowerStatus getStatus();
2627
void setSpeedPercentage(Percentage speedPercentage);
28+
Percentage getSpeedPercentage();
2729
String getId();
2830
ActuatorType getType();
2931

3032
private:
3133
const String id;
3234
const int ventilationPin;
35+
PowerStatus currentStatus;
3336
Percentage speedPercentage;
3437
};
3538

room_control_unit/src/app/logic/baseio/Ventilation.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,26 @@ class Ventilation: public Actuator {
2727
*/
2828
virtual void turn(PowerStatus status) = 0;
2929

30+
/*
31+
Get the status of the ventilation.
32+
33+
@return the current status.
34+
*/
35+
virtual PowerStatus getStatus() = 0;
36+
3037
/*
3138
Set che ventilation speed percentage.
3239
3340
@param speedPercentage the speed percentage of the ventilation.
3441
*/
3542
virtual void setSpeedPercentage(Percentage speedPercentage) = 0;
43+
44+
/*
45+
Get the speed percentage.
46+
47+
@return the speed percentage of the ventilation.
48+
*/
49+
virtual Percentage getSpeedPercentage() = 0;
3650
};
3751

3852
#endif

0 commit comments

Comments
 (0)