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