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@170:f9406996ff5b, 2016-10-03 (annotated)
- Committer:
- jmarkel44
- Date:
- Mon Oct 03 21:57:36 2016 +0000
- Revision:
- 170:f9406996ff5b
- Parent:
- 164:7cecd731882e
- Child:
- 196:78397baf0802
reduced control thread size;
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 | 170:f9406996ff5b | 7 | static void serviceManualControls(void); |
| jmarkel44 | 170:f9406996ff5b | 8 | static void serviceTimerControls(void); |
| jmarkel44 | 170:f9406996ff5b | 9 | static void serviceSetpointControls(void); |
| jmarkel44 | 170:f9406996ff5b | 10 | |
| jmarkel44 | 170:f9406996ff5b | 11 | |
| jmarkel44 | 46:4cb96ab2d1c8 | 12 | /***************************************************************************** |
| jmarkel44 | 46:4cb96ab2d1c8 | 13 | * Function: ControlTask() |
| jmarkel44 | 131:a290a3934132 | 14 | * Description: This task will loop through all of the configured |
| jmarkel44 | 131:a290a3934132 | 15 | * controls |
| jmarkel44 | 46:4cb96ab2d1c8 | 16 | * |
| jmarkel44 | 46:4cb96ab2d1c8 | 17 | * @param msg |
| jmarkel44 | 46:4cb96ab2d1c8 | 18 | * @return none |
| jmarkel44 | 46:4cb96ab2d1c8 | 19 | *****************************************************************************/ |
| jmarkel44 | 20:653923c2f37a | 20 | void ControlTask(void const *args) |
| jmarkel44 | 20:653923c2f37a | 21 | { |
| jmarkel44 | 20:653923c2f37a | 22 | printf("\r%s has started...\n", __func__); |
| jmarkel44 | 20:653923c2f37a | 23 | |
| jmarkel44 | 20:653923c2f37a | 24 | while ( true ) { |
| jmarkel44 | 170:f9406996ff5b | 25 | serviceManualControls(); |
| jmarkel44 | 170:f9406996ff5b | 26 | |
| jmarkel44 | 170:f9406996ff5b | 27 | serviceTimerControls(); |
| jmarkel44 | 170:f9406996ff5b | 28 | |
| jmarkel44 | 170:f9406996ff5b | 29 | serviceSetpointControls(); |
| jmarkel44 | 170:f9406996ff5b | 30 | |
| jmarkel44 | 170:f9406996ff5b | 31 | // TODO: service the composite controls |
| jmarkel44 | 170:f9406996ff5b | 32 | |
| jmarkel44 | 170:f9406996ff5b | 33 | Thread::wait(1000); // do we need to wait? |
| jmarkel44 | 170:f9406996ff5b | 34 | } |
| jmarkel44 | 170:f9406996ff5b | 35 | } |
| jmarkel44 | 170:f9406996ff5b | 36 | |
| jmarkel44 | 170:f9406996ff5b | 37 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 38 | * Function: serviceManualControls() |
| jmarkel44 | 170:f9406996ff5b | 39 | * Description: service the manual controls |
| jmarkel44 | 170:f9406996ff5b | 40 | * controls |
| jmarkel44 | 170:f9406996ff5b | 41 | * |
| jmarkel44 | 170:f9406996ff5b | 42 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 43 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 44 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 45 | static void serviceManualControls(void) |
| jmarkel44 | 170:f9406996ff5b | 46 | { |
| jmarkel44 | 170:f9406996ff5b | 47 | // service the manual controls |
| jmarkel44 | 170:f9406996ff5b | 48 | if ( !manualTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 49 | StringManualMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 50 | for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 51 | pos->second->update(); |
| jmarkel44 | 97:5cf6ab71dcd0 | 52 | } |
| jmarkel44 | 170:f9406996ff5b | 53 | } |
| jmarkel44 | 170:f9406996ff5b | 54 | } |
| jmarkel44 | 170:f9406996ff5b | 55 | |
| jmarkel44 | 170:f9406996ff5b | 56 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 57 | * Function: serviceSetpointControls() |
| jmarkel44 | 170:f9406996ff5b | 58 | * Description: service the setpoint controls |
| jmarkel44 | 170:f9406996ff5b | 59 | * controls |
| jmarkel44 | 170:f9406996ff5b | 60 | * |
| jmarkel44 | 170:f9406996ff5b | 61 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 62 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 63 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 64 | static void serviceSetpointControls(void) |
| jmarkel44 | 170:f9406996ff5b | 65 | { |
| jmarkel44 | 170:f9406996ff5b | 66 | // service the setpoint controls |
| jmarkel44 | 170:f9406996ff5b | 67 | if ( !setpointTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 68 | StringSetpointMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 69 | for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 70 | pos->second->update(); |
| jmarkel44 | 170:f9406996ff5b | 71 | } |
| jmarkel44 | 170:f9406996ff5b | 72 | } |
| jmarkel44 | 170:f9406996ff5b | 73 | } |
| jmarkel44 | 170:f9406996ff5b | 74 | |
| jmarkel44 | 170:f9406996ff5b | 75 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 76 | * Function: serviceTimerControls() |
| jmarkel44 | 170:f9406996ff5b | 77 | * Description: service the timer controls |
| jmarkel44 | 170:f9406996ff5b | 78 | * controls |
| jmarkel44 | 170:f9406996ff5b | 79 | * |
| jmarkel44 | 170:f9406996ff5b | 80 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 81 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 82 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 83 | static void serviceTimerControls(void) |
| jmarkel44 | 170:f9406996ff5b | 84 | { |
| jmarkel44 | 170:f9406996ff5b | 85 | // service the timer controls |
| jmarkel44 | 170:f9406996ff5b | 86 | if ( !timerTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 87 | StringVectorTimerMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 88 | for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 89 | // the timer vector is sorted by starttime, so we only need |
| jmarkel44 | 170:f9406996ff5b | 90 | // to service the first timer |
| jmarkel44 | 170:f9406996ff5b | 91 | TimerError_t rc = pos->second.front()->update(); |
| jmarkel44 | 170:f9406996ff5b | 92 | if ( rc == TIMER_CONTROL_DESTROY ) { |
| jmarkel44 | 170:f9406996ff5b | 93 | // free the memory |
| jmarkel44 | 170:f9406996ff5b | 94 | delete pos->second.front(); |
| jmarkel44 | 170:f9406996ff5b | 95 | pos->second.erase(pos->second.begin()); |
| jmarkel44 | 46:4cb96ab2d1c8 | 96 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 97 | } |
| jmarkel44 | 20:653923c2f37a | 98 | } |
| jmarkel44 | 170:f9406996ff5b | 99 | |
| jmarkel44 | 51:66b820f203a5 | 100 | } |
