Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -r00b0fcefb9f74e7c050b5c83ad5c285e6769ef78 -rae407abdc3020559c5051fe02f5ab06fdb63b9db --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision 00b0fcefb9f74e7c050b5c83ad5c285e6769ef78) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision ae407abdc3020559c5051fe02f5ab06fdb63b9db) @@ -16,8 +16,8 @@ #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 26 ///< Inlet UV reactor N2HET1 pin number (health check). -#define OUTLET_UV_REACTOR_INDICATION_PIN 11 ///< Outlet UV reactor N2HET1 pin number (health check). +#define INLET_UV_REACTOR_INDICATION_PIN 0x1A ///< 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. #define SELF_TEST_DELAY_TIME 1000 @@ -90,9 +90,10 @@ void initUVReactors( void ) { UV_REACTORS_T reactor; - uvReactosSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; + + uvReactosSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; uvReactorsSelfTestStates = UV_REACTORS_SELF_TEST_OFF; - dataPublishCounter = 0; + dataPublishCounter = 0; // Initialize the UV reactors. These values are specific to the inlet and outlet reactor // so they cannot be in a for loop @@ -105,9 +106,10 @@ // 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 ].hasTurnOnBeenRequested = FALSE; + reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_LOW; + reactorsStatus[ reactor ].execState = UV_REACTOR_STATE_OFF; + reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + reactorsStatus[ reactor ].reactorUnhealthyCounter = 0; } } @@ -173,9 +175,10 @@ reactorsStatus[ reactor].execState = UV_REACTOR_STATE_OFF; break; } - - publishUVReactorsData(); } + + // Publish all reactors data once + publishUVReactorsData(); } /*********************************************************************//** @@ -188,7 +191,7 @@ *************************************************************************/ BOOL getUVReactorHealth( UV_REACTORS_T reactor ) { - BOOL health; + BOOL health = FALSE; // Check if the reactor selected is in range if ( reactor < NUM_OF_UV_REACTORS ) @@ -251,6 +254,7 @@ BOOL turnOffUVReactor( UV_REACTORS_T reactor ) { BOOL result = FALSE; + // Check if the called reactor is in range if ( reactor < NUM_OF_UV_REACTORS ) { @@ -299,25 +303,26 @@ if ( didTimeout( selfTestElapsedTime, SELF_TEST_DELAY_TIME ) ) { // Get the health status of the reactors - BOOL isInletHealthy = (BOOL)isReactorHealthy( INLET_UV_REACTOR ); - BOOL isOutletHealty = (BOOL)isReactorHealthy( OUTLET_UV_REACTOR ); + BOOL isInletHealthy = (BOOL)isReactorHealthy( INLET_UV_REACTOR ); + BOOL isOutletHealthy = (BOOL)isReactorHealthy( OUTLET_UV_REACTOR ); // Check if both of them are healthy and if not, raise an alarm - if ( TRUE == isInletHealthy && TRUE == isOutletHealty ) + if ( TRUE == isInletHealthy && TRUE == isOutletHealthy ) { uvReactosSelfTestResult = SELF_TEST_STATUS_PASSED; } else { uvReactosSelfTestResult = SELF_TEST_STATUS_FAILED; + // Check which reactor has not been healthy and raise an alarm - if ( !isInletHealthy ) + if ( FALSE == isInletHealthy ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY , INLET_UV_REACTOR ); + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY, INLET_UV_REACTOR ); } else { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY , OUTLET_UV_REACTOR ); + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY, OUTLET_UV_REACTOR ); } } @@ -370,10 +375,18 @@ reactorsStatus[ reactor ].healthStatus.data = isReactorHealthy( reactor ); // Check if the reactor is healthy - if ( FALSE == getUVReactorHealth( reactor ) && ++reactorsStatus[ reactor ].reactorUnhealthyCounter > MAX_ALLOWED_UNHEALTHY_REACTOR_COUNTER ) + if ( FALSE == getUVReactorHealth( reactor ) ) { - // The reactor has been unhealthy for a certain amount of time - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY, reactor ); + // Check if the reactor has been unhealthy for the defined duration + if ( ++reactorsStatus[ reactor ].reactorUnhealthyCounter > MAX_ALLOWED_UNHEALTHY_REACTOR_COUNTER ) + { + // The reactor has been unhealthy for a certain amount of time + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_UV_REACTOR_NOT_HEALTHY, reactor ); + + // Done with health. turn off the reactor and go to off state + reactorsStatus[ reactor ].reactorUnhealthyCounter = 0; + reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + } } else { @@ -538,7 +551,6 @@ 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; - result = TRUE; } @@ -562,6 +574,7 @@ { reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.override = OVERRIDE_RESET; reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.ovData = reactorsStatus[ (UV_REACTORS_T)reactor ].healthStatus.ovInitData; + result = TRUE; } return result;