Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -ra8bb1da29825b5d666333629fda871652d16229a -re44aad7a9d5fa48aeaa55c65bd28ad9acde6ce05 --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision a8bb1da29825b5d666333629fda871652d16229a) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision e44aad7a9d5fa48aeaa55c65bd28ad9acde6ce05) @@ -19,7 +19,7 @@ #define INLET_UV_REACTOR_ENABLE_PIN 0 ///< Inlet UV reactor GPIO pin number (enable pin). #define OUTLET_UV_REACTOR_ENABLE_PIN 1 ///< Outlet UV reactor GPIO pin number (enable Pin). -#define INLET_UV_REACTOR_INDICATION_PIN 0x1A ///< Inlet UV reactor N2HET1 pin number (health check). +#define INLET_UV_REACTOR_INDICATION_PIN 0x18 ///< Inlet UV reactor N2HET1 pin number (health check). #define OUTLET_UV_REACTOR_INDICATION_PIN 0x0B ///< Outlet UV reactor N2HET1 pin number (health check). #define UV_REACTORS_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< UV reactors data publication time interval. /// Self test wait time after enabling the reactors and before checking for their health in ms. @@ -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 ); @@ -93,7 +93,7 @@ { UV_REACTORS_T reactor; - uvReactorsSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; + uvReactorsSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; uvReactorsSelfTestStates = UV_REACTORS_SELF_TEST_OFF; dataPublishCounter = 0; @@ -108,9 +108,9 @@ // Initialize the common values in the UV reactors for( reactor = INLET_UV_REACTOR; reactor < NUM_OF_UV_REACTORS; reactor++ ) { - reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_LOW; - reactorsStatus[ reactor ].execState = UV_REACTOR_STATE_OFF; - reactorsStatus[ reactor ].switchState = TURN_OFF; + reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_LOW; + reactorsStatus[ reactor ].execState = UV_REACTOR_STATE_OFF; + reactorsStatus[ reactor ].switchState = TURN_OFF; } initPersistentAlarm( ALARM_ID_UV_REACTOR_NOT_HEALTHY, MAX_ALLOWED_UNHEALTHY_REACTOR_PERIOD, MAX_ALLOWED_UNHEALTHY_REACTOR_PERIOD ); @@ -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,18 +307,19 @@ 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; } else { uvReactorsSelfTestResult = SELF_TEST_STATUS_FAILED; +#ifndef DISABLE_UV_REACTOR_MONITOR // Check which reactor has not been healthy and raise an alarm if ( FALSE == isInletHealthy ) { @@ -327,6 +329,7 @@ { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY, OUTLET_UV_REACTOR ); } +#endif } // Turn off the UV reactors once the test is finished @@ -351,6 +354,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,17 +382,21 @@ { 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 ); +#ifndef DISABLE_UV_REACTOR_MONITOR + checkPersistentAlarm( ALARM_ID_UV_REACTOR_NOT_HEALTHY, isReactorUnhealthy, (U32)reactor, MAX_ALLOWED_UNHEALTHY_REACTOR_PERIOD ); // Check if the alarm has been active if ( TRUE == isAlarmActive( ALARM_ID_UV_REACTOR_NOT_HEALTHY ) ) { reactorsStatus[ reactor ].switchState = TURN_OFF; } +#endif // Check if it has been requested to turn off a reactor if ( TURN_OFF == reactorsStatus[ reactor ].switchState ) @@ -411,23 +422,23 @@ static void setReactorEnableStatus( UV_REACTORS_T reactor, PIN_SIGNAL_STATE_T state ) { // Set the GIO pin to enable or disable - gioSetBit( gioPORTA, reactorsStatus[ reactor ].reactorEnablePin, state ); + gioSetBit( gioPORTA, reactorsStatus[ reactor ].reactorEnablePin, (U32)state ); // Update the pin signal state reactorsStatus[ reactor ].pinSignalState = state; } /*********************************************************************//** * @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 +473,18 @@ { UV_REACTORS_DATA_T uvReactorsData; // Publish the reactors health status - uvReactorsData.inletUVReactorHealthStatus = reactorsStatus[ INLET_UV_REACTOR ].reactorHealthStatusPin; - uvReactorsData.outletUVReactorHealthStatus = reactorsStatus[ OUTLET_UV_REACTOR ].reactorHealthStatusPin; - uvReactorsData.inletUVReactorState = reactorsStatus[ INLET_UV_REACTOR ].execState; - uvReactorsData.outletUVReactorHealthStatus = 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 +547,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; }