Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r6982379266891326c9d45aecd7d54ad5c85ea69f -r6c1d6a3eaf065c2b2d537d9fef793d73ea328359 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 6982379266891326c9d45aecd7d54ad5c85ea69f) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 6c1d6a3eaf065c2b2d537d9fef793d73ea328359) @@ -10,6 +10,7 @@ #include "MessageSupport.h" #include "ModeTreatment.h" #include "ModeTreatmentParams.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Reservoirs.h" #include "TaskGeneral.h" @@ -71,8 +72,13 @@ static F32 previousUFFlowMLP = 0.0; ///< Previous ultrafiltration flow rate in mL/min. static DG_MIXING_RATIOS_T ratios; ///< Mixing ratios and fill prep time in milliseconds structure. -static const F32 RESERVOIR_DILUTION_RATIO = MAX_RESERVOIR_DILUTION / ( 1.0 - MAX_RESERVOIR_DILUTION ); +static const F32 RESERVOIR_DILUTION_RATIO = MAX_RESERVOIR_DILUTION / ( 1.0 - MAX_RESERVOIR_DILUTION ); ///< Reservoir dilution ratio. +// TODO remove +// FALSE for reservoir 1 and TRUE for reservoir 2 +static BOOL test = TRUE; +// TODO remove + // ********** private function prototypes ********** // Reservoir management functions @@ -201,6 +207,7 @@ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TREATMENT_RESERVOIR_MANAGEMENT_STATE, (U32)reservoirsState ) reservoirsState = TREATMENT_RESERVOIR_MGMT_START_STATE; + break; } publishReservoirData(); @@ -235,9 +242,12 @@ // Check if the time that the reservoir has been use has exceeded the limit if ( TRUE == didTimeout( timeReservoirInUseMS, MAX_RESERVOIR_DEPLETION_TIME_MS ) ) { -#ifndef SKIP_RESERVOIR_ALARMS - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_DEPLETION_TIME_OUT, calcTimeSince( timeReservoirInUseMS ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RESERVOIRS_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_DEPLETION_TIME_OUT, calcTimeSince( timeReservoirInUseMS ) ) + } } } @@ -504,7 +514,9 @@ timeWaitToFillMS = timeDepleteMS - ( getFillTimeMS() + RESERVOIR_SETTLE_TIME_MS + RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS ); // If the wait time has elapsed, trigger a fill command - if ( timeWaitToFillMS <= 0 ) + // TODO uncomment + //if ( timeWaitToFillMS <= 0 ) + // TODO uncomment { cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); } @@ -541,9 +553,13 @@ // diluted to much if ( recirculationLevelPct >= MAX_RESERVOIR_RECIRCULATION ) { -#ifndef SKIP_RESERVOIR_ALARMS - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE, recirculationLevelPct ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RESERVOIRS_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_RECIRCULATION_OUT_OF_RANGE, recirculationLevelPct ) + } + } // Check if DG has moved out of the fill mode @@ -565,7 +581,7 @@ * @brief * The handleReservoirMgmtWaitForFillSettleState function executes the reservoir * management wait for fill to settle state. - * @details Inputs: reservoirSwitchTimer + * @details Inputs: reservoirSwitchTimer, volSpentML * @details Outputs: reservoirSwitchTimer, volSpentML * @return next reservoir management state of the state machine *************************************************************************/ @@ -574,26 +590,42 @@ TREATMENT_RESERVOIR_MGMT_STATE_T state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_FILL_SETTLE_STATE; // Wait for the reservoir to settle and then send the commands to switch the active reservoir - if ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_SETTLE_TIME_MS ) ) + if ( ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_SETTLE_TIME_MS ) ) && ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) ) { DG_RESERVOIR_ID_T inactiveRes = getDGInactiveReservoir(); - // Signal dialysis sub-mode to capture baseline volume for next reservoir. - setStartReservoirVolume( inactiveRes ); + // TODO test code remove + //if ( TRUE == test ) + { + // Signal dialysis sub-mode to capture baseline volume for next reservoir. + setStartReservoirVolume( inactiveRes ); - // Command DG to switch reservoirs - cmdSetDGActiveReservoir( inactiveRes ); + // Command DG to switch reservoirs + cmdSetDGActiveReservoir( inactiveRes ); - // Signal dialysis sub-mode to switch reservoirs - signalReservoirsSwitched(); + // Signal dialysis sub-mode to switch reservoirs + signalReservoirsSwitched(); + } + // TODO test code // Get ready for the next delivery volSpentML = 0.0; // Wait for used reservoir to settle reservoirSwitchStartTimeMS = getMSTimerCount(); - state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + // TODO test code + // For reservoir test, it should go back to start state + /*if ( FALSE == test ) + { + state = TREATMENT_RESERVOIR_MGMT_START_STATE; + } + else*/ + { + state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + test = FALSE; + } + // TODO test code } return state;