Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r256d5cb05f1ef09e19e2f2733a111f600c73a7ee -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 256d5cb05f1ef09e19e2f2733a111f600c73a7ee) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -22,6 +22,7 @@ #include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" +#include "Utilities.h" /** * @addtogroup ConcentratePumps @@ -447,11 +448,11 @@ *************************************************************************/ static void stopConcentratePump( CONCENTRATE_PUMPS_T pumpId ) { - concentratePumps[ pumpId ].currentPumpSpeed = 0.0; - concentratePumps[ pumpId ].measuredPumpSpeed.data = 0.0; + concentratePumps[ pumpId ].currentPumpSpeed = 0.0F; + concentratePumps[ pumpId ].measuredPumpSpeed.data = 0.0F; #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { if ( CONCENTRATEPUMPS_CP1_ACID == pumpId ) { @@ -492,7 +493,7 @@ U08 controlSet = 0; #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { controlSet = ( CONCENTRATE_PUMP_ON_CONTROL | concentratePumps[ pumpId ].direction ); CONCENTRATEPUMPS_CP1_ACID == pumpId ? setFPGAV3AcidPumpControl( controlSet ) : setFPGAV3BicarbPumpControl( controlSet ); Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -ra8ea22dced3777b08a1317a05ad996bab34358ba -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision a8ea22dced3777b08a1317a05ad996bab34358ba) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -231,7 +231,7 @@ } #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { processCPiCPoSensorRead( CONDUCTIVITYSENSORS_CPI_SENSOR, EMSTAT_CPI_OR_CD1_INDEX, getFPGACPi(), getFPGACPiReadCount(), getFPGACPiErrorCount(), getFPGACPiFault() ); processCPiCPoSensorRead( CONDUCTIVITYSENSORS_CPO_SENSOR, EMSTAT_CPO_OR_CD2_INDEX, getFPGACPo(), getFPGACPoReadCount(), getFPGACPoErrorCount(), getFPGACPoFault() ); Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -rcff72ec53660ec3ff6775c0508e3c721240ffba2 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision cff72ec53660ec3ff6775c0508e3c721240ffba2) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -33,6 +33,7 @@ #include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" +#include "Utilities.h" #include "Valves.h" /** @@ -365,7 +366,7 @@ #endif { #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_DRAIN_PUMP_DIR_HALL_SENSOR, dirHallSensorErrorCount ); @@ -388,7 +389,7 @@ } #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_CURRENT_OUT_OF_RANGE, isOffCurrentOut, currentA, DRAIN_PUMP_MAX_CURRENT_WHEN_OFF_A ); @@ -409,7 +410,7 @@ checkPersistentAlarm( ALARM_ID_DRAIN_PUMP_OFF_FAULT, FALSE, getDrainPumpMeasuredRPM(), MIN_DRAIN_PUMP_RPM ); #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_DIRECTION_INVALID, isDirInvalid, (F32)direction, DRAIN_PUMP_FORWARD_DIR ); @@ -423,7 +424,7 @@ BOOL isDirInvalid = ( direction != DRAIN_PUMP_FORWARD_DIR ? TRUE : FALSE ); #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_DIRECTION_INVALID, isDirInvalid, (F32)direction, DRAIN_PUMP_FORWARD_DIR ); @@ -440,7 +441,7 @@ } #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { // Check the persistent alarm for the maximum drain pump current Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -450,7 +450,7 @@ static void monitorFans( void ) { FAN_NAMES_T fan; - F32 rpm = 0.0; + F32 rpm = 0.0F; BOOL isAlarmTriggered = FALSE; BOOL isFanRPMOutOfRange = FALSE; Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r0516c804fc8c41a097fda9ab8dac1527e1683d29 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 0516c804fc8c41a097fda9ab8dac1527e1683d29) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -38,6 +38,7 @@ #include "TaskPriority.h" #include "TemperatureSensors.h" #include "Timers.h" +#include "Utilities.h" #include "Voltages.h" /** @@ -91,11 +92,11 @@ F32 targetFlow; ///< Heater target flow. BOOL hasTargetTempChanged; ///< Heater target temperature change flag indicator. F32 heaterEstGain; ///< Heater estimation gain during the run. - BOOL hasTargetBeenReached; ///< Heater flag to indicate whether the target temperature has been reached. F32 calculatedTemperature; ///< Heater calculated temperature. DG_RESERVOIR_ID_T inactiveRsrvr; ///< Heater inactive reservoir. U32 controlIntervalCounter; ///< Heater control interval counter. BOOL isThisFirstControl; ///< Heater is this first control interval. + BOOL useLastDutyCycle; ///< Heater has use previous duty cycle been requested flag. } HEATER_STATUS_T; static HEATER_STATUS_T heatersStatus[ NUM_OF_DG_HEATERS ]; ///< Heaters status. @@ -145,9 +146,9 @@ heatersStatus[ heater ].targetFlow = 0.0F; heatersStatus[ heater ].hasTargetTempChanged = FALSE; heatersStatus[ heater ].heaterEstGain = HEATERS_NEUTRAL_EST_GAIN; - heatersStatus[ heater ].hasTargetBeenReached = FALSE; heatersStatus[ heater ].controlIntervalCounter = 0; heatersStatus[ heater ].isThisFirstControl = TRUE; + heatersStatus[ heater ].useLastDutyCycle = FALSE; } // Initialize the persistent alarms @@ -440,6 +441,20 @@ /*********************************************************************//** * @brief + * The setTrimmerHeaterUseLastDutyCycleStatus function sets the flag that + * signals the trimmer heater control to use the last duty cycle or not + * @details Inputs: none + * @details Outputs: heatersStatus + * @param status which is the flag to indicate the status + * @return none + *************************************************************************/ +void setTrimmerHeaterUseLastDutyCycleStatus( BOOL status ) +{ + heatersStatus[ DG_TRIMMER_HEATER ].useLastDutyCycle = status; +} + +/*********************************************************************//** + * @brief * The handleHeaterStateOff function handles the heater not running state. * @details Inputs: heaterStatus * @details Outputs: heaterStatus @@ -608,9 +623,17 @@ if ( ( DG_MODE_FILL == opMode ) || ( DG_MODE_GENE == opMode ) || ( DG_MODE_DRAI == opMode ) ) { - currentTemperature = getReservoirCurrentTemperature(); - dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, currentTemperature, targetFlowLPM, TRUE ); - state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; + if ( FALSE == heatersStatus[ heater ].useLastDutyCycle ) + { + currentTemperature = getReservoirCurrentTemperature(); + dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, currentTemperature, targetFlowLPM, TRUE ); + } + else + { + dutyCycle = heatersStatus[ heater ].dutyCycle; + } + + state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; } else if ( DG_MODE_HEAT == opMode ) { @@ -929,7 +952,7 @@ BOOL isTrimmerOut = FALSE; #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { // V3 use CPU based value for Primary, same as Secondary mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_GND_SMALL_PRIM_HTR_V ); @@ -953,7 +976,7 @@ checkPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, isTrimmerOut, trimmerDC, HEATERS_VOLTAGE_TOLERANCE_V ); #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE != getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { // If the system is DVT, check the primary heater's power line voltage Index: firmware/App/Controllers/Heaters.h =================================================================== diff -u -r256d5cb05f1ef09e19e2f2733a111f600c73a7ee -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 256d5cb05f1ef09e19e2f2733a111f600c73a7ee) +++ firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -68,6 +68,8 @@ void calculateHeaterEstimationGain( DG_HEATERS_T heater ); +void setTrimmerHeaterUseLastDutyCycleStatus( BOOL status ); + BOOL testSetHeatersPublishIntervalOverride( U32 value ); BOOL testResetHeatersPublishIntervalOverride( void ); Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r7ffa5c7ed2439e3bfba81cac21f8d286e617c143 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 7ffa5c7ed2439e3bfba81cac21f8d286e617c143) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -28,7 +28,8 @@ #include "TaskGeneral.h" #include "TaskPriority.h" #include "TemperatureSensors.h" -#include "Timers.h" +#include "Timers.h" +#include "Utilities.h" /** * @addtogroup DGPressures @@ -309,13 +310,10 @@ U08 sensorId; #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) { - if ( getCurrentOperationMode() != DG_MODE_INIT ) - { - zeroPressureOffset = PUMP_V3_PRESSURE_ZERO; - count2PressureConv = PUMP_V3_PRESSURE_PSIA_PER_COUNT; - } + zeroPressureOffset = PUMP_V3_PRESSURE_ZERO; + count2PressureConv = PUMP_V3_PRESSURE_PSIA_PER_COUNT; } #endif @@ -496,7 +494,7 @@ F32 baroPressure = getF32OverrideValue( &pressures[ PRESSURE_SENSOR_BAROMETRIC ] ); #ifndef _RELEASE_ - if ( ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) { baroPressure = PUMP_PRESSURE_PSIA_TO_PSI_OFFSET; } @@ -560,7 +558,7 @@ } // Once the sensors were all checked to be out of range, check the persistent alarm - checkPersistentAlarm( ALARM_ID_DG_PRESSURE_OUT_OF_RANGE, isPressureOutOfRange, pressureOutID, pressureReading ); + //checkPersistentAlarm( ALARM_ID_DG_PRESSURE_OUT_OF_RANGE, isPressureOutOfRange, pressureOutID, pressureReading ); } Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r19934ca6e36e2dcabd6a6083a9a1f15b1ed32189 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 19934ca6e36e2dcabd6a6083a9a1f15b1ed32189) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -36,6 +36,7 @@ #include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" +#include "Utilities.h" #include "Valves.h" /** @@ -373,7 +374,7 @@ } #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rcff72ec53660ec3ff6775c0508e3c721240ffba2 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision cff72ec53660ec3ff6775c0508e3c721240ffba2) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -465,7 +465,7 @@ #ifndef _RELEASE_ // If the system is V3 and THd or its ADC internal temperature is requested, return TRo instead. V3 does not have // the electrical connection of THd sensor. - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { if ( TEMPSENSORS_HEAT_DISINFECT == sensorIndex ) { @@ -851,7 +851,7 @@ processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR, getFPGACondSnsrInternalTemp() ); #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { errorCount = (U32)getFPGATHdErrorCount(); @@ -1032,15 +1032,11 @@ U32 externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_REF_RESISTANCE; #ifndef _RELEASE_ - //if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) - if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) + if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { - if ( getCurrentOperationMode() != DG_MODE_INIT ) - { - primaryAndCondSensorsRefResistance = PRIMARY_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; - externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; - } + primaryAndCondSensorsRefResistance = PRIMARY_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; + externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; } tempSensors[ TEMPSENSORS_INLET_PRIMARY_HEATER ].refResistance = primaryAndCondSensorsRefResistance; Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -24,6 +24,7 @@ #include "SystemCommMessages.h" #include "Thermistors.h" #include "TaskGeneral.h" +#include "Utilities.h" /** * @addtogroup Thermistors @@ -226,7 +227,7 @@ if ( ++adcReadCounter >= THERMISTORS_ADC_READ_INTERVAL ) { #ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); } Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rcff72ec53660ec3ff6775c0508e3c721240ffba2 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision cff72ec53660ec3ff6775c0508e3c721240ffba2) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -18,7 +18,8 @@ #include "FPGA.h" #include "MessageSupport.h" #include "SystemCommMessages.h" -#include "TaskPriority.h" +#include "TaskPriority.h" +#include "Timers.h" #include "Valves.h" /** @@ -28,14 +29,25 @@ // ********** private definitions ********** -#define DEENERGIZED 0 ///< 0 for de-energized valve. -#define ENERGIZED 1 ///< 1 for energized valve. -#define ALL_VALVES_DEENERGIZED 0x0000 ///< 0 in U16 bit field for all valves. +#define DEENERGIZED 0 ///< 0 for de-energized valve. +#define ENERGIZED 1 ///< 1 for energized valve. +#define ALL_VALVES_DEENERGIZED 0x0000 ///< 0 in U16 bit field for all valves. -#define MAX_VALVE_STATE_MISMATCH_COUNT 3 ///< Maximum number of times commanded valves state can fail to match read back valve states in a row. +#define MAX_VALVE_STATE_MISMATCH_COUNT 3 ///< Maximum number of times commanded valves state can fail to match read back valve states in a row. -#define VALVES_STATE_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval ( ms / task time) at which valves states are published on CAN bus. -#define DATA_PUBLISH_COUNTER_START_COUNT 50 ///< Data publish counter start count. +#define VALVES_STATE_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval ( ms / task time) at which valves states are published on CAN bus. +#define DATA_PUBLISH_COUNTER_START_COUNT 50 ///< Data publish counter start count. + +#define VPI_MIN_OPEN_TO_SKIP_DISINFECT_FLUSH_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< VPi minimum required time to be open to skip disinfects flush state in milliseconds. +#define VPI_MAX_OPEN_WINDOW_TO_SKIP_DISINFECT_FLUSH_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< VPi maximum allowed time window that VPi could have been open in milliseconds. + +/// VPi open/close time status for disinfects +typedef struct +{ + U32 vpiOpenStartTimeMS; ///< VPi open start time in milliseconds. + U32 vpiOpenDurationMS; ///< VPi duration that is has been open in milliseconds. + U32 vpiClosedStartTimeMS; ///< VPi closed start time in milliseconds. +} VPI_OPEN_CLOSE_TIME_T; // ********** private data ********** @@ -48,6 +60,7 @@ static OVERRIDE_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states. static OVERRIDE_U32_T valveSensedStates[ NUM_OF_VALVES ]; ///< Valve sensed states override. static OVERRIDE_U32_T valvesStatesPublishInterval = { VALVES_STATE_PUB_INTERVAL, VALVES_STATE_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms/task interval) at which to publish valves state to CAN bus. +static VPI_OPEN_CLOSE_TIME_T vpiTime; ///< VPi open/close time structure. // ********** private function prototypes ********** @@ -56,6 +69,7 @@ static U16 fromU32ArrayToU16( void ); static void publishValvesStates( void ); static U32 getValveState( U32 valveID ); +static void checkVPiTimeStatus( void ); /*********************************************************************//** * @brief @@ -66,6 +80,7 @@ * commandedValvesStates * @return none *************************************************************************/ + void initValves( void ) { U32 i; @@ -85,6 +100,8 @@ valveSensedStates[ i ].override = OVERRIDE_RESET; } + memset( &vpiTime, 0, sizeof( VPI_OPEN_CLOSE_TIME_T ) ); + valveStateMismatchCounter = 0; commandedValvesStates = fromU32ArrayToU16(); setFPGAValveStates( commandedValvesStates ); // initially set all valves to de-energized state via FPGA @@ -136,6 +153,8 @@ commandedValvesStates = fromU32ArrayToU16(); setFPGAValveStates( commandedValvesStates ); + checkVPiTimeStatus(); + // Publish valve states on interval publishValvesStates(); } @@ -403,8 +422,8 @@ /*********************************************************************//** * @brief * The getValveStateName function gets the current valve state enum for given valve. - * @details Inputs: valveStates[], valveSensedStates - * @details Outputs: valveSensedStates + * @details Inputs: valveStates[] + * @details Outputs: none * @param valveID ID of valve to get state for * @return the current valve state for given valve in enum *************************************************************************/ @@ -462,6 +481,26 @@ } return name; +} + +/*********************************************************************//** + * @brief + * The isFliterFlushRequired function checks whether filter flush is required in + * cleaning modes. + * @details Inputs: vpiTime + * @details Outputs: none + * @return TRUE if filter flush is required otherwise, FALSE + *************************************************************************/ +BOOL isFliterFlushRequired( void ) +{ + BOOL status = TRUE; + + if ( vpiTime.vpiOpenDurationMS >= VPI_MIN_OPEN_TO_SKIP_DISINFECT_FLUSH_MS ) + { + status = ( calcTimeSince( vpiTime.vpiClosedStartTimeMS ) <= VPI_MAX_OPEN_WINDOW_TO_SKIP_DISINFECT_FLUSH_MS ? FALSE : TRUE ); + } + + return status; } /*********************************************************************//** @@ -516,6 +555,29 @@ return valveState; } +/*********************************************************************//** + * @brief + * The checkVPiTimeStatus function checks the status of the VPi to see if + * it was open or closed. + * @details Inputs: vpiTime + * @details Outputs: vpiTime + * @return none + *************************************************************************/ +static void checkVPiTimeStatus( void ) +{ + if ( ( VALVE_STATE_OPEN == getValveStateName( VPI ) ) && ( 0 == vpiTime.vpiOpenStartTimeMS ) ) + { + vpiTime.vpiOpenStartTimeMS = getMSTimerCount(); + vpiTime.vpiClosedStartTimeMS = 0; + } + else if ( ( VALVE_STATE_CLOSED == getValveStateName( VPI ) ) && ( 0 == vpiTime.vpiClosedStartTimeMS ) ) + { + vpiTime.vpiOpenDurationMS = calcTimeSince( vpiTime.vpiOpenStartTimeMS ); + vpiTime.vpiOpenStartTimeMS = 0; + vpiTime.vpiClosedStartTimeMS = getMSTimerCount(); + } +} + /************************************************************************* * TEST SUPPORT FUNCTIONS Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -r2b9d10664884e9b20d391cc3178d3c85347cdf2c -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -82,7 +82,9 @@ BOOL setValveState( VALVES_T valve, VALVE_STATE_NAMES_T valveState ); BOOL setValveStateDelayed( VALVES_T valve, VALVE_STATE_NAMES_T valveState, U32 delayMs ); -VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ); +VALVE_STATE_NAMES_T getValveStateName( VALVES_T valveID ); + +BOOL isFliterFlushRequired( void ); BOOL testSetValvesStatesPublishIntervalOverride( U32 value ); BOOL testResetValvesStatesPublishIntervalOverride( void ); Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r2b9d10664884e9b20d391cc3178d3c85347cdf2c -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -38,6 +38,7 @@ #include "TaskGeneral.h" #include "TemperatureSensors.h" #include "Timers.h" +#include "Utilities.h" #include "UVReactors.h" #include "Valves.h" @@ -738,10 +739,10 @@ DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; DG_RESERVOIR_ID_T inactiveRsrvr = getInactiveReservoir(); F32 acidConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD1_SENSOR ); - F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); - F32 inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); + F32 bicarbConductivity = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); // TODO the systems team will let us know when we can use TD2 in DVT. Until then it is disabled + F32 inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); //getTemperatureValue( (U32)TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + if ( HW_CONFIG_BETA == getHardwareConfigStatus() ) { inletTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_PRIMARY_HEATER ); } Index: firmware/App/Modes/ModeFill.h =================================================================== diff -u -ra89d6b091874136d75a9bfbdbbc1ff00f42467b3 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision a89d6b091874136d75a9bfbdbbc1ff00f42467b3) +++ firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -31,6 +31,7 @@ // ********** public definitions ********** +/// Chemical bottles typedef enum { ACID = 0, Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rcff72ec53660ec3ff6775c0508e3c721240ffba2 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision cff72ec53660ec3ff6775c0508e3c721240ffba2) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -570,7 +570,7 @@ fpgaReadByteSize = sizeof( DG_FPGA_SENSORS_T ); #ifndef _RELEASE_ - if( ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) || ( DG_MODE_INIT == getCurrentOperationMode() ) ) + if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) || ( DG_MODE_INIT == getCurrentOperationMode() ) ) { fpgaReadByteSize = FPGA_SIZE_OF_V3_READ_BYTES; } @@ -637,7 +637,7 @@ fpgaReadByteSize = sizeof( DG_FPGA_SENSORS_T ); #ifndef _RELEASE_ - if( ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) || ( DG_MODE_INIT == getCurrentOperationMode() ) ) + if ( ( HW_CONFIG_BETA == getHardwareConfigStatus() ) || ( DG_MODE_INIT == getCurrentOperationMode() ) ) { fpgaReadByteSize = FPGA_SIZE_OF_V3_READ_BYTES; } Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -30,7 +30,8 @@ #include "Reservoirs.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" -#include "Timers.h" +#include "Timers.h" +#include "Utilities.h" #include "Valves.h" /** Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r2b9d10664884e9b20d391cc3178d3c85347cdf2c -r6f2991204047ccbceeb5461f7c35af6d8f5dfd0b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2b9d10664884e9b20d391cc3178d3c85347cdf2c) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 6f2991204047ccbceeb5461f7c35af6d8f5dfd0b) @@ -899,15 +899,16 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof( U32 ) ) + if ( message->hdr.payloadLen == sizeof( DG_SWITCH_RSRVRS_CMD_T ) ) { - DG_RESERVOIR_ID_T reservoirID; - U32 resID; + DG_SWITCH_RSRVRS_CMD_T cmd; + memcpy( &cmd, message->payload, sizeof( DG_SWITCH_RSRVRS_CMD_T ) ); + + setActiveReservoirCmd( (DG_RESERVOIR_ID_T)cmd.reservoirID ); + setTrimmerHeaterUseLastDutyCycleStatus( cmd.useLastTrimmerHeaterDC ); + result = TRUE; - memcpy( &resID, message->payload, sizeof( U32 ) ); - reservoirID = (DG_RESERVOIR_ID_T)resID; - setActiveReservoirCmd( reservoirID ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result );