Erick / Mbed 2 deprecated ICE-F412

Dependencies:   mbed-rtos mbed

ICE-Application/src/OutputTask/ControlClass/Control.cpp

Committer:
jmarkel44
Date:
2017-01-24
Revision:
0:61364762ee0e

File content as of revision 0:61364762ee0e:

/******************************************************************************
 *
 * File:                Control.cpp
 * Desciption:          ICE Control Class implementation for Output Thread
 *
 *****************************************************************************/
#include <Control.h>

//
// method:          getMappedState
// description:     convert the control state into its analytics code
//                  the values here should map to the RELAY_STATUS_* codes
//                  define in global.h
//
// @param           none
// @return          relay-status code
//
int Control::getMappedState(void) const
{
    switch (controlType) {
        case CONTROL_TIMER:
        case CONTROL_SETPOINT:
            // automatic control
             return (state) ? RELAY_STATUS_AUTO_ON : RELAY_STATUS_AUTO_OFF;
        case CONTROL_MANUAL:
            // manual control
            return (state) ? RELAY_STATUS_MANUAL_ON : RELAY_STATUS_MANUAL_OFF;
        case CONTROL_FAILSAFE:
            // failsafe control
            return (state) ? RELAY_STATUS_FAILSAFE_ON : RELAY_STATUS_FAILSAFE_OFF;
        case CONTROL_COMPOSITE:
            // FIXME! This is a hack to get the correct mapped relay status
            if ( input.compare(0, strlen("i_flowsw"), "i_flowsw") == 0 ) {
                return ( state ) ? RELAY_STATUS_FLOW_FAILSAFE_ON : RELAY_STATUS_FLOW_FAILSAFE_OFF;
            } else {
                return ( state ) ? RELAY_STATUS_AUTO_ON : RELAY_STATUS_AUTO_OFF;
            }
        case CONTROL_PID:
            // not implememented 
        default:
            return -1;
    }
}