Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rb9300084966f27ebd166962121c5217f5cd30eb0 -rf9570a9717805d0759622da836a33ee04f3fa40f --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision b9300084966f27ebd166962121c5217f5cd30eb0) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision f9570a9717805d0759622da836a33ee04f3fa40f) @@ -18,15 +18,16 @@ // ********** private definitions ********** -#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Allocated time to settle the filled reservoir in milliseconds. -#define RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS 8000 ///< Reservoir extra time in during the cycle for error in milliseconds. +#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Allocated time to settle the filled reservoir in milliseconds. +#define RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS 8000 ///< Reservoir extra time in during the cycle for error in milliseconds. #define MAX_RESERVOIR_VOLUME_ML 1950.0 ///< Maximum allowed fluid in a reservoir in milliliters. #define MAX_RESERVOIR_DILUTION 0.15F ///< Maximum reservoir dilution limit. #define MAX_RESERVOIR_RECIRCULATION 1.1F ///< Maximum reservoir recirculation limit. -#define MAX_RESERVOIR_DEPLETION_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum allowed depletion time in milliseconds. -#define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the reservoir data is published on the CAN bus. +#define MAX_RESERVOIR_DEPLETION_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum allowed depletion time in milliseconds. +#define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the reservoir data is published on the CAN bus. +#define RESERVOIR_DEPLETION_INTERVAL ( MAX_RESERVOIR_DEPLETION_TIME_MS / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) for maximum allowed depletion time. #define DIALYSATE_FLOW_RATE_350_ML_PER_MIN 0.35F ///< Dialysate flow rate 350 mL/min. #define DIALYSATE_FLOW_RATE_400_ML_PER_MIN 0.4F ///< Dialysate flow rate 400 mL/min. @@ -63,7 +64,7 @@ static F32 dilutionLevelPct = 0.0; ///< Reservoir dilution level. static DG_OP_MODE_T dgOpMode = DG_MODE_INIT; ///< DG operation mode. static U32 dgSubMode = 0; ///< DG operation submode. -static U32 timeReservoirInUseMS = 0; ///< Reservoir time in use in milliseconds. +static U32 timeReservoirInUse = 0; ///< Reservoir time in use in milliseconds. static F32 volSpentUFML = 0.0; ///< Ultrafiltration volume in milliliters. static DG_RESERVOIR_ID_T activeReservoir; ///< Active reservoir. static F32 recirculationLevelPct = 0.0; ///< Recirculation level in percent. @@ -105,7 +106,7 @@ * @details Inputs: none * @details Outputs: reservoirsState, timeStartMS, timeDepletionMS, volTotalMl, * volSpentMl, reservoirsPublicationCounter, dilutionLevelPct, dgOpMode, dgSubMode, - * timeReservoirInUseMS, volSpentUFML, activeReservoir, recirculationLevelPct, + * timeReservoirInUse, volSpentUFML, activeReservoir, recirculationLevelPct, * reservoirSwitchStartTimeMS, timeWaitToFillMS, targetFillFlowLPM, ratios * previousDialysateFlowRate * @return none @@ -121,7 +122,7 @@ dilutionLevelPct = 0.0; dgOpMode = DG_MODE_INIT; dgSubMode = 0; - timeReservoirInUseMS = 0; + timeReservoirInUse = 0; volSpentUFML = 0.0; activeReservoir = DG_RESERVOIR_1; recirculationLevelPct = 0.0; @@ -174,7 +175,14 @@ if ( ( TREATMENT_DIALYSIS_STATE == getTreatmentState() ) && ( getDialysisState() != DIALYSIS_SALINE_BOLUS_STATE ) ) { volSpentML += ( flowRateMLPerMS * msSinceLastVolumeCalc ); + + if ( TREATMENT_DIALYSIS_STATE == getTreatmentState()) + { + + ++timeReservoirInUse; + } } + // Update the reservoir start time timeStartMS = getMSTimerCount(); @@ -240,13 +248,13 @@ static void checkReservoirDepletionTime( void ) { // Check if the time that the reservoir has been use has exceeded the limit - if ( TRUE == didTimeout( timeReservoirInUseMS, MAX_RESERVOIR_DEPLETION_TIME_MS ) ) + if ( timeReservoirInUse >= RESERVOIR_DEPLETION_INTERVAL ) { #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 ) ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_DEPLETION_TIME_OUT, (timeReservoirInUse * TASK_GENERAL_INTERVAL) ) } } } @@ -655,7 +663,7 @@ setFinalReservoirVolume(); // Switched the active reservoir so reset the reservoir in use timer - timeReservoirInUseMS = getMSTimerCount(); + timeReservoirInUse = 0; // Reset to start state to restart drain, fill, switch process. state = TREATMENT_RESERVOIR_MGMT_START_STATE;