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
src/ControlTask/ControlTask.cpp
- Committer:
- jmarkel44
- Date:
- 2016-10-03
- Revision:
- 170:f9406996ff5b
- Parent:
- 164:7cecd731882e
- Child:
- 196:78397baf0802
File content as of revision 170:f9406996ff5b:
#include "ControlTask.h"
#include <stdio.h>
#include "rtos.h"
#include "ConfigurationHandler.h"
#include "MTSLog.h"
static void serviceManualControls(void);
static void serviceTimerControls(void);
static void serviceSetpointControls(void);
/*****************************************************************************
* Function: ControlTask()
* Description: This task will loop through all of the configured
* controls
*
* @param msg
* @return none
*****************************************************************************/
void ControlTask(void const *args)
{
printf("\r%s has started...\n", __func__);
while ( true ) {
serviceManualControls();
serviceTimerControls();
serviceSetpointControls();
// TODO: service the composite controls
Thread::wait(1000); // do we need to wait?
}
}
/*****************************************************************************
* Function: serviceManualControls()
* Description: service the manual controls
* controls
*
* @param none
* @return none
*****************************************************************************/
static void serviceManualControls(void)
{
// service the manual controls
if ( !manualTable.empty() ) {
StringManualMap::iterator pos;
for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) {
pos->second->update();
}
}
}
/*****************************************************************************
* Function: serviceSetpointControls()
* Description: service the setpoint controls
* controls
*
* @param none
* @return none
*****************************************************************************/
static void serviceSetpointControls(void)
{
// service the setpoint controls
if ( !setpointTable.empty() ) {
StringSetpointMap::iterator pos;
for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) {
pos->second->update();
}
}
}
/*****************************************************************************
* Function: serviceTimerControls()
* Description: service the timer controls
* controls
*
* @param none
* @return none
*****************************************************************************/
static void serviceTimerControls(void)
{
// service the timer controls
if ( !timerTable.empty() ) {
StringVectorTimerMap::iterator pos;
for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) {
// the timer vector is sorted by starttime, so we only need
// to service the first timer
TimerError_t rc = pos->second.front()->update();
if ( rc == TIMER_CONTROL_DESTROY ) {
// free the memory
delete pos->second.front();
pos->second.erase(pos->second.begin());
}
}
}
}
