Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -rfcd31ba31379396ba18db1a7e13b9f26d7837958 -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision fcd31ba31379396ba18db1a7e13b9f26d7837958) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -489,31 +489,15 @@ if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( balChamberExecState > BAL_CHAMBER_STATE_IDLE ) ) { -#ifdef CONDUCTIVE_LEVEL_SENSOR_ENABLED if ( LVL_STATE_LOW == bicarbChamberLevel ) { - if ( FALSE == setBicarbChamberFillRequested() ) + if ( FALSE == setBicarbChamberSupplyRequested() ) { // TODO //drybicart state machines are combined and so this is not an issue in future //set alarm ? } } -#else // time based chamber F fill - // Increment counter for dry bicarb chamber fill - bicarbChamberPeriodicFillCounter += 1; - // Fill bicarb chamber once every 60secs. - if ( bicarbChamberPeriodicFillCounter >= BICARB_CHAMBER_PERIODIC_FILL_TIME ) - { - if ( FALSE == setBicarbChamberFillRequested() ) - { - // TODO - //drybicart state machines are combined and so this is not an issue in future - //set alarm ? - } - bicarbChamberPeriodicFillCounter = 0; - } -#endif } switch ( balChamberExecState ) Index: firmware/App/Controllers/DryBiCart.c =================================================================== diff -u -rd513f36b5f073cab9dcb91db28f2b5bb6599eaf4 -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision d513f36b5f073cab9dcb91db28f2b5bb6599eaf4) +++ firmware/App/Controllers/DryBiCart.c (.../DryBiCart.c) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -32,6 +32,7 @@ #include "PersistentAlarm.h" #include "Pressure.h" #include "TaskGeneral.h" +#include "TDInterface.h" #include "TemperatureSensors.h" #include "Timers.h" #include "Valves.h" @@ -43,14 +44,14 @@ // ********** private definitions ********** -#define DRY_BICART_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the drybicart data published. -#define WCDI2_PRESSURE_OFFSET_PSI 7.0F ///< The difference between the actual pressure measured at bicart assembly using Alicat and the measured D66 pressure sensor for WCID2 +#define DRY_BICART_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the drybicart data published. +#define WCDI2_PRESSURE_OFFSET_PSI 10.0F ///< The difference between the actual pressure measured at bicart assembly using Alicat and the measured D66 pressure sensor for WCID2 #define WCID1_PRESSURE_OFFSET_PSI 1.0F ///< The difference between the actual pressure measured at bicart assembly using Alicat and the measured D66 pressure sensor for WCID1 #define DRY_BICART_PERSISTENCE_DURATION_MS 200 ///< Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. #define DRY_BICART_SUPPLY_PERSISTENCE_DURATION_MS 500 ///< Supply Fill persistence duration to overcome the pressure overshoot/ drop for beta 1.9 and above. // Dry Bicart Fill -#define DRY_BICART_FILL_COMPLETE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to reset the request flag after fill complete +//#define DRY_BICART_FILL_COMPLETE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to reset the request flag after fill complete #define DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCDI2_PRESSURE_OFFSET_PSI ) ///< The maximum pressure has been reached, indicating that the dry bicart fill for WCID2 is complete #define DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ( 10.0F + WCID1_PRESSURE_OFFSET_PSI ) ///< The maximum pressure has been reached, indicating that the dry bicart fill for WCID1 is complete @@ -60,9 +61,6 @@ #define GET_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ DRY_BICART_WCID2_FILL_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_FILL_COMPLETE_PRESSURE_PSI ) ///< Get fill complete pressure based on the WCID configuration -#define GET_SUPPLY_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ - DRY_BICART_WCID2_SUPPLY_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_SUPPLY_COMPLETE_PRESSURE_PSI ) ///< Get supply fill complete pressure based on the WCID configuration - #define DRY_BICART_FILL_INITIATE_PRESSURE_PSI 1.5F ///< Minimum pressure required to initiate the dry bicart fill process. #define DRY_BICART_FILL_COMPLETE_SUPPLY_PRESSURE_PSI 10.0F ///< Maximum pressure allowed at bicart fill during supply process/state #define DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI 4.0F ///< Minimum pressure required to initiate the dry bicart fill during supply process/state @@ -76,32 +74,29 @@ #define DRY_BICART_FILL_VENT_COMPLETE_PRESSURE_PSI 1.5F ///< Minimum Pressure to indicate the dry bicart venting being completed. // Bicarb chamber Supply/Vent -#ifdef CONDUCTIVE_LEVEL_SENSOR_ENABLED #define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 60 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill using level sensor -#else -#define DRY_BICART_SUPPLY_VALVE_D80_OPEN_TIME_MS ( 3 * MS_PER_SECOND ) ///< Max time allowed for supply (opening D80 valve) during bicarb chamber (F) fill time based fill -#endif -#define DRY_BICART_SUPPLY_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bicart gas before actuating Bicarb chamber(F) venting. -#define DRY_BICART_SUPPLY_VENT_MAX_TIME_MS ( 1 * MS_PER_SECOND ) ///< Max time to vent both dry bicart and Chamber F. +#define DRY_BICART_SUPPLY_VENT_TIME_MS ( 1 * MS_PER_SECOND ) ///< Wait time to vent dry bicart before actuating Bicarb chamber(F) venting. #define DRY_BICART_SUPPLY_COMPLETE_TIME_MS ( 2 * MS_PER_SECOND ) ///< Wait time to close the D80 valve after D65 is closed #define DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI 4.0F ///< Minimum decay pressure needed to end the supply process. #define DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ( 15 * SEC_PER_MIN * MS_PER_SECOND ) ///< Vent cycle time to initiate D85 opening. +#define GET_SUPPLY_FILL_COMPLETE_PRESSURE_PSI (getTestConfigStatus( TEST_CONFIG_DD_ENABLE_WCID_1 ) != TRUE ? \ + DRY_BICART_WCID2_SUPPLY_COMPLETE_PRESSURE_PSI : DRY_BICART_WCID1_SUPPLY_COMPLETE_PRESSURE_PSI ) ///< Get supply fill complete pressure based on the WCID configuration + + // Dry Bicart Drain -#define LARGE_DRY_BICART_MAX_DRAIN_TIME_MS ( 8 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for large dry bicart in ms. -#define SMALL_DRY_BICART_MAX_DRAIN_TIME_MS ( 4 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for small dry bicart in ms. +#define DRY_BICART_MAX_DRAIN_TIME_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Max drain time for small dry bicart in ms. #define DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ( 3 * MS_PER_SECOND ) ///< Time to stay in fluid drain per cycle -#define DRY_BICART_DRAIN_VENT_PHASE_TIME_MS ( 8 * MS_PER_SECOND ) ///< Time to keep D64 open per vent cycle -#define DRY_BICART_DRAIN_D18_PRESSURE_PSI 5 +#define DIAL_PUMP_DRAIN_D48_RPM 2500 ///< Nominal RPM target for dialysate pump D48 to drain the dry bicart. +#define DIAL_PUMP_DRAIN_D12_RPM 1600 ///< Nominal RPM target for dialysate pump D12 to drain the dry bicart. -#define DIAL_PUMP_DRAIN_D48_RPM 2500 ///< Nominal RPM target for dialysate pump D48 to drain the dry bicart. -#define DIAL_PUMP_DRAIN_D12_RPM 1600 ///< Nominal RPM target for dialysate pump D12 to drain the dry bicart. +#define INITIAL_FILL_PRESSURE_OUT_OF_RANGE_TIMEOUT_MS ( 3 * MS_PER_SECOND ) ///< Persistence period for initial fill d66 pressure out of range error in milliseconds. +#define INITIAL_FILL_PRESSURE_OUT_OF_RANGE_CLEAR_MS ( 3 * MS_PER_SECOND ) ///< Persistence period for initial fill d66 pressure out of range clear in milliseconds. +#define SUPPLY_FILL_PRESSURE_OUT_OF_RANGE_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< Persistence period for supply fill d66 pressure out of range error in milliseconds. +#define SUPPLY_FILL_PRESSURE_OUT_OF_RANGE_CLEAR_MS ( 30 * MS_PER_SECOND ) ///< Persistence period for supply fill d66 pressure out of range clear in milliseconds. -#define INLET_PRES_OUT_OF_RANGE_TIMEOUT_MS ( 3 * MS_PER_SECOND ) ///< Persistence period for d66 pressure out of range error in milliseconds. -#define INLET_PRES_OUT_OF_RANGE_CLEAR_MS ( 3 * MS_PER_SECOND ) ///< Persistence period for d66 pressure out of range clear in milliseconds. - /// Payload record structure for dry bicart fill request typedef struct { @@ -113,7 +108,7 @@ { DRY_BICART_IDLE = 0, ///< Dry bicart Idle DRY_BICART_INITIAL_FILL, ///< Dry bicart initial fill - DRY_BICART_SUPPLY, ///< Dry bicart chamber fill + DRY_BICART_SUPPLY, ///< Dry bicart chamber supply DRY_BICART_DRAIN, ///< Dry bicart drain DRY_BICART_DEPRESSURIZE, ///< Dry bicart depressurize NUM_OF_DRY_BICART_OPERATION ///< Number of dry bicart operation @@ -126,7 +121,7 @@ static U32 dryBiCartDataPublicationTimerCounter; ///< Used to schedule drybicart data publication to CAN bus. static DRY_BICART_FILL_EXEC_STATE_T dryBiCartFillExecState; ///< Current state of dry bicart fill executive state machine. -static BICARB_CHAMBER_FILL_EXEC_STATE_T bicarbChamberFillExecState; ///< Current state of bicarb chamber fill executive state machine. +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T bicarbChamberSupplyExecState; ///< Current state of bicarb chamber supply executive state machine. static DRY_BICART_DRAIN_EXEC_STATE_T dryBiCartDrainExecState; ///< Current state of dry bicart drain executive state machine static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T dryBiCartDepressurizeExecState; ///< Current state of dry bicart depressurize executive state machine @@ -138,18 +133,30 @@ static U32 currentFillDurationInMS; ///< Current time duration to fill the bicart fill. static OVERRIDE_U32_T biCartMaxFillCycleCount; ///< Maximum number of drybicart fill cycle ( overrideable) static BOOL dryBiCartFillVentTimeOut; ///< Vent time out flag +static U32 dryBiCartFillPersistenceStartTime; ///< Dry bicart fill Persistence time. +static U32 dryBiCartFillVentPersistenceStartTime; ///< Dry bicart Vent Persistence time. + // initiate the fill/supply/drain static OVERRIDE_U32_T dryBiCartFillRequested; ///< Start/stop dry bicart fill. -static OVERRIDE_U32_T bicarbChamberFillRequested; ///< Start/stop bicarb chamber fill. +static OVERRIDE_U32_T bicarbChamberSupplyRequested; ///< Start/stop bicarb chamber Supply. static OVERRIDE_U32_T dryBiCartDrainRequested; ///< Start/stop dry bicart drain. static OVERRIDE_U32_T dryBiCartDepressurizeRequested; ///< Start/stop dry bicart depressurize +// buffer for pending requests +static BOOL pendingBbicarbChamberSupplyRequest; ///< Pending bicarb chamber supply request while supply in progress // supply static U32 dryBiCarbSupplyStartTime; ///< Bicarb supply start time from bicart to Chamber F. static U32 dryBiCarbSypplyVentStartTime; ///< Bicarb supply vent start time for both bicart & Chamber F. static OVERRIDE_F32_T dryBiCartUpperCartPressure; ///< Upper cart pressure static OVERRIDE_F32_T dryBiCartLowerCartPressure; ///< Lower cart pressure +static U32 dryBiCartOceanSprayeDecayStartTime; ///< Ocean Spray decay start time +static U32 dryBiCartSupplyFillPersistenceStartTime; ///< Dry bicart supply fill Persistence time. +static U32 dryBiCartSupplyVentPersistenceStartTime; ///< Dry bicart supply fill Persistence time. +static U32 drybicartLowercartPressurePersistenceStartTime; ///< Dry bicart Persistence on lower cart pressure start time. +static U32 drybicartUppercartPressurePersistenceStartTime; ///< Dry bicart Persistence on upper cart pressure start time. +static U32 dryBiCartVentCycleStartTime; ///< Dry bicart Vent cycle start time. +static BOOL dryBiCartVentCycleWaitTimeStartedFlag; ///< Flag indicating venting cycle timer started for opening D85. // drain // cart selection for draining @@ -158,20 +165,9 @@ static U32 dryBiCartPumpStartStopStartTime ; ///< Pump start time (for delaying after valves are open) static U32 dryBiCartDrainTimePeriod; ///< Dry bicart drain time period. -static BOOL dryBiCartPressureDecayStartTimeFlag; ///< Dry bicart d66 pressure decay to 4 PSI start timer flag -static BOOL dryBiCartVentCycleWaitTimeStartedFlag; ///< Flag indicating venting cycle timer started for opening D85. - -static U32 dryBiCartFillPersistenceStartTime; ///< Dry bicart fill Persistence time. -static U32 dryBiCartFillVentPersistenceStartTime; ///< Dry bicart Vent Persistence time. -static U32 dryBiCartSupplyFillPersistenceStartTime; ///< Dry bicart supply fill Persistence time. -static U32 dryBiCartSupplyVentPersistenceStartTime; ///< Dry bicart supply fill Persistence time. -static U32 dryBiCartDepressurizePersistenceStartTime; ///< Dry bicart depressurize Persistence time. -static U32 drybicartLowercartPressurePersistenceStartTime; ///< Dry bicart Persistence on lower cart pressure start time. -static U32 drybicartUppercartPressurePersistenceStartTime; ///< Dry bicart Persistence on upper cart pressure start time. -static U32 dryBiCartVentCycleStartTime; ///< Dry bicart Vent cycle start time. - // depressurize static U32 dryBiCartDepressurizeStartTime; ///< Drain overall start time (for max timeout) +static U32 dryBiCartDepressurizePersistenceStartTime; ///< Dry bicart depressurize Persistence time. static DRY_BICART_OPERATION_T dryBicartStartRequest; ///< Dry bicart operation, fill or supply or drain request static DRY_BICART_OPERATION_T prevDryBicartState; ///< Dry BiCart State Change Tracker @@ -180,6 +176,7 @@ static void updateDrybicartOperation(void); // Fill & Vent +static void startDryBicartFill( void ); static void startDryBicartVent( void ); static void resetDryBicartFillRequest( void ); static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillIdleState( void ); @@ -195,14 +192,15 @@ static BOOL isDryBicartChamberFillWindowOpen( void ); static void updateValvesOnBalChamberSwitch( void ); static void resetBicarbChamberFillRequest( void ); -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyIdleState( void ); -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberCartridgeFillWaterState( void ); -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyState( void ); -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyVentState(void); +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyIdleState( void ); +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberCartridgeFillWaterState( void ); +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyState( void ); +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberOceanSprayDecayState( void ); +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyVentState(void); // Drain -static configureValvesForDrain( void ); -static terminateDrainSequence( void ); +static void configureValvesForDrain( void ); +static void terminateDrainSequence( void ); static void resetDryBicartDrainRequest( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainIdleState( void ); static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainState( void ); @@ -227,10 +225,10 @@ *************************************************************************/ void initDryBiCart( void ) { - dryBiCartFillExecState = DRY_BICART_FILL_IDLE_STATE; - bicarbChamberFillExecState = BICARB_CHAMBER_SUPPLY_IDLE_STATE; - dryBiCartDrainExecState = BICART_DRAIN_IDLE_STATE; - dryBiCartDepressurizeExecState = DRY_BICART_DEPRESSURIZE_IDLE_STATE; + dryBiCartFillExecState = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_IDLE; + bicarbChamberSupplyExecState = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; + dryBiCartDrainExecState = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_IDLE; + dryBiCartDepressurizeExecState = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_IDLE; dryBicartStartRequest = DRY_BICART_IDLE; prevDryBicartState = DRY_BICART_IDLE; @@ -254,10 +252,10 @@ dryBiCartDrainRequested.ovInitData = FALSE; dryBiCartDrainRequested.override = OVERRIDE_RESET; - bicarbChamberFillRequested.data = FALSE; - bicarbChamberFillRequested.ovData = FALSE; - bicarbChamberFillRequested.ovInitData = FALSE; - bicarbChamberFillRequested.override = OVERRIDE_RESET; + bicarbChamberSupplyRequested.data = FALSE; + bicarbChamberSupplyRequested.ovData = FALSE; + bicarbChamberSupplyRequested.ovInitData = FALSE; + bicarbChamberSupplyRequested.override = OVERRIDE_RESET; dryBiCartType.data = FALSE; dryBiCartType.ovData = FALSE; @@ -274,7 +272,6 @@ dryBiCartLowerCartPressure.ovInitData = 0.0F; dryBiCartLowerCartPressure.override = OVERRIDE_RESET; - dryBiCartPressureDecayStartTimeFlag = FALSE; dryBiCartVentCycleWaitTimeStartedFlag = FALSE; dryBiCartFillVentTimeOut = FALSE; dryBiCartVentCycleStartTime = 0; @@ -290,11 +287,15 @@ dryBiCartDrainTimePeriod = 0; dryBiCartFillPersistenceStartTime = 0; - //dryBiCartVentPersistenceStartTime = 0; + dryBiCartFillVentPersistenceStartTime = 0; drybicartLowercartPressurePersistenceStartTime = 0; drybicartUppercartPressurePersistenceStartTime = 0; + dryBiCartOceanSprayeDecayStartTime = 0; + dryBiCartSupplyFillPersistenceStartTime = 0; + dryBiCartSupplyVentPersistenceStartTime = 0; - initPersistentAlarm( ALARM_ID_DD_DRY_BICART_FILL_INLET_PRESSURE_LOW, INLET_PRES_OUT_OF_RANGE_TIMEOUT_MS, INLET_PRES_OUT_OF_RANGE_CLEAR_MS ); + initPersistentAlarm( ALARM_ID_DD_DRY_BICART_INITIAL_FILL_INLET_PRESSURE_LOW, INITIAL_FILL_PRESSURE_OUT_OF_RANGE_TIMEOUT_MS, INITIAL_FILL_PRESSURE_OUT_OF_RANGE_CLEAR_MS ); + initPersistentAlarm( ALARM_ID_DD_DRY_BICART_SUPPLY_FILL_INLET_PRESSURE_LOW, SUPPLY_FILL_PRESSURE_OUT_OF_RANGE_TIMEOUT_MS , SUPPLY_FILL_PRESSURE_OUT_OF_RANGE_CLEAR_MS ); } /*********************************************************************//** @@ -325,6 +326,7 @@ // top level state machine selection DRY_BICART_OPERATION_T dryBicartState = dryBicartStartRequest; + // TODO: it should be part of the pre-gen state hydChamberWaterInletControl(); switch ( dryBicartState ) @@ -386,19 +388,19 @@ // execute drybicart fill state machine switch ( dryBiCartFillExecState ) { - case DRY_BICART_FILL_IDLE_STATE: + case DRY_BICARBONATE_FILL_CARTRIDGE_STATE_IDLE: dryBiCartFillExecState = handleDryBicartFillIdleState(); break; - case DRY_BICART_FILL_WATER_STATE: + case DRY_BICARBONATE_FILL_CARTRIDGE_STATE_FILL_WATER: dryBiCartFillExecState = handleDryBicartFillWaterState(); break; - case DRY_BICART_VENT_STATE: + case DRY_BICARBONATE_FILL_CARTRIDGE_STATE_VENT: dryBiCartFillExecState = handleDryBicartVentState(); break; - case DRY_BICART_FILL_DURATION_CHECK_STATE: + case DRY_BICARBONATE_FILL_CARTRIDGE_STATE_DURATION_CHECK: dryBiCartFillExecState = handleDryBicartFillDurationCheckState(); break; @@ -423,30 +425,34 @@ U32 execBicarbChamberSupply( void ) { // execute bicarb chamber fill state machine - switch ( bicarbChamberFillExecState ) + switch ( bicarbChamberSupplyExecState ) { - case BICARB_CHAMBER_SUPPLY_IDLE_STATE: - bicarbChamberFillExecState = handleBicarbChamberSupplyIdleState(); + case BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE: + bicarbChamberSupplyExecState = handleBicarbChamberSupplyIdleState(); break; - case BICARB_CARTRIDGE_FILL_WATER_STATE: - bicarbChamberFillExecState = handleBicarbChamberCartridgeFillWaterState(); + case BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_FILL_WATER: + bicarbChamberSupplyExecState = handleBicarbChamberCartridgeFillWaterState(); break; - case BICARB_CHAMBER_SUPPLY_STATE: - bicarbChamberFillExecState = handleBicarbChamberSupplyState(); + case BICARBONATE_CHAMBER_SUPPLY_STATE_ACTIVE: + bicarbChamberSupplyExecState = handleBicarbChamberSupplyState(); break; - case BICARB_SUPPLY_VENT_STATE: - bicarbChamberFillExecState = handleBicarbChamberSupplyVentState(); + case BICARBONATE_CHAMBER_SUPPLY_STATE_OCEAN_SPRAY_DECAY: + bicarbChamberSupplyExecState = handleBicarbChamberOceanSprayDecayState(); break; + case BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_VENT: + bicarbChamberSupplyExecState = handleBicarbChamberSupplyVentState(); + break; + default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_BICARB_CHAMBER_FILL_INVALID_EXEC_STATE, bicarbChamberFillExecState ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_BICARB_CHAMBER_FILL_INVALID_EXEC_STATE, bicarbChamberSupplyExecState ); break; } - return bicarbChamberFillExecState; + return bicarbChamberSupplyExecState; } /*********************************************************************//** @@ -463,15 +469,15 @@ // execute drybicart drain state machine switch ( dryBiCartDrainExecState ) { - case BICART_DRAIN_IDLE_STATE: + case DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_IDLE: dryBiCartDrainExecState = handleDryBicartDrainIdleState(); break; - case BICART_DRAIN_STATE: + case DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DRAIN: dryBiCartDrainExecState = handleDryBicartDrainState(); break; - case BICART_DRAIN_DURATION_CHECK_STATE: + case DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DURATION_CHECK: dryBiCartDrainExecState = handleDryBicartDrainDurationCheckState(); break; @@ -497,11 +503,11 @@ // execute drybicart depressurize state machines switch ( dryBiCartDepressurizeExecState ) { - case DRY_BICART_DEPRESSURIZE_IDLE_STATE: + case DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_IDLE: dryBiCartDepressurizeExecState = handleDryBicartDepressurizeIdleState(); break; - case DRY_BICART_DEPRESSURIZE_STATE: + case DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_VENT: dryBiCartDepressurizeExecState = handleDryBicartDepressurizeState(); break; @@ -515,43 +521,60 @@ /*********************************************************************//** * @brief - * The setBicarbChamberFillRequested function sets the chmaberFillRequest + * The setbicarbChamberSupplyRequested function sets the chmaberFillRequest * flag value to be True. * @details \b Inputs: dryBiCartFillRequested, dryBiCartDrainRequested, - * dryBiCartDepressurizeRequested - * @details \b Outputs: bicarbChamberFillRequested + * bicarbChamberSupplyRequested, dryBiCartDepressurizeRequested + * @details \b Outputs: bicarbChamberSupplyRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ -BOOL setBicarbChamberFillRequested( void ) +BOOL setBicarbChamberSupplyRequested( void ) { BOOL result = FALSE; BOOL requestStatus = getU32OverrideValue( &dryBiCartFillRequested ) ||\ getU32OverrideValue( &dryBiCartDrainRequested ) || \ - getU32OverrideValue( &dryBiCartDepressurizeRequested ); + getU32OverrideValue( &dryBiCartDepressurizeRequested ) || \ + getU32OverrideValue( &bicarbChamberSupplyRequested ); // ensure that there is no other operation in progress before new request set to true if ( FALSE == requestStatus ) { - bicarbChamberFillRequested.data = TRUE; + // No operation in progress, safe to start immediately + bicarbChamberSupplyRequested.data = TRUE; result = TRUE; } + else + { + // supply is in progress, but instead of discarding, mark it as pending + if ( getU32OverrideValue( &bicarbChamberSupplyRequested ) ) + { + pendingBbicarbChamberSupplyRequest = TRUE; + // acknowledge that the request was queued + result = TRUE; + } + else + { + // reject or handle other conflicting requests + result = FALSE; + } + } return result; } /*********************************************************************//** * @brief - * The getBicarbChamberFillRequested function gets the chmaberFillRequest + * The getBicarbChamberSupplyRequested function gets the chmaberFillRequest * flag values - * @details \b Inputs: bicarbChamberFillRequested + * @details \b Inputs: bicarbChamberSupplyRequested * @details \b Outputs: none * @return TRUE if successful, FALSE if not. *************************************************************************/ -BOOL getBicarbChamberFillRequested( void ) +BOOL getBicarbChamberSupplyRequested( void ) { BOOL result = FALSE; - if ( (TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) ) + if ( (TRUE == getU32OverrideValue( &bicarbChamberSupplyRequested ) ) ) { result = TRUE; } @@ -561,57 +584,17 @@ /*********************************************************************//** * @brief - * The isDryBicartChamberFillWindowOpen function checks whether D65 may be - * opened for dry bicarb refill: fresh-side BC valves closed and BC switch not - * within the 50 ms valve-close window. - * @details \b Inputs: getBalChamberFreshSideValvesClosedStatus, isBalChamberSwitchImminent - * @details \b Outputs: none - * @return TRUE when the BC fill is completed and allow D65 to fill Chamber F - *************************************************************************/ -static BOOL isDryBicartChamberFillWindowOpen( void ) -{ - BOOL result = FALSE; - - if ( ( TRUE == getBalChamberFreshSideValvesClosedStatus() ) && - ( FALSE == isBalChamberSwitchImminent() ) ) - { - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The updateValvesOnBalChamberSwitch function closes D65 when the balancing - * chamber is within 100 ms of switching and open D80 - * @details \b Inputs: isBalChamberSwitchImminent - * @details \b Outputs: valve states - * @return none - *************************************************************************/ -static void updateValvesOnBalChamberSwitch( void ) -{ - if ( TRUE == isBalChamberSwitchImminent() ) - { - setValveState( D65_VALV, VALVE_STATE_CLOSED ); - // Open D80 only in supply state - setValveState( D80_VALV, VALVE_STATE_OPEN ); - } -} - -/*********************************************************************//** - * @brief * The setBicartFillRequested function sets the bicart fill request * flag value to be True. - * @details \b Inputs: bicarbChamberFillRequested, dryBiCartDrainRequested, + * @details \b Inputs: bicarbChamberSupplyRequested, dryBiCartDrainRequested, * dryBiCartDepressurizeRequested * @details \b Outputs: dryBiCartFillRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicartFillRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) \ + BOOL requestStatus = getU32OverrideValue( &bicarbChamberSupplyRequested ) \ || getU32OverrideValue( &dryBiCartDrainRequested ) || \ getU32OverrideValue( &dryBiCartDepressurizeRequested ) ; @@ -649,15 +632,15 @@ * @brief * The setBicartDrainRequested function sets the bicart drain request * flag value to be True. - * @details \b Inputs: bicarbChamberFillRequested,dryBiCartFillRequested, + * @details \b Inputs: bicarbChamberSupplyRequested,dryBiCartFillRequested, * dryBiCartDepressurizeRequested * @details \b Outputs: dryBiCartDrainRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicartDrainRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || \ + BOOL requestStatus = getU32OverrideValue( &bicarbChamberSupplyRequested ) || \ getU32OverrideValue( &dryBiCartFillRequested ) || \ getU32OverrideValue( &dryBiCartDepressurizeRequested ); @@ -695,14 +678,14 @@ * @brief * The setBicartDepressurizeRequested function sets the bicart depressurize request * flag value to be True. - * @details \b Inputs: bicarbChamberFillRequested,dryBiCartFillRequested,dryBiCartDrainRequested + * @details \b Inputs: bicarbChamberSupplyRequested,dryBiCartFillRequested,dryBiCartDrainRequested * @details \b Outputs: dryBiCartDepressurizeRequested * @return TRUE if successful, FALSE if not. *************************************************************************/ BOOL setBicartDepressurizeRequested( void ) { BOOL result = FALSE; - BOOL requestStatus = getU32OverrideValue( &bicarbChamberFillRequested ) || \ + BOOL requestStatus = getU32OverrideValue( &bicarbChamberSupplyRequested ) || \ getU32OverrideValue( &dryBiCartFillRequested ) || \ getU32OverrideValue( &dryBiCartDrainRequested ); @@ -751,22 +734,78 @@ /*********************************************************************//** * @brief - * The checkDryBicartInletPressure function check the persistence alarm + * The isDryBicartChamberFillWindowOpen function checks whether D65 may be + * opened for dry bicarb refill: fresh-side BC valves closed and BC switch not + * within the 50 ms valve-close window. + * @details \b Inputs: getBalChamberFreshSideValvesClosedStatus, isBalChamberSwitchImminent + * @details \b Outputs: none + * @return TRUE when the BC fill is completed and allow D65 to fill Chamber F + *************************************************************************/ +static BOOL isDryBicartChamberFillWindowOpen( void ) +{ + BOOL result = FALSE; + + if ( ( TRUE == getBalChamberFreshSideValvesClosedStatus() ) && + ( FALSE == isBalChamberSwitchImminent() ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The updateValvesOnBalChamberSwitch function closes D65 when the balancing + * chamber is within 100 ms of switching and open D80 + * @details \b Inputs: isBalChamberSwitchImminent + * @details \b Outputs: valve states + * @return none + *************************************************************************/ +static void updateValvesOnBalChamberSwitch( void ) +{ + if ( TRUE == isBalChamberSwitchImminent() ) + { + setValveState( D65_VALV, VALVE_STATE_CLOSED ); + // Open D80 only in supply state + setValveState( D80_VALV, VALVE_STATE_OPEN ); + } +} + +/*********************************************************************//** + * @brief + * The checkDryBicartInitialFillInletPressure function check the persistence alarm * @details \b Inputs: none * @details \b Outputs: none * @return none. *************************************************************************/ -void checkDryBicartInletPressure( ALARM_ID_T alarm, F32 lowerThreshold ) +void checkDryBicartInitialFillInletPressure( void ) { F32 pressureD66 = getFilteredPressure( D66_PRES ); - BOOL isPressureLowRange = ( ( pressureD66 < lowerThreshold ) ? TRUE : FALSE ); + BOOL isPressureLowRange = ( ( pressureD66 < DRY_BICART_FILL_INITIATE_PRESSURE_PSI ) ? TRUE : FALSE ); - checkPersistentAlarm( alarm, isPressureLowRange, pressureD66, lowerThreshold ); + checkPersistentAlarm( ALARM_ID_DD_DRY_BICART_INITIAL_FILL_INLET_PRESSURE_LOW, isPressureLowRange, pressureD66, DRY_BICART_FILL_INITIATE_PRESSURE_PSI ); } /*********************************************************************//** * @brief + * The checkDryBicartSupplyFillInletPressure function check the persistence alarm + * @details \b Inputs: none + * @details \b Outputs: none + * @return none. + *************************************************************************/ +void checkDryBicartSupplyFillInletPressure( void ) +{ + F32 pressureD66 = getFilteredPressure( D66_PRES ); + + BOOL isPressureLowRange = ( ( pressureD66 < DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI ) ? TRUE : FALSE ); + + checkPersistentAlarm( ALARM_ID_DD_DRY_BICART_SUPPLY_FILL_INLET_PRESSURE_LOW, isPressureLowRange, pressureD66, DRY_BICART_FILL_INITIATE_SUPPLY_PRESSURE_PSI ); +} + +/*********************************************************************//** + * @brief * The getDryBicartUpperCartPressure function gets the bicart upper threshold pressure * @details \b Inputs: dryBiCartUpperCartPressure * @details \b Outputs: none @@ -804,7 +843,7 @@ *************************************************************************/ static void updateDrybicartOperation(void) { - if ( TRUE == getBicarbChamberFillRequested() ) + if ( TRUE == getBicarbChamberSupplyRequested() ) { // supply dryBicartStartRequest = DRY_BICART_SUPPLY ; @@ -839,49 +878,61 @@ *************************************************************************/ static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillIdleState( void ) { - DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_IDLE_STATE; + DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_IDLE; if ( TRUE == getU32OverrideValue( &dryBiCartFillRequested ) ) { // TODO: pre gen should start the D12 pump and D14 valve setValveState( D14_VALV, VALVE_STATE_OPEN ); setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0, TRUE ); - // Close vent valves and de-scaling valve - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D81_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_CLOSED ); + startDryBicartFill(); - // Open D65 and D64 - setValveState( D65_VALV, VALVE_STATE_OPEN ); - setValveState( D64_VALV, VALVE_STATE_OPEN ); - - // Initiate timer to measure length of fill (ONLY ONCE) - dryBiCartFillStartTime = getMSTimerCount(); - - state = DRY_BICART_FILL_WATER_STATE; + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_FILL_WATER; } return state; } /*********************************************************************//** * @brief - * The handleDryBicartFillWaterStartState function initiates the water fill + * The startDryBicartFill function initiates the fill water * into dry bicarbonate cartridge. + * @details \b Inputs: dryBiCartFillStartTime + * @details \b Outputs: valve states + * @return none. + *************************************************************************/ +static void startDryBicartFill( void ) +{ + // Close vent valves and de-scaling valve + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D81_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_CLOSED ); + + // Open D65 and D64 + setValveState( D65_VALV, VALVE_STATE_OPEN ); + setValveState( D64_VALV, VALVE_STATE_OPEN ); + + // Initiate timer to measure length of fill (ONLY ONCE) + dryBiCartFillStartTime = getMSTimerCount(); +} + +/*********************************************************************//** + * @brief + * The handleDryBicartFillWaterState function wait for fill water complete * @details \b Inputs: dryBiCartFillPersistenceStartTime * @details \b Outputs: valve states, dryBiCartFillStartTime, lastFillDurationInMS, - * currentFillDurationInMS + * currentFillDurationInMS, biCartFillCycleCounter * @return the next drybicart fill water end state. *************************************************************************/ static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillWaterState( void ) { - DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_WATER_STATE; + DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_FILL_WATER; F32 d66Pressure = getFilteredPressure( D66_PRES ); F32 fillCompletePressure = GET_FILL_COMPLETE_PRESSURE_PSI; - checkDryBicartInletPressure(ALARM_ID_DD_DRY_BICART_FILL_INLET_PRESSURE_LOW, DRY_BICART_FILL_INITIATE_PRESSURE_PSI ); + checkDryBicartInitialFillInletPressure( ); // Close dry bicart inlet water if D66 pressure is equal to fill complete pressure if ( d66Pressure >= fillCompletePressure ) @@ -905,7 +956,7 @@ startDryBicartVent(); - state = DRY_BICART_VENT_STATE; + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_VENT; } } else @@ -937,7 +988,7 @@ /*********************************************************************//** * @brief - * The handleDryBicartDegasEndState function open vent valve present in + * The handleDryBicartVentState function open vent valve present in * the F Chamber (Bicarb) and closes the vent valve once pressure is met. * @details \b Inputs: D66 pressure sensor reading, dryBiCarbFillVentStartTime, * dryBiCartFillVentPersistenceStartTime @@ -946,7 +997,7 @@ *************************************************************************/ static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartVentState( void ) { - DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_VENT_STATE; + DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_VENT; F32 d66Pressure = getFilteredPressure( D66_PRES ); if ( TRUE == didTimeout( dryBiCarbFillVentStartTime, DRY_BICART_FILL_VENT_TIME_MS ) ) @@ -968,7 +1019,7 @@ setValveState( D85_VALV, VALVE_STATE_CLOSED ); dryBiCartFillVentPersistenceStartTime = 0; - state = DRY_BICART_FILL_DURATION_CHECK_STATE; + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_DURATION_CHECK; } } else if ( ( TRUE == didTimeout( dryBiCarbFillVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) @@ -977,7 +1028,7 @@ dryBiCartFillVentPersistenceStartTime = 0; dryBiCartFillVentTimeOut = TRUE; - state = DRY_BICART_FILL_DURATION_CHECK_STATE; + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_DURATION_CHECK; } else { @@ -1001,7 +1052,7 @@ *************************************************************************/ static DRY_BICART_FILL_EXEC_STATE_T handleDryBicartFillDurationCheckState( void ) { - DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICART_FILL_DURATION_CHECK_STATE; + DRY_BICART_FILL_EXEC_STATE_T state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_DURATION_CHECK; U32 dryBiCartMaxFillCount = getU32OverrideValue( &biCartMaxFillCycleCount ); F32 d66Pressure = getFilteredPressure( D66_PRES ); @@ -1017,14 +1068,18 @@ resetDryBicartFillRequest(); - state = DRY_BICART_FILL_IDLE_STATE; + setDialysatePumpTargetRPM( D12_PUMP, FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0, TRUE ); + + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_IDLE; } else { dryBiCartFillVentTimeOut = FALSE; + startDryBicartFill(); + // transition to next fill cycle and degas - state = DRY_BICART_FILL_WATER_STATE; + state = DRY_BICARBONATE_FILL_CARTRIDGE_STATE_FILL_WATER; } return state; @@ -1041,7 +1096,6 @@ *************************************************************************/ static void resetDryBicartFillRequest( void ) { - // TODO: in pre-gen, need to check the fill complete status currentFillDurationInMS = 0; lastFillDurationInMS = 0; biCartFillCycleCounter = 0; @@ -1072,23 +1126,20 @@ /*********************************************************************//** * @brief * The handleBicarbChamberSupplyIdleState function wait for bicarb chamber fill request - * @details \b Inputs: bicarbChamberFillRequested - * @details \b Outputs: dryBiCartVentCycleWaitTimeStartedFlag, dryBiCartPressureDecayStartTimeFlag, + * @details \b Inputs: bicarbChamberSupplyRequested + * @details \b Outputs: dryBiCartVentCycleWaitTimeStartedFlag * dryBiCartVentCycleStartTime. * @return the next drybicart fluid supply state. *************************************************************************/ -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyIdleState( void ) +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyIdleState( void ) { - BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_SUPPLY_IDLE_STATE; + BICARB_CHAMBER_SUPPLY_EXEC_STATE_T state = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; - dryBiCartPressureDecayStartTimeFlag = FALSE; - - if ( TRUE == getU32OverrideValue( &bicarbChamberFillRequested ) ) + if ( TRUE == getU32OverrideValue( &bicarbChamberSupplyRequested ) ) { - //startBicarbChamberCartridgeFillWaterSequence(); startBicarbChamberSupply(); - state = BICARB_CHAMBER_SUPPLY_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_ACTIVE; if ( FALSE == dryBiCartVentCycleWaitTimeStartedFlag ) { @@ -1108,39 +1159,35 @@ *************************************************************************/ static void startBicarbChamberCartridgeFillWaterSequence( void ) { - if ( TRUE == isDryBicartChamberFillWindowOpen() ) - { - // Close vent valves and descaling valve - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D81_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_CLOSED ); + // Close vent valves and descaling valve + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D81_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_CLOSED ); - // open inlet water to bicart only when fresh-side BC valves are closed - setValveState( D65_VALV, VALVE_STATE_OPEN ); - setValveState( D64_VALV, VALVE_STATE_OPEN ); + setValveState( D64_VALV, VALVE_STATE_OPEN ); - //startBicarbChamberSupply(); + dryBiCarbSupplyStartTime = getMSTimerCount(); + dryBiCartSupplyFillPersistenceStartTime = 0; - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCartSupplyFillPersistenceStartTime = 0; - } } /*********************************************************************//** * @brief * The handleBicarbChamberCartridgeFillWaterState function stops the inlet water to cartridge. - * @details \b Inputs: dryBiCartSupplyFillPersistenceStartTime + * @details \b Inputs: dryBiCartSupplyFillPersistenceStartTime, pendingBbicarbChamberSupplyRequest * @details \b Outputs: valve states * @return the next bicarb chamber check level state. *************************************************************************/ -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberCartridgeFillWaterState( void ) +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberCartridgeFillWaterState( void ) { - BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CARTRIDGE_FILL_WATER_STATE; + BICARB_CHAMBER_SUPPLY_EXEC_STATE_T state = BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_FILL_WATER; F32 d66Pressure = getFilteredPressure( D66_PRES ); F32 fillCompletePressure = GET_SUPPLY_FILL_COMPLETE_PRESSURE_PSI; LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); + checkDryBicartSupplyFillInletPressure(); + if ( FALSE == isDryBicartChamberFillWindowOpen() ) { setValveState( D65_VALV, VALVE_STATE_CLOSED ); @@ -1169,8 +1216,15 @@ // Return to idle resetBicarbChamberFillRequest(); - state = BICARB_CHAMBER_SUPPLY_IDLE_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; + if ( TRUE == pendingBbicarbChamberSupplyRequest ) + { + pendingBbicarbChamberSupplyRequest = FALSE; + + setBicarbChamberSupplyRequested(); + } + } } else @@ -1184,7 +1238,7 @@ // Force return to idle to allow next supply resetBicarbChamberFillRequest(); - state = BICARB_CHAMBER_SUPPLY_IDLE_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; } return state; @@ -1199,7 +1253,6 @@ *************************************************************************/ static void startBicarbChamberSupply( void ) { - // TODO: set supply in progress to inform BC control to disable alarm setValveState( D64_VALV, VALVE_STATE_OPEN ); // Open the Bicarb chamber inlet valve @@ -1208,27 +1261,24 @@ // Start a timer when bicarb supply started to chamber F dryBiCarbSupplyStartTime = getMSTimerCount(); - // TODO: alarm } /*********************************************************************//** * @brief - * The handleBicarbChamberPressureCheckStartState function actuates the vent valve - * present in the Bicart assembly. + * The handleBicarbChamberSupplyState function initiate the bicarbonate to the Chamber F * @details \b Inputs: dryBiCarbSupplyStartTime, dryBiCarbSypplyVentStartTime, * drybicartUppercartPressurePersistenceStartTime, - * bicarbChamberLevel, dryBiCartPressureDecayStartTimeFlag, - * drybicartLowercartPressurePersistenceStartTime + * bicarbChamberLevel, drybicartLowercartPressurePersistenceStartTime * @details \b Outputs: dryBiCarbSypplyVentStartTime, valve states * @return the next bicarb chamber Supply Vent Start state. *************************************************************************/ -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyState( void ) +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyState( void ) { - BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_CHAMBER_SUPPLY_STATE; + BICARB_CHAMBER_SUPPLY_EXEC_STATE_T state = BICARBONATE_CHAMBER_SUPPLY_STATE_ACTIVE; F32 d66Pressure = getFilteredPressure( D66_PRES ); LVL_STATE_T bicarbChamberLevel = getBicarbChamberLevelStatus(); - // Close D65 , open D85 irrespective of pressure for balancing chamber fresh side fill to complete. + // Close D65 , open D80 irrespective of pressure for balancing chamber fresh side fill to complete. updateValvesOnBalChamberSwitch(); // Once upper level reached high , close the valve, timeout is for safety in case level sensor didn't work(10 sec), or else its a time based filling (3 sec) @@ -1237,24 +1287,9 @@ { if ( TRUE == didTimeout( dryBiCartVentCycleStartTime, DRY_BICART_SUPPLY_VENT_CYCLE_TIME_MS ) ) { - // start the timer for d66 pressure decay - if ( FALSE == dryBiCartPressureDecayStartTimeFlag ) - { - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCartPressureDecayStartTimeFlag = TRUE; - } - // do not close the D80 valve, wait till d66 decays to supply decay complete pressure - if ( ( TRUE == didTimeout( dryBiCarbSupplyStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) || ( d66Pressure <= DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI ) ) - { - setValveState( D80_VALV, VALVE_STATE_CLOSED ); - setValveState( D64_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_OPEN ); + dryBiCartOceanSprayeDecayStartTime = getMSTimerCount(); - dryBiCarbSupplyStartTime = getMSTimerCount(); - dryBiCarbSypplyVentStartTime = getMSTimerCount(); - - state = BICARB_SUPPLY_VENT_STATE; - } + state = BICARBONATE_CHAMBER_SUPPLY_STATE_OCEAN_SPRAY_DECAY; } else { @@ -1265,7 +1300,7 @@ startBicarbChamberCartridgeFillWaterSequence(); - state = BICARB_CARTRIDGE_FILL_WATER_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_FILL_WATER; } } else if ( d66Pressure <= getDryBicartLowerCartPressure() ) @@ -1315,17 +1350,47 @@ /*********************************************************************//** * @brief + * The handleBicarbChamberOceanSprayDecayState function initiates D66 pressure + * decay ie. Ocean spray decay settling state prior to venting + * @details \b Inputs: dryBiCartSupplyFillPersistenceStartTime + * @details \b Outputs: valve states, dryBiCarbSypplyVentStartTime + * @return the next bicarb chamber check level state. + *************************************************************************/ +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberOceanSprayDecayState( void ) +{ + BICARB_CHAMBER_SUPPLY_EXEC_STATE_T state = BICARBONATE_CHAMBER_SUPPLY_STATE_OCEAN_SPRAY_DECAY; + + F32 d66Pressure = getFilteredPressure( D66_PRES ); + + // do not close the D80 valve, wait till d66 decays to supply decay complete pressure + if ( ( TRUE == didTimeout( dryBiCartOceanSprayeDecayStartTime, DRY_BICART_SUPPLY_COMPLETE_TIME_MS ) ) \ + || ( d66Pressure <= DRY_BICART_SUPPLY_DECAY_COMPLETE_PRESSURE_PSI ) ) + { + setValveState( D80_VALV, VALVE_STATE_CLOSED ); + setValveState( D64_VALV, VALVE_STATE_CLOSED ); + setValveState( D85_VALV, VALVE_STATE_OPEN ); + + dryBiCarbSypplyVentStartTime = getMSTimerCount(); + + state = BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_VENT; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleBicarbChamberSupplyVentState function actuates the vent valve * present in the Bicart assembly. * @details \b Inputs: dryBiCarbSypplyVentStartTime, dryBiCartSupplyVentPersistenceStartTime * @details \b Outputs: dryBiCarbSypplyVentStartTime,dryBiCartVentCycleWaitTimeStartedFlag, - * dryBiCartFillVentTimeOut, valve states + * dryBiCartFillVentTimeOut, valve states, pendingBbicarbChamberSupplyRequest * @return the next bicarb chamber Supply Vent End state. *************************************************************************/ -static BICARB_CHAMBER_FILL_EXEC_STATE_T handleBicarbChamberSupplyVentState(void) +static BICARB_CHAMBER_SUPPLY_EXEC_STATE_T handleBicarbChamberSupplyVentState(void) { - BICARB_CHAMBER_FILL_EXEC_STATE_T state = BICARB_SUPPLY_VENT_STATE; - F32 d66Pressure = getFilteredPressure( D66_PRES ); + BICARB_CHAMBER_SUPPLY_EXEC_STATE_T state = BICARBONATE_CHAMBER_SUPPLY_STATE_CARTRIDGE_VENT; + F32 d66Pressure = getFilteredPressure( D66_PRES ); if ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_SUPPLY_VENT_TIME_MS ) ) { @@ -1350,7 +1415,14 @@ resetBicarbChamberFillRequest(); - state = BICARB_CHAMBER_SUPPLY_IDLE_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; + + if ( TRUE == pendingBbicarbChamberSupplyRequest ) + { + pendingBbicarbChamberSupplyRequest = FALSE; + + setBicarbChamberSupplyRequested(); + } } } else if ( ( TRUE == didTimeout( dryBiCarbSypplyVentStartTime, DRY_BICART_FILL_VENT_MAX_TIME_MS ) ) ) @@ -1363,7 +1435,14 @@ resetBicarbChamberFillRequest(); - state = BICARB_CHAMBER_SUPPLY_IDLE_STATE; + state = BICARBONATE_CHAMBER_SUPPLY_STATE_IDLE; + + if ( TRUE == pendingBbicarbChamberSupplyRequest ) + { + pendingBbicarbChamberSupplyRequest = FALSE; + + setBicarbChamberSupplyRequested(); + } } else { @@ -1379,17 +1458,16 @@ * The resetBicarbChamberFillRequest function clears bicarb chamber fill * request. * @details \b Inputs: none - * @details \b Outputs: bicarbChamberFillRequested, dryBiCartPressureDecayStartTimeFlag, + * @details \b Outputs: bicarbChamberSupplyRequested * dryBicartStartRequest * @return BICARB_CHAMBER_START_STATE *************************************************************************/ static void resetBicarbChamberFillRequest( void ) { - bicarbChamberFillRequested.data = FALSE; + bicarbChamberSupplyRequested.data = FALSE; // for this request override also cleared - bicarbChamberFillRequested.ovData = FALSE; + bicarbChamberSupplyRequested.ovData = FALSE; - dryBiCartPressureDecayStartTimeFlag = FALSE; dryBicartStartRequest = DRY_BICART_IDLE; } @@ -1400,42 +1478,38 @@ * @details \b Outputs: valve states * @return None. *************************************************************************/ -static configureValvesForDrain() +static void configureValvesForDrain( void ) { //Close valves setValveState( D8_VALV, VALVE_STATE_CLOSED ); setValveState( D14_VALV, VALVE_STATE_CLOSED ); - setValveState( D34_VALV, VALVE_STATE_CLOSED ); + setValveState( D31_VALV, VALVE_STATE_CLOSED ); + setValveState( D35_VALV, VALVE_STATE_CLOSED ); setValveState( D40_VALV, VALVE_STATE_CLOSED ); + setValveState( D47_VALV, VALVE_STATE_CLOSED ); setValveState( D52_VALV, VALVE_STATE_CLOSED ); setValveState( D54_VALV, VALVE_STATE_CLOSED ); setValveState( D65_VALV, VALVE_STATE_CLOSED ); - setValveState( D34_VALV, VALVE_STATE_CLOSED ); - setValveState( D35_VALV, VALVE_STATE_CLOSED ); - setValveState( D40_VALV, VALVE_STATE_CLOSED ); setValveState( D80_VALV, VALVE_STATE_CLOSED ); setValveState( D81_VALV, VALVE_STATE_CLOSED ); - setValveState( D83_VALV, VALVE_STATE_CLOSED ); - setValveState( D85_VALV, VALVE_STATE_CLOSED ); + //TODO: D88 not defined + //setValveState( D88_VALV, VALVE_STATE_CLOSED ); setValveState( D91_VALV, VALVE_STATE_CLOSED ); + setValveState( D95_VALV, VALVE_STATE_CLOSED ); setValveState( D100_VALV, VALVE_STATE_CLOSED ); - // Open vent valves and supply valve - + // TODO: D83 will be updated to new valve D117 once new valve driver added setValveState( D83_VALV, VALVE_STATE_OPEN ); setValveState( D85_VALV, VALVE_STATE_OPEN ); - // Open D64 valve (vent for chamber F) setValveState( D64_VALV, VALVE_STATE_OPEN ); - // open bypass valve setValveState( D34_VALV, VALVE_STATE_OPEN ); // TODO: open iofp drain valve, remove, this should be handled in IO/FP module. setValveState( M12_VALV, VALVE_STATE_OPEN ); - // Open balancing chamber valves - //valveControlForBCOpenState(); + // Open balancing chamber spent side valves valveControlForBCSpentSideOnlyOpenState(); dryBiCartPumpStartStopStartTime = getMSTimerCount(); @@ -1451,24 +1525,17 @@ *************************************************************************/ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainIdleState( void ) { - DRY_BICART_DRAIN_EXEC_STATE_T state = BICART_DRAIN_IDLE_STATE; + DRY_BICART_DRAIN_EXEC_STATE_T state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_IDLE; if ( TRUE == getU32OverrideValue( &dryBiCartDrainRequested ) ) { - if ( TRUE == getU32OverrideValue( &dryBiCartType ) ) - { - dryBiCartDrainTimePeriod = LARGE_DRY_BICART_MAX_DRAIN_TIME_MS; - } - else - { - dryBiCartDrainTimePeriod = SMALL_DRY_BICART_MAX_DRAIN_TIME_MS; - } + dryBiCartDrainTimePeriod = DRY_BICART_MAX_DRAIN_TIME_MS; dryBiCartDrainStartTime = getMSTimerCount(); configureValvesForDrain(); - state = BICART_DRAIN_STATE; + state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DRAIN; } return state; @@ -1484,7 +1551,7 @@ *************************************************************************/ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainState( void ) { - DRY_BICART_DRAIN_EXEC_STATE_T state = BICART_DRAIN_STATE; + DRY_BICART_DRAIN_EXEC_STATE_T state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DRAIN; if ( TRUE == didTimeout( dryBiCartPumpStartStopStartTime, DRY_BICART_DRAIN_FLUID_PHASE_TIME_MS ) ) { @@ -1501,7 +1568,7 @@ dryBiCartDrainStartTime = getMSTimerCount(); } - state = BICART_DRAIN_DURATION_CHECK_STATE; + state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DURATION_CHECK; } return state; @@ -1514,7 +1581,7 @@ * @details \b Outputs: valve states, pumps state * @return None. *************************************************************************/ -static terminateDrainSequence( void ) +static void terminateDrainSequence( void ) { // Stop pumps requestConcentratePumpOff( D10_PUMP, FALSE ); @@ -1539,23 +1606,26 @@ /*********************************************************************//** * @brief - * The handleDryBicartFluidDrainDurationCheckState function determines drain complete by max timeout + * The handleDryBicartDrainDurationCheckState function determines drain complete by max timeout * @details \b Inputs: dryBiCartDrainStartTime * @details \b Outputs: none * @return the next drybicart drain idle state. *************************************************************************/ static DRY_BICART_DRAIN_EXEC_STATE_T handleDryBicartDrainDurationCheckState( void ) { - // switch back to DRY_BICART_FLUID_DRAIN_STATE if not fully drained or not timeout - DRY_BICART_DRAIN_EXEC_STATE_T state = BICART_DRAIN_DURATION_CHECK_STATE; + DRY_BICART_DRAIN_EXEC_STATE_T state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_DURATION_CHECK; - // Max drain time fall back, it is different for small and large bicart, - // 4 minutes for small bicart with full of water and 8 minutes for large bicart - // TODO: user settings should be derived for large and small dry bicart for drain time out - // right now dialin override is provided. + // if user request drain cancel + if ( TRUE == getTDDrainCancelRequest() ) + { + dryBiCartDrainStartTime = 0; + // clear the cancel request + setTDDrainCancelRequest( FALSE ); + } + if ( TRUE == didTimeout( dryBiCartDrainStartTime, dryBiCartDrainTimePeriod ) ) { - state = BICART_DRAIN_IDLE_STATE; + state = DRY_BICARBONATE_DRAIN_CARTRIDGE_STATE_IDLE; terminateDrainSequence(); @@ -1593,13 +1663,13 @@ *************************************************************************/ static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeIdleState( void ) { - DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICART_DEPRESSURIZE_IDLE_STATE; + DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_IDLE; if ( TRUE == getU32OverrideValue( &dryBiCartDepressurizeRequested ) ) { setValveState( D85_VALV, VALVE_STATE_OPEN ); - state = DRY_BICART_DEPRESSURIZE_STATE; + state = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_VENT; } return state; @@ -1615,7 +1685,7 @@ *************************************************************************/ static DRY_BICART_DEPRESSURIZE_EXEC_STATE_T handleDryBicartDepressurizeState( void ) { - DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICART_DEPRESSURIZE_STATE; + DRY_BICART_DEPRESSURIZE_EXEC_STATE_T state = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_VENT; F32 d66Pressure = getFilteredPressure( D66_PRES ); @@ -1640,7 +1710,7 @@ resetDryBicartDepressurizeRequest(); - state = DRY_BICART_DEPRESSURIZE_IDLE_STATE; + state = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_IDLE; } } else if ( ( TRUE == didTimeout( dryBiCartDepressurizeStartTime, DRY_BICART_DEPRESSURIZE_VENT_MAX_TIME_MS ) ) ) @@ -1651,7 +1721,7 @@ resetDryBicartDepressurizeRequest(); - state = DRY_BICART_DEPRESSURIZE_IDLE_STATE; + state = DRY_BICARBONATE_DEPRESSURIZE_CARTRIDGE_STATE_IDLE; } else { @@ -1696,13 +1766,13 @@ DRY_BICART_DATA_T data; data.dryBiCartFillExecState = (U32)dryBiCartFillExecState; - data.bicarbChamberFillExecState = (U32)bicarbChamberFillExecState; + data.bicarbChamberSupplyExecState = (U32)bicarbChamberSupplyExecState; data.dryBiCartDrainExecState = (U32)dryBiCartDrainExecState; data.dryBiCartDepressurizeExecState = (U32)dryBiCartDepressurizeExecState; data.dryBiCartFillCycleCounter = biCartFillCycleCounter; data.dryBiCartMaxFillCycleCount = getU32OverrideValue( &biCartMaxFillCycleCount ); data.dryBiCartFillRequest = getU32OverrideValue( &dryBiCartFillRequested ); - data.bicarbChamberFillRequest = getU32OverrideValue( &bicarbChamberFillRequested ); + data.bicarbChamberSupplyRequest = getU32OverrideValue( &bicarbChamberSupplyRequested ); data.dryBiCartDrainRequest = getU32OverrideValue( &dryBiCartDrainRequested ); data.dryBiCartDepressurizeRequest = getU32OverrideValue( &dryBiCartDepressurizeRequested ); data.dryBiCartLastFillTime = lastFillDurationInMS; @@ -1777,15 +1847,15 @@ * @brief * The testBiCarbChamberFillRequestOverride function starts/stops the bicarb * chamber F fill. - * @details \b Inputs: bicarbChamberFillRequested - * @details \b Outputs: bicarbChamberFillRequested + * @details \b Inputs: bicarbChamberSupplyRequested + * @details \b Outputs: bicarbChamberSupplyRequested * @param message set message from Dialin which includes the bicarb chamber * fill start/stop. * @return TRUE if set request is successful, FALSE if not *************************************************************************/ BOOL testBiCarbChamberFillRequestOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &bicarbChamberFillRequested, FALSE, TRUE ); + BOOL result = u32Override( message, &bicarbChamberSupplyRequested, FALSE, TRUE ); return result; } Index: firmware/App/Controllers/DryBiCart.h =================================================================== diff -u -rd513f36b5f073cab9dcb91db28f2b5bb6599eaf4 -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision d513f36b5f073cab9dcb91db28f2b5bb6599eaf4) +++ firmware/App/Controllers/DryBiCart.h (.../DryBiCart.h) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -24,7 +24,7 @@ /** * @defgroup DryBiCart DryBiCart * @brief DryBiCart unit. Performs dry bicarbonate cartridge fill, bicarb - * chamber(F) fill and cartridge draining functions via a state machine. + * chamber(F) supply and cartridge draining functions via a state machine. * * @addtogroup DryBiCart * @{ @@ -37,13 +37,13 @@ typedef struct { U32 dryBiCartFillExecState; ///< Dry bicart execution state - U32 bicarbChamberFillExecState; ///< Bicarb chamber Fill execution state + U32 bicarbChamberSupplyExecState; ///< Bicarb chamber supply execution state U32 dryBiCartDrainExecState; ///< Dry bicart drain execution state U32 dryBiCartDepressurizeExecState; ///< Dry bicart depressurize execution state U32 dryBiCartFillCycleCounter; ///< Dry bicart fill cycle counter U32 dryBiCartMaxFillCycleCount; ///< Dry bicart fill cycle max count U32 dryBiCartFillRequest; ///< Dry bicart fill request - U32 bicarbChamberFillRequest; ///< Bicarb chamber fill request + U32 bicarbChamberSupplyRequest; ///< Bicarb chamber supply request U32 dryBiCartDrainRequest; ///< Dry bicart drain request U32 dryBiCartDepressurizeRequest; ///< Dry bicart depressurize request U32 dryBiCartLastFillTime; ///< Dry bicart last fill duration in milli second @@ -62,8 +62,8 @@ U32 execDryBicartDrain( void ); U32 execDryBicartDepressurize( void ); void execDryBicart( void ); -BOOL setBicarbChamberFillRequested( void ); -BOOL getBicarbChamberFillRequested( void ); +BOOL setBicarbChamberSupplyRequested( void ); +BOOL getBicarbChamberSupplyRequested( void ); BOOL setBicartFillRequested( void ); BOOL setBicartDrainRequested( void ); BOOL setBicartDepressurizeRequested( void ); Index: firmware/App/DDCommon.h =================================================================== diff -u -rab0d10f8e78958ca0dba8b5e9abb5ab15eae132a -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/DDCommon.h (.../DDCommon.h) (revision ab0d10f8e78958ca0dba8b5e9abb5ab15eae132a) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -54,9 +54,6 @@ //Uncomment below if D1 placement is used for Temp control at dialyzer //#define __USE_D1_TEMP_ 1 -// comment below to disable bicarb multi level sensor for time based chamber F fill -#define CONDUCTIVE_LEVEL_SENSOR_ENABLED 1 - //Uncomment below to disable d30 heater alarm(as all units are not equipped with d30 temp sensor) #define __D30_TEMPERATURE_DISABLED__ 1 Index: firmware/App/Modes/ModeGenDialysate.h =================================================================== diff -u -rfcd31ba31379396ba18db1a7e13b9f26d7837958 -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision fcd31ba31379396ba18db1a7e13b9f26d7837958) +++ firmware/App/Modes/ModeGenDialysate.h (.../ModeGenDialysate.h) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -33,6 +33,7 @@ #define FRESH_DIAL_PUMP_INITIAL_RPM 2500 ///< Nominal RPM target for fresh dialysate pump to maintain required pressure. #define FRESH_DIAL_PUMP_INITIAL_RPM_B1_9_B2_0 1600 ///< Nominal RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. +#define FRESH_DIAL_PUMP_INITIAL_FILL_RPM 1250 ///< Initial Fill RPM target for fresh dialysate pump for beta 1.9 and 2.0 hardware. #define SPENT_DIAL_PUMP_INITIAL_RPM 2300 ///< Nominal RPM target for spent dialysate pump to maintain required pressure. #define DIAL_PUMP_DRAIN_RPM 1000 ///< Nominal RPM target for dialysate pump to drain the dry bicart. #define SPENT_DIAL_PUMP_FILL_RPM 200 ///< Nominal RPM target for spent chamber fill operations. Index: firmware/App/Modes/ModePreGenDialysate.c =================================================================== diff -u -rbd522c8ffdf75130571e5b6a79d1b1d6acd78b1c -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision bd522c8ffdf75130571e5b6a79d1b1d6acd78b1c) +++ firmware/App/Modes/ModePreGenDialysate.c (.../ModePreGenDialysate.c) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -42,13 +42,15 @@ #define PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pre-gen dialysate mode data published. #define HYD_CHAMBER_PRES_CHECK_TIME_OUT ( 30 * MS_PER_SECOND ) ///< Time out period when hydraulics chamber pressure check initiated #define NEG_PRES_PERSISTENCE_TIME_MS ( 1 * MS_PER_SECOND ) ///< Persistence time for Hydraulics chamber negative degassing pressure check. +#define DRY_BICART_INITIAL_FILL_REQUEST_TIME_MS ( 150 / TASK_GENERAL_INTERVAL ) ///< Wait time for the initial fill request // ********** private data ********** static DD_PRE_GEN_DIALYSATE_STATE_T preGenDialysateState; ///< Currently active pre-gen dialysate state. static DD_WET_SELF_TEST_STATE_T wetSelfTestState; ///< Currently active pre-gen Wet self test state. static U32 hydChamberPressureCheckStartTimeMS; ///< Current time when hydraulics chamber pressure check started in milliseconds. static U32 pressureCheckPersistanceStartTimeMS; ///< Current time for pressure check persistance time started in milliseconds. +static U32 dryBiCartInitialFillRequestStartTime; ///< Drybicart Initial Fill request wait time static BOOL pendingStartDDGenDialRequest; ///< Flag indicating TD has requested DD start the generation dialysate request. static BOOL pendingStopDDPreGenDialRequest; ///< Flag indicating TD has requested DD stop the pre generation dialysate. static U32 preGenDialysatePublishTimerCounter; ///< Pre-Gen Dialysate data broadcast timer counter used to schedule when to transmit data. @@ -81,6 +83,7 @@ wetSelfTestState = DD_WET_SELF_TEST_START; hydChamberPressureCheckStartTimeMS = 0; pressureCheckPersistanceStartTimeMS = 0; + dryBiCartInitialFillRequestStartTime = 0; pendingStartDDGenDialRequest = FALSE; pendingStopDDPreGenDialRequest = FALSE; preGenDialysateModePublishInterval.data = PRE_GEN_DIALYSATE_DATA_PUB_INTERVAL; @@ -273,10 +276,11 @@ //TODO: Change to wet self test state later DD_PRE_GEN_DIALYSATE_STATE_T state = DD_PRE_GEN_DRY_BICART_INITIAL_FILL; - if ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) + // need to wait for valve actuation from Idle state to Fill water state since starting and end state is Idle state + if ( ( FALSE == getTestConfigStatus( TEST_CONFIG_DD_DISABLE_DRY_BICARB ) ) && ( TRUE == didTimeout( dryBiCartInitialFillRequestStartTime, DRY_BICART_INITIAL_FILL_REQUEST_TIME_MS ) ) ) { // stay in this state till bicart fill complete. - if ( getCurrentDryBiCartFillExecState() == DRY_BICART_FILL_COMPLETE_STATE ) + if ( getCurrentDryBiCartFillExecState() == DRY_BICARBONATE_FILL_CARTRIDGE_STATE_IDLE ) { state = DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND; } Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -rbd522c8ffdf75130571e5b6a79d1b1d6acd78b1c -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision bd522c8ffdf75130571e5b6a79d1b1d6acd78b1c) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -104,6 +104,7 @@ static OVERRIDE_U32_T tdSodium; ///< TD Sodium concentrate static OVERRIDE_U32_T tdBicarbonate; ///< TD Bicarbonate concentrate static OVERRIDE_F32_T tdSubstitutionFlowRate; ///< TD Subsitution flow rate +static BOOL tdDrainCancel; ///< TD Drain Cancel request // ********** private function prototypes ********** @@ -123,6 +124,7 @@ tdSubMode = 0U; tdDialyzerBypass = FALSE; tdOpModeDataFreshFlag = FALSE; + tdDrainCancel = FALSE; // Initialize treatment parameters from TD tdDialysateFlowrate.data = 0.0F; @@ -338,6 +340,20 @@ /*********************************************************************//** * @brief + * The setTDDrainCancelRequest function sets the latest TD drain cancel request + * enable. + * @details \b Inputs: none + * @details \b Outputs: tdDrainCancel + * @param Drain Cancel. + * @return none. + *************************************************************************/ +void setTDDrainCancelRequest( BOOL drainCancel ) +{ + tdDrainCancel = drainCancel; +} + +/*********************************************************************//** + * @brief * The getTDDialysateFlowrate function gets the latest TD dialysate flow * rate. * @details \b Inputs: tdDialysateFlowrate @@ -387,6 +403,7 @@ { return getF32OverrideValue( &tdSubstitutionFlowRate ); } + /*********************************************************************//** * @brief * The getTDDialyzerBypass function gets the latest TD dailyzer bypass valve @@ -460,6 +477,18 @@ /*********************************************************************//** * @brief + * The getTDDrainCancelRequest function gets the latest TD Drain cancel request + * @details \b Inputs: tdDrainCancel + * @details \b Outputs: none + * @return Latest Drain cancel request + *************************************************************************/ +BOOL getTDDrainCancelRequest( void ) +{ + return tdDrainCancel; +} + +/*********************************************************************//** + * @brief * The handlePreGenDialysateRequestMsg function handles a pre gen dailysate * delivery request from TD to perform required self test and priming process. * @details Inputs: none Index: firmware/App/Services/TDInterface.h =================================================================== diff -u -rc992ffdef2060d3d534abd2538bfb31dd25b9fbc -r57bbf4b3e97f2c3e966eb1305aa30395ea61897d --- firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision c992ffdef2060d3d534abd2538bfb31dd25b9fbc) +++ firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision 57bbf4b3e97f2c3e966eb1305aa30395ea61897d) @@ -47,6 +47,7 @@ void setTDTargetDialysateTemperature( F32 dialTemperature ); void setTDDialyzerBypass( BOOL dialBypass ); void setTDAcidAndBicarbType( F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ); +void setTDDrainCancelRequest( BOOL drainCancel ); U32 getTDSubMode( void ); F32 getTDDialysateFlowrate( void ); F32 getTDUFRate( void ); @@ -56,6 +57,7 @@ F32 getTDBicarbConversionFactor( void ); U32 getTDSodiumConcentration( void ); U32 getTDBicarbonateConcentration( void ); +BOOL getTDDrainCancelRequest( void ); TD_OP_MODE_T getTDOpMode( void );