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

Committer:
sbouber1
Date:
Fri Jun 24 13:51:42 2016 +0000
Revision:
80:38e274c4dafa
Parent:
72:f8c4f731f0fe
final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sbouber1 57:8dc3192ff150 1 #ifndef __SENSORALARMCONTROLLER_H__
sbouber1 57:8dc3192ff150 2 #define __SENSORALARMCONTROLLER_H__
sbouber1 10:fd4670ec0806 3
sbouber1 64:735009c4c8aa 4 #include <iostream>
sbouber1 64:735009c4c8aa 5
sbouber1 10:fd4670ec0806 6 #include "mbed.h"
sbouber1 10:fd4670ec0806 7 #include "SensorController.h"
joran 40:1668630544c7 8 #include "PIDController.h"
sbouber1 57:8dc3192ff150 9 #include "settings.h"
sbouber1 10:fd4670ec0806 10
sbouber1 57:8dc3192ff150 11 /** The AlarmController monitors a Sensor and registers unsafe values.
sbouber1 52:eaddbde192f1 12 * After a specified amount of time an alarm is raised by means of a buzzer.
sbouber1 52:eaddbde192f1 13 */
sbouber1 57:8dc3192ff150 14 class SensorAlarmController : public Controller {
sbouber1 10:fd4670ec0806 15
sbouber1 10:fd4670ec0806 16 public:
sbouber1 52:eaddbde192f1 17
sbouber1 57:8dc3192ff150 18 /** Contructs a new AlarmController which monitors the given SensorController. */
sbouber1 57:8dc3192ff150 19 SensorAlarmController(bool threaded, int interval_ms, SensorController *sensor,
sbouber1 57:8dc3192ff150 20 float min_crit, float min_undesired, float max_crit, float max_undesired)
sbouber1 10:fd4670ec0806 21 : Controller(threaded, interval_ms) {
sbouber1 57:8dc3192ff150 22 this->sensor = sensor;
sbouber1 57:8dc3192ff150 23 this->error = false;
sbouber1 57:8dc3192ff150 24 this->is_crit = false;
joran 43:0abb54448b75 25
sbouber1 57:8dc3192ff150 26 this->min_crit = min_crit;
sbouber1 57:8dc3192ff150 27 this->min_undesired = min_undesired;
sbouber1 57:8dc3192ff150 28 this->max_crit = max_crit;
sbouber1 57:8dc3192ff150 29 this->max_undesired = max_undesired;
sbouber1 64:735009c4c8aa 30
sbouber1 64:735009c4c8aa 31 this->error_msg_critical = "crit alarm";
sbouber1 64:735009c4c8aa 32 this->error_msg_undesired = "undes alarm";
sbouber1 10:fd4670ec0806 33 }
sbouber1 10:fd4670ec0806 34
sbouber1 52:eaddbde192f1 35 /** Overrides update() in the Controller class */
sbouber1 10:fd4670ec0806 36 virtual void update();
sbouber1 10:fd4670ec0806 37
sbouber1 52:eaddbde192f1 38 /** Overrides get_name() in the Controller class */
sbouber1 57:8dc3192ff150 39 virtual std::string getName();
sbouber1 10:fd4670ec0806 40
sbouber1 52:eaddbde192f1 41 /** Return \a true if there is an error condition and the alarm was raised. */
sbouber1 57:8dc3192ff150 42 bool isError();
sbouber1 10:fd4670ec0806 43
sbouber1 52:eaddbde192f1 44 /** Returns a message describing the last error */
sbouber1 64:735009c4c8aa 45 std::string getErrorMessage();
sbouber1 64:735009c4c8aa 46
sbouber1 64:735009c4c8aa 47 /** Activates the buzzer */
sbouber1 64:735009c4c8aa 48 static void buzzOnce();
sbouber1 64:735009c4c8aa 49
sbouber1 64:735009c4c8aa 50 void setCriticalErrorMsg(std::string msg);
sbouber1 64:735009c4c8aa 51
sbouber1 64:735009c4c8aa 52 void setUndesiredErrorMsg(std::string msg);
sbouber1 72:f8c4f731f0fe 53
sbouber1 72:f8c4f731f0fe 54 bool isActive();
sbouber1 10:fd4670ec0806 55
sbouber1 10:fd4670ec0806 56
sbouber1 10:fd4670ec0806 57 private:
sbouber1 57:8dc3192ff150 58 SensorController *sensor;
sbouber1 57:8dc3192ff150 59
sbouber1 59:614f713fb48b 60 float value;
sbouber1 57:8dc3192ff150 61 bool error;
sbouber1 64:735009c4c8aa 62 std::string error_msg;
sbouber1 57:8dc3192ff150 63 bool is_crit;
sbouber1 57:8dc3192ff150 64 Timer timer;
sbouber1 10:fd4670ec0806 65
sbouber1 57:8dc3192ff150 66 float min_crit;
sbouber1 57:8dc3192ff150 67 float min_undesired;
sbouber1 57:8dc3192ff150 68 float max_crit;
sbouber1 57:8dc3192ff150 69 float max_undesired;
sbouber1 64:735009c4c8aa 70
sbouber1 64:735009c4c8aa 71 std::string error_msg_critical;
sbouber1 64:735009c4c8aa 72 std::string error_msg_undesired;
sbouber1 64:735009c4c8aa 73
sbouber1 10:fd4670ec0806 74
sbouber1 57:8dc3192ff150 75 /** Activates an alarm for the sensor controller */
sbouber1 57:8dc3192ff150 76 void raiseAlarm(bool);
joran 27:4f73f754fdc9 77
sbouber1 10:fd4670ec0806 78 };
sbouber1 10:fd4670ec0806 79
sbouber1 10:fd4670ec0806 80
sbouber1 10:fd4670ec0806 81 #endif