Index: firmware/App/Modes/BalancingChamber.c =================================================================== diff -u -rda2f672aa60ddf3a2ad40068313cfaac0b58bc5e -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision da2f672aa60ddf3a2ad40068313cfaac0b58bc5e) +++ firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -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" /** @@ -38,6 +41,13 @@ #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. @@ -50,6 +60,7 @@ 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 ********** @@ -80,6 +91,7 @@ balChamberDataPublishInterval.ovData = BAL_CHAMBER_DATA_PUBLISH_INTERVAL; balChamberDataPublishInterval.ovInitData = 0; balChamberDataPublishInterval.override = OVERRIDE_RESET; + balanceChamberSwitchingOnly = FALSE; balChamberSwitchingPeriod = 0; balChamberValveClosePeriod = 0; isBalChamberFillInProgress = FALSE; @@ -327,11 +339,12 @@ F32 freshDialPressure = getFilteredPressure( PRESSURE_SENSOR_FRESH_DIALYSATE ); F32 spentDialPressure = getFilteredPressure( PRESSURE_SENSOR_SPENT_DIALYSATE ); - // Check fresh and spent dialysate pressure in range + // 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 ) ) ) + //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(); @@ -362,11 +375,15 @@ { BAL_CHAMBER_EXEC_STATE_T state; - // start acid and bicarb pump with the expected quantity - setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP1_ACID, CONCENTRATE_PUMP_MAX_SPEED, TEST_ACID_VOLUME_ML ); - setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, CONCENTRATE_PUMP_MAX_SPEED, TEST_BICARB_VOLUME_ML ); - requestConcentratePumpOn( CONCENTRATEPUMPS_CP1_ACID ); - requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); + // Deliver dosing during generate dialysate mode + if ( FALSE == getBalChamberSwitchingOnlyStatus() ) + { + // start acid and bicarb pump with the expected quantity + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP1_ACID, CONCENTRATE_PUMP_MAX_SPEED, TEST_ACID_VOLUME_ML ); + setConcentratePumpTargetSpeed( CONCENTRATEPUMPS_CP2_BICARB, CONCENTRATE_PUMP_MAX_SPEED, TEST_BICARB_VOLUME_ML ); + requestConcentratePumpOn( CONCENTRATEPUMPS_CP1_ACID ); + requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); + } // On triggering of dosing, transition to next state based on the current switching state if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) @@ -409,7 +426,7 @@ // 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 ) ) { @@ -424,7 +441,8 @@ // 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 ); @@ -466,7 +484,8 @@ //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 ) ) ) + // ( ( spentDialPressure >= SPENT_DIAL_PRESSURE_MIN_PSIG ) && ( spentDialPressure <= SPENT_DIAL_PRESSURE_MAX_PSIG ) ) || + // ( TRUE == getBalChamberSwitchingOnlyStatus() ) ) { // Valve control for state 2 fill valveControlForBCState2FillStart(); @@ -527,7 +546,8 @@ // 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 ); @@ -594,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 @@ -635,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 ) ); @@ -682,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; +} + /**@}*/ Index: firmware/App/Modes/BalancingChamber.h =================================================================== diff -u -r77f16abd083c385b3ed9cb0c41a60dff7295022c -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Modes/BalancingChamber.h (.../BalancingChamber.h) (revision 77f16abd083c385b3ed9cb0c41a60dff7295022c) +++ firmware/App/Modes/BalancingChamber.h (.../BalancingChamber.h) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -46,6 +46,7 @@ BOOL isBalChamberFillInProgress; ///< Whether balancing chamber fill in progress or not U32 currentBalChamberSwitchingCounter; ///< Current balancing chamber switching counter BOOL isPressureStalbilizedDuringFill; ///< Whether pressure stabilized during fill or not + BOOL balChamberSWOnlyState; ///< Balancing chamber switching only status ( On/Off) } BAL_CHAMBER_DATA_T; // ********** public function prototypes ********** @@ -61,9 +62,12 @@ BOOL getBalancingChamberFillinProgressStatus( void ); // Get the balancing chamber fill in progress status void valveControlForBCClosedState( void ); // Closes all balancing chamber valves void valveControlForBCOpenState( void ); // Open all balancing chamber valves +BOOL getBalChamberSwitchingOnlyStatus( void ); // Get balancing chamber switching only status +void setBalChamberSwitchingOnlyStatus( BOOL OnOff ); // Set balancing chamber switching only status BOOL testDDBalChamberDataPublishIntervalOverride( MESSAGE_T *message ); // To override the balancing chamber data publish interval BOOL testBalChamberSwFreqOverride( MESSAGE_T *message ); // To override the balancing chamber switching frequency +BOOL testBCSwitchOnlyStartStopOverride( MESSAGE_T *message ); // To override the balancning chamber switching only start/stop control /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r62adb12dba3ca647a28460a98c63db425b492bf3 -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 62adb12dba3ca647a28460a98c63db425b492bf3) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "BalancingChamber.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "Heaters.h" @@ -43,6 +44,7 @@ static DD_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. static OVERRIDE_U32_T pendingStartDDRequest; ///< Flag indicating TD has requested DD start the dialysis delivery(Overridable). +static BOOL pendingBalanceChamberSwOnlyRequest; ///< Flag indicating balancing chamber switch only request. //static BOOL pendingStartDDFlushRequest; ///< Flag indicating TD has requested DD start flush. //static BOOL pendingStartDDHeatDisinfectRequest; ///< Flag indicating TD has requested DD start heat disinfect. //static BOOL pendingStartDDHeatDisinfectActiveCoolRequest; ///< Flag indicating TD has requested DD start heat disinfect active cool. @@ -67,6 +69,7 @@ pendingStartDDRequest.ovData = FALSE; pendingStartDDRequest.ovInitData = FALSE; pendingStartDDRequest.override = OVERRIDE_RESET; + pendingBalanceChamberSwOnlyRequest = FALSE; // pendingStartDDFlushRequest = FALSE; // pendingStartDDHeatDisinfectRequest = FALSE; // pendingStartDDHeatDisinfectActiveCoolRequest = FALSE; @@ -199,6 +202,11 @@ pendingStartDDRequest.data = FALSE; requestNewOperationMode( DD_MODE_GEND ); } + //Test request to handle only balancing chamber switching + else if ( TRUE == pendingBalanceChamberSwOnlyRequest ) + { + execBalancingChamberControl(); + } // else if ( TRUE == pendingStartDDFlushRequest ) // { // pendingStartDDFlushRequest = FALSE; @@ -265,6 +273,42 @@ /*********************************************************************//** * @brief + * The requestBCSwitchingOnlyStart function handles Balancing chamber switching + * only start request. + * @details \b Inputs: standbyState + * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestBCSwitchingOnlyStart( void ) +{ + BOOL result = FALSE; + + if ( DD_STANDBY_MODE_STATE_IDLE == standbyState ) + { + result = TRUE; + pendingBalanceChamberSwOnlyRequest = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The requestBCSwitchingOnlyStop function handles Balancing chamber switching + * only stop request. + * @details \b Inputs: standbyState + * @details \b Outputs: pendingBalanceChamberSwOnlyRequest + * @return none. + *************************************************************************/ +void requestBCSwitchingOnlyStop( void ) +{ + pendingBalanceChamberSwOnlyRequest = FALSE; + // Close all balancing chamber valves + valveControlForBCClosedState(); +} + +/*********************************************************************//** + * @brief * The startDDFlush function starts DD flush mode. * @details \b Inputs: standbyState * @details \b Outputs: none Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -46,6 +46,8 @@ BOOL areInletWaterConditionsAlarmsActive( void ); // checks water inlet pressure, temperature and conductivity alarms. BOOL requestDDStart( void ); // TD requests DD start (go to generation dialysate mode) +BOOL requestBCSwitchingOnlyStart( void ); // request to start performing balancing chamber switching only without dosing/pressure validation +void requestBCSwitchingOnlyStop( void ); // request to stop balancing chamber switching only without dosing/pressure validation BOOL startDDFlush( void ); // TD start flush mode BOOL startDDHeatDisinfect( void ); // TD start heat disinfect mode Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r95e32e6462b952f744f77c7e56f00bffdf8ec5bd -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 95e32e6462b952f744f77c7e56f00bffdf8ec5bd) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -145,6 +145,7 @@ MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST, MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST, #endif + MSG_ID_DD_BC_SWITCH_ONLY_START_STOP_OVERRIDE_REQUEST, }; /// Message handling function table @@ -209,6 +210,7 @@ &testDDPistonPumpControlDataPublishIntervalOverride, &testDDPistonPumpStartStopOverride, #endif + &testBCSwitchOnlyStartStopOverride, }; #define NUM_OF_FUNCTION_HANDLERS (sizeof(MSG_FUNCTION_HANDLERS) / sizeof(MsgFuncPtr)) Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -rbce6e6d1cfb6e8a0b186419416460ead3a44e5e1 -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision bce6e6d1cfb6e8a0b186419416460ead3a44e5e1) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -35,7 +35,6 @@ // ********** private definitions ********** #define TD_DATA_FRESHNESS_TIMEOUT_MS ( 3 * MS_PER_SECOND ) ///< TD data freshness timeout (in ms). -#define TD_MAX_DIALYSIS_FLOW_RATE ( 600.0F ) ///< TD Max dialysis flow rate // ********** private data ********** @@ -67,7 +66,7 @@ // Initialize unit variables tdCurrentOpMode = MODE_INIT; tdSubMode = 0; - tdDialysateFlowrate = TD_MAX_DIALYSIS_FLOW_RATE; // Will update later based on the TD value + tdDialysateFlowrate = MAX_DIALYSIS_FLOW_RATE; // Will update later based on the TD value tdUFRate = 0.0F; tdTargetDialysateTemp = 0.0F; tdDialyzerBypass = FALSE; Index: firmware/App/Services/TDInterface.h =================================================================== diff -u -rbce6e6d1cfb6e8a0b186419416460ead3a44e5e1 -r015acf2ae3ec46adbdd2f1028f01831418f1733d --- firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision bce6e6d1cfb6e8a0b186419416460ead3a44e5e1) +++ firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision 015acf2ae3ec46adbdd2f1028f01831418f1733d) @@ -33,8 +33,9 @@ // ********** public definitions ********** +#define MIN_DIALYSIS_FLOW_RATE ( 100.0F ) ///< TD minimum dialysis flow rate +#define MAX_DIALYSIS_FLOW_RATE ( 600.0F ) ///< TD Max dialysis flow rate - // ********** public function prototypes ********** void initTDInterface( void );