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/ConfigurationHandler/ConfigurationHandler.cpp@5:5e77a1db4d45, 2016-09-06 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Sep 06 19:20:39 2016 +0000
- Revision:
- 5:5e77a1db4d45
- Parent:
- 3:8ea4db957749
- Child:
- 10:38d8ece439da
- Child:
- 11:0695c1091129
- Child:
- 12:ea87887ca7ad
testing the repo
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jmarkel44 | 0:65cfa4873284 | 1 | /****************************************************************************** |
| jmarkel44 | 0:65cfa4873284 | 2 | * |
| jmarkel44 | 0:65cfa4873284 | 3 | * File: ConfigurationHandler.cpp |
| jmarkel44 | 0:65cfa4873284 | 4 | * Desciption: source for the ICE Configuration Handler |
| jmarkel44 | 0:65cfa4873284 | 5 | * |
| jmarkel44 | 0:65cfa4873284 | 6 | *****************************************************************************/ |
| jmarkel44 | 3:8ea4db957749 | 7 | #include "ConfigurationHandler.h" |
| jmarkel44 | 0:65cfa4873284 | 8 | #include "global.h" |
| jmarkel44 | 5:5e77a1db4d45 | 9 | #include "SetpointControl.h" |
| jmarkel44 | 5:5e77a1db4d45 | 10 | |
| jmarkel44 | 5:5e77a1db4d45 | 11 | // local function prototypes |
| jmarkel44 | 5:5e77a1db4d45 | 12 | static int loadPersistentControls(void); |
| jmarkel44 | 5:5e77a1db4d45 | 13 | |
| jmarkel44 | 5:5e77a1db4d45 | 14 | static int createControl(const Message_t *msg); |
| jmarkel44 | 5:5e77a1db4d45 | 15 | static int modifyControl(const Message_t *msg); |
| jmarkel44 | 5:5e77a1db4d45 | 16 | static int destroyControl(const Message_t *msg); |
| jmarkel44 | 5:5e77a1db4d45 | 17 | |
| jmarkel44 | 5:5e77a1db4d45 | 18 | static int loadPersistentControls(void) |
| jmarkel44 | 5:5e77a1db4d45 | 19 | { |
| jmarkel44 | 5:5e77a1db4d45 | 20 | printf("\r%s: stubbed.\n", __func__); |
| jmarkel44 | 5:5e77a1db4d45 | 21 | return 0; |
| jmarkel44 | 5:5e77a1db4d45 | 22 | } |
| jmarkel44 | 0:65cfa4873284 | 23 | |
| jmarkel44 | 0:65cfa4873284 | 24 | void ConfigurationHandler(void const *args) |
| jmarkel44 | 0:65cfa4873284 | 25 | { |
| jmarkel44 | 5:5e77a1db4d45 | 26 | loadPersistentControls(); |
| jmarkel44 | 0:65cfa4873284 | 27 | osSignalSet(mainThreadId, sig_continue); |
| jmarkel44 | 5:5e77a1db4d45 | 28 | |
| jmarkel44 | 3:8ea4db957749 | 29 | while ( true ) { |
| jmarkel44 | 5:5e77a1db4d45 | 30 | // wait for an event |
| jmarkel44 | 5:5e77a1db4d45 | 31 | osEvent evt = MailBox.get(); |
| jmarkel44 | 5:5e77a1db4d45 | 32 | if (evt.status == osEventMail) { |
| jmarkel44 | 5:5e77a1db4d45 | 33 | Message_t *msg = (Message_t*) evt.value.p; |
| jmarkel44 | 5:5e77a1db4d45 | 34 | |
| jmarkel44 | 5:5e77a1db4d45 | 35 | printf("\r%s: mes->action = %d\n", __func__, msg->action); |
| jmarkel44 | 5:5e77a1db4d45 | 36 | printf("\r%s: msg->control = %d\n", __func__, msg->control); |
| jmarkel44 | 5:5e77a1db4d45 | 37 | printf("\r%s: msg->controlFile = %s\n", __func__, msg->controlFile); |
| jmarkel44 | 5:5e77a1db4d45 | 38 | |
| jmarkel44 | 5:5e77a1db4d45 | 39 | switch ( msg->action ) { |
| jmarkel44 | 5:5e77a1db4d45 | 40 | case ACTION_CREATE: { |
| jmarkel44 | 5:5e77a1db4d45 | 41 | (void)createControl(msg); |
| jmarkel44 | 5:5e77a1db4d45 | 42 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 43 | } |
| jmarkel44 | 5:5e77a1db4d45 | 44 | case ACTION_MODIFY: { |
| jmarkel44 | 5:5e77a1db4d45 | 45 | (void)modifyControl(msg); |
| jmarkel44 | 5:5e77a1db4d45 | 46 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 47 | } |
| jmarkel44 | 5:5e77a1db4d45 | 48 | case ACTION_DESTROY: { |
| jmarkel44 | 5:5e77a1db4d45 | 49 | (void)destroyControl(msg); |
| jmarkel44 | 5:5e77a1db4d45 | 50 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 51 | } |
| jmarkel44 | 5:5e77a1db4d45 | 52 | default: |
| jmarkel44 | 5:5e77a1db4d45 | 53 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 54 | } |
| jmarkel44 | 5:5e77a1db4d45 | 55 | |
| jmarkel44 | 5:5e77a1db4d45 | 56 | // free the message |
| jmarkel44 | 5:5e77a1db4d45 | 57 | MailBox.free(msg); |
| jmarkel44 | 5:5e77a1db4d45 | 58 | } |
| jmarkel44 | 0:65cfa4873284 | 59 | } |
| jmarkel44 | 0:65cfa4873284 | 60 | } |
| jmarkel44 | 5:5e77a1db4d45 | 61 | |
| jmarkel44 | 5:5e77a1db4d45 | 62 | static int createControl(const Message_t *msg) |
| jmarkel44 | 5:5e77a1db4d45 | 63 | { |
| jmarkel44 | 5:5e77a1db4d45 | 64 | printf("\r%s invoked\n", __func__); |
| jmarkel44 | 5:5e77a1db4d45 | 65 | |
| jmarkel44 | 5:5e77a1db4d45 | 66 | switch (msg->control) { |
| jmarkel44 | 5:5e77a1db4d45 | 67 | case CONTROL_SETPOINT: { |
| jmarkel44 | 5:5e77a1db4d45 | 68 | SetpointControl *setpointControl = new SetpointControl(msg->controlFile); |
| jmarkel44 | 5:5e77a1db4d45 | 69 | printf("\r%s: setpoint control file = %s\n", __func__, setpointControl->getControlFile().c_str()); |
| jmarkel44 | 5:5e77a1db4d45 | 70 | |
| jmarkel44 | 5:5e77a1db4d45 | 71 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 72 | } |
| jmarkel44 | 5:5e77a1db4d45 | 73 | case CONTROL_TIMER: { |
| jmarkel44 | 5:5e77a1db4d45 | 74 | // do something similar here |
| jmarkel44 | 5:5e77a1db4d45 | 75 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 76 | } |
| jmarkel44 | 5:5e77a1db4d45 | 77 | default: |
| jmarkel44 | 5:5e77a1db4d45 | 78 | break; |
| jmarkel44 | 5:5e77a1db4d45 | 79 | } |
| jmarkel44 | 5:5e77a1db4d45 | 80 | return 0; |
| jmarkel44 | 5:5e77a1db4d45 | 81 | } |
| jmarkel44 | 5:5e77a1db4d45 | 82 | static int modifyControl(const Message_t *msg) |
| jmarkel44 | 5:5e77a1db4d45 | 83 | { |
| jmarkel44 | 5:5e77a1db4d45 | 84 | printf("\r%s invoked\n", __func__); |
| jmarkel44 | 5:5e77a1db4d45 | 85 | return 0; |
| jmarkel44 | 5:5e77a1db4d45 | 86 | |
| jmarkel44 | 5:5e77a1db4d45 | 87 | } |
| jmarkel44 | 5:5e77a1db4d45 | 88 | static int destroyControl(const Message_t *msg) |
| jmarkel44 | 5:5e77a1db4d45 | 89 | { |
| jmarkel44 | 5:5e77a1db4d45 | 90 | printf("\r%s invoked\n", __func__); |
| jmarkel44 | 5:5e77a1db4d45 | 91 | return 0; |
| jmarkel44 | 5:5e77a1db4d45 | 92 | |
| jmarkel44 | 5:5e77a1db4d45 | 93 | } |
