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; Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rae407abdc3020559c5051fe02f5ab06fdb63b9db -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision ae407abdc3020559c5051fe02f5ab06fdb63b9db) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -127,8 +127,8 @@ postState = handlePOSTStatus( testStatus ); break; - case DG_POST_STATE_UV_REACTORS: #ifdef _VECTORCAST_ // To be only seen by VectorCAST for testing + case DG_POST_STATE_UV_REACTORS: testStatus = execUVReactorsSelfTest(); postState = handlePOSTStatus( testStatus ); break; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r00b0fcefb9f74e7c050b5c83ad5c285e6769ef78 -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 00b0fcefb9f74e7c050b5c83ad5c285e6769ef78) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -1156,20 +1156,16 @@ handleConcentratePumpPublishIntervalOverride( message ); break; - case MSG_ID_DG_START_STOP_INLET_UV_REACTOR: - handleStartStopInletUVReactor( message ); + case MSG_ID_DG_START_STOP_UV_REACTORS: + handleStartStopUVReactors( message ); break; case MSG_ID_UV_REACTORS_DATA_PUBLISH_INTERVAL_OVERRIDE: - handleUVReactorsDataPublishIntervalOverride( message ); + handleTestUVReactorsDataPublishIntervalOverride( message ); break; - case MSG_ID_DG_START_STOP_OUTLET_UV_REACTOR: - handleStartStopOutletUVReactor( message ); - break; - case MSG_ID_DG_UV_REACTORS_HEALTH_OVERRIDE: - handleUVReactorsHealthOverride( message ); + handleTestUVReactorsHealthOverride( message ); break; default: Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r00b0fcefb9f74e7c050b5c83ad5c285e6769ef78 -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 00b0fcefb9f74e7c050b5c83ad5c285e6769ef78) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -1885,36 +1885,39 @@ /*********************************************************************//** * @brief -* The handleStartStopInletUVReactor function handles a request to turn on/off -* the inlet UV reactor. +* The handleStartStopUVReactors function handles a request to turn on/off +* the UV reactors. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -BOOL handleStartStopInletUVReactor( MESSAGE_T *message ) +void handleStartStopUVReactors( MESSAGE_T *message ) { + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - BOOL startingReactor; - - memcpy( &startingReactor, message->payload, sizeof(U32) ); - - if ( TRUE == startingReactor ) + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( payload.index < NUM_OF_UV_REACTORS ) { - result = turnOnUVReactor( INLET_UV_REACTOR ); + switch ( payload.state.u32 ) + { + case TURN_OFF: + result = turnOffUVReactor( (UV_REACTORS_T)payload.index ); + break; + + case TURN_ON: + result = turnOnUVReactor( (UV_REACTORS_T)payload.index ); + break; + } } - else - { - result = turnOffUVReactor( INLET_UV_REACTOR ); - } } - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** @@ -1926,7 +1929,7 @@ * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleUVReactorsDataPublishIntervalOverride( MESSAGE_T *message ) +void handleTestUVReactorsDataPublishIntervalOverride( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -1951,48 +1954,14 @@ /*********************************************************************//** * @brief -* The handleStartStopOutletUVReactor function handles a request to turn -* on/off the outlet UV reactor. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -BOOL handleStartStopOutletUVReactor( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingReactor; - - memcpy( &startingReactor, message->payload, sizeof(U32) ); - - if ( TRUE == startingReactor ) - { - result = turnOnUVReactor( OUTLET_UV_REACTOR ); - } - else - { - result = turnOffUVReactor( OUTLET_UV_REACTOR ); - } - } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - -/*********************************************************************//** -* @brief * The handleUVReactorsHealthOverride function handles UV reactors health * status override. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleUVReactorsHealthOverride( MESSAGE_T *message ) +void handleTestUVReactorsHealthOverride( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r00b0fcefb9f74e7c050b5c83ad5c285e6769ef78 -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 00b0fcefb9f74e7c050b5c83ad5c285e6769ef78) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -201,19 +201,16 @@ void handleSetAccelCalibration( MESSAGE_T *message ); // MSG_ID_DG_START_STOP_INLET_UV_REACTOR -BOOL handleStartStopInletUVReactor( MESSAGE_T *message ); +void handleStartStopUVReactors( MESSAGE_T *message ); //MSG_ID_UV_REACTORS_DATA_PUBLISH_INTERVAL_OVERRIDE -void handleUVReactorsDataPublishIntervalOverride( MESSAGE_T *message ); +void handleTestUVReactorsDataPublishIntervalOverride( MESSAGE_T *message ); // MSG_ID_DG_SOFTWARE_RESET_REQUEST void handleDGSoftwareResetRequest( MESSAGE_T *message); -// MSG_ID_DG_START_STOP_OUTLET_UV_REACTOR -BOOL handleStartStopOutletUVReactor( MESSAGE_T *message ); - // MSG_ID_DG_UV_REACTORS_HEALTH_OVERRIDE -void handleUVReactorsHealthOverride( MESSAGE_T *message ); +void handleTestUVReactorsHealthOverride( MESSAGE_T *message ); // MSG_ID_DG_CONCENTRATE_PUMP_MEASURED_SPEED_OVERRIDE void handleConcentratePumpMeasuredSpeedOverride( MESSAGE_T *message ); Index: firmware/source/sys_main.c =================================================================== diff -u -rae407abdc3020559c5051fe02f5ab06fdb63b9db -r4638fd77792d0c7ecbeca3c84369cbed6c2ecee1 --- firmware/source/sys_main.c (.../sys_main.c) (revision ae407abdc3020559c5051fe02f5ab06fdb63b9db) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 4638fd77792d0c7ecbeca3c84369cbed6c2ecee1) @@ -177,14 +177,14 @@ initConcentratePump(); initROPump(); initDrainPump(); + initUVReactors(); initAccel(); initRTC(); initCommBuffers(); initMsgQueues(); initSystemComm(); initReservoirs(); initOperationModes(); - initUVReactors(); } /*************************************************************************