Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rfc78b1e5af6d7ab8f7656b410c4cacdfd76a49e6 -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision fc78b1e5af6d7ab8f7656b410c4cacdfd76a49e6) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -684,8 +684,8 @@ } else { - // If not any of the above modes, just calculate the energy equation based on TRo - currentTemperature = getTemperatureValue( (U32)TEMPSENSORS_OUTLET_REDUNDANT ); + // If not any of the above modes, just calculate the energy equation based on TDi + currentTemperature = getTemperatureValue( (U32)TEMPSENSORS_INLET_DIALYSATE ); dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, currentTemperature, targetFlowLPM, TRUE ); state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; } @@ -734,10 +734,10 @@ // When the trimmer heater is on, its duty cycle is adjusted at the control interval. For this control check, // dialysate inlet temperature sensor is used rather than the theoretical calculations. - F32 outletRedundantTemperature = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); - F32 targetTemperature = heatersStatus[ heater ].targetTempC; - F32 targetFlowLPM = heatersStatus[ heater ].targetFlowLPM; - F32 dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, outletRedundantTemperature, targetFlowLPM, TRUE ); + F32 dialysateInletTemperature = getTemperatureValue( (U32)TEMPSENSORS_INLET_DIALYSATE ); + F32 targetTemperature = heatersStatus[ heater ].targetTempC; + F32 targetFlowLPM = getTargetDialysateFlowLPM(); + F32 dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, dialysateInletTemperature, targetFlowLPM, TRUE ); tempDutyCycle = heatersStatus[ heater ].dutyCycle.data + dutyCycle; tempDutyCycle = MIN( tempDutyCycle, HEATERS_MAX_DUTY_CYCLE ); Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rc940dea020a10f2bab23ae92aa6932c375c26dd4 -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision c940dea020a10f2bab23ae92aa6932c375c26dd4) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -972,7 +972,7 @@ { // SRSDG 400 if ( ( FALSE == isValueWithinPercentRange( avgBicarbConductivity, bicarbNormalConductivity, FIVE_PERCENT_FACTOR ) ) && - ( getTestConfigStatus( TEST_CONFIG_MIX_WITH_WATER ) != TRUE ) ) + ( getTestConfigStatus( TEST_CONFIG_MIX_WITH_WATER ) != TRUE ) && ( getTargetFillVolumeML() > MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML ) ) { setBadAvgConductivityDetectedFlag( TRUE ); // signal idle bad avg conductivity detected setThisFisrtFillFlag( TRUE ); @@ -982,7 +982,7 @@ } if ( ( FALSE == isValueWithinPercentRange( avgAcidConductivity, acidNormalConductivity, FIVE_PERCENT_FACTOR ) ) && - ( getTestConfigStatus( TEST_CONFIG_MIX_WITH_WATER ) != TRUE ) ) + ( getTestConfigStatus( TEST_CONFIG_MIX_WITH_WATER ) != TRUE ) && ( getTargetFillVolumeML() > MIN_FILL_TARGET_TO_CHECK_RO_AND_CPO_ML ) ) { setBadAvgConductivityDetectedFlag( TRUE ); // signal idle bad avg conductivity detected setThisFisrtFillFlag( TRUE ); Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -rc4f3105da2ed8a7c40950588b54b79067185a3ad -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision c4f3105da2ed8a7c40950588b54b79067185a3ad) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -47,7 +47,6 @@ #define TARGET_RO_PRESSURE_PSI 130 ///< Target pressure for RO pump. #define TARGET_RO_FLOW_RATE_L 0.4F ///< Target flow rate for RO pump. -#define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state. #define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) ///< The time of HD lost comm before DG transition back to standby. #define BAD_FILL_SUBSTATES_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the bad fill sub-states is published on the CAN bus. #define DATA_PUBLISH_COUNTER_START_COUNT 61 ///< Data publish counter start count. @@ -157,6 +156,19 @@ /*********************************************************************//** * @brief + * The getCurrentGenIdleBadFillState function returns the current state of the + * generation idle mode bad fill. + * @details Inputs: badFillState + * @details Outputs: none + * @return the current state of generation idle mode bad fill + *************************************************************************/ +DG_GEN_IDLE_MODE_BAD_FILL_STATE_T getCurrentGenIdleBadFillState( void ) +{ + return badFillState; +} + +/*********************************************************************//** + * @brief * The requestDGStop function handles an HD request to stop (return to standby mode). * @details Inputs: none * @details Outputs: DG standby mode requested @@ -356,10 +368,9 @@ if ( FALSE == isAlarmActive( ALARM_ID_DG_FILL_CONDUCTIVITY_OUT_OF_RANGE ) ) { // Save the HD target fill volume before command 1000 mL fill volume - targetFillVolumeML = getTargetFillVolumeML(); + //targetFillVolumeML = getTargetFillVolumeML(); + state = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; - state = DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL; - // Start the flush fill startFillCmd( BAD_FLUSH_FILL_TARGET_VOLUME_ML, getTargetFillFlowRateLPM() ); } @@ -444,7 +455,7 @@ data.badFillSignal = (U32)handleBadFillFlag; data.badFillState = (U32)badFillState; data.genIdleState = (U32)getCurrentGenIdleState(); - data.targetFillVolumemL = targetFillVolumeML; + data.targetFillVolumemL = getTargetFillVolumeML(); broadcastData( MSG_ID_DG_GEN_IDLE_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( DG_GEN_IDLE_DATA_T ) ); Index: firmware/App/Modes/ModeGenIdle.h =================================================================== diff -u -r6499ea25921fcf67826fa0c35bb03caf411ba542 -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision 6499ea25921fcf67826fa0c35bb03caf411ba542) +++ firmware/App/Modes/ModeGenIdle.h (.../ModeGenIdle.h) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -48,6 +48,7 @@ void setBadAvgConductivityDetectedFlag( BOOL badAvgConducitivyflag ); // used by fill mode to signal idle mode of bad average conductivity 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 ); BOOL requestDGStop( void ); // HD requests DG stop (go back to standby mode) Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rbec5bb7634100c96341d19cf89e540a01aa86b1d -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -94,8 +94,7 @@ static U32 dataPublishCounter; ///< used to schedule reservoir data publication to CAN bus. static OVERRIDE_U32_T activeReservoir = { 0, 0, 0, 0 }; ///< The active reservoir that the DG is filling/draining/etc. -static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). - +static OVERRIDE_U32_T fillVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir fill volume (in mL). static OVERRIDE_U32_T drainVolumeTargetMl = { 0, 0, 0, 0 }; ///< The target reservoir drain volume (in mL). /// The reservoirs' associate load cell. @@ -367,9 +366,13 @@ // validate parameters if ( fillToVolMl < MAX_FILL_VOLUME_ML ) { - fillVolumeTargetMl.data = fillToVolMl; - cmdResponse.rejected = FALSE; + if ( getCurrentGenIdleBadFillState() != DG_HANDLE_BAD_FILL_STATE_FIRST_DRAIN ) + { + fillVolumeTargetMl.data = fillToVolMl; + } + cmdResponse.rejected = FALSE; + if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || // reject moving to fill mode if ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) // alarm is active { @@ -849,8 +852,15 @@ F32 loadcellWeight1 = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); F32 loadcellWeight2 = getLoadCellSmallFilteredWeight( redundantLoadCell[ reservoirId ] ); U32 targetFillVolume = getU32OverrideValue( &fillVolumeTargetMl ); - BOOL hasTargetReached = ( ( loadcellWeight1 >= targetFillVolume || loadcellWeight2 > ( targetFillVolume + MAX_REDUNDANT_LOAD_CELL_DIFF ) ) ? TRUE : FALSE ); + BOOL hasTargetReached = FALSE; + if ( DG_HANDLE_BAD_FILL_STATE_FLUSH_FILL == getCurrentGenIdleBadFillState() ) + { + targetFillVolume = BAD_FLUSH_FILL_TARGET_VOLUME_ML; + } + + hasTargetReached = ( ( loadcellWeight1 >= targetFillVolume || loadcellWeight2 > ( targetFillVolume + MAX_REDUNDANT_LOAD_CELL_DIFF ) ) ? TRUE : FALSE ); + // if redundant load cells too far apart at end of fill, alarm if ( loadcellWeight1 < targetFillVolume ) { @@ -934,6 +944,7 @@ *************************************************************************/ BOOL hasTargetDrainToVolumeBeenReached( DG_RESERVOIR_ID_T reservoirId, U32 targetVolumeML, U32 timeoutMS ) { + // NOTE: this function is used for testing only. No timeout is implemented right now. BOOL result = FALSE; F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 drainPumpFeedbackRPM = getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ); @@ -944,17 +955,6 @@ { result = TRUE; } - - if ( 0 == reservoirWeightUnchangeStartTime[ reservoirId ] ) - { - // This function is only used when drain is done to a non-zero target which is for testing only so using - // the current available variables was used. - reservoirWeightUnchangeStartTime[ reservoirId ] = getMSTimerCount(); - } - else if ( TRUE == didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeoutMS ) ) - { - result = TRUE; - } } return result; Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -rbec5bb7634100c96341d19cf89e540a01aa86b1d -r7e1358a440116fedad5a049d49c2d6f9be85d60e --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision bec5bb7634100c96341d19cf89e540a01aa86b1d) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 7e1358a440116fedad5a049d49c2d6f9be85d60e) @@ -35,7 +35,9 @@ #define MAX_RESERVOIR_VOLUME_ML 2000 ///< Maximum reservoir volume in mL. #define RESERVOIR_EXTRA_TEMPERATURE 2.0F ///< Reservoirs extra margin temperature. +#define BAD_FLUSH_FILL_TARGET_VOLUME_ML 1000 ///< Target fill volume in the bad flush fill state in millileters. + /// Fill command data structure. typedef struct {