Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rfebf34ac531641da5c58262c56d3be6aeff3b209 -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision febf34ac531641da5c58262c56d3be6aeff3b209) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ModeStandby.c * -* @author (last) Sean Nash -* @date (last) 31-May-2023 +* @author (last) Dara Navaei +* @date (last) 10-Nov-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -49,7 +49,7 @@ #define DISINFECTS_DATA_PUB_INTERVAL ( 1 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Disinfects data publish interval in counts. #define DISINFECTS_TIME_INTERVAL_S ( 3 * SECONDS_IN_A_DAY ) ///< HD/DG 3-day service interval in seconds. -#define FLUSH_TIME_INTERVAL_S ( 30 * SEC_PER_MIN ) ///< Flush time interval in seconds. +#define FLUSH_TIME_INTERVAL_S ( 2 * MIN_PER_HOUR * SEC_PER_MIN ) ///< Flush time interval in seconds. #define MAX_ALLOWED_RO_FILTER_TEMP_FOR_TX_C 44.0F ///< Maximum allowed temperature to start a treatment in C. /// DG cleaning mode status data structure @@ -70,6 +70,7 @@ static BOOL treatStartReqReceived; ///< Flag indicates user has requested initiation of a treatment. static GENERIC_CONFIRM_ID_T disinfectCancelReqID; ///< ID of requested cancel disinfect mode. static BOOL homingInitiated; ///< Boolean flag to indicate homing is initiated. +static BOOL flagNoDisinfectRequired = FALSE; ///< Flag indicates disinfect not required on next mode entry. static DG_CLEANING_MODE_STATUS_T currentDGCleaningMode; ///< Current DG cleaning mode status. /// Interval (in task intervals) at which to publish standby mode data to CAN bus. @@ -152,13 +153,14 @@ setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); // If we just exited Post Treatment Mode, goto disinfect sub state. - if ( MODE_POST == previousOpMode ) + if ( ( MODE_POST == previousOpMode ) && ( flagNoDisinfectRequired != TRUE ) ) { doorClosedRequired( FALSE, FALSE ); // door no longer required to be closed in standby mode currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; } else { + flagNoDisinfectRequired = FALSE; doorClosedRequired( TRUE, FALSE ); } syringeDetectionRequired( FALSE ); @@ -307,6 +309,19 @@ /*********************************************************************//** * @brief + * The signalNoDisinfectRequired function signals the standby mode module + * that a disinfection will not be required on next entry to standby mode. + * @details Inputs: none + * @details Outputs: flagNoDisinfectRequired + * @return none + *************************************************************************/ +void signalNoDisinfectRequired( void ) +{ + flagNoDisinfectRequired = TRUE; +} + +/*********************************************************************//** + * @brief * The signalAlarmActionToStandbyMode function executes the given alarm action * as appropriate while in Standby Mode. * @details Inputs: none @@ -639,7 +654,7 @@ else #endif { - if ( ( TRUE == homingInitiated ) && ( TRUE == isSyringePumpHome() ) && ( TRUE == isSyringePumpStopped() ) ) + if ( ( TRUE == isSyringePumpHome() ) && ( TRUE == isSyringePumpStopped() ) ) { syringePumpVerifyForceSensorDACCalibration(); homingInitiated = FALSE; // reset for next time @@ -1141,6 +1156,7 @@ getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&usageRecord, sizeof( HD_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); U32 lastChemCompleteDateS = data.dgUsageInfo.lastChemDisCompleteDateEpoch; + U32 lastChemStartDateS = data.dgUsageInfo.lastChemDisStartDateEpoch; U32 lastChemFlushCompleteDateS = data.dgUsageInfo.lastChemDisFlushCompleteDateEpoch; U32 lastHeatCompleteDateS = data.dgUsageInfo.lastHeatDisCompleteDateEpoch; U32 lastFlushCompleteDateS = data.dgUsageInfo.lastBasicFlushCompleteDateEpoch; @@ -1156,13 +1172,15 @@ BOOL isHeatDisValid = ( ( currentRTCEpochTimeS - lastHeatCompleteDateS ) < DISINFECTS_TIME_INTERVAL_S ? TRUE : FALSE ); // Last Chem Flush Complete < Last Chem Disinfect Start, so after running a chemical disinfect, a chemical disinfect flush has been done - BOOL isChemFlushComplete = ( lastChemFlushCompleteDateS > lastChemCompleteDateS ? TRUE : FALSE ); + BOOL isChemFlushComplete = ( lastChemFlushCompleteDateS > lastChemStartDateS ? TRUE : FALSE ); // If either of the basic flush, heat disinfect, or chemical disinfect flush have been done within the interval, it means the filters have been flushed BOOL isBasicFlushValid = ( ( currentRTCEpochTimeS - lastFlushCompleteDateS ) < FLUSH_TIME_INTERVAL_S ? TRUE : FALSE ); BOOL isChemFlushValid = ( ( currentRTCEpochTimeS - lastChemFlushCompleteDateS ) < FLUSH_TIME_INTERVAL_S ? TRUE : FALSE ); BOOL isHeatDisCoolFlushValid = ( ( currentRTCEpochTimeS - lastHeatCoolCompleteDateS ) < FLUSH_TIME_INTERVAL_S ? TRUE : FALSE ); - BOOL isFlushValid = ( ( TRUE == isBasicFlushValid ) || ( TRUE == isChemFlushValid ) || ( TRUE == isHeatDisCoolFlushValid ) ? TRUE : FALSE ); + BOOL isHeatDisFlushValid = ( ( currentRTCEpochTimeS - lastHeatCompleteDateS ) < FLUSH_TIME_INTERVAL_S ? TRUE : FALSE ); + BOOL isFlushValid = ( ( ( TRUE == isBasicFlushValid ) || ( TRUE == isChemFlushValid ) || ( TRUE == isHeatDisCoolFlushValid ) || + ( TRUE == isHeatDisFlushValid ) ) ? TRUE : FALSE ); // If all of the above conditions are true, it means we can start a treatment if ( ( TRUE == hasDisBeenDone ) && ( TRUE == isHeatDisValid ) && ( TRUE == isChemFlushComplete ) && ( TRUE == isFlushValid ) )