Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

src/ControlTask/ControlTask.cpp

Committer:
jmarkel44
Date:
2016-09-30
Revision:
157:0d79678ed00f
Parent:
156:44f87c5a83ae
Child:
164:7cecd731882e

File content as of revision 157:0d79678ed00f:

#include "ControlTask.h"
#include <stdio.h>
#include "rtos.h"
#include "ConfigurationHandler.h"
#include "MTSLog.h"

/*****************************************************************************
 * 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 ) {
        
        // service the manual controls
        if ( !manualTable.empty() ) {
            StringManualMap::iterator pos;
            for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) {
                pos->second->update();
            }
        }
        // service the setpoint controls
        if ( !setpointTable.empty() ) {
            StringSetpointMap::iterator pos;
            for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) {
                pos->second->update();
            }
        }
        // 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 ) {
                    pos->second.erase(pos->second.begin());
                }
            }
        }
        
        // service the composite controls 
        
        Thread::wait(1000);     // do we need to wait?
    }
}