Saltware / Mbed 2 deprecated Water Play

Dependencies:   mbed DRV88255 TextLCD Ping mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SensorAlarmController.h Source File

SensorAlarmController.h

00001 #ifndef __SENSORALARMCONTROLLER_H__
00002 #define __SENSORALARMCONTROLLER_H__
00003 
00004 #include <iostream>
00005 
00006 #include "mbed.h"
00007 #include "SensorController.h"
00008 #include "PIDController.h"
00009 #include "settings.h"
00010 
00011 /** The AlarmController monitors a Sensor and registers unsafe values.
00012  * After a specified amount of time an alarm is raised by means of a buzzer.
00013  */
00014 class SensorAlarmController  : public Controller {
00015 
00016     public:
00017     
00018         /** Contructs a new AlarmController which monitors the given SensorController. */
00019         SensorAlarmController(bool threaded, int interval_ms, SensorController *sensor,
00020             float min_crit, float min_undesired, float max_crit, float max_undesired)
00021          : Controller(threaded, interval_ms) {
00022             this->sensor = sensor;
00023             this->error = false;
00024             this->is_crit = false;        
00025             
00026             this->min_crit = min_crit;
00027             this->min_undesired = min_undesired;
00028             this->max_crit = max_crit;
00029             this->max_undesired = max_undesired;
00030             
00031             this->error_msg_critical = "crit alarm";
00032             this->error_msg_undesired = "undes alarm";
00033         }
00034         
00035         /** Overrides update() in the Controller class */
00036         virtual void update();
00037         
00038         /** Overrides get_name() in the Controller class */
00039         virtual std::string getName();
00040         
00041         /** Return \a true if there is an error condition and the alarm was raised. */
00042         bool isError();
00043         
00044         /** Returns a message describing the last error */
00045         std::string getErrorMessage();
00046         
00047         /** Activates the buzzer */
00048         static void buzzOnce();
00049         
00050         void setCriticalErrorMsg(std::string msg);
00051         
00052         void setUndesiredErrorMsg(std::string msg);
00053         
00054         bool isActive();
00055 
00056     
00057     private:
00058         SensorController *sensor;
00059 
00060         float value;
00061         bool error;
00062         std::string error_msg;
00063         bool is_crit;
00064         Timer timer;
00065         
00066         float min_crit;
00067         float min_undesired;
00068         float max_crit;
00069         float max_undesired;
00070         
00071         std::string error_msg_critical;
00072         std::string error_msg_undesired;
00073         
00074         
00075         /** Activates an alarm for the sensor controller */
00076         void raiseAlarm(bool);
00077         
00078 };
00079 
00080 
00081 #endif