Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r75ecd5ee8a56b8d9faef07cdeb0a8dc7975ff476 -r5126b79e4970ffe2ed9db4cccea18a1216c78570 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 75ecd5ee8a56b8d9faef07cdeb0a8dc7975ff476) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 5126b79e4970ffe2ed9db4cccea18a1216c78570) @@ -56,8 +56,7 @@ static U32 currentBalChamberSwitchingCounter; ///< Counter (in task interval) to monitor the timing spent during balancing chamber fill/drain operation. static BOOL isBalChamberFillInProgress; ///< Flag indicating balancing chamber fill/drain is in progress. static BOOL isPressureStalbilizedDuringFill; ///< Flag indicating that the pressure is stablized due to fill complete. -static BOOL isPressureDroppedDuringState1Fill; ///< Flag indicating that the pressure is dropped due to BC state 1 fill in progress condition. -static BOOL isPressureDroppedDuringState2Fill; ///< Flag indicating that the pressure is dropped due to BC state 2 fill in progress condition. +static BOOL isPressureDroppedDuringFill; ///< Flag indicating that the pressure is dropped due to BC fill (state 1 or state 2) in progress condition. static BAL_CHAMBER_SW_STATE_T balChamberSWState; ///< Current balancing chamber switching state ( state 1 or state 2). static U32 balChamberDataPublicationTimerCounter; ///< Used to schedule balancing chamber data publication to CAN bus. static OVERRIDE_U32_T balChamberDataPublishInterval; ///< Balancing chamber data publish interval. @@ -371,7 +370,7 @@ currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; isPressureStalbilizedDuringFill = FALSE; - isPressureDroppedDuringState1Fill = FALSE; + isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE1; F32 freshDialPressure = getFilteredPressure( D18_PRES ); @@ -392,7 +391,7 @@ isBalChamberFillInProgress = TRUE; // Deliver dosing during generate dialysate mode - if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { // start acid and bicarb pump with the expected quantity setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidVolume ); @@ -417,7 +416,7 @@ * The handleBalChamberConcentrateControl function handles the Acid and Bicarb * concentrate doisng and checks the conductivity of the dialysate for the treatment. * @details \b Inputs: balChamberSWState , Concentrate volume - * @details \b Outputs: state + * @details \b Outputs: isPressureDroppedDuringFill, state * @return next balancing chamber state. *************************************************************************/ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) @@ -428,22 +427,14 @@ F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Pressure drop check during fill process helps to find if there is any issue with valves opening - if ( ( ( freshDialPressure >= BC_FILL_PRESSURE_MAX_PSIG ) && ( freshDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) && - ( ( spentDialPressure >= BC_FILL_PRESSURE_MAX_PSIG ) && ( spentDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) ) + if ( ( freshDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= BC_FILL_PRESSURE_MIN_PSIG ) ) { - if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) - { - isPressureDroppedDuringState1Fill = TRUE; - } - else - { - isPressureDroppedDuringState2Fill = TRUE; - } + isPressureDroppedDuringFill = TRUE; } // On dosing completion, transition to next state based on the current switching state - if ( ( ( TRUE == getConcentratePumpDosingStatus( D11_PUMP ) ) && - ( TRUE == getConcentratePumpDosingStatus( D10_PUMP ) ) ) || + if ( ( ( TRUE == isConcentratePumpDosingCompleted( D11_PUMP ) ) && + ( TRUE == isConcentratePumpDosingCompleted( D10_PUMP ) ) ) || ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) @@ -502,9 +493,9 @@ // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { - if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringState1Fill ) + if ( TRUE != isPressureDroppedDuringFill ) { // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); @@ -548,7 +539,7 @@ currentBalChamberSwitchingCounter = 0; isBalChamberFillInProgress = FALSE; isPressureStalbilizedDuringFill = FALSE; - isPressureDroppedDuringState2Fill = FALSE; + isPressureDroppedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; F32 freshDialPressure = getFilteredPressure( D18_PRES ); @@ -570,7 +561,7 @@ isBalChamberFillInProgress = TRUE; // Deliver dosing during generate dialysate mode - if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { // start acid and bicarb pump with the expected quantity setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, acidVolume ); @@ -633,9 +624,9 @@ if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { // Pressure alarm check - if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + if ( TRUE != getBalChamberSwitchingOnlyStatus() ) { - if ( TRUE != isPressureDroppedDuringState2Fill ) + if ( TRUE != isPressureDroppedDuringFill ) { // When fill initiated, pressure is not dropped to the expected range, possible valve failures. SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_PRESSURE_DROP_OUT_OF_RANGE, freshDialPressure, spentDialPressure );