Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ICE-Application/src/ConfigurationHandler/Controls/FailsafeControl.h
- Revision:
- 2:02cb20446785
- Parent:
- 1:b2e90cda7a5a
diff -r b2e90cda7a5a -r 02cb20446785 ICE-Application/src/ConfigurationHandler/Controls/FailsafeControl.h
--- a/ICE-Application/src/ConfigurationHandler/Controls/FailsafeControl.h Tue Jan 24 19:06:45 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-#ifndef FAILSAFECONTROL_H
-#define FAILSAFECONTROL_H
-
-#include <stdio.h>
-#include <string>
-#include "global.h"
-
-#define FAILSAFE_CONTROL_DEBUG
-
-typedef enum {
- FAILSAFE_CONTROL_OK,
- FAILSAFE_CONTROL_UNK_STATE,
- FAILSAFE_CONTROL_ERROR,
-} FailsafeControlError_t;
-
-//! FailsafeControl - implements a failsafe by reading values from an
-// input signal and manipulating an output.
-class FailsafeControl
-{
-private:
- std::string controlFile; // the control file
- std::string id; // unique control identifier
- std::string input; // sensor to read
- std::string output; // output to manipulate
- unsigned int priority; // control priority (typically 700)
-
- typedef struct hfs_tag {
- float value; // high-failsafe trigger value
- float dutyCycle; // percentage of on-time
- float interval; // in minutes
- } hfs;
- typedef struct lfs_tag {
- float value; // low-failsafe trigger value
- float dutyCycle; // percentag of on-time
- float interval; // in minutes
- } lfs;
-
- lfs lfs_data; // Low Failsafe data
- hfs hfs_data; // High Failsafe data
-
- typedef struct timer_tag {
- unsigned long offTime; // epoch time
- unsigned long expirationTime; // epoch time
- } Timer_t;
-
- Timer_t duty_timer; // the duty timer
-
- enum State {
- STATE_INIT, // object instantiated
- STATE_START, // control has been started
- STATE_CONTROL_OFF, // control is not above/below limit
- STATE_CONTROL_ON_LFS, // low-failsafe with output on
- STATE_CONTROL_OFF_LFS, // low-failsafe with output off
- STATE_CONTROL_ON_HFS, // high-failsafe with output on
- STATE_CONTROL_OFF_HFS, // high-failsafe with output off
- STATE_CONTROL_SENSOR_ERROR, // input sensor is faulted
- STATE_MAX
- };
- State currentState;
-
- bool isVirtualOutput;
-
- bool validateControlData(const char *buf);
- void copyControlData(const char *buf);
-
- bool aboveHighFailsafe(void); // boolean check if above HFS watermark
- bool belowLowFailsafe(void); // boolean check if below LFS watermark
-
- void startHfsDutyTimer(void); // start the HFS duty timer
- void stopHfsDutyTimer(void); // stop the HFS duty timer
-
- void startLfsDutyTimer(void); // start the LFS duty timer
- void stopLfsDutyTimer(void); // stop the LFS duty timer
-
- bool dutyOnExpired(void); // boolean check if duty ON-time expired
- bool dutyOffExpired(void); // boolean check if duty OFF-time expired
-
- bool sensorError(void); // boolean check if input is faulted
-
- void sendMailToOutput(OutputAction action);
-
-public:
- /// Create a failsafe control instance
- FailsafeControl() {
- currentState = STATE_INIT;
- isVirtualOutput = false;
- }
- /// Destroy a failsafe control instance
- ~FailsafeControl() {
- // "erased...from existence!" -- Doc Brown
- printf("\r%s invoked\n", __func__);
- }
-
- /// load a failsafe control instance with data from a JSON configuration file
- bool load(std::string filename);
-
- /// start a failsafe control instance
- void start(void);
-
- /// update a failsafe control instance
- FailsafeControlError_t update(void);
-
- /// unregister a failsafe control instance
- void unregisterControl(void);
-
-
- /// display the pertinent data of a failsafe control instance
- void display(void);
-
- /// get control identifier
- std::string getId() const {
- return id;
- }
-};
-
-#endif
\ No newline at end of file