Program for the water play project for the course Software Testing Practical 2016 given at the VU University
Dependencies: mbed DRV88255 TextLCD Ping mbed-rtos
Diff: SensorAlarmController.cpp
- Revision:
- 72:f8c4f731f0fe
- Parent:
- 67:851db0511c7c
- Child:
- 73:bafd8d0f3daf
--- a/SensorAlarmController.cpp Tue Jun 21 12:09:12 2016 +0000 +++ b/SensorAlarmController.cpp Tue Jun 21 13:48:28 2016 +0000 @@ -27,7 +27,9 @@ } } else { //clear alarm + printf("Clearing alarm: %s\r\n", this->getName().c_str()); timer.stop(); + timer.reset(); this->is_crit = false; sensor->setLed(false); } @@ -40,9 +42,9 @@ int readtimer = timer.read(); if (isCrit) - cout << "Received a critical " << this->sensor->getName() << " alarm " << value << " timer is at " << readtimer << "\r\n"; + printf("Received a critical %s alarm %f timer is at %d\r\n", this->sensor->getName().c_str(), value, readtimer); if (!isCrit) - cout << "Received a non-critical " << this->sensor->getName() << " alarm " << value << " timer is at " << readtimer << "\r\n"; + printf("Received a non-critical %s alarm %f timer is at %d\r\n", this->sensor->getName().c_str(), value, readtimer); if (readtimer > 0 ) { //already running if ((readtimer >= NUMBER_OF_SEC_BEFORE_CRITICAL_ALARM && is_crit) || @@ -55,7 +57,7 @@ this->error_msg = this->error_msg_undesired; } - cout << "### " << this->getName() << " alarm has been triggered after " << " ###" << readtimer << "\r\n"; + printf("### %s alarm has been triggered after ### %d seconds\r\n", this->getName().c_str(), readtimer); sensor->setLed(true); buzzOnce(); timer.stop(); @@ -87,6 +89,9 @@ this->error_msg_undesired = msg; } +void SensorAlarmController::isActive() { + return this->timer.read() > 0; +} void SensorAlarmController::buzzOnce() {