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@218:e0c05b4f470b, 2016-10-11 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Oct 11 18:34:28 2016 +0000
- Revision:
- 218:e0c05b4f470b
- Parent:
- 196:78397baf0802
- Child:
- 221:2a5e9902003c
more general cleanup;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 218:e0c05b4f470b | 1 | /****************************************************************************** |
| jmarkel44 | 218:e0c05b4f470b | 2 | * |
| jmarkel44 | 218:e0c05b4f470b | 3 | * File: ControlTask.cpp |
| jmarkel44 | 218:e0c05b4f470b | 4 | * Desciption: source for the ICE Control task |
| jmarkel44 | 218:e0c05b4f470b | 5 | * |
| jmarkel44 | 218:e0c05b4f470b | 6 | *****************************************************************************/ |
| jmarkel44 | 218:e0c05b4f470b | 7 | |
| jmarkel44 | 20:653923c2f37a | 8 | #include "ControlTask.h" |
| jmarkel44 | 20:653923c2f37a | 9 | #include <stdio.h> |
| jmarkel44 | 20:653923c2f37a | 10 | #include "rtos.h" |
| jmarkel44 | 46:4cb96ab2d1c8 | 11 | #include "ConfigurationHandler.h" |
| jmarkel44 | 46:4cb96ab2d1c8 | 12 | #include "MTSLog.h" |
| jmarkel44 | 196:78397baf0802 | 13 | #include "global.h" |
| jmarkel44 | 20:653923c2f37a | 14 | |
| jmarkel44 | 218:e0c05b4f470b | 15 | // control functions |
| jmarkel44 | 170:f9406996ff5b | 16 | static void serviceManualControls(void); |
| jmarkel44 | 170:f9406996ff5b | 17 | static void serviceTimerControls(void); |
| jmarkel44 | 170:f9406996ff5b | 18 | static void serviceSetpointControls(void); |
| jmarkel44 | 218:e0c05b4f470b | 19 | static void serviceCompositeControls(void); |
| jmarkel44 | 170:f9406996ff5b | 20 | |
| jmarkel44 | 46:4cb96ab2d1c8 | 21 | /***************************************************************************** |
| jmarkel44 | 46:4cb96ab2d1c8 | 22 | * Function: ControlTask() |
| jmarkel44 | 131:a290a3934132 | 23 | * Description: This task will loop through all of the configured |
| jmarkel44 | 131:a290a3934132 | 24 | * controls |
| jmarkel44 | 46:4cb96ab2d1c8 | 25 | * |
| jmarkel44 | 46:4cb96ab2d1c8 | 26 | * @param msg |
| jmarkel44 | 46:4cb96ab2d1c8 | 27 | * @return none |
| jmarkel44 | 46:4cb96ab2d1c8 | 28 | *****************************************************************************/ |
| jmarkel44 | 20:653923c2f37a | 29 | void ControlTask(void const *args) |
| jmarkel44 | 20:653923c2f37a | 30 | { |
| jmarkel44 | 20:653923c2f37a | 31 | printf("\r%s has started...\n", __func__); |
| jmarkel44 | 20:653923c2f37a | 32 | |
| jmarkel44 | 20:653923c2f37a | 33 | while ( true ) { |
| jmarkel44 | 170:f9406996ff5b | 34 | serviceManualControls(); |
| jmarkel44 | 170:f9406996ff5b | 35 | |
| jmarkel44 | 170:f9406996ff5b | 36 | serviceTimerControls(); |
| jmarkel44 | 170:f9406996ff5b | 37 | |
| jmarkel44 | 170:f9406996ff5b | 38 | serviceSetpointControls(); |
| jmarkel44 | 170:f9406996ff5b | 39 | |
| jmarkel44 | 218:e0c05b4f470b | 40 | serviceCompositeControls(); |
| jmarkel44 | 170:f9406996ff5b | 41 | |
| jmarkel44 | 170:f9406996ff5b | 42 | Thread::wait(1000); // do we need to wait? |
| jmarkel44 | 170:f9406996ff5b | 43 | } |
| jmarkel44 | 170:f9406996ff5b | 44 | } |
| jmarkel44 | 170:f9406996ff5b | 45 | |
| jmarkel44 | 170:f9406996ff5b | 46 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 47 | * Function: serviceManualControls() |
| jmarkel44 | 170:f9406996ff5b | 48 | * Description: service the manual controls |
| jmarkel44 | 170:f9406996ff5b | 49 | * controls |
| jmarkel44 | 170:f9406996ff5b | 50 | * |
| jmarkel44 | 170:f9406996ff5b | 51 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 52 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 53 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 54 | static void serviceManualControls(void) |
| jmarkel44 | 170:f9406996ff5b | 55 | { |
| jmarkel44 | 170:f9406996ff5b | 56 | // service the manual controls |
| jmarkel44 | 170:f9406996ff5b | 57 | if ( !manualTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 58 | StringManualMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 59 | for ( pos = manualTable.begin(); pos != manualTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 60 | pos->second->update(); |
| jmarkel44 | 97:5cf6ab71dcd0 | 61 | } |
| jmarkel44 | 170:f9406996ff5b | 62 | } |
| jmarkel44 | 170:f9406996ff5b | 63 | } |
| jmarkel44 | 170:f9406996ff5b | 64 | |
| jmarkel44 | 170:f9406996ff5b | 65 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 66 | * Function: serviceSetpointControls() |
| jmarkel44 | 170:f9406996ff5b | 67 | * Description: service the setpoint controls |
| jmarkel44 | 170:f9406996ff5b | 68 | * controls |
| jmarkel44 | 170:f9406996ff5b | 69 | * |
| jmarkel44 | 170:f9406996ff5b | 70 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 71 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 72 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 73 | static void serviceSetpointControls(void) |
| jmarkel44 | 170:f9406996ff5b | 74 | { |
| jmarkel44 | 170:f9406996ff5b | 75 | // service the setpoint controls |
| jmarkel44 | 170:f9406996ff5b | 76 | if ( !setpointTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 77 | StringSetpointMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 78 | for ( pos = setpointTable.begin(); pos != setpointTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 79 | pos->second->update(); |
| jmarkel44 | 170:f9406996ff5b | 80 | } |
| jmarkel44 | 170:f9406996ff5b | 81 | } |
| jmarkel44 | 170:f9406996ff5b | 82 | } |
| jmarkel44 | 170:f9406996ff5b | 83 | |
| jmarkel44 | 170:f9406996ff5b | 84 | /***************************************************************************** |
| jmarkel44 | 170:f9406996ff5b | 85 | * Function: serviceTimerControls() |
| jmarkel44 | 170:f9406996ff5b | 86 | * Description: service the timer controls |
| jmarkel44 | 170:f9406996ff5b | 87 | * controls |
| jmarkel44 | 170:f9406996ff5b | 88 | * |
| jmarkel44 | 170:f9406996ff5b | 89 | * @param none |
| jmarkel44 | 170:f9406996ff5b | 90 | * @return none |
| jmarkel44 | 170:f9406996ff5b | 91 | *****************************************************************************/ |
| jmarkel44 | 170:f9406996ff5b | 92 | static void serviceTimerControls(void) |
| jmarkel44 | 170:f9406996ff5b | 93 | { |
| jmarkel44 | 170:f9406996ff5b | 94 | // service the timer controls |
| jmarkel44 | 170:f9406996ff5b | 95 | if ( !timerTable.empty() ) { |
| jmarkel44 | 170:f9406996ff5b | 96 | StringVectorTimerMap::iterator pos; |
| jmarkel44 | 170:f9406996ff5b | 97 | for ( pos = timerTable.begin(); pos != timerTable.end(); ++pos ) { |
| jmarkel44 | 170:f9406996ff5b | 98 | // the timer vector is sorted by starttime, so we only need |
| jmarkel44 | 170:f9406996ff5b | 99 | // to service the first timer |
| jmarkel44 | 170:f9406996ff5b | 100 | TimerError_t rc = pos->second.front()->update(); |
| jmarkel44 | 170:f9406996ff5b | 101 | if ( rc == TIMER_CONTROL_DESTROY ) { |
| jmarkel44 | 196:78397baf0802 | 102 | GLOBAL_mdot->deleteUserFile(pos->second.front()->getControlFile().c_str()); |
| jmarkel44 | 196:78397baf0802 | 103 | logInfo("%s: deleted %s", __func__, pos->second.front()->getControlFile().c_str()); |
| jmarkel44 | 170:f9406996ff5b | 104 | // free the memory |
| jmarkel44 | 170:f9406996ff5b | 105 | delete pos->second.front(); |
| jmarkel44 | 170:f9406996ff5b | 106 | pos->second.erase(pos->second.begin()); |
| jmarkel44 | 46:4cb96ab2d1c8 | 107 | } |
| jmarkel44 | 46:4cb96ab2d1c8 | 108 | } |
| jmarkel44 | 20:653923c2f37a | 109 | } |
| jmarkel44 | 170:f9406996ff5b | 110 | |
| jmarkel44 | 218:e0c05b4f470b | 111 | } |
| jmarkel44 | 218:e0c05b4f470b | 112 | |
| jmarkel44 | 218:e0c05b4f470b | 113 | /***************************************************************************** |
| jmarkel44 | 218:e0c05b4f470b | 114 | * Function: serviceCompositeControls() |
| jmarkel44 | 218:e0c05b4f470b | 115 | * Description: service the composite controls |
| jmarkel44 | 218:e0c05b4f470b | 116 | * controls |
| jmarkel44 | 218:e0c05b4f470b | 117 | * |
| jmarkel44 | 218:e0c05b4f470b | 118 | * @param none |
| jmarkel44 | 218:e0c05b4f470b | 119 | * @return none |
| jmarkel44 | 218:e0c05b4f470b | 120 | *****************************************************************************/ |
| jmarkel44 | 218:e0c05b4f470b | 121 | static void serviceCompositeControls(void) |
| jmarkel44 | 218:e0c05b4f470b | 122 | { |
| jmarkel44 | 51:66b820f203a5 | 123 | } |
