Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r594e11a544c7d3f97f057a2d4c146f464e437948 -r9c3746ecf75ef64d6fc0e0e9510af9d84763cb18 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 594e11a544c7d3f97f057a2d4c146f464e437948) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 9c3746ecf75ef64d6fc0e0e9510af9d84763cb18) @@ -404,45 +404,43 @@ handleDialysateMixing(); - if ( ( TRUE == checkDialysateConductivity() ) && ( TRUE == checkDialysateTemperature() ) ) + if ( ( checkDialysateConductivity() != TRUE ) || ( checkDialysateTemperature() != TRUE ) ) { - if ( getReservoirWeight( inactiveReservoir ) >= ONE_LITER_WEIGHT_GRAMS ) - { - avgDialysateConductivity = dialysateConductivityTotal / dialysateConductivitySampleCount; +#ifndef DISABLE_DIALYSATE_CHECK + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + result = DG_FILL_MODE_STATE_DIALYSATE_PRODUCTION; +#endif + } - if ( ( avgDialysateConductivity < MIN_DIALYSATE_CONDUCTIVITY ) || ( avgDialysateConductivity > MAX_DIALYSATE_CONDUCTIVITY ) ) - { + if ( getReservoirWeight( inactiveReservoir ) >= ONE_LITER_WEIGHT_GRAMS ) + { + avgDialysateConductivity = dialysateConductivityTotal / dialysateConductivitySampleCount; + + if ( ( avgDialysateConductivity < MIN_DIALYSATE_CONDUCTIVITY ) || ( avgDialysateConductivity > MAX_DIALYSATE_CONDUCTIVITY ) ) + { #ifndef DISABLE_DIALYSATE_CHECK - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT, avgDialysateConductivity ); - requestNewOperationMode( DG_MODE_CIRC ); + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT, avgDialysateConductivity ); + requestNewOperationMode( DG_MODE_CIRC ); #endif - } } + } - // if we've reached our target fill to volume (by weight), we're done filling - go back to re-circ mode - if ( TRUE == hasTargetFillVolumeBeenReached( inactiveReservoir ) ) - { - F32 const filledVolume_mL = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; - F32 const integratedVolume_mL = totalROFlowRate_LPM * RO_FLOW_INTEGRATOR * ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER; - F32 const integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolume_mL / integratedVolume_mL ) ); + // if we've reached our target fill to volume (by weight), we're done filling - go back to re-circ mode + if ( TRUE == hasTargetFillVolumeBeenReached( inactiveReservoir ) ) + { + F32 const filledVolume_mL = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; + F32 const integratedVolume_mL = totalROFlowRate_LPM * RO_FLOW_INTEGRATOR * ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER; + F32 const integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolume_mL / integratedVolume_mL ) ); - if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) - { + if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) + { #ifndef DISABLE_MIXING - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FLOW_METER_CHECK_FAILURE, filledVolume_mL, integratedVolume_mL ); + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FLOW_METER_CHECK_FAILURE, filledVolume_mL, integratedVolume_mL ); #endif - } - - requestNewOperationMode( DG_MODE_CIRC ); } + + requestNewOperationMode( DG_MODE_CIRC ); } - else - { -#ifndef DISABLE_DIALYSATE_CHECK - setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - result = DG_FILL_MODE_STATE_DIALYSATE_PRODUCTION; -#endif - } return result; }