Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r83e2e219e3a8aeea65d6dbaeea15c9498427fd78 -r86617288c49b57eca42cf2d0b67ade76e69f96bd --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 83e2e219e3a8aeea65d6dbaeea15c9498427fd78) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 86617288c49b57eca42cf2d0b67ade76e69f96bd) @@ -58,6 +58,8 @@ #define MAXIMUM_DIALYSATE_TEMPERATURE 42.0 ///< Maximum allowed dialysate temperature in degree C. #define MINIMUM_DIALYSATE_TEMPERATURE 33.0 ///< Minimum allowed dialysate temperature in degree C. +#define ONE_LITER_WEIGHT_GRAMS ( ML_PER_LITER ) ///< One liter weight in grams. + /// Multiplier to convert flow (L/min) into volume (mL) for period of general task interval. static const F32 RO_FLOW_INTEGRATOR = ( ( ML_PER_LITER * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ) ); @@ -69,6 +71,8 @@ static F32 totalROFlowRate_LPM; ///< Total RO flow rate over period of time. static U32 concentrateTestStartTime; ///< Starting time for concentrate test. static U32 waterQualityCheckStartTime; ///< Starting time for inlet water quality check. +static F32 dialysateConductivityTotal; ///< Total of dialysate conductivity during fill. +static U32 dialysateConductivitySampleCount; ///< Sample count of dialysate conductivity during fill. // ********** private function prototypes ********** @@ -97,6 +101,8 @@ reservoirBaseWeight = 0.0; totalROFlowRate_LPM = 0.0; concentrateTestStartTime = 0; + dialysateConductivityTotal = 0.0; + dialysateConductivitySampleCount = 0; initPersistentAlarm( ALARM_ID_ACID_CONDUCTIVITY_OUT_OF_RANGE, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS ); initPersistentAlarm( ALARM_ID_DIALYSATE_CONDUCTIVITY_OUT_OF_RANGE, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS ); @@ -396,9 +402,12 @@ *************************************************************************/ static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ) { + F32 avgDialysateConductivity; DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); totalROFlowRate_LPM += getMeasuredROFlowRate(); + dialysateConductivityTotal += getConductivityValue( CONDUCTIVITYSENSORS_CD2_SENSOR ); + dialysateConductivitySampleCount++; handleDialysateMixing(); @@ -410,6 +419,17 @@ #endif } + if ( getReservoirWeight( inactiveReservoir ) >= ONE_LITER_WEIGHT_GRAMS ) + { + avgDialysateConductivity = dialysateConductivityTotal / dialysateConductivitySampleCount; + + if ( ( avgDialysateConductivity < MIN_DIALYSATE_CONDUCTIVITY ) || ( avgDialysateConductivity > MAX_DIALYSATE_CONDUCTIVITY ) ) + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT, avgDialysateConductivity ); + requestNewOperationMode( DG_MODE_CIRC ); + } + } + // if we've reached our target fill to volume (by weight), we're done filling - go back to re-circ mode if ( hasTargetFillVolumeBeenReached( inactiveReservoir ) ) {