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.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
Diff: src/ConfigurationHandler/Controls/SetpointControl.cpp
- Revision:
- 56:225786c56315
- Parent:
- 51:66b820f203a5
- Child:
- 70:7427f4959201
--- a/src/ConfigurationHandler/Controls/SetpointControl.cpp Tue Sep 13 21:40:11 2016 +0000 +++ b/src/ConfigurationHandler/Controls/SetpointControl.cpp Wed Sep 14 12:56:00 2016 +0000 @@ -12,12 +12,19 @@ extern mDot *GLOBAL_mdot; +// Method: load +// Description: open the configuration file and assign data to the +// setpoint control object +// +// @param controlFile -> name of the control file +// @return true if data is assigned; false on error + bool SetpointControl::load(string _controlFile) { MbedJSONValue json_value; // JSON parsing element controlFile = _controlFile; - // open and read from the control file + // open and read from the control file mDot::mdot_file file = GLOBAL_mdot->openUserFile(controlFile.c_str(), mDot::FM_RDONLY); if ( file.fd < 0 ) return false; @@ -51,25 +58,44 @@ lowFailsafe = atof(json_value["lfs"].get<string>().c_str()); tol = atof(json_value["tol"].get<string>().c_str()); - return true; // object created successfully + return true; // object created successfully } +// Method: registerControl +// Description: register the setpoint control with the output task +// +// @param none +// @return none + void SetpointControl::registerControl(void) { if ( GLOBAL_outputTask_thread ) { - // register our priority with the output master + // register our priority with the output master } } +// Method: start +// Description: start the setpoint control +// +// @param none +// @return none + void SetpointControl::start(void) { - // this is the initial state, let's determine what needs to be done + // this is the initial state; what else needs to be done?? this->currentState = STATE_STARTUP; } +// Method: update +// Description: based on the state of the control, check for +// under limit and over limit values, adjust the +// state accordingly +// +// @param none +// @return none + void SetpointControl::update(void) { - printf("\r%s is working on %s\n", __func__, controlFile.c_str()); switch (this->currentState) { case STATE_STARTUP: if ( this->underLimit() ) { @@ -98,34 +124,82 @@ // do nothing } break; - //case STATE_CONTROL_DISABLED: - //case STATE_CONTROL_PAUSED: + //case STATE_CONTROL_DISABLED: + //case STATE_CONTROL_PAUSED: default: break; } } +// Method: overLimit +// Description: (see @return) +// +// @param none +// @return true if product is over the upper limit for normal mode +// or under the limit for reverse mode; false otherwise + bool SetpointControl::overLimit(void) { + // stubbed for now return false; } +// Method: underLimit +// Description: (see @return) +// +// @param none +// @return true if product is under lower limit for normal mode or +// over the upper limit for reverse mode; false otherwise + bool SetpointControl::underLimit(void) { + // stubbed for now return false; } +// Method: startFeed() +// Description: send ON indication to Output Master for this control's +// relay +// +// @param none +// @return none + void SetpointControl::startFeed(void) { - logInfo("%s attempting to start feed on relay %s\n", - controlFile.c_str(), output.c_str()); - - // TODO: send a message to the output task to turn the relay ON + logInfo("%s: %s attempting to start feed on relay %s\n", + __func__, controlFile.c_str(), output.c_str()); + + OutputControlReq_t *msg = OutputMasterMailBox.alloc(); + + // construct the ON message + msg->relay = this->output; + msg->state = ON; + msg->priority = this->priority; + + // ship it + OutputMasterMailBox.put(msg); + } +// Method: stopFeed +// Description: send OFF indication to Output Master for this control's +// relay +// +// @param none +// @return none + void SetpointControl::stopFeed(void) { - logInfo("%s attempting to stop feed on relay %s\n", - controlFile.c_str(), output.c_str()); - // TODO: send a message to the output task to turn the relay OFF + logInfo("%s: %s attempting to start feed on relay %s\n", + __func__, controlFile.c_str(), output.c_str()); + + OutputControlReq_t *msg = OutputMasterMailBox.alloc(); + + // construct the OFF message + msg->relay = this->output; + msg->state = OFF; + msg->priority = this->priority; + + // ship it + OutputMasterMailBox.put(msg); } \ No newline at end of file