Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -racb534a5d5921959493304a26dbc21d2b03338e0 -r573a26b2a0273a4983b1de1cbff5bed63e01dce0 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision acb534a5d5921959493304a26dbc21d2b03338e0) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 573a26b2a0273a4983b1de1cbff5bed63e01dce0) @@ -65,6 +65,7 @@ static U32 balChamberFillCompleteStablePressureCounter; ///< Counter to check balancing chamber fill complete and stable pressure is met. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. static BOOL balanceChamberSwitchingOnly; ///< Balancing chamber switching without any pressure check and dosing delivery. +static BOOL isFirstCycleBCSwitchingCompleted; ///< Flag indicating that first time balancing chamber swithcing is done to trigger alarms from next cycle onwards. static OVERRIDE_F32_T acidDoseVolume; ///< Acid concentrate volume in ml ( overrideable). static OVERRIDE_F32_T bicarbDoseVolume; ///< Bicarb concentrate volume in ml ( overrideable). static F32 lastTdDialysateFlowrate; ///< Previous TD dialysate flow rate @@ -116,6 +117,7 @@ balChamberDataPublicationTimerCounter = 0; balChamberFillPressureDropCounter = 0; balChamberFillCompleteStablePressureCounter = 0; + isFirstCycleBCSwitchingCompleted = FALSE; } /*********************************************************************//** @@ -158,6 +160,9 @@ //Update last td dialysate flow rate lastTdDialysateFlowrate = tdDialysateFlowrate; + //Reset the BC switching flag for new Qd. + isFirstCycleBCSwitchingCompleted = FALSE; + //Update heater control on dialysate flow change signalHeaterControlOnQDUpdate( D5_HEAT ); @@ -396,8 +401,8 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); F32 acidVolume = getF32OverrideValue( &acidDoseVolume ); F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); + // Check fresh and spent dialysate pressure in range or BC switch only flag set - //TODO : comment the pressure check //if ( 1 ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || @@ -443,10 +448,18 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) { BAL_CHAMBER_EXEC_STATE_T state; - F32 freshDialPressure = getFilteredPressure( D18_PRES ); F32 spentDialPressure = getFilteredPressure( D51_PRES ); + if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) + { + state = BAL_CHAMBER_STATE1_BICARB_ACID_DOSING_CNTRL; + } + else + { + state = BAL_CHAMBER_STATE2_BICARB_ACID_DOSING_CNTRL; + } + // Pressure drop check during fill process helps to find if there is any issue with valves opening if ( ( freshDialPressure <= BC_FRESH_FILL_PRESSURE_PSIG ) && ( spentDialPressure <= BC_SPENT_FILL_PRESSURE_PSIG ) ) { @@ -494,7 +507,6 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - //TODO : comment the pressure check //if ( 1 ) //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && @@ -506,7 +518,6 @@ isPressureStalbilizedDuringFill = TRUE; isBalChamberFillInProgress = FALSE; } - // isPressureStalbilizedDuringFill = FALSE; } // Switching time met or pressure in range, close valves @@ -525,7 +536,7 @@ if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringFill ) + if ( ( TRUE != isPressureDroppedDuringFill ) && ( TRUE == isFirstCycleBCSwitchingCompleted ) ) { //#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. @@ -582,7 +593,6 @@ F32 bicarbVolume = getF32OverrideValue( &bicarbDoseVolume ); // Check fresh and spent dialysate pressure in range - //TODO : comment the pressure check //if ( 1 ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || @@ -636,7 +646,6 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - //TODO : comment the pressure check //if ( 1 ) //if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) if ( ( ( freshDialPressure >= FRESH_DIAL_PRESSURE_MIN_PSIG ) && ( freshDialPressure <= FRESH_DIAL_PRESSURE_MAX_PSIG ) ) && @@ -668,7 +677,7 @@ // Pressure alarm check if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringFill ) + if ( ( TRUE != isPressureDroppedDuringFill ) && ( TRUE == isFirstCycleBCSwitchingCompleted ) ) { //#ifdef ENABLE_ALARM_2 // When fill initiated, pressure is not dropped to the expected range, possible valve failures. @@ -686,6 +695,11 @@ { // Move to next state when pressure is in range. state = BAL_CHAMBER_STATE1_FILL_START; + + if ( FALSE == isFirstCycleBCSwitchingCompleted ) + { + isFirstCycleBCSwitchingCompleted = TRUE; + } } //TODO : Temporarily allow to proceed next state even though pressure is not stabilized.