Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r9324981b9eeeb2735a379019acc8f7184023460b -r43949bb09b178239911c2e46c6555bc31289090f --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 9324981b9eeeb2735a379019acc8f7184023460b) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 43949bb09b178239911c2e46c6555bc31289090f) @@ -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; @@ -91,6 +91,7 @@ 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 ); @@ -581,6 +582,19 @@ return result; } +/*********************************************************************//** + * @brief + * The signalROPermeateSampleDGReadyToDispense function set the signal + * that DG is ready for more RO permeate dispensing + * @details Inputs: none + * @details Outputs: currentDGCleaningMode + * @return none + *************************************************************************/ +void signalROPermeateSampleDGReadyToDispense( void ) +{ + currentDGCleaningMode.sampleRqstTrgrd = TRUE; +} + // ********** private functions ********** /*********************************************************************//** @@ -823,7 +837,7 @@ } else if ( DG_MODE_ROPS == currentDGCleaningMode.dgOpMode ) { - // TODO a function to handle the ROPS sampling message + handleROPermeateSampleCollection(); } if ( getDGOpMode() != currentDGCleaningMode.dgOpMode ) @@ -926,6 +940,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; @@ -934,6 +949,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; @@ -942,6 +958,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; @@ -950,6 +967,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; @@ -959,6 +977,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; @@ -967,6 +986,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; @@ -987,14 +1007,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 @@ -1003,17 +1023,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 ) @@ -1049,6 +1069,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