Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r2de8d8e0962237bc863ec0c8b69ac7e6ee50e9ff -rc6565acec36584dc703eaa807e5a2da0b697c4de --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 2de8d8e0962237bc863ec0c8b69ac7e6ee50e9ff) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision c6565acec36584dc703eaa807e5a2da0b697c4de) @@ -59,7 +59,7 @@ DG_COMMAND_T startRequestCmdID; ///< DG cleaning mode start request command ID. ALARM_ID_T alarmID; ///< The informative alarm to trigger for each cleaning mode. DG_OP_MODE_T dgOpMode; ///< DG operation mode. - BOOL sampleAlarmTrgrd; ///< Flag to indicate the sample alarm has been triggered (for RO perm and chem flush). + BOOL sampleRqstTrgrd; ///< Flag to indicate the sample alarm has been triggered (for RO perm and chem flush). GENERIC_CONFIRM_ID_T sampleRequestID; ///< Sample request pass/fail message status. GENERIC_CONFIRM_ID_T stopRequestCmdID; ///< Stop DG cleaning request command ID } DG_CLEANING_MODE_STATUS_T; @@ -80,8 +80,6 @@ // ********** private function prototypes ********** -static void handleDisinfectCancel( BOOL stop ); - static HD_STANDBY_STATE_T handleStandbyModeStartState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ); static HD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ); @@ -90,9 +88,11 @@ static HD_STANDBY_STATE_T handleStandbyModeWaitForDGCleaningModeStartState( void ); static HD_STANDBY_STATE_T handleStandbyModeDGCleaningModeInProgressState( void ); +static void handleDisinfectCancel( BOOL stop ); static void setRequestedCleaningMode( DG_OP_MODE_T opMode ); static void clearCurrentCleaningModeStatus( void ); static void handleChemFlushSampleCollection( void ); +static void handleROPermeateSampleCollection( void ); static BOOL isDGDisinfectValid( void ); static BOOL haveHDDGServicesBeenExpired( REQUEST_REJECT_REASON_CODE_T* rejReason ); @@ -583,81 +583,21 @@ return result; } -// ********** private functions ********** - /*********************************************************************//** * @brief - * The handleDisinfectCancel function handles - * DG disinfect cancel UI interaction. + * The signalROPermeateSampleDGReadyToDispense function set the signal + * that DG is ready for more RO permeate dispensing * @details Inputs: none - * @details Outputs: none - * @param stop button status + * @details Outputs: currentDGCleaningMode * @return none *************************************************************************/ -static void handleDisinfectCancel( BOOL stop ) +void signalROPermeateSampleDGReadyToDispense( void ) { - CONFIRMATION_REQUEST_STATUS_T confirm_status; - - if ( STANDBY_CLEANING_MODE_IN_PROGRESS_STATE == currentStandbyState ) - { - if ( ( TRUE == stop ) && ( GENERIC_CONFIRM_ID_NONE == disinfectCancelReqID ) ) - { - disinfectCancelReqID = addConfirmationRequest( currentDGCleaningMode.stopRequestCmdID, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); - } - else if ( disinfectCancelReqID != GENERIC_CONFIRM_ID_NONE ) - { - // Get the confirmation request. It consumes the request if completed and responds to UI. - confirm_status = getConfirmationRequestStatus( disinfectCancelReqID ); - switch ( confirm_status ) - { - case CONFIRMATION_REQUEST_STATUS_ACCEPTED: - // Clear request active status - disinfectCancelReqID = GENERIC_CONFIRM_ID_NONE; - - switch ( currentDGCleaningMode.dgOpMode ) - { - case DG_MODE_FLUS: - cmdStopDGFlush(); - break; - - case DG_MODE_HEAT: - cmdStopDGHeatDisinfect(); - break; - - case DG_MODE_CHEM: - cmdStopDGChemicalDisinfect(); - break; - - case DG_MODE_CHFL: - cmdStopDGChemFlushDisinfect(); - break; - - case DG_MODE_HCOL: - cmdStopDGActiveCool(); - break; - - case DG_MODE_ROPS: - cmdStopDGROPermeateSampleMode(); - break; - } - break; - - case CONFIRMATION_REQUEST_STATUS_TIMEOUT: - case CONFIRMATION_REQUEST_STATUS_REJECTED: - // Clear request active status - disinfectCancelReqID = GENERIC_CONFIRM_ID_NONE; - break; - - case CONFIRMATION_REQUEST_STATUS_PENDING: - case CONFIRMATION_REQUEST_STATUS_UNUSED: - default: - // Nothing to do - break; - } - } - } + currentDGCleaningMode.sampleRqstTrgrd = TRUE; } +// ********** private functions ********** + /*********************************************************************//** * @brief * The handleStandbyModeStartState function handles the standby start state. @@ -898,7 +838,7 @@ } else if ( DG_MODE_ROPS == currentDGCleaningMode.dgOpMode ) { - // TODO a function to handle the ROPS sampling message + handleROPermeateSampleCollection(); } if ( getDGOpMode() != currentDGCleaningMode.dgOpMode ) @@ -913,6 +853,79 @@ /*********************************************************************//** * @brief + * The handleDisinfectCancel function handles + * DG disinfect cancel UI interaction. + * @details Inputs: none + * @details Outputs: none + * @param stop button status + * @return none + *************************************************************************/ +static void handleDisinfectCancel( BOOL stop ) +{ + CONFIRMATION_REQUEST_STATUS_T confirm_status; + + if ( STANDBY_CLEANING_MODE_IN_PROGRESS_STATE == currentStandbyState ) + { + if ( ( TRUE == stop ) && ( GENERIC_CONFIRM_ID_NONE == disinfectCancelReqID ) ) + { + disinfectCancelReqID = addConfirmationRequest( currentDGCleaningMode.stopRequestCmdID, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); + } + else if ( disinfectCancelReqID != GENERIC_CONFIRM_ID_NONE ) + { + // Get the confirmation request. It consumes the request if completed and responds to UI. + confirm_status = getConfirmationRequestStatus( disinfectCancelReqID ); + switch ( confirm_status ) + { + case CONFIRMATION_REQUEST_STATUS_ACCEPTED: + // Clear request active status + disinfectCancelReqID = GENERIC_CONFIRM_ID_NONE; + + switch ( currentDGCleaningMode.dgOpMode ) + { + case DG_MODE_FLUS: + cmdStopDGFlush(); + break; + + case DG_MODE_HEAT: + cmdStopDGHeatDisinfect(); + break; + + case DG_MODE_CHEM: + cmdStopDGChemicalDisinfect(); + break; + + case DG_MODE_CHFL: + cmdStopDGChemFlushDisinfect(); + break; + + case DG_MODE_HCOL: + cmdStopDGActiveCool(); + break; + + case DG_MODE_ROPS: + cmdStopDGROPermeateSampleMode(); + break; + } + break; + + case CONFIRMATION_REQUEST_STATUS_TIMEOUT: + case CONFIRMATION_REQUEST_STATUS_REJECTED: + // Clear request active status + disinfectCancelReqID = GENERIC_CONFIRM_ID_NONE; + break; + + case CONFIRMATION_REQUEST_STATUS_PENDING: + case CONFIRMATION_REQUEST_STATUS_UNUSED: + default: + // Nothing to do + break; + } + } + } +} + +/*********************************************************************//** + * @brief * The setRequestedCleaningMode function sets the variables for the requested * DG cleaning mode. * @details Inputs: currentDGCleaningMode @@ -928,6 +941,7 @@ currentDGCleaningMode.startCleaningMode = TRUE; currentDGCleaningMode.startRequestCmdID = DG_CMD_START_FLUSH; currentDGCleaningMode.dgOpMode = DG_MODE_FLUS; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_DISINFECT_FLUSH; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_WATERFLUSH; break; @@ -936,6 +950,7 @@ currentDGCleaningMode.startCleaningMode = TRUE; currentDGCleaningMode.startRequestCmdID = DG_CMD_START_HEAT_DISINFECT; currentDGCleaningMode.dgOpMode = DG_MODE_HEAT; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_DISINFECT_HEAT; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_HEAT; break; @@ -944,6 +959,7 @@ currentDGCleaningMode.startCleaningMode = TRUE; currentDGCleaningMode.startRequestCmdID = DG_CMD_START_CHEM_DISINFECT; currentDGCleaningMode.dgOpMode = DG_MODE_CHEM; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_DISINFECT_CHEM; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_CHEMICAL; break; @@ -952,6 +968,7 @@ currentDGCleaningMode.startCleaningMode = TRUE; currentDGCleaningMode.startRequestCmdID = DG_CMD_START_CHEM_DISINFECT_FLUSH; currentDGCleaningMode.dgOpMode = DG_MODE_CHFL; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_DISINFECT_CHEM_FLUSH; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_CHEMICAL_FLUSH; break; @@ -961,6 +978,7 @@ currentDGCleaningMode.startCleaningMode = FALSE; currentDGCleaningMode.startRequestCmdID = DG_CMD_NONE; currentDGCleaningMode.dgOpMode = DG_MODE_HCOL; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_DISINFECT_HEAT_COOL; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_ACTIVE_COOL; break; @@ -969,6 +987,7 @@ currentDGCleaningMode.startCleaningMode = TRUE; currentDGCleaningMode.startRequestCmdID = DG_CMD_START_RO_PERMEATE_SAMPLE; currentDGCleaningMode.dgOpMode = DG_MODE_ROPS; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.alarmID = ALARM_ID_HD_RO_PERMEATE_SAMPLE; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_RO_PERMEATE_SAMPLE; break; @@ -989,13 +1008,14 @@ currentDGCleaningMode.alarmID = ALARM_ID_NO_ALARM; currentDGCleaningMode.startRequestCmdID = DG_CMD_NONE; currentDGCleaningMode.dgOpMode = DG_MODE_FAUL; - currentDGCleaningMode.sampleAlarmTrgrd = FALSE; + currentDGCleaningMode.sampleRqstTrgrd = FALSE; currentDGCleaningMode.sampleRequestID = GENERIC_CONFIRM_ID_NONE; currentDGCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_NONE; } + /*********************************************************************//** * @brief - * The handleChemFlushSampleCollection function handle the chemical disinfect + * The handleChemFlushSampleCollection function handles the chemical disinfect * flush mode's sample collection. In this state of the chemical disinfect * flush mode, user interaction is needed. * @details Inputs: currentDGCleaningMode @@ -1004,17 +1024,17 @@ *************************************************************************/ static void handleChemFlushSampleCollection( void ) { - if ( ( FALSE == currentDGCleaningMode.sampleAlarmTrgrd ) && ( TRUE == isAlarmActive( ALARM_ID_DG_CHEM_DISINFECT_FLUSH_FLUSH_SAMPLE ) ) ) + if ( ( FALSE == currentDGCleaningMode.sampleRqstTrgrd ) && ( TRUE == isAlarmActive( ALARM_ID_DG_CHEM_DISINFECT_FLUSH_FLUSH_SAMPLE ) ) ) { // Check if the flush sample alarm has been raised for the first time in the sample flush state - currentDGCleaningMode.sampleAlarmTrgrd = TRUE; + currentDGCleaningMode.sampleRqstTrgrd = TRUE; } - else if ( ( TRUE == currentDGCleaningMode.sampleAlarmTrgrd ) && ( FALSE == isAlarmActive( ALARM_ID_DG_CHEM_DISINFECT_FLUSH_FLUSH_SAMPLE ) ) ) + else if ( ( TRUE == currentDGCleaningMode.sampleRqstTrgrd ) && ( FALSE == isAlarmActive( ALARM_ID_DG_CHEM_DISINFECT_FLUSH_FLUSH_SAMPLE ) ) ) { // Sample flush alarm has been triggered and the user has cleared the alarm by pressing Ok. The user is collecting sample. // Send the notification to the UI to prompt the pass/fail screen so the user can choose whether the sampling after flush passed or failed - currentDGCleaningMode.sampleAlarmTrgrd = FALSE; - currentDGCleaningMode.sampleRequestID = addConfirmationRequest( GENERIC_CONFIRM_ID_DISINFECT_CHEM_FLUSH_SAMPLE_PASS_FAIL, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); + currentDGCleaningMode.sampleRqstTrgrd = FALSE; + currentDGCleaningMode.sampleRequestID = addConfirmationRequest( GENERIC_CONFIRM_ID_DISINFECT_CHEM_FLUSH_SAMPLE_PASS_FAIL, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); } if ( currentDGCleaningMode.sampleRequestID != GENERIC_CONFIRM_ID_NONE ) @@ -1050,6 +1070,60 @@ /*********************************************************************//** * @brief + * The handleROPermeateSampleCollection function handles the RO permeate + * sample collection with the user + * @details Inputs: currentDGCleaningMode + * @details Outputs: currentDGCleaningMode + * @return none + *************************************************************************/ +static void handleROPermeateSampleCollection( void ) +{ + if ( ( FALSE == currentDGCleaningMode.sampleRqstTrgrd ) && ( TRUE == isAlarmActive( ALARM_ID_DG_RO_PERMEATE_SAMPLE_REMOVE_DIA_CAP ) ) ) + { + // Check if the flush sample alarm has been raised for the first time in the sample flush state + currentDGCleaningMode.sampleRqstTrgrd = TRUE; + } + else if ( ( TRUE == currentDGCleaningMode.sampleRqstTrgrd ) && ( FALSE == isAlarmActive( ALARM_ID_DG_RO_PERMEATE_SAMPLE_REMOVE_DIA_CAP ) ) ) + { + // Sample flush alarm has been triggered and the user has cleared the alarm by pressing Ok. The user is collecting sample. + // Send the notification to the UI to prompt the pass/fail screen so the user can choose whether the sampling after flush passed or failed + currentDGCleaningMode.sampleRqstTrgrd = FALSE; + currentDGCleaningMode.sampleRequestID = addConfirmationRequest( GENERIC_CONFIRM_ID_RO_PERMEATE_SAMPLE_STOP_OR_DISPENSE, GENERIC_CONFIRM_CMD_REQUEST_OPEN, 0 ); + } + + if ( currentDGCleaningMode.sampleRequestID != GENERIC_CONFIRM_ID_NONE ) + { + // There is a user confirm + CONFIRMATION_REQUEST_STATUS_T status = getConfirmationRequestStatus( currentDGCleaningMode.sampleRequestID ); + U32 sampleStatus = 0; + + switch( status ) + { + // If the request status is accepted send a 1 to DG + case CONFIRMATION_REQUEST_STATUS_ACCEPTED: + sampleStatus = (U32)CONFIRMATION_REQUEST_STATUS_ACCEPTED; + currentDGCleaningMode.sampleRequestID = GENERIC_CONFIRM_ID_NONE; + sendRequestROPermeateSampleCollectionToDG( sampleStatus ); + break; + + // If the request timed out or rejected, it is 0 or failure to DG + case CONFIRMATION_REQUEST_STATUS_TIMEOUT: + case CONFIRMATION_REQUEST_STATUS_REJECTED: + currentDGCleaningMode.sampleRequestID = GENERIC_CONFIRM_ID_NONE; + sendRequestROPermeateSampleCollectionToDG( sampleStatus ); + break; + + case CONFIRMATION_REQUEST_STATUS_PENDING: + case CONFIRMATION_REQUEST_STATUS_UNUSED: + default: + // Nothing to do + break; + } + } +} + +/*********************************************************************//** + * @brief * The isDGDisinfectValid function checks whether the DG disinfects is * acceptable to start another treatment. * @details Inputs: none