Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r9d20238b17f5c9089db526fd65c32c19927c6c0c -r53d2eecfd8e4393f14ba3c24ca8d668619834a3a --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 9d20238b17f5c9089db526fd65c32c19927c6c0c) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 53d2eecfd8e4393f14ba3c24ca8d668619834a3a) @@ -46,9 +46,9 @@ /// TODO: Restore to 100 when DPi flow control is fixed. #define DIP_PATIENT_CONNECTION_FLOW_RATE_ML_MIN 250 ///< Patient connection sub-mode dialysate inlet pump flow rate in mL/min. -#define PRE_TREATMENT_MIN_FILL_RESERVOIR_VOLUME_ML 125 ///< Fill reservoir to this volume minimum to prep volume during development. +#define PRE_TREATMENT_MIN_RESERVOIR_VOLUME_ML 400 ///< Fill reservoir to this volume minimum to prep volume during development. #define PRE_TREATMENT_FLUSH_RESERVOIR_VOLUME_ML 500 ///< Fill reservoir to this volume (in mL) to flush filter and lines. -#define PRE_TREATMENT_FILL_RESERVOIR_ONE_VOLUME_ML 1200 ///< Fill reservoir one to this volume (in mL) during pre-treatment mode, prep for wet test. +#define PRE_TREATMENT_FILL_RESERVOIR_ONE_VOLUME_ML 1200 ///< Fill reservoir one to this volume (in mL) during pre-treatment mode. #define PRE_TREATMENT_FILL_RESERVOIR_TWO_VOLUME_ML 600 ///< Fill reservoir two to this volume (in mL) during pre-treatment mode. #define PRE_TREATMENT_FULL_RESERVOIR_VOLUME_ML 1500 ///< Fill reservoir to this volume minimum to prep volume during development. @@ -92,12 +92,12 @@ static HD_PRE_TREATMENT_MODE_STATE_T currentPreTreatmentState; ///< Current state of pre-treatment mode state machine. static BOOL fillReservoirOneStartRequested; ///< Flag indicates fill reservoir one has been requested. static U32 preTreatmentPublishTimerCounter; ///< Pre-treatment data broadcast timer counter used to schedule when to transmit data. - /// Interval (in task intervals) at which to publish pre-treatment mode data to CAN bus. static OVERRIDE_U32_T preTreatmentModePublishInterval = { PRE_TREATMENT_DATA_PUB_INTERVAL, PRE_TREATMENT_DATA_PUB_INTERVAL, PRE_TREATMENT_DATA_PUB_INTERVAL, 0 }; static U32 submodeCompleteTransitionTimeCounter; ///< Sub-mode completed transition wait time counter. static PRE_TREATMENT_RESERVOIR_MGMT_STATE_T currentReservoirMgmtState; ///< Current pre-treatment reservoir management state. +static DG_RESERVOIR_ID_T activeReservoir = DG_RESERVOIR_2; static PRE_TREATMENT_RESERVOIR_VAR_T reservoirStatus[ NUM_OF_DG_RESERVOIRS ]; ///< Detailed state of each reservoir. #ifndef _RELEASE_ @@ -925,6 +925,9 @@ *************************************************************************/ static void execPreTreatmentReservoirMgmt( void ) { + // update the active reservoir. + activeReservoir = getDGActiveReservoir(); + // treatment reservoir mgmt. state machine switch ( currentReservoirMgmtState ) { @@ -1009,7 +1012,6 @@ PRE_TREATMENT_RESERVOIR_MGMT_STATE_T state = PRE_TREATMENT_RESERVOIR_MGMT_DRAIN_CMD_STATE; DG_OP_MODE_T dgOpMode = getDGOpMode(); U32 dgSubMode = getDGSubMode(); - DG_RESERVOIR_ID_T activeReservoir = getDGActiveReservoir(); // If DG has not started yet, start DG if ( DG_MODE_STAN == dgOpMode ) @@ -1085,39 +1087,25 @@ DG_OP_MODE_T dgOpMode = getDGOpMode(); U32 dgSubMode = getDGSubMode(); U32 volume = 0; - DG_RESERVOIR_ID_T inactiveReservoir = getDGInactiveReservoir(); if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) { // Drain both reservoirs and return to active res 2 before initial fills - if ( reservoirStatus[ inactiveReservoir ].initialDrain != TRUE ) + if ( reservoirStatus[ activeReservoir ].initialDrain != TRUE ) { - reservoirStatus[ inactiveReservoir ].initialDrain = TRUE; + reservoirStatus[ activeReservoir ].initialDrain = TRUE; state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; } // Once both reservoirs drained and returned to active res 2, wait for pre-tx workflow // to get to point where fills are allowed, before starting fill // not flushed and need to fill -OR- // flushed and need to fill after entering dry self test state - else if ( ( TRUE == reservoirStatus[ inactiveReservoir ].startFlushFill ) || - ( ( TRUE == reservoirStatus[ inactiveReservoir ].startNormalFill ) && + else if ( ( TRUE == reservoirStatus[ activeReservoir ].startFlushFill ) || + ( ( TRUE == reservoirStatus[ activeReservoir ].startNormalFill ) && ( currentPreTreatmentState >= HD_PRE_TREATMENT_SELF_TEST_DRY_STATE ) ) ) { - // Start tracking flush cycles, flushComplete => don't drain again. - if ( FALSE == reservoirStatus[ inactiveReservoir ].flushComplete ) - { - if ( reservoirStatus[ inactiveReservoir ].flushCount > 0 ) - { - reservoirStatus[ inactiveReservoir ].flushCount -= 1; - } - if ( 0 == reservoirStatus[ inactiveReservoir ].flushCount ) - { - reservoirStatus[ inactiveReservoir ].flushComplete = TRUE; - } - } - - volume = getPreTreatmentFillVolume( inactiveReservoir ); + volume = getPreTreatmentFillVolume( activeReservoir ); cmdStartDGFill( volume, DEFAULT_TARGET_FILL_FLOW_RATE_LPM ); state = PRE_TREATMENT_RESERVOIR_MGMT_FILL_CMD_RESP_STATE; } @@ -1176,34 +1164,34 @@ PRE_TREATMENT_RESERVOIR_MGMT_STATE_T state = PRE_TREATMENT_RESERVOIR_MGMT_FILL_COMPLETE_STATE; DG_OP_MODE_T dgOpMode = getDGOpMode(); U32 dgSubMode = getDGSubMode(); - DG_RESERVOIR_ID_T inactiveReservoir = getDGInactiveReservoir(); - DG_RESERVOIR_ID_T activeReservoir = getDGActiveReservoir(); if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) { - if ( ( TRUE == reservoirStatus[ DG_RESERVOIR_1 ].flushComplete ) && - ( TRUE == reservoirStatus[ DG_RESERVOIR_2 ].flushComplete ) ) + state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; + + // Start tracking flush cycles, flushComplete => don't drain again. + if ( FALSE == reservoirStatus[ inactiveReservoir ].flushComplete ) { - if( FALSE == reservoirStatus[ DG_RESERVOIR_1 ].fillComplete ) + if ( 0 < reservoirStatus[ inactiveReservoir ].flushCount ) { - reservoirStatus[ DG_RESERVOIR_1 ].fillComplete = TRUE; - state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; + reservoirStatus[ inactiveReservoir ].flushCount -= 1; } - else + if ( 0 == reservoirStatus[ inactiveReservoir ].flushCount ) { - if ( FALSE == reservoirStatus[ DG_RESERVOIR_2 ].fillComplete ) - { - reservoirStatus[ DG_RESERVOIR_2 ].fillComplete = TRUE; - state = PRE_TREATMENT_RESERVOIR_MGMT_COMPLETE_STATE; - } + reservoirStatus[ inactiveReservoir ].flushComplete = TRUE; } } + + if ( ( TRUE == reservoirStatus[ DG_RESERVOIR_1 ].flushComplete ) && + ( TRUE == reservoirStatus[ DG_RESERVOIR_2 ].flushComplete ) ) + { + reservoirStatus[ activeReservoir ].fillComplete = TRUE; // TODO - need to restore code that takes us to complete state when all fills done + } else { DG_SWITCH_RSRVRS_CMD_T rsrvrCmd; - state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; - rsrvrCmd.reservoirID = inactiveReservoir; + rsrvrCmd.reservoirID = activeReservoir; rsrvrCmd.useLastTrimmerHeaterDC = FALSE; cmdSetDGActiveReservoir( &rsrvrCmd ); } @@ -1290,32 +1278,14 @@ // Fill volumes after flushing if ( TRUE == reservoirStatus[ inactiveRes ].flushComplete ) { -#ifndef _RELEASE_ - if ( ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRIMING ) ) || - ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_WET_SELF_TEST ) ) ) + if ( DG_RESERVOIR_1 == inactiveRes ) { - if ( DG_RESERVOIR_1 == inactiveRes ) - { - volume = PRE_TREATMENT_FULL_RESERVOIR_VOLUME_ML; - } - // Reservoir 2 - else - { - volume = PRE_TREATMENT_MIN_FILL_RESERVOIR_VOLUME_ML; - } + volume = PRE_TREATMENT_FILL_RESERVOIR_ONE_VOLUME_ML; } + // Reservoir 2 else -#endif { - if ( DG_RESERVOIR_1 == inactiveRes ) - { - volume = PRE_TREATMENT_FILL_RESERVOIR_ONE_VOLUME_ML; - } - // Reservoir 2 - else - { - volume = PRE_TREATMENT_FILL_RESERVOIR_TWO_VOLUME_ML; - } + volume = PRE_TREATMENT_FILL_RESERVOIR_TWO_VOLUME_ML; } } // Flush fill volumes