Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r59b7b1cd099ab5a5e943fb5307aec264cbadb51a -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 59b7b1cd099ab5a5e943fb5307aec264cbadb51a) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -96,11 +96,11 @@ #define BARO_SENSOR_REFERENCE_TEMP_C 2000 ///< Barometric sensor reference temperature in C. #define BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ( 20 * MS_PER_SECOND ) ///< Barometric sensor wait for coefficients timeout in milliseconds. -#define TDI_TRO_TEMP_SENSORS_MAX_DEVIATION_C 2.0F ///< Dialysate temperature sensors maximum allowed deviation in C. +#define TDI_TRO_TEMP_SENSORS_MAX_DEVIATION_C 3.0F ///< Dialysate temperature sensors maximum allowed deviation in C. #define DIALYSATE_TEMP_SNSRS_OUT_OF_RANGE_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Dialysate temperature sensors drift timeout in milliseconds. #define TDI_TRO_TEMP_SENSORS_MAX_DEVIATION_IN_HEAT_DIS_C 5.0F ///< Dialysate temperature sensors maximum allowed deviation in heat disinfect in C. #define DIAL_TEMP_MOVING_AVG_NUM_OF_SAMPLES 30 ///< Dialysate temperature sensors moving average number of samples. -#define TDI_TRO_DATA_COLLECTION_TIMEOUT_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature sensors data collection timeout in milliseconds. +#define TDI_TRO_DATA_COLLECTION_TIME_MS ( 1 * MS_PER_SECOND ) ///< Dialysate temperature sensors data collection time in milliseconds. /// Temperature sensor exec states. typedef enum tempSensors_Exec_States @@ -113,8 +113,8 @@ /// Dialysate temperature sensors enums typedef enum Dial_Temps_Sensors { - DIAL_TEMP_FIRST = 0, ///< Dialysate temperature first. - DIAL_TEMP_TRO = DIAL_TEMP_FIRST, ///< Dialysate temperature TRo. + DIAL_TEMP_TRO = 0, + DIAL_TEMP_FIRST = DIAL_TEMP_TRO, ///< Dialysate temperature first. DIAL_TEMP_TDI, ///< Dialysate temperature TDi. NUM_OF_DIAL_TEMPS ///< Number of Dialysate temperature sensors. } DIAL_TEMPERATURE_SENSORS_T; @@ -1139,7 +1139,7 @@ dialTempMovingAvgData[ i ].dialTempDataColStartTimeMS = getMSTimerCount(); dialTempMovingAvgData[ i ].dialTempColHasTimerBeenSet = TRUE; } - else if ( TRUE == didTimeout( dialTempMovingAvgData[ i ].dialTempDataColStartTimeMS, TDI_TRO_DATA_COLLECTION_TIMEOUT_MS ) ) + else if ( TRUE == didTimeout( dialTempMovingAvgData[ i ].dialTempDataColStartTimeMS, TDI_TRO_DATA_COLLECTION_TIME_MS ) ) { TEMPERATURE_SENSORS_T sensor = ( DIAL_TEMP_TDI == i ? TEMPSENSORS_INLET_DIALYSATE : TEMPSENSORS_OUTLET_REDUNDANT ); F32 temperatureC = getTemperatureValue( sensor ); Index: firmware/App/Modes/ModeChemicalDisinfect.c =================================================================== diff -u -r8f5a1b18748e7461bb657ef72ab6d5f77e1532b8 -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 8f5a1b18748e7461bb657ef72ab6d5f77e1532b8) +++ firmware/App/Modes/ModeChemicalDisinfect.c (.../ModeChemicalDisinfect.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -91,7 +91,7 @@ #define RO_PUMP_PRIME_DISINECTANT_FLOW_RATE_LPM 0.8F ///< ROP flow rate for disinfectant prime #define MAX_RO_PUMP_PRIME_DISINFECTANT_PRESSURE_PSI 130.0F ///< ROP max pressure for disinfectant prime #define DISINFECTANT_MIX_RATIO_PRIME 19.0F ///< Disinfectant mixing ratio during prime, water/disinfectant. -#define PRIME_ACID_MINIMUM_PRIME_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< Prime acid minimum prime timeout in milliseconds. +#define PRIME_ACID_MINIMUM_PRIME_TIME_MS ( 60 * MS_PER_SECOND ) ///< Prime acid minimum prime time in milliseconds. // Stabilize disinfectant mixing state defines #define MAX_ALLOWED_DISINFECTANT_FLUSH_PERIODS 4 ///< Number of allowed periods to check conductivity and temperature in disinfectant flush state @@ -135,7 +135,7 @@ #define MAX_DRP_VOLUME_CONTROL_RPM 1500.0F ///< Maximum DRP RPM for volume control. The maximum recommended value is 2400 RPM #define ACID_MOVING_AVG_NUM_OF_SAMPLES 30 ///< Acid moving average number of samples. -#define ACID_DATA_COLLECTION_TIMEOUT_MS ( 0.5F * MS_PER_SECOND ) ///< Acid data collection timeout in milliseconds. +#define ACID_DATA_COLLECTION_TIME_MS ( 0.5F * MS_PER_SECOND ) ///< Acid data collection time in milliseconds. /// Non-volatile write structure typedef struct @@ -703,16 +703,8 @@ // Check if the flush circulation time has elapsed and the temperature sensors are not in range yet if ( TRUE == didTimeout( stateTimer, flushCircWaitTime ) ) { - F32 TPoTemp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); - F32 TD2Temp = getTemperatureValue( TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); - -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_USING_TPO_FOR_PRIMARY_HEATER_CONTROL ) ) - { - TD2Temp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); - } -#endif - + F32 TPoTemp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + F32 TD2Temp = getTemperatureValue( TEMPSENSORS_CONDUCTIVITY_SENSOR_2 ); F32 avgTemp = ( TPoTemp + TD2Temp ) / NUM_OF_TEMP_SENSORS_TO_AVG; F32 cd2CondUSPCM = getConductivityValue( (U32)CONDUCTIVITYSENSORS_CD2_SENSOR ); F32 cpoCondUSPCM = getConductivityValue( (U32)CONDUCTIVITYSENSORS_CPO_SENSOR ); @@ -722,6 +714,13 @@ BOOL isCPoOut = FALSE; #ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_USING_TPO_FOR_PRIMARY_HEATER_CONTROL ) ) + { + TD2Temp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + } +#endif + +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_TEMPERATURE_SENSORS_ALARM ) != SW_CONFIG_ENABLE_VALUE ) #endif { @@ -793,7 +792,7 @@ handleDisinfectantMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, disinfectantMixRatio ); - if ( TRUE == didTimeout( stateTimer, PRIME_ACID_MINIMUM_PRIME_TIMEOUT_MS ) ) + if ( TRUE == didTimeout( stateTimer, PRIME_ACID_MINIMUM_PRIME_TIME_MS ) ) { #ifndef _RELEASE_ if ( nelsonSupport != NELSON_CHEM_DISINFECT ) @@ -840,9 +839,10 @@ * within the specified range within the specified time, the function transitions * to another state. If the minimum conductivity and temperature are not * reached within the defined period of time, it transition to a cancellation path. - * @details Inputs: stateTimer, primeAcidSteadyStateCounter, - * temperature, conductivity, disinfectNVOps - * @details Outputs: stateTimer, prevChemDisinfectState, alarm + * @details Inputs: stateTimer, disinfectantMixRatio, stateTrialCounter + * @details Outputs: stateTimer, stateTrialCounter, rsrvr1Status, rsrvr2Status, + * chemDisinfectReservoirTime, rsrvrFillStableTimeCounter, isChemDisinfectTempAboveTarget, + * disinfectNVOps * @return next state of the chemical disinfect state machine *************************************************************************/ static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectDisinfectantFlushState( void ) @@ -1019,8 +1019,10 @@ * within a certain period of time, it transitions to water cancellation. * If reservoir 2 is filled within the specified time, it * transitions to the next state. - * @details Inputs: stateTimer, rsrvr2Status - * @details Outputs: stateTimer + * @details Inputs: stateTimer, rsrvr2Status, disinfectantMixRatio + * @details Outputs: stateTimer, isRsrvrLeaking, chemDisinfectReservoirTime, + * isChemDisinfectTempAboveTarget, ischemDisinfectWarmupTargetReached, + * prevChemDisinfectState * @return next state of the chemical disinfect state machine *************************************************************************/ static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectPartialDrainR1FillR2ToR1State( void ) @@ -1158,8 +1160,9 @@ * within a certain period of time, it transitions to water cancellation. * If reservoir 1 is filled within the specified time, it * transitions to the next state. - * @details Inputs: stateTimer, rsrvr1Status - * @details Outputs: stateTimer + * @details Inputs: stateTimer, rsrvr1Status, disinfectantMixRatio + * @details Outputs: stateTimer, chemDisinfectReservoirTime, isChemDisinfectTempAboveTarget, + * ischemDisinfectWarmupTargetReached, isRsrvrLeaking, prevChemDisinfectState * @return next state of the chemical disinfect state machine *************************************************************************/ static DG_CHEM_DISINFECT_STATE_T handleChemicalDisinfectPartialDrainR2FillR1ToR2State( void ) @@ -1807,7 +1810,7 @@ acidDataStatus.acidDataColStartTimeMS = getMSTimerCount(); acidDataStatus.acidDataColHasTimerBeenSet = TRUE; } - else if ( TRUE == didTimeout( acidDataStatus.acidDataColStartTimeMS, ACID_DATA_COLLECTION_TIMEOUT_MS ) ) + else if ( TRUE == didTimeout( acidDataStatus.acidDataColStartTimeMS, ACID_DATA_COLLECTION_TIME_MS ) ) { F32 acidCondUSPCM = getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); U32 currentIndex = acidDataStatus.acidCondSamplesNextIndex; Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r728c213b3958b98a416772d3857f08e390fd04fe -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 728c213b3958b98a416772d3857f08e390fd04fe) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -302,7 +302,6 @@ { resetChemicalUsedVolumeML( ACID ); setThisFisrtFillFlag( TRUE ); // indicates bottles need prime - setEmptyBottleDetectedFlag( TRUE ); activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); activateAlarmNoData ( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); } @@ -311,7 +310,6 @@ { resetChemicalUsedVolumeML( BICARB ); setThisFisrtFillFlag( TRUE ); - setEmptyBottleDetectedFlag( TRUE ); activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); activateAlarmNoData ( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -reca8d3222a8fbcda268c8ea1c004dfe0a7ed30db -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision eca8d3222a8fbcda268c8ea1c004dfe0a7ed30db) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -338,10 +338,7 @@ switch ( fillState ) { case DG_FILL_MODE_STATE_START: - if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) && ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) - { - fillState = DG_FILL_MODE_STATE_TEST_INLET_WATER; - } + fillState = DG_FILL_MODE_STATE_TEST_INLET_WATER; break; case DG_FILL_MODE_STATE_TEST_INLET_WATER: @@ -941,21 +938,14 @@ } } - if ( TRUE == getEmpytBottleDetectedFlag() ) - { - // If the alarm was triggered due to the empty bottle alarm, clear the alarm since we are at the end of the fill - // Set the empty bottle flag to false since we are done - clearAlarm( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); - setEmptyBottleDetectedFlag( FALSE ); - } - // SRSDG 400 if ( ( FALSE == isValueWithinPercentRange( avgBicarbConduSPerCM, bicarbNormalConduSPerCM, FIVE_PERCENT_FACTOR ) ) && ( getTargetFillVolumeML() > MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML ) && ( getTestConfigStatus( TEST_CONFIG_MIX_WITH_WATER ) != TRUE ) ) { setBadAvgConductivityDetectedFlag( TRUE ); // signal idle bad avg conductivity detected setThisFisrtFillFlag( TRUE ); resetChemicalUsedVolumeML( BICARB ); + resetChemicalUsedVolumeML( ACID ); SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FILL_CONDUCTIVITY_OUT_OF_RANGE, avgBicarbConduSPerCM, bicarbNormalConduSPerCM ); // trigger replace bottles alarm #1 clearAlarm( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); // clear this alarm before triggering in case previous fill was bad and still active from before activateAlarmNoData ( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -reca8d3222a8fbcda268c8ea1c004dfe0a7ed30db -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision eca8d3222a8fbcda268c8ea1c004dfe0a7ed30db) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -58,9 +58,11 @@ // NOTE: the bad fill state must be initialized here and not in the transition function since in case of a bad fill, the transition function is called // several times to drain and fill and handle a bad fill. static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. +// NOTE: the empty bottle flag must be initialized here and not in transition function since this flag must be set to false once the empty bottle +// fill is finished. +static BOOL handleEmptyBottleFlag = FALSE; ///< Internal siganl flag to handle empty bottle flag. static U32 hdLostCommStartTime_ms; ///< Lost communication with HD start time in ms. static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. -static BOOL handleEmptyBottleFlag; ///< Internal siganl flag to handle empty bottle flag. static OVERRIDE_U32_T genIdleDataPublicationInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, BAD_FILL_SUBSTATES_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. @@ -199,32 +201,6 @@ /*********************************************************************//** * @brief - * The setEmptyBottleDetectedFlag function sets a flag to indicate - * that empty bottle flag has been detected. - * @details Inputs: none - * @details Outputs: handleEmptyBottleFlag - * @param flag to TRUE if empty bottle flag is TRUE otherwise FALSE - *************************************************************************/ -void setEmptyBottleDetectedFlag( BOOL emptyBottleFlag ) -{ - handleEmptyBottleFlag = emptyBottleFlag; -} - -/*********************************************************************//** - * @brief - * The getEmpytBottleDetectedFlag function returns the status of the empty - * bottle detected flag. - * @details Inputs: handleEmptyBottleFlag - * @details Outputs: none - * @return the status of the empty bottle flag - *************************************************************************/ -BOOL getEmpytBottleDetectedFlag( void ) -{ - return handleEmptyBottleFlag; -} - -/*********************************************************************//** - * @brief * The execGenIdleMode function executes the generation idle mode state machine. * @details Inputs: genIdleState * @details Outputs: Check water quality, generation idle mode state machine executed @@ -296,6 +272,12 @@ { badFillState = DG_HANDLE_BAD_FILL_STATE_START; result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; + + if ( ( TRUE == handleEmptyBottleFlag ) && ( DG_MODE_FILL == getPreviousOperationMode() ) ) + { + handleEmptyBottleFlag = FALSE; + clearAlarmCondition( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); + } } return result; @@ -313,10 +295,16 @@ { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; - if ( TRUE == handleEmptyBottleFlag ) + if ( ( TRUE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || ( TRUE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) { // Empty bottle flag is TRUE and HD is on pause. So HD will not request a fill and it is // commanded to fill. + handleEmptyBottleFlag = TRUE; + } + else if ( ( TRUE == handleEmptyBottleFlag ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) + { requestNewOperationMode( DG_MODE_FILL ); } Index: firmware/App/Modes/ModeGenIdle.h =================================================================== diff -u -reca8d3222a8fbcda268c8ea1c004dfe0a7ed30db -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision eca8d3222a8fbcda268c8ea1c004dfe0a7ed30db) +++ firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -46,8 +46,6 @@ U32 transitionToGenIdleMode( void ); // prepares for transition to generation idle mode U32 execGenIdleMode( void ); // execute the generation idle mode state machine (call from OperationModes) void setBadAvgConductivityDetectedFlag( BOOL badAvgConducitivyflag ); // used by fill mode to signal idle mode of bad average conductivity -void setEmptyBottleDetectedFlag( BOOL emptyBottleFlag ); -BOOL getEmpytBottleDetectedFlag( void ); DG_GEN_IDLE_MODE_STATE_T getCurrentGenIdleState( void ); // get the current state of generation idle mode DG_GEN_IDLE_MODE_BAD_FILL_STATE_T getCurrentGenIdleBadFillState( void ); // get the current bad fill state