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.
ICE-Application/src/OutputTask/ControlClass/Control.cpp@0:61364762ee0e, 2017-01-24 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Jan 24 19:05:33 2017 +0000
- Revision:
- 0:61364762ee0e
Port from IAR to Nucleo-F412 board
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 0:61364762ee0e | 1 | /****************************************************************************** |
jmarkel44 | 0:61364762ee0e | 2 | * |
jmarkel44 | 0:61364762ee0e | 3 | * File: Control.cpp |
jmarkel44 | 0:61364762ee0e | 4 | * Desciption: ICE Control Class implementation for Output Thread |
jmarkel44 | 0:61364762ee0e | 5 | * |
jmarkel44 | 0:61364762ee0e | 6 | *****************************************************************************/ |
jmarkel44 | 0:61364762ee0e | 7 | #include <Control.h> |
jmarkel44 | 0:61364762ee0e | 8 | |
jmarkel44 | 0:61364762ee0e | 9 | // |
jmarkel44 | 0:61364762ee0e | 10 | // method: getMappedState |
jmarkel44 | 0:61364762ee0e | 11 | // description: convert the control state into its analytics code |
jmarkel44 | 0:61364762ee0e | 12 | // the values here should map to the RELAY_STATUS_* codes |
jmarkel44 | 0:61364762ee0e | 13 | // define in global.h |
jmarkel44 | 0:61364762ee0e | 14 | // |
jmarkel44 | 0:61364762ee0e | 15 | // @param none |
jmarkel44 | 0:61364762ee0e | 16 | // @return relay-status code |
jmarkel44 | 0:61364762ee0e | 17 | // |
jmarkel44 | 0:61364762ee0e | 18 | int Control::getMappedState(void) const |
jmarkel44 | 0:61364762ee0e | 19 | { |
jmarkel44 | 0:61364762ee0e | 20 | switch (controlType) { |
jmarkel44 | 0:61364762ee0e | 21 | case CONTROL_TIMER: |
jmarkel44 | 0:61364762ee0e | 22 | case CONTROL_SETPOINT: |
jmarkel44 | 0:61364762ee0e | 23 | // automatic control |
jmarkel44 | 0:61364762ee0e | 24 | return (state) ? RELAY_STATUS_AUTO_ON : RELAY_STATUS_AUTO_OFF; |
jmarkel44 | 0:61364762ee0e | 25 | case CONTROL_MANUAL: |
jmarkel44 | 0:61364762ee0e | 26 | // manual control |
jmarkel44 | 0:61364762ee0e | 27 | return (state) ? RELAY_STATUS_MANUAL_ON : RELAY_STATUS_MANUAL_OFF; |
jmarkel44 | 0:61364762ee0e | 28 | case CONTROL_FAILSAFE: |
jmarkel44 | 0:61364762ee0e | 29 | // failsafe control |
jmarkel44 | 0:61364762ee0e | 30 | return (state) ? RELAY_STATUS_FAILSAFE_ON : RELAY_STATUS_FAILSAFE_OFF; |
jmarkel44 | 0:61364762ee0e | 31 | case CONTROL_COMPOSITE: |
jmarkel44 | 0:61364762ee0e | 32 | // FIXME! This is a hack to get the correct mapped relay status |
jmarkel44 | 0:61364762ee0e | 33 | if ( input.compare(0, strlen("i_flowsw"), "i_flowsw") == 0 ) { |
jmarkel44 | 0:61364762ee0e | 34 | return ( state ) ? RELAY_STATUS_FLOW_FAILSAFE_ON : RELAY_STATUS_FLOW_FAILSAFE_OFF; |
jmarkel44 | 0:61364762ee0e | 35 | } else { |
jmarkel44 | 0:61364762ee0e | 36 | return ( state ) ? RELAY_STATUS_AUTO_ON : RELAY_STATUS_AUTO_OFF; |
jmarkel44 | 0:61364762ee0e | 37 | } |
jmarkel44 | 0:61364762ee0e | 38 | case CONTROL_PID: |
jmarkel44 | 0:61364762ee0e | 39 | // not implememented |
jmarkel44 | 0:61364762ee0e | 40 | default: |
jmarkel44 | 0:61364762ee0e | 41 | return -1; |
jmarkel44 | 0:61364762ee0e | 42 | } |
jmarkel44 | 0:61364762ee0e | 43 | } |