Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rb41ffefac4fa72f8120849dd8a21af8f8c10948a -r8e62ede02d0f1d4bfc8aebbfa75a5ce308c994bd --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision b41ffefac4fa72f8120849dd8a21af8f8c10948a) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 8e62ede02d0f1d4bfc8aebbfa75a5ce308c994bd) @@ -97,6 +97,16 @@ // ********** private data ********** +/// Fill for calibration check enumeration +typedef enum fill_for_cal +{ + FILL_FOR_CAL_PRIME = 0, ///< Fill for calibration prime. + FILL_FOR_CAL_BICARB_CHECK, ///< Fill for calibration bicarb check. + FILL_FOR_CAL_ACID_CHECK, ///< Fill for calibration acid check. + FILL_FOR_CAL_NONE, ///< Fill for calibration none. + NUM_OF_FILL_FOR_CAL ///< Number of fill for calibration. +} FILL_FOR_CAL_CHECK_T; + /// Fill conditions status typedef struct { @@ -158,6 +168,9 @@ // NOTE: This variable should be initialized here because the init function is called every time and then this variable is set to FALSE even if the settings from the // UI wants the RO only mode. static BOOL hasROOnlyModeBeenEnabled = FALSE; ///< Flag to indicate the RO only mode has been set or not. +// NOTE: This variable should be initialized here because the init function is called every time and then it cannot be initialized there. This variable is +// set via Dialin for calibration check purposes only +static FILL_FOR_CAL_CHECK_T fillForCalCheck = FILL_FOR_CAL_NONE; ///< Fill for calibration check. static OVERRIDE_F32_T usedAcidVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated acid concentration volume has been used in mL. static OVERRIDE_F32_T usedBicarbVolumeML = { 0.0, 0.0, 0.0, 0.0 }; ///< The integrated bicarb concentration volume has been used in mL. static OVERRIDE_U32_T fillModeDataPublishInterval = { FILL_MODE_DATA_PUB_INTERVAL, @@ -616,6 +629,25 @@ { result = DG_FILL_MODE_STATE_PRODUCE_DIALYSATE; } + + switch ( fillForCalCheck ) + { + case FILL_FOR_CAL_PRIME: + result = DG_FILL_MODE_STATE_PRIME_CONCENTRATE_LINES; + break; + + case FILL_FOR_CAL_BICARB_CHECK: + result = DG_FILL_MODE_STATE_TEST_BICARB_CONDUCTIVITY; + break; + + case FILL_FOR_CAL_ACID_CHECK: + result = DG_FILL_MODE_STATE_TEST_ACID_CONDUCTIVITY; + break; + + default: + // Do nothing. This means there is not a request for the fill calibration check so proceed with the normal operations. + break; + } setModeFillStateTransition( result ); return result; @@ -1061,6 +1093,13 @@ pumpSpeedIndex = 0; setROPumpTargetFlowRateLPM( RO_PUMP_FLUSH_BUBBLES_FLOWS[ pumpSpeedIndex ] / MILLILITERS_PER_LITER, TARGET_RO_PRESSURE_PSI ); flushBubblesStartTime = getMSTimerCount(); + if ( FILL_FOR_CAL_PRIME == fillForCalCheck ) + { + // After prime, the state transitions to flush bubbles. If the cal for check prime was set, transition to Gen Idle and + // set the fill for cal check to none. This is done upon the transition of the next state so then we can transition to Gen Idle. + fillForCalCheck = FILL_FOR_CAL_NONE; + requestNewOperationMode( DG_MODE_GENE ); + } break; case DG_FILL_MODE_STATE_TEST_BICARB_CONDUCTIVITY: @@ -1092,6 +1131,15 @@ bicarbConductivitySampleCount = 0; acidConductivitySampleCount = 0; concentrateTestStartTime = getMSTimerCount(); + if ( FILL_FOR_CAL_BICARB_CHECK == fillForCalCheck ) + { + // After bicarb test, the state transitions to acid test. If the cal for check prime was set, transition to Gen Idle and + // set the fill for cal check to none. This is done upon the transition of the next state so then we can transition to Gen Idle. + // NOTE: If the bicarb test fails, it transitions to fault mode so it automatically exits mode fill so this is only for the situation + // that bicarb test was successful + fillForCalCheck = FILL_FOR_CAL_NONE; + requestNewOperationMode( DG_MODE_GENE ); + } break; case DG_FILL_MODE_STATE_PRODUCE_DIALYSATE: @@ -1101,6 +1149,15 @@ requestConcentratePumpOn( CONCENTRATEPUMPS_CP2_BICARB ); concPumpPrimeStartTimeMS = getMSTimerCount(); fillStatus.isThisFirstFill = FALSE; + if ( FILL_FOR_CAL_ACID_CHECK == fillForCalCheck ) + { + // After acid test, the state transitions to acid test. If the cal for check prime was set, transition to Gen Idle and + // set the fill for cal check to none. This is done upon the transition of the next state so then we can transition to Gen Idle. + // NOTE: If the acid test fails, it transitions to fault mode so it automatically exits mode fill so this is only for the situation + // that bicarb test was successful + fillForCalCheck = FILL_FOR_CAL_NONE; + requestNewOperationMode( DG_MODE_GENE ); + } break; case DG_FILL_MODE_STATE_DELIVER_DIALYSATE: @@ -1461,4 +1518,27 @@ return result; } +/*********************************************************************//** + * @brief + * The testSetModeFillForCal function sets the variable to run mode fill only + * for calibration check + * @details Inputs: none + * @details Outputs: fillForCalCheck + * @param calForCheck the mode that is requested (0 = prime, 1 = bicarb check, + * 2 = acid check) + * @return TRUE if the request is in the range otherwise, FALSE + *************************************************************************/ +BOOL testSetModeFillForCal( U32 calForCheck ) +{ + BOOL result = FALSE; + + if ( calForCheck < NUM_OF_FILL_FOR_CAL ) + { + fillForCalCheck = (FILL_FOR_CAL_CHECK_T)calForCheck; + result = TRUE; + } + + return result; +} + /**@}*/