Index: firmware/App/Modes/BalancingChamber.c =================================================================== diff -u -r9102c5da21a15bdaf4bb3bc38795ceb064e3c443 -rbc30c54270ec51f947b129da3c7daad54ec4eb5f --- firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision 9102c5da21a15bdaf4bb3bc38795ceb064e3c443) +++ firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision bc30c54270ec51f947b129da3c7daad54ec4eb5f) @@ -19,11 +19,14 @@ #include "Conductivity.h" #include "ConcentratePumps.h" #include "FpgaDD.h" +#include "ModeStandby.h" +#include "Messaging.h" #include "OperationModes.h" #include "Pressure.h" -#include "Temperature.h" -#include "TDInterface.h" #include "TaskGeneral.h" +#include "TDInterface.h" +#include "Temperature.h" +#include "TestSupport.h" #include "Valves.h" /** @@ -34,23 +37,30 @@ // ********** private definitions ********** #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. -#define FRESH_DIAL_PRESSURE_MIN_PSIG 23.0F ///< Minimum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. -#define FRESH_DIAL_PRESSURE_MAX_PSIG 25.0F ///< Maximum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MIN_PSIG 29.0F ///< Minimum spent dialysate pressure (PDs) limit for balancing chamber fill operations. -#define SPENT_DIAL_PRESSURE_MAX_PSIG 30.0F ///< Maximum spent dialysate pressure (PDs) limit for balancing chamber fill operations. #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. +#define TEST_ACID_VOLUME_ML 0.67F ///< Acid concentrate volume in ml. +#define TEST_BICARB_VOLUME_ML 1.15F ///< Bicarb concentrate volume in ml. +/// Payload record structure for balancing chamber switch only request +typedef struct +{ + U32 startStop; ///< balancing chamber switching only start:1 and stop: 0 + F32 flowrate; ///< dialysate flowrate in ml/min +} BC_SWITCHING_ONLY_START_CMD_PAYLOAD_T; + // ********** private data ********** static BAL_CHAMBER_EXEC_STATE_T balChamberExecState; ///< Current balancing chamber executive state. static OVERRIDE_F32_T balChamberSwitchingFreq; ///< Balancing chamber switching rate ( switches per min) based on the dialysate flow rate ( overrideable) static U32 balChamberSwitchingPeriod; ///< Periodic balancing chamber switching time in task interval count. +static U32 balChamberValveClosePeriod; ///< Close balancing chamber valves with the defined time prior switching state. 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 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. +static BOOL balanceChamberSwitchingOnly; ///< Balancing chamber switching without any pressure check and dosing delivery. // ********** private function prototypes ********** @@ -81,7 +91,9 @@ balChamberDataPublishInterval.ovData = BAL_CHAMBER_DATA_PUBLISH_INTERVAL; balChamberDataPublishInterval.ovInitData = 0; balChamberDataPublishInterval.override = OVERRIDE_RESET; + balanceChamberSwitchingOnly = FALSE; balChamberSwitchingPeriod = 0; + balChamberValveClosePeriod = 0; isBalChamberFillInProgress = FALSE; currentBalChamberSwitchingCounter = 0; isPressureStalbilizedDuringFill = FALSE; @@ -120,6 +132,10 @@ // finish the balancing chamber fill 50 ms prior completing the regular cycle time. balChamberSwitchingPeriod -= 1; + + //Testing + balChamberValveClosePeriod = balChamberSwitchingPeriod; + balChamberValveClosePeriod -= 1; // Close valves prior 50 msecond for testing } /*********************************************************************//** @@ -132,11 +148,8 @@ *************************************************************************/ U32 execBalancingChamberControl( void ) { - // Increment counter during fill time only, Also check dialysate needs to be bypassed. - if ( TRUE == isBalChamberFillInProgress ) - { - currentBalChamberSwitchingCounter += 1; - } + // Increment counter indicating fill is in progress. + currentBalChamberSwitchingCounter += 1; // execute current balancing chamber exec state switch ( balChamberExecState ) @@ -191,17 +204,17 @@ *************************************************************************/ static void valveControlForBCState1FillStart( void ) { - // Close balancing chamber valve combinations V1,V6 and V4,V7 - setValveState( BCV1, VALVE_STATE_CLOSED ); - setValveState( BCV6, VALVE_STATE_CLOSED ); - setValveState( BCV4, VALVE_STATE_CLOSED ); - setValveState( BCV7, VALVE_STATE_CLOSED ); + // Close balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D20_VALV, VALVE_STATE_CLOSED ); + setValveState( D21_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); - //Open balancing chamber valve combinations V2,V5 and V3,V8 - setValveState( BCV2, VALVE_STATE_OPEN ); - setValveState( BCV5, VALVE_STATE_OPEN ); - setValveState( BCV3, VALVE_STATE_OPEN ); - setValveState( BCV8, VALVE_STATE_OPEN ); + //Open balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D24_VALV, VALVE_STATE_OPEN ); + setValveState( D25_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); } /*********************************************************************//** @@ -214,11 +227,11 @@ *************************************************************************/ static void valveControlForBCState1FillEnd( void ) { - //Close balancing chamber valve combinations V2,V5 and V3,V8 - setValveState( BCV2, VALVE_STATE_CLOSED ); - setValveState( BCV5, VALVE_STATE_CLOSED ); - setValveState( BCV3, VALVE_STATE_CLOSED ); - setValveState( BCV8, VALVE_STATE_CLOSED ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); } /*********************************************************************//** @@ -231,17 +244,17 @@ *************************************************************************/ static void valveControlForBCState2FillStart( void ) { - //Close balancing chamber valve combinations V2,V5 and V3,V8 - setValveState( BCV2, VALVE_STATE_CLOSED ); - setValveState( BCV5, VALVE_STATE_CLOSED ); - setValveState( BCV3, VALVE_STATE_CLOSED ); - setValveState( BCV8, VALVE_STATE_CLOSED ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); - // Open balancing chamber valve combinations V1,V6 and V4,V7 - setValveState( BCV1, VALVE_STATE_OPEN ); - setValveState( BCV6, VALVE_STATE_OPEN ); - setValveState( BCV4, VALVE_STATE_OPEN ); - setValveState( BCV7, VALVE_STATE_OPEN ); + // Open balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D26_VALV, VALVE_STATE_OPEN ); } /*********************************************************************//** @@ -254,11 +267,11 @@ *************************************************************************/ static void valveControlForBCState2FillEnd( void ) { - // Close balancing chamber valve combinations V1,V6 and V4,V7 - setValveState( BCV1, VALVE_STATE_CLOSED ); - setValveState( BCV6, VALVE_STATE_CLOSED ); - setValveState( BCV4, VALVE_STATE_CLOSED ); - setValveState( BCV7, VALVE_STATE_CLOSED ); + // Close balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D20_VALV, VALVE_STATE_CLOSED ); + setValveState( D21_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); } /*********************************************************************//** @@ -271,17 +284,17 @@ *************************************************************************/ void valveControlForBCClosedState( void ) { - // Close balancing chamber valve combinations V1,V6 and V4,V7 - setValveState( BCV1, VALVE_STATE_CLOSED ); - setValveState( BCV6, VALVE_STATE_CLOSED ); - setValveState( BCV4, VALVE_STATE_CLOSED ); - setValveState( BCV7, VALVE_STATE_CLOSED ); + // Close balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_CLOSED ); + setValveState( D20_VALV, VALVE_STATE_CLOSED ); + setValveState( D21_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); - //Close balancing chamber valve combinations V2,V5 and V3,V8 - setValveState( BCV2, VALVE_STATE_CLOSED ); - setValveState( BCV5, VALVE_STATE_CLOSED ); - setValveState( BCV3, VALVE_STATE_CLOSED ); - setValveState( BCV8, VALVE_STATE_CLOSED ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); } /*********************************************************************//** @@ -294,17 +307,17 @@ *************************************************************************/ void valveControlForBCOpenState( void ) { - // Open balancing chamber valve combinations V1,V6 and V4,V7 - setValveState( BCV1, VALVE_STATE_OPEN ); - setValveState( BCV6, VALVE_STATE_OPEN ); - setValveState( BCV4, VALVE_STATE_OPEN ); - setValveState( BCV7, VALVE_STATE_OPEN ); + // Open balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D26_VALV, VALVE_STATE_OPEN ); - //Open balancing chamber valve combinations V2,V5 and V3,V8 - setValveState( BCV2, VALVE_STATE_OPEN ); - setValveState( BCV5, VALVE_STATE_OPEN ); - setValveState( BCV3, VALVE_STATE_OPEN ); - setValveState( BCV8, VALVE_STATE_OPEN ); + //Open balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D24_VALV, VALVE_STATE_OPEN ); + setValveState( D25_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); } /*********************************************************************//** @@ -323,12 +336,15 @@ isPressureStalbilizedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE1; - F32 freshDialPressure = getFilteredPressure( PRESSURE_SENSOR_FRESH_DIALYSATE ); - F32 spentDialPressure = getFilteredPressure( PRESSURE_SENSOR_SPENT_DIALYSATE ); + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); - // Check fresh and spent dialysate pressure in range - 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 ) ) ) + // 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 ) ) || + // ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { //Valve control for state 1 fill valveControlForBCState1FillStart(); @@ -358,9 +374,18 @@ static BAL_CHAMBER_EXEC_STATE_T handleBalChamberConcentrateControl( void ) { BAL_CHAMBER_EXEC_STATE_T state; - // TODO : start acid and bicarb pump with the expected quantity - // On completion of dosing, transition to next state based on the current switching state + // Deliver dosing during generate dialysate mode + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + { + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( D11_PUMP, CONCENTRATE_PUMP_MAX_SPEED, TEST_ACID_VOLUME_ML ); + setConcentratePumpTargetSpeed( D10_PUMP, CONCENTRATE_PUMP_MAX_SPEED, TEST_BICARB_VOLUME_ML ); + requestConcentratePumpOn( D11_PUMP ); + requestConcentratePumpOn( D10_PUMP ); + } + + // On triggering of dosing, transition to next state based on the current switching state if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { state = BAL_CHAMBER_STATE1_FILL_END; @@ -385,32 +410,46 @@ { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE1_FILL_END; - F32 freshDialPressure = getFilteredPressure( PRESSURE_SENSOR_FRESH_DIALYSATE ); - F32 spentDialPressure = getFilteredPressure( PRESSURE_SENSOR_SPENT_DIALYSATE ); + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - 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 ) ) ) + //TODO : comment the pressure check + //if ( 1 ) + if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) + //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 ) ) ) { // stabilized pressure indicating fill is complete + //TODO : due to pressure testing override, comment the code below for now isPressureStalbilizedDuringFill = TRUE; + // isPressureStalbilizedDuringFill = FALSE; } - // Swithcing time met or pressure in range, close valves + // Switching time met or pressure in range, close valves if ( ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) || ( TRUE == isPressureStalbilizedDuringFill ) ) { // close the state 1 opened valves valveControlForBCState1FillEnd(); + + //Stop the concentrate pumps + requestConcentratePumpOff( D11_PUMP, NO_PARK_CONC_PUMPS ); + requestConcentratePumpOff( D10_PUMP, NO_PARK_CONC_PUMPS ); } // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { - if ( TRUE != isPressureStalbilizedDuringFill ) + if ( ( TRUE != isPressureStalbilizedDuringFill ) && + ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) { // Alarm when switching time expired, but still pressure not in range, SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE1_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + + //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. + isBalChamberFillInProgress = FALSE; + state = BAL_CHAMBER_STATE2_FILL_START; } else { @@ -438,12 +477,15 @@ isPressureStalbilizedDuringFill = FALSE; balChamberSWState = BAL_CHAMBER_SW_STATE2; - F32 freshDialPressure = getFilteredPressure( PRESSURE_SENSOR_FRESH_DIALYSATE ); - F32 spentDialPressure = getFilteredPressure( PRESSURE_SENSOR_SPENT_DIALYSATE ); + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure in range - 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 ) ) ) + //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 ) ) || + // ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { // Valve control for state 2 fill valveControlForBCState2FillStart(); @@ -473,15 +515,20 @@ { BAL_CHAMBER_EXEC_STATE_T state = BAL_CHAMBER_STATE2_FILL_END; - F32 freshDialPressure = getFilteredPressure( PRESSURE_SENSOR_FRESH_DIALYSATE ); - F32 spentDialPressure = getFilteredPressure( PRESSURE_SENSOR_SPENT_DIALYSATE ); + F32 freshDialPressure = getFilteredPressure( D18_PRES ); + F32 spentDialPressure = getFilteredPressure( D51_PRES ); // Check fresh and spent dialysate pressure back in range to indicate fill complete. - 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 ) ) ) + //TODO : comment the pressure check + //if ( 1 ) + if ( currentBalChamberSwitchingCounter >= balChamberValveClosePeriod ) + //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 ) ) ) { // stabilized pressure indicating fill is complete + //TODO : due to pressure testing override, comment the code below for now isPressureStalbilizedDuringFill = TRUE; + //isPressureStalbilizedDuringFill = FALSE; } // Check switching cycle time or pressure check for valve closure @@ -490,15 +537,24 @@ { // close the valves valveControlForBCState2FillEnd(); + + //Stop the concentrate pumps + requestConcentratePumpOff( D11_PUMP, NO_PARK_CONC_PUMPS ); + requestConcentratePumpOff( D10_PUMP, NO_PARK_CONC_PUMPS ); } // On completion of cycle time, transition to next state if ( currentBalChamberSwitchingCounter >= balChamberSwitchingPeriod ) { - if ( TRUE != isPressureStalbilizedDuringFill ) + if ( ( TRUE != isPressureStalbilizedDuringFill ) && + ( FALSE == getBalChamberSwitchingOnlyStatus() ) ) { // Alarm when switching time expired, but still pressure not in range, SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DD_BC_STATE2_FILL_END_PRESSURE_OUT_OF_RANGE, freshDialPressure, spentDialPressure ); + + //TODO : Temporarily allow to proceed next state even though pressure is not stabilized. + isBalChamberFillInProgress = FALSE; + state = BAL_CHAMBER_STATE1_FILL_START; } else { @@ -558,6 +614,33 @@ /*********************************************************************//** * @brief + * The setBalChamberSwitchingOnlyStatus function sets the balancing chamber + * switching only On/Off status. + * @details \b Inputs: balanceChamberSwitchingOnly + * @details \b Outputs: none + * @return none + *************************************************************************/ +void setBalChamberSwitchingOnlyStatus( BOOL OnOff ) +{ + balanceChamberSwitchingOnly = OnOff; +} + +/*********************************************************************//** + * @brief + * The getBalChamberSwitchingOnlyStatus function gets the balancing chamber + * switching only status. + * @details \b Inputs: balanceChamberSwitchingOnly + * @details \b Outputs: none + * @return balancing chamber switching only without any pressure validation + * and dosing delivery + *************************************************************************/ +BOOL getBalChamberSwitchingOnlyStatus( void ) +{ + return balanceChamberSwitchingOnly; +} + +/*********************************************************************//** + * @brief * The getBalChamberDataPublishInterval function gets the balancing chamber * data publish interval. * @details \b Inputs: balChamberDataPublishInterval @@ -599,6 +682,7 @@ data.isBalChamberFillInProgress = isBalChamberFillInProgress; data.currentBalChamberSwitchingCounter = currentBalChamberSwitchingCounter; data.isPressureStalbilizedDuringFill = isPressureStalbilizedDuringFill; + data.balChamberSWOnlyState = balanceChamberSwitchingOnly; broadcastData( MSG_ID_DD_BAL_CHAMBER_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( BAL_CHAMBER_DATA_T ) ); @@ -646,4 +730,56 @@ return result; } +/*********************************************************************//** + * @brief + * The testBCSwitchOnlyStartStopOverride function starts/stops balancing + * chamber switching only without dosing delivery and pressure check condition. + * @details \b Inputs: tester logged in + * @details \b Outputs: tdDialysateFlowrate,balanceChamberSwitchingOnly + * pendingBalanceChamberSwOnlyRequest + * @param message set message from Dialin which includes the balancing chamber + * to start/stop switching and update switching rate based on the flow rate. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testBCSwitchOnlyStartStopOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify tester has logged in with TD + if ( TRUE == isTestingActivated() ) + { + // Verify payload length is valid + if ( sizeof( BC_SWITCHING_ONLY_START_CMD_PAYLOAD_T ) == message->hdr.payloadLen ) + { + BC_SWITCHING_ONLY_START_CMD_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(BC_SWITCHING_ONLY_START_CMD_PAYLOAD_T) ); + + // Handle start command + if ( ( TRUE == payload.startStop ) && + ( ( payload.flowrate >= MIN_DIALYSIS_FLOW_RATE ) && ( payload.flowrate <= MAX_DIALYSIS_FLOW_RATE ) ) ) + { + // First set BC switching frequency based on the dialysate flow rate + setTDDialysateFlowrate( payload.flowrate ); + // then set BC switching only flag to ignore pressure check and dosing. + setBalChamberSwitchingOnlyStatus( TRUE ); + // Now, if the current operating mode is standby mode idle state, execute the balancing chamber switching only control + result = requestBCSwitchingOnlyStart(); + } + + //Handle stop command + if ( FALSE == payload.startStop ) + { + //Reset the flag + setBalChamberSwitchingOnlyStatus( FALSE ); + //Stop the BC switching execution only control + requestBCSwitchingOnlyStop(); + result = TRUE; + } + } + } + + return result; +} + /**@}*/