Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -rc48569a478d727afa7cd69aadb396814248c83f9 -r86eec09ab556fbd970ddcae9dc622727928ee757 --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision c48569a478d727afa7cd69aadb396814248c83f9) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision 86eec09ab556fbd970ddcae9dc622727928ee757) @@ -75,7 +75,7 @@ static UV_REACTOR_STATE_T handleUVReactorStateOn( UV_REACTORS_T reactor ); // Support functions -static BOOL isReactorHealthy( UV_REACTORS_T reactor ); +static U32 getReactorHealth( UV_REACTORS_T reactor ); static void setReactorEnableStatus( UV_REACTORS_T reactor, PIN_SIGNAL_STATE_T state ); static void publishUVReactorsData( void ); static U32 getPublishUVReactorsDataInterval( void ); @@ -186,27 +186,28 @@ /*********************************************************************//** * @brief - * The getUVReactorHealth function returns the health status of a UV reactor. + * The getUVReactorHealth function returns the health status of a UV + * reactor. * @details Inputs: reactorsStatus * @details Outputs: none * @param reactor to return its health - * @return returns the health of the requested UV reactor + * @return returns the health of the requested UV reactor as an enum *************************************************************************/ -BOOL getUVReactorHealth( UV_REACTORS_T reactor ) +UV_REACTORS_HEALTH_STATUS_T getUVReactorHealth( UV_REACTORS_T reactor ) { - BOOL health = FALSE; + UV_REACTORS_HEALTH_STATUS_T health = UV_REACTOR_OFF; // Check if the reactor selected is in range if ( reactor < NUM_OF_UV_REACTORS ) { // Check if the health is in override or not if ( reactorsStatus[ reactor ].healthStatus.override == OVERRIDE_KEY ) { - health = reactorsStatus[ reactor ].healthStatus.ovData; + health = (UV_REACTORS_HEALTH_STATUS_T)reactorsStatus[ reactor ].healthStatus.ovData; } else { - health = reactorsStatus[ reactor ].healthStatus.data; + health = (UV_REACTORS_HEALTH_STATUS_T)reactorsStatus[ reactor ].healthStatus.data; } } else @@ -306,11 +307,11 @@ if ( TRUE == didTimeout( selfTestElapsedTime, SELF_TEST_DELAY_TIME ) ) { // Get the health status of the reactors - BOOL isInletHealthy = isReactorHealthy( INLET_UV_REACTOR ); - BOOL isOutletHealthy = isReactorHealthy( OUTLET_UV_REACTOR ); + BOOL isInletHealthy = (BOOL)getReactorHealth( INLET_UV_REACTOR ); + BOOL isOutletHealthy = (BOOL)getReactorHealth( OUTLET_UV_REACTOR ); // Check if both of them are healthy and if not, raise an alarm - if ( TRUE == isInletHealthy && TRUE == isOutletHealthy ) + if ( ( TRUE == isInletHealthy ) &&( TRUE == isOutletHealthy ) ) { uvReactorsSelfTestResult = SELF_TEST_STATUS_PASSED; } @@ -351,6 +352,10 @@ { UV_REACTOR_STATE_T state = UV_REACTOR_STATE_OFF; + // Set the health status to be off. When the reactor is off, it does not report + // its health status + reactorsStatus[reactor].healthStatus.data = (U32)UV_REACTOR_OFF; + // If the a reactor is requested to be on and it is off, turn it on // and change the state if( TURN_ON == reactorsStatus[ reactor ].switchState ) @@ -375,14 +380,16 @@ { UV_REACTOR_STATE_T state = UV_REACTOR_STATE_ON; - reactorsStatus[ reactor ].healthStatus.data = (U32)isReactorHealthy( reactor ); + // Update the UV reactor's health. It should be either healthy (1) or not healthy (0) + reactorsStatus[ reactor ].healthStatus.data = getReactorHealth( reactor ); - BOOL isReactorHealthy = getUVReactorHealth( reactor ); + // Get the health of the reactor (override or non-override) and decide the status + BOOL isReactorUnhealthy = ( UV_REACTOR_HEALTHY == getUVReactorHealth( reactor ) ? FALSE : TRUE ); - checkPersistentAlarm( ALARM_ID_UV_REACTOR_NOT_HEALTHY, !isReactorHealthy, (U32)reactor, MAX_ALLOWED_UNHEALTHY_REACTOR_PERIOD ); + checkPersistentAlarm( ALARM_ID_UV_REACTOR_NOT_HEALTHY, isReactorUnhealthy, (U32)reactor, MAX_ALLOWED_UNHEALTHY_REACTOR_PERIOD ); // Check if the alarm has been active - /*if( isAlarmActive( ALARM_ID_UV_REACTOR_NOT_HEALTHY ) ) + if( isAlarmActive( ALARM_ID_UV_REACTOR_NOT_HEALTHY ) ) { reactorsStatus[ reactor ].switchState = TURN_OFF; } @@ -393,7 +400,7 @@ setReactorEnableStatus( reactor, PIN_SIGNAL_LOW ); state = UV_REACTOR_STATE_OFF; - }*/ + } return state; } @@ -419,15 +426,15 @@ /*********************************************************************//** * @brief - * The isReactorHealthy function checks the health status of a reactor. + * The getReactorHealth function checks the health status of a reactor. * @details Inputs: reactorsStatus * @details Outputs: none * @param reactor to check its health - * @return returns TRUE if the reactor is healthy otherwise a FALSE + * @return returns 1 if the reactor is healthy otherwise a 0 *************************************************************************/ -static BOOL isReactorHealthy( UV_REACTORS_T reactor ) +static U32 getReactorHealth( UV_REACTORS_T reactor ) { - return (BOOL)gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); + return gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); } /*********************************************************************//** @@ -462,17 +469,18 @@ { UV_REACTORS_DATA_T uvReactorsData; // Publish the reactors health status - uvReactorsData.inletUVReactorHealthStatus = getUVReactorHealth( INLET_UV_REACTOR ); - uvReactorsData.outletUVReactorHealthStatus = getUVReactorHealth( OUTLET_UV_REACTOR ); - uvReactorsData.inletUVReactorState = reactorsStatus[ INLET_UV_REACTOR ].execState; - uvReactorsData.outletUVReactorState = reactorsStatus[ OUTLET_UV_REACTOR ].execState; + uvReactorsData.inletUVReactorHealthStatus = (U32)getUVReactorHealth( INLET_UV_REACTOR ); + uvReactorsData.outletUVReactorHealthStatus = (U32)getUVReactorHealth( OUTLET_UV_REACTOR ); + uvReactorsData.inletUVReactorState = (U32)reactorsStatus[ INLET_UV_REACTOR ].execState; + uvReactorsData.outletUVReactorState = (U32)reactorsStatus[ OUTLET_UV_REACTOR ].execState; broadcastUVReactorsData( &uvReactorsData ); dataPublishCounter = 0; } } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -535,15 +543,15 @@ * @param health which is high for healthy on and low for not healthy * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetUVReactorHealthOverride( U32 reactor, BOOL health ) +BOOL testSetUVReactorHealthOverride( U32 reactor, U32 health ) { BOOL result = FALSE; - if ( TRUE == isTestingActivated() && (UV_REACTORS_T)reactor < NUM_OF_UV_REACTORS ) + if ( ( TRUE == isTestingActivated() ) && ( (UV_REACTORS_T)reactor < NUM_OF_UV_REACTORS ) ) { reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.ovInitData = reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.data; reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.override = OVERRIDE_KEY; - reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.ovData = (U32)health; + reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.ovData = health; result = TRUE; }