Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -178,6 +178,7 @@ targetDrainPumpDeltaPressure.data = deltaP; hasClosedLoopBeenRequested = TRUE; + drainPumpDAC = DRAIN_PUMP_MIN_DAC; drainPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; result = TRUE; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -714,14 +714,14 @@ // publish RO pump data on interval if ( ++roPumpDataPublicationTimerCounter >= getPublishROPumpDataInterval() ) { - RO_PUMP_DATA_T valveData; + RO_PUMP_DATA_T pumpData; - valveData.roPumpTgtPressure = tgtROPumpPressure; - valveData.measROFlowRate = getMeasuredROFlowRate(); - valveData.roPumpPWM = roPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; - valveData.roPumpState = (U32)roPumpState; + pumpData.roPumpTgtPressure = tgtROPumpPressure; + pumpData.measROFlowRate = getMeasuredROFlowRate(); + pumpData.roPumpPWM = roPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; + pumpData.roPumpState = (U32)roPumpState; - broadcastROPumpData( &valveData ); + broadcastROPumpData( &pumpData ); roPumpDataPublicationTimerCounter = 0; } } Index: firmware/App/Controllers/ROPump.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -32,7 +32,6 @@ #define MAX_RO_FLOWRATE_LPM 1.2 ///< Maximum target RO flow rate (in LPM) #define MIN_RO_FLOWRATE_LPM 0.2 ///< Minimum target RO flow rate (in LPM) -#pragma pack(push, 1) /// RO pump data struct. typedef struct { @@ -42,7 +41,6 @@ U32 roPumpState; ///< RO pump current state F32 roPumpTgtPressure; ///< RO pump target pressure } RO_PUMP_DATA_T; -#pragma pack(pop) // ********** public function prototypes ********** Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rab304e2ca6e3e40ed8cb12650e9855ae0b9649d8 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision ab304e2ca6e3e40ed8cb12650e9855ae0b9649d8) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -72,7 +72,7 @@ #define HEATERS_INTERNAL_TEMP_SENSOR_FAULT 0x01 ///< Heaters internal temperature sensor fault. #define TEMP_SENSORS_DATA_PUBLISH_INTERVAL (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Temperature sensors publish data time interval. -#define MAX_TEMPERATURE_SENSOR_FAILURES 10 ///< Maximum number of temperature sensor errors within window period before alarm. +#define MAX_TEMPERATURE_SENSOR_FAILURES 5//10 ///< Maximum number of temperature sensor errors within window period before alarm. #define MAX_TEMPERATURE_SENSOR_FAILURE_WINDOW_MS (10 * MS_PER_SECOND) ///< Temperature sensor error window. /// Temperature sensor self-test states. Index: firmware/App/Controllers/UVReactors.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/UVReactors.c (.../UVReactors.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -5,6 +5,7 @@ #include "UVReactors.h" #include "Common.h" #include "SystemCommMessages.h" +#include "Timers.h" /** * @addtogroup UV Reactors @@ -13,14 +14,24 @@ // ********** private definitions ********** -#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_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 24 ///< Inlet UV reactor N2HET1 pin number (health check) +#define OUTLET_UV_REACTOR_INDICATION_PIN 11 ///< 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 +#define MAX_ALLOWED_UNHEALTHY_REACTOR_COUNTER ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< UV reactors max counter to be unhealthy -#define INLET_UV_REACTOR_INDICATION_PIN 24 ///< Inlet UV reactor N2HET1 pin number (health check) -#define OUTLET_UV_REACTOR_INDICATION_PIN 11 ///< Outlet UV reactor N2HET1 pin number (health check) +/// UV reactors self test states +typedef enum self_tests +{ + UV_REACTORS_SELF_TEST_OFF = 0, ///< UV reactors self test state off + UV_REACTORS_SELF_TEST_CHECK_HEALTH, ///< UV reactors self test check health + UV_REACTORS_SELF_TEST_COMPLETE, ///< UV reactors self test complete + NUM_OF_UV_REACTORS_SELF_TEST_STATES, ///< Number of UV reactors self test states +} UV_REACTORS_SELF_TEST_STATE_T; -#define UV_REACTORS_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< UV reactors data publication time interval - /// UV reactors exec states typedef enum exec_states { @@ -32,52 +43,111 @@ /// UV reactor status typedef struct { - PIN_SIGNAL_STATE_T enableStatus; ///< UV reactor enable status - UV_REACTOR_STATE_T execState; ///< UV reactor executive state - BOOL hasTurnOnBeenRequested; ///< UV reactor turn on request - U32 reactorEnablePin; ///< UV reactor enable pin of GIO port A - U32 reactorHealthStatusPin; ///< UV reactor status pin of N2HET1 + 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 + 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 } UV_REACTOR_STATUS_T; // ********** private data ********** -static UV_REACTOR_STATUS_T reactorsStatus[ NUM_OF_UV_REACTORS ]; ///< UV reactors status array -static SELF_TEST_STATUS_T uvReactosSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< Valves self test result +static UV_REACTOR_STATUS_T reactorsStatus[ NUM_OF_UV_REACTORS ]; ///< UV reactors status array +static UV_REACTORS_SELF_TEST_STATE_T uvReactorsSelfTestStates = UV_REACTORS_SELF_TEST_OFF; ///< UV reactors self test state +static SELF_TEST_STATUS_T uvReactosSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< Valves self test result static OVERRIDE_U32_T uvReactorsDataPublishInterval = { UV_REACTORS_DATA_PUB_INTERVAL, - UV_REACTORS_DATA_PUB_INTERVAL, 0, 0 }; ///< UV reactors data publish interval -static U32 dataPublishCounter = 0; + UV_REACTORS_DATA_PUB_INTERVAL, 0, 0 }; ///< UV reactors data publish interval -// Monitor function of the UV reactors +static OVERRIDE_U32_T uvReactorsStateOverride[ NUM_OF_UV_REACTORS ] = { PIN_SIGNAL_LOW, PIN_SIGNAL_LOW, 0, 0 }; ///< UV reactors state override + +static U32 dataPublishCounter = 0; ///< UV reactors data publish counter +static U32 selfTestElapsedTime = 0; ///< UV reactors self test elapsed time + +// Self test functions +static UV_REACTORS_SELF_TEST_STATE_T handleUVReactorsSelfTestOff( void ); +static UV_REACTORS_SELF_TEST_STATE_T handleUVReactorsSelfTestCheckHealth( void ); + +// Exec functions static UV_REACTOR_STATE_T handleUVReactorStateOff( UV_REACTORS_T reactor ); static UV_REACTOR_STATE_T handleUVReactorStateOn( UV_REACTORS_T reactor ); -static void execMonitorUVReactors( void ); + +// Support functions +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 getPublishValvesDataInterval( void ); +/*********************************************************************//** + * @brief + * The initUVReactors function initializes the UV reactors module. + * @details Inputs: uvReactosSelfTestResult, dataPublishCounter, + * reactorsStatus, selfTestStates + * @details Outputs: uvReactosSelfTestResult, dataPublishCounter, + * reactorsStatus, selfTestStates + * @return none + *************************************************************************/ void initUVReactors( void ) { uvReactosSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; + uvReactorsSelfTestStates = UV_REACTORS_SELF_TEST_OFF; dataPublishCounter = 0; - reactorsStatus[ INLET_UV_REACTOR ].reactorEnablePin = INLET_UV_REACTOR_ENABLE_PIN; + // Initialize the UV reactors + reactorsStatus[ INLET_UV_REACTOR ].reactorEnablePin = INLET_UV_REACTOR_ENABLE_PIN; reactorsStatus[ INLET_UV_REACTOR ].reactorHealthStatusPin = INLET_UV_REACTOR_INDICATION_PIN; + reactorsStatus[ INLET_UV_REACTOR ].pinSignalState = PIN_SIGNAL_LOW; - reactorsStatus[ OUTLET_UV_REACTOR ].reactorEnablePin = OUTLET_UV_REACTOR_ENABLE_PIN; + reactorsStatus[ OUTLET_UV_REACTOR ].reactorEnablePin = OUTLET_UV_REACTOR_ENABLE_PIN; reactorsStatus[ OUTLET_UV_REACTOR ].reactorHealthStatusPin = OUTLET_UV_REACTOR_INDICATION_PIN; + reactorsStatus[ OUTLET_UV_REACTOR ].pinSignalState = PIN_SIGNAL_LOW; } +/*********************************************************************//** + * @brief + * The execUVReactorsSelfTest function executes the UV reactors self test. + * @details Inputs: FuvReactorsSelfTestStates + * @details Outputs: uvReactorsSelfTestStates + * @return Status of self test + *************************************************************************/ SELF_TEST_STATUS_T execUVReactorsSelfTest( void ) { - //TODO what to do in POST? + switch ( uvReactorsSelfTestStates ) + { + case UV_REACTORS_SELF_TEST_OFF: + uvReactorsSelfTestStates = handleUVReactorsSelfTestOff(); + break; + + case UV_REACTORS_SELF_TEST_CHECK_HEALTH: + uvReactorsSelfTestStates = handleUVReactorsSelfTestCheckHealth(); + break; + + case UV_REACTORS_SELF_TEST_COMPLETE: + // Done with self test, do nothing. + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_UV_REACTORS_INVALID_SELF_TEST_STATE, + uvReactorsSelfTestStates ); + uvReactorsSelfTestStates = UV_REACTORS_SELF_TEST_COMPLETE; + break; + } + + return uvReactosSelfTestResult; } +/*********************************************************************//** + * @brief + * The execUVReactos function executes the UV reactors exec states. + * @details Inputs: reactorsStatus + * @details Outputs: reactorsStatus + * @return none + *************************************************************************/ void execUVReactos( void ) { UV_REACTORS_T reactor; - execMonitorUVReactors(); - for ( reactor = INLET_UV_REACTOR; reactor < NUM_OF_UV_REACTORS; reactor++ ) { switch ( reactorsStatus[ reactor ].execState ) @@ -101,72 +171,212 @@ } } +/*********************************************************************//** + * @brief + * The turnOnUVReactor function turns on the selected UV reactor per request. + * @details Inputs: reactorsStatus + * @details Outputs: reactorsStatus + * @return returns TRUE if the reactor was not already on + *************************************************************************/ BOOL turnOnUVReactor( UV_REACTORS_T reactor ) { BOOL result = FALSE; - //TODO check the status of reactor if ( FALSE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) { reactorsStatus[ reactor ].hasTurnOnBeenRequested = TRUE; - result = TRUE; } return result; } +/*********************************************************************//** + * @brief + * The turnOffUVReactor function turns off the selected UV reactor per request. + * @details Inputs: reactorsStatus + * @details Outputs: reactorsStatus + * @return returns TRUE if the reactor was not already off + *************************************************************************/ BOOL turnOffUVReactor( UV_REACTORS_T reactor ) { BOOL result = FALSE; - //TODO check the status of reactor if ( TRUE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) { reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; - result = TRUE; } return result; } +/*********************************************************************//** + * @brief + * The handleUVReactorsSelfTestOff function handles the self test off state. + * @details Inputs: selfTestElapsedTime + * @details Outputs: selfTestElapsedTime + * @return returns the next state of the self test state machine + *************************************************************************/ +static UV_REACTORS_SELF_TEST_STATE_T handleUVReactorsSelfTestOff( void ) +{ + UV_REACTORS_SELF_TEST_STATE_T state = UV_REACTORS_SELF_TEST_CHECK_HEALTH; + + // Enable both the reactors and set the timer to check the health of the reactors after time elapsed + setReactorEnableStatus( INLET_UV_REACTOR, PIN_SIGNAL_HIGH ); + setReactorEnableStatus( OUTLET_UV_REACTOR, PIN_SIGNAL_HIGH ); + selfTestElapsedTime = getMSTimerCount(); + + return state; +} + +/*********************************************************************//** + * @brief + * The handleUVReactorsSelfTestCheckHealth function handles the self test + * check health state. + * @details Inputs: selfTestElapsedTime, uvReactosSelfTestResult + * @details Outputs: uvReactosSelfTestResult + * @return returns the next state of the self test state machine + *************************************************************************/ +static UV_REACTORS_SELF_TEST_STATE_T handleUVReactorsSelfTestCheckHealth( void ) +{ + UV_REACTORS_SELF_TEST_STATE_T state = UV_REACTORS_SELF_TEST_CHECK_HEALTH; + + + if ( didTimeout( selfTestElapsedTime, SELF_TEST_DELAY_TIME ) ) + { + // Get the health status of the reactors + BOOL isInletHealthy = isReactorHealthy( INLET_UV_REACTOR ); + BOOL isOutletHealty = isReactorHealthy( OUTLET_UV_REACTOR ); + + // Check if both of them are healthy and if not, raise an alarm + if ( isInletHealthy || isOutletHealty ) + { + uvReactosSelfTestResult = SELF_TEST_STATUS_PASSED; + } + else + { + uvReactosSelfTestResult = SELF_TEST_STATUS_FAILED; + // Check which reactor has not been healthy and raise an alarm + if ( !isInletHealthy ) + { + 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 ); + } + } + + // Turn off the UV reactors once the test is finished + setReactorEnableStatus( INLET_UV_REACTOR, PIN_SIGNAL_LOW ); + setReactorEnableStatus( OUTLET_UV_REACTOR, PIN_SIGNAL_LOW ); + + state = UV_REACTORS_SELF_TEST_COMPLETE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleUVReactorStateOff function handles the off state. + * @details Inputs: reactorsStatus + * @details Outputs: none + * @return returns the next state of the exec state machine + *************************************************************************/ static UV_REACTOR_STATE_T handleUVReactorStateOff( UV_REACTORS_T reactor ) { UV_REACTOR_STATE_T state = UV_REACTOR_STATE_OFF; - //TODO check the health + // 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 ) { - gioSetBit( gioPORTA, reactorsStatus[ reactor ].reactorEnablePin, PIN_SIGNAL_HIGH ); + setReactorEnableStatus( reactor, PIN_SIGNAL_HIGH ); + + // Set the turn on request flag to FALSE + reactorsStatus[ reactor ].hasTurnOnBeenRequested = FALSE; + // Update the pin signal state + reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_HIGH; state = UV_REACTOR_STATE_ON; } return state; } - +/*********************************************************************//** + * @brief + * The handleUVReactorStateOn function handles the on state. + * @details Inputs: reactorsStatus + * @details Outputs: reactorsStatus + * @return returns the next state of the exec state machine + *************************************************************************/ static UV_REACTOR_STATE_T handleUVReactorStateOn( UV_REACTORS_T reactor ) { UV_REACTOR_STATE_T state = UV_REACTOR_STATE_ON; - gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); + // Check if the reactor is healthy + if ( FALSE == isReactorHealthy( reactor ) && + ++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 ); + } + else + { + // If the reactor is healthy, zero out the counter + reactorsStatus[ reactor ].reactorUnhealthyCounter = 0; + } + // Check if a reactor has been requested to be open if( FALSE == reactorsStatus[ reactor ].hasTurnOnBeenRequested ) { - gioSetBit( gioPORTA, reactorsStatus[ reactor ].reactorEnablePin, PIN_SIGNAL_LOW ); + setReactorEnableStatus( reactor, PIN_SIGNAL_LOW ); + + // Update the pin signal state + reactorsStatus[ reactor ].pinSignalState = PIN_SIGNAL_LOW; state = UV_REACTOR_STATE_OFF; } return state; } +/*********************************************************************//** + * @brief + * The setReactorEnableStatus function sets a reactor to enable or + * disable state. + * @details Inputs: reactorsStatus + * @details Outputs: none + * @return none + *************************************************************************/ +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 ); +} -static void execMonitorUVReactors( void ) +/*********************************************************************//** + * @brief + * The isReactorHealthy function checks the health status of a reactor. + * @details Inputs: reactorsStatus + * @details Outputs: none + * @return returns TRUE if the reactor is healthy otherwise a FALSE + *************************************************************************/ +static BOOL isReactorHealthy( UV_REACTORS_T reactor ) { + U32 status = gioGetBit( hetPORT1, reactorsStatus[ reactor ].reactorHealthStatusPin ); + return (BOOL)status; } +/*********************************************************************//** + * @brief + * The getPublishValvesDataInterval function gets the data publish interval + * @details Inputs: uvReactorsDataPublishInterval + * @details Outputs: none + * @return returns data publish interval + *************************************************************************/ static U32 getPublishValvesDataInterval( void ) { U32 result = uvReactorsDataPublishInterval.data; @@ -179,16 +389,20 @@ return result; } +/*********************************************************************//** + * @brief + * The publishUVReactorsData function publishes the UV reactors data. + * @details Inputs: dataPublishCounter, uvReactorsData, reactorsStatus + * @details Outputs: dataPublishCounter, uvReactorsData + * @return none + *************************************************************************/ static void publishUVReactorsData( void ) { if ( ++dataPublishCounter > getPublishValvesDataInterval() ) { UV_REACTORS_DATA_T uvReactorsData; - - uvReactorsData.inletUVReactorEnable = reactorsStatus[ INLET_UV_REACTOR ].enableStatus; - uvReactorsData.inletUVReactorHealthStatus = reactorsStatus[ INLET_UV_REACTOR ].reactorHealthStatusPin; - - uvReactorsData.outletUVReactorEnable = reactorsStatus[ OUTLET_UV_REACTOR ].enableStatus; + // Publish the reactors health status + uvReactorsData.inletUVReactorHealthStatus = reactorsStatus[ INLET_UV_REACTOR ].reactorHealthStatusPin; uvReactorsData.outletUVReactorHealthStatus = reactorsStatus[ OUTLET_UV_REACTOR ].reactorHealthStatusPin; broadcastUVReactorsData( &uvReactorsData ); @@ -197,4 +411,123 @@ } } +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + +/*********************************************************************//** + * @brief + * The testSetReactorsDataPublishInterval function overrides the UV + * reactors data publish interval. + * @details Inputs: uvReactorsDataPublishInterval + * @details Outputs: uvReactorsDataPublishInterval + * @param value which is override value for the UV reactors data publish + * interval + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetReactorsDataPublishInterval( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = value / TASK_GENERAL_INTERVAL; + + result = TRUE; + uvReactorsDataPublishInterval.ovData = intvl; + uvReactorsDataPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetReactorsDataPublishInterval function resets the override + * of the UV reactors publish interval. + * @details Inputs: uvReactorsDataPublishInterval + * @details Outputs: uvReactorsDataPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetReactorsDataPublishInterval( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + uvReactorsDataPublishInterval.override = OVERRIDE_RESET; + uvReactorsDataPublishInterval.ovData = uvReactorsDataPublishInterval.ovInitData; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testSetUVReactorsStateOverride function overrides the UV reactors + * state + * @details Inputs: uvReactorsStateOverride, reactorsStatus + * @details Outputs: uvReactorsStateOverride + * @param reactor that its state will be overridden + * @param signal which is high for turn on and low for turn off + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetUVReactorsStateOverride( U32 reactor, PIN_SIGNAL_STATE_T signal ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() && (UV_REACTORS_T)reactor < NUM_OF_UV_REACTORS ) + { + // Get the current position of the valve as the initial position + uvReactorsStateOverride[ reactor ].ovInitData = reactorsStatus[ reactor ].pinSignalState; + uvReactorsStateOverride[ reactor ].ovData = signal; + uvReactorsStateOverride[ reactor ].override = OVERRIDE_KEY; + + // If the signal is high, turn on the reactor + if ( signal == PIN_SIGNAL_HIGH ) + { + result = turnOnUVReactor( (UV_REACTORS_T)reactor ); + } + else + { + result = turnOffUVReactor( (UV_REACTORS_T)reactor ); + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetUVReactorsStateOverride function resets the override + * of the UV reactors state + * @details Inputs: uvReactorsStateOverride + * @details Outputs: uvReactorsStateOverride + * @param reactor that its state will be reset + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetUVReactorsStateOverride( U32 reactor ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() && (UV_REACTORS_T)reactor < NUM_OF_UV_REACTORS ) + { + uvReactorsStateOverride[ reactor ].override = OVERRIDE_RESET; + uvReactorsStateOverride[ reactor ].ovData = uvReactorsStateOverride[ reactor ].ovInitData; + + if ( uvReactorsStateOverride[ reactor ].ovData == PIN_SIGNAL_HIGH ) + { + result = turnOnUVReactor( (UV_REACTORS_T)reactor ); + } + else + { + result = turnOffUVReactor( (UV_REACTORS_T)reactor ); + } + + } + + return result; +} + /**@}*/ Index: firmware/App/Controllers/UVReactors.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Controllers/UVReactors.h (.../UVReactors.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/UVReactors.h (.../UVReactors.h) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -1,9 +1,3 @@ -/* - * UVReactors.h - * - * Created on: Jun 20, 2020 - * Author: fw - */ #ifndef APP_CONTROLLERS_UVREACTORS_H_ #define APP_CONTROLLERS_UVREACTORS_H_ @@ -31,9 +25,7 @@ /// UV reactors data publish typedef struct { - U32 inletUVReactorEnable; ///< Inlet UV reactor enable status U32 inletUVReactorHealthStatus; ///< Inlet UV reactor health status - U32 outletUVReactorEnable; ///< Outlet UV reactor enable status U32 outletUVReactorHealthStatus; ///< Outlet UV reactor health status } UV_REACTORS_DATA_T; #pragma pack(pop) @@ -45,8 +37,17 @@ void execUVReactos( void ); BOOL turnOnUVReactor( UV_REACTORS_T reactor ); + BOOL turnOffUVReactor( UV_REACTORS_T reactor ); +BOOL testSetReactorsDataPublishInterval( U32 value ); + +BOOL testResetReactorsDataPublishInterval( void ); + +BOOL testSetUVReactorsStateOverride( U32 reactor, PIN_SIGNAL_STATE_T signal ); + +BOOL testResetUVReactorsStateOverride( U32 reactor ); + /**@}*/ #endif Index: firmware/App/Drivers/SafetyShutdown.c =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -46,7 +46,7 @@ *************************************************************************/ void initSafetyShutdown( void ) { - CLR_SAFETY_SHUTDOWN(); + CLR_SAFETY_SHUTDOWN(); } /*********************************************************************//** Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -326,7 +326,7 @@ setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); - setDrainPumpTargetDeltaPressure( 0.05 ); //DRAIN_PUMP_TARGET_DELTA_PRESSURE + setDrainPumpTargetDeltaPressure( DRAIN_PUMP_TARGET_DELTA_PRESSURE ); //DRAIN_PUMP_TARGET_DELTA_PRESSURE setPrimaryHeaterTargetTemperature( HEAT_DISINFECT_TARGET_TEMPERATURE ); startPrimaryHeater(); @@ -407,9 +407,6 @@ setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); - setDrainPumpTargetDeltaPressure( DRAIN_PUMP_TARGET_DELTA_PRESSURE ); - setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); - stateTimer = getMSTimerCount(); state = DG_HEAT_DISINFECT_STATE_DISINFECT_R1_TO_R2; } @@ -450,9 +447,6 @@ setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); - setDrainPumpTargetDeltaPressure( DRAIN_PUMP_TARGET_DELTA_PRESSURE ); - setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); - stateTimer = getMSTimerCount(); state = DG_HEAT_DISINFECT_STATE_DISINFECT_R2_TO_R1; } @@ -517,7 +511,6 @@ setValveState( VRD, VALVE_STATE_R1_C_TO_NO ); setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); - setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); stateTimer = getMSTimerCount(); heatDisinfectInternalState = INTERNAL_HEAT_DISINFECT_STATE_OFF; state = DG_HEAT_DISINFECT_STATE_DISINFECT_RECIRC_PATH; Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -145,6 +145,7 @@ SW_FAULT_ID_UTIL_INVALID_WIN_MAX_COUNT, SW_FAULT_ID_PERSISTENT_ALARM_INVALID_INDEX, SW_FAULT_ID_UV_REACTORS_INVALID_EXEC_STATE, // 55 + SW_FAULT_ID_UV_REACTORS_INVALID_SELF_TEST_STATE, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rab304e2ca6e3e40ed8cb12650e9855ae0b9649d8 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision ab304e2ca6e3e40ed8cb12650e9855ae0b9649d8) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -1177,6 +1177,14 @@ handleSetAccelCalibration( message ); break; + case MSG_ID_DG_START_STOP_UV_REACTORS_OVERRIDE: + handleStartStopUVReactorsOverrideRequest( message ); + break; + + case MSG_ID_UV_REACTORS_DATA_PUBLISH_INTERVAL_OVERRIDE: + handleUVReactorsDataPunlishIntervalOverride( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -2094,4 +2094,67 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleStartStopUVReactorsOverrideRequest function handles a request +* to override a UV reactors state. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleStartStopUVReactorsOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + + BOOL result = FALSE; + // verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetUVReactorsStateOverride( payload.index, (PIN_SIGNAL_STATE_T)(payload.state.u32) ); + } + else + { + result = testResetUVReactorsStateOverride( payload.index ); + } + } + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleUVReactorsDataPunlishIntervalOverride function handles a request +* to override the publish interval of the UV reactors data +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleUVReactorsDataPunlishIntervalOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetReactorsDataPublishInterval( payload.state.u32 ); + } + else + { + result = testResetReactorsDataPublishInterval(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1538c71d0c6b97469d599befce15f068d9acf5d4 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) @@ -237,6 +237,12 @@ // MSG_ID_DG_ACCEL_SET_CALIBRATION: void handleSetAccelCalibration( MESSAGE_T *message ); +//MSG_ID_DG_START_STOP_UV_REACTORS +void handleStartStopUVReactorsOverrideRequest( MESSAGE_T *message ); + +//MSG_ID_UV_REACTORS_DATA_PUBLISH_INTERVAL_OVERRIDE +void handleUVReactorsDataPunlishIntervalOverride( MESSAGE_T *message ); + /**@}*/ #endif