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@157:0d79678ed00f, 2016-09-30 (annotated)
- Committer:
- jmarkel44
- Date:
- Fri Sep 30 13:57:45 2016 +0000
- Revision:
- 157:0d79678ed00f
- Parent:
- 156:44f87c5a83ae
- Child:
- 164:7cecd731882e
new timer control algorithms
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 20:653923c2f37a | 1 | #include "ControlTask.h" |
| jmarkel44 | 20:653923c2f37a | 2 | #include <stdio.h> |
| jmarkel44 | 20:653923c2f37a | 3 | #include "rtos.h" |
| jmarkel44 | 46:4cb96ab2d1c8 | 4 | #include "ConfigurationHandler.h" |
| jmarkel44 | 46:4cb96ab2d1c8 | 5 | #include "MTSLog.h" |
| jmarkel44 | 20:653923c2f37a | 6 | |
| jmarkel44 | 46:4cb96ab2d1c8 | 7 | /***************************************************************************** |
| jmarkel44 | 46:4cb96ab2d1c8 | 8 | * Function: ControlTask() |
| jmarkel44 | 131:a290a3934132 | 9 | * Description: This task will loop through all of the configured |
| jmarkel44 | 131:a290a3934132 | 10 | * controls |
| jmarkel44 | 46:4cb96ab2d1c8 | 11 | * |
| jmarkel44 | 46:4cb96ab2d1c8 | 12 | * @param msg |
| jmarkel44 | 46:4cb96ab2d1c8 | 13 | * @return none |
| jmarkel44 | 46:4cb96ab2d1c8 | 14 | *****************************************************************************/ |
| jmarkel44 | 20:653923c2f37a | 15 | void ControlTask(void const *args) |
| jmarkel44 | 20:653923c2f37a | 16 | { |
| jmarkel44 | 20:653923c2f37a | 17 | printf("\r%s has started...\n", __func__); |
| jmarkel44 | 20:653923c2f37a | 18 | |
| jmarkel44 | 20:653923c2f37a | 19 | while ( true ) { |
| jmarkel44 | 97:5cf6ab71dcd0 | 20 | |
| jmarkel44 | 97:5cf6ab71dcd0 | 21 | // service the manual controls |
| jmarkel44 | 97:5cf6ab71dcd0 | 22 | if ( !manualTable.empty() ) { |
| jmarkel44 | 97:5cf6ab71dcd0 | 23 | StringManualMap::iterator pos; |
| jmarkel44 | 97:5cf6ab71dcd0 | 24 | for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) { |
| jmarkel44 | 97:5cf6ab71dcd0 | 25 | pos->second->update(); |
| jmarkel44 | 97:5cf6ab71dcd0 | 26 | } |
| jmarkel44 | 97:5cf6ab71dcd0 | 27 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 28 | // service the setpoint controls |
| jmarkel44 | 46:4cb96ab2d1c8 | 29 | if ( !setpointTable.empty() ) { |
| jmarkel44 | 46:4cb96ab2d1c8 | 30 | StringSetpointMap::iterator pos; |
| jmarkel44 | 46:4cb96ab2d1c8 | 31 | for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) { |
| jmarkel44 | 51:66b820f203a5 | 32 | pos->second->update(); |
| jmarkel44 | 46:4cb96ab2d1c8 | 33 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 34 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 35 | // service the timer controls |
| jmarkel44 | 46:4cb96ab2d1c8 | 36 | if ( !timerTable.empty() ) { |
| jmarkel44 | 156:44f87c5a83ae | 37 | StringVectorTimerMap::iterator pos; |
| jmarkel44 | 46:4cb96ab2d1c8 | 38 | for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) { |
| jmarkel44 | 156:44f87c5a83ae | 39 | // the timer vector is sorted by starttime, so we only need |
| jmarkel44 | 156:44f87c5a83ae | 40 | // to service the first timer |
| jmarkel44 | 157:0d79678ed00f | 41 | TimerError_t rc = pos->second.front()->update(); |
| jmarkel44 | 157:0d79678ed00f | 42 | if ( rc == TIMER_CONTROL_DESTROY ) { |
| jmarkel44 | 157:0d79678ed00f | 43 | pos->second.erase(pos->second.begin()); |
| jmarkel44 | 157:0d79678ed00f | 44 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 45 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 46 | } |
| jmarkel44 | 51:66b820f203a5 | 47 | |
| jmarkel44 | 156:44f87c5a83ae | 48 | // service the composite controls |
| jmarkel44 | 156:44f87c5a83ae | 49 | |
| jmarkel44 | 132:45821e189dd0 | 50 | Thread::wait(1000); // do we need to wait? |
| jmarkel44 | 20:653923c2f37a | 51 | } |
| jmarkel44 | 51:66b820f203a5 | 52 | } |
