Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -rae407abdc3020559c5051fe02f5ab06fdb63b9db -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision ae407abdc3020559c5051fe02f5ab06fdb63b9db) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -1,11 +1,12 @@ -#include "reg_het.h" #include "gio.h" -#include "TaskGeneral.h" -#include "UVReactors.h" +#include "reg_het.h" + #include "Common.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "Timers.h" +#include "UVReactors.h" /** * @addtogroup UV Reactors @@ -45,7 +46,7 @@ { UV_REACTOR_STATE_T execState; ///< UV reactor executive state PIN_SIGNAL_STATE_T pinSignalState; ///< UV reactor pin signal state - BOOL hasTurnOnBeenRequested; ///< UV reactor turn on request + SWITCH_STATES_T switchState; ///< UV reactor turn on/turn off state U32 reactorEnablePin; ///< UV reactor enable pin of GIO port A U32 reactorHealthStatusPin; ///< UV reactor status pin of N2HET1 U32 reactorUnhealthyCounter; ///< UV reactor counter of the number of times it is unhealthy in a row @@ -73,7 +74,7 @@ static UV_REACTOR_STATE_T handleUVReactorStateOn( UV_REACTORS_T reactor ); // Support functions -static U32 isReactorHealthy( UV_REACTORS_T reactor ); +static BOOL isReactorHealthy( UV_REACTORS_T reactor ); static void setReactorEnableStatus( UV_REACTORS_T reactor, PIN_SIGNAL_STATE_T state ); static void publishUVReactorsData( void ); static U32 getPublishUVReactorsDataInterval( void ); @@ -108,7 +109,7 @@ { reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_LOW; reactorsStatus[ reactor ].execState = UV_REACTOR_STATE_OFF; - reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + reactorsStatus[ reactor ].switchState = TURN_OFF; reactorsStatus[ reactor ].reactorUnhealthyCounter = 0; } } @@ -229,9 +230,9 @@ // Check if the called reactor is in range. Otherwise, raise an alarm if ( reactor < NUM_OF_UV_REACTORS ) { - if ( FALSE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) + if ( TURN_OFF == reactorsStatus[ reactor ].switchState ) { - reactorsStatus[ reactor ].hasTurnOnBeenRequested = TRUE; + reactorsStatus[ reactor ].switchState = TURN_ON; result = TRUE; } } @@ -258,7 +259,7 @@ // Check if the called reactor is in range if ( reactor < NUM_OF_UV_REACTORS ) { - reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + reactorsStatus[ reactor ].switchState = TURN_OFF; result = TRUE; } else @@ -300,11 +301,11 @@ { UV_REACTORS_SELF_TEST_STATE_T state = UV_REACTORS_SELF_TEST_CHECK_HEALTH; - if ( didTimeout( selfTestElapsedTime, SELF_TEST_DELAY_TIME ) ) + if ( TRUE == didTimeout( selfTestElapsedTime, SELF_TEST_DELAY_TIME ) ) { // Get the health status of the reactors - BOOL isInletHealthy = (BOOL)isReactorHealthy( INLET_UV_REACTOR ); - BOOL isOutletHealthy = (BOOL)isReactorHealthy( OUTLET_UV_REACTOR ); + BOOL isInletHealthy = isReactorHealthy( INLET_UV_REACTOR ); + BOOL isOutletHealthy = isReactorHealthy( OUTLET_UV_REACTOR ); // Check if both of them are healthy and if not, raise an alarm if ( TRUE == isInletHealthy && TRUE == isOutletHealthy ) @@ -350,7 +351,7 @@ // If the a reactor is requested to be on and it is off, turn it on // and change the state - if( TRUE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) + if( TURN_ON == reactorsStatus[ reactor ].switchState ) { setReactorEnableStatus( reactor, PIN_SIGNAL_HIGH ); @@ -372,7 +373,7 @@ { UV_REACTOR_STATE_T state = UV_REACTOR_STATE_ON; - reactorsStatus[ reactor ].healthStatus.data = isReactorHealthy( reactor ); + reactorsStatus[ reactor ].healthStatus.data = (U32)isReactorHealthy( reactor ); // Check if the reactor is healthy if ( FALSE == getUVReactorHealth( reactor ) ) @@ -385,7 +386,7 @@ // Done with health. turn off the reactor and go to off state reactorsStatus[ reactor ].reactorUnhealthyCounter = 0; - reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + reactorsStatus[ reactor ].switchState = TURN_OFF; } } else @@ -395,7 +396,7 @@ } // Check if it has been requested to turn off a reactor - if( FALSE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) + if( TURN_OFF == reactorsStatus[ reactor ].switchState ) { setReactorEnableStatus( reactor, PIN_SIGNAL_LOW ); @@ -432,9 +433,9 @@ * @param reactor to check its health * @return returns TRUE if the reactor is healthy otherwise a FALSE *************************************************************************/ -static U32 isReactorHealthy( UV_REACTORS_T reactor ) +static BOOL isReactorHealthy( UV_REACTORS_T reactor ) { - return gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); + return (BOOL)gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); } /*********************************************************************//** @@ -444,7 +445,7 @@ * @details Outputs: none * @return returns data publish interval *************************************************************************/ -static U32 getPublishUVReactorsDataInterval( void ) +static U32 getPublishUVReactorsDataInterval( void ) { U32 result = uvReactorsDataPublishInterval.data;