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 Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r0b084a3430750d40473bbd5dc3cdc2d73f4163d2 -r43949bb09b178239911c2e46c6555bc31289090f --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 0b084a3430750d40473bbd5dc3cdc2d73f4163d2) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 43949bb09b178239911c2e46c6555bc31289090f) @@ -45,6 +45,7 @@ BOOL signalUserInitiateChemcialDisinfectFlushMode( void ); BOOL signalUserInitiateROPermeateSampleMode( void ); BOOL signalInitiateStandbyDisinfectSubmode( U32 cmd ); +void signalROPermeateSampleDGReadyToDispense( void ); BOOL testSetStandbyModePublishIntervalOverride( U32 ms ); BOOL testResetStandbyModePublishIntervalOverride( void ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -re5167d0700038c1faf8b689b844a905f20c0d3c6 -r43949bb09b178239911c2e46c6555bc31289090f --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e5167d0700038c1faf8b689b844a905f20c0d3c6) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 43949bb09b178239911c2e46c6555bc31289090f) @@ -1182,6 +1182,10 @@ handleSetHDServiceTime( message ); break; + case MSG_ID_DG_SEND_RO_PERMEATE_SAMPLE_DISPENSE_READY_TO_HD: + handleReceiveROPermeateSampleReadyToDispenseFromDG(); + break; + // NOTE: this always must be the last case case MSG_ID_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r41a41275952290677df1fb0d27db3f354be26dd8 -r43949bb09b178239911c2e46c6555bc31289090f --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 41a41275952290677df1fb0d27db3f354be26dd8) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 43949bb09b178239911c2e46c6555bc31289090f) @@ -3284,18 +3284,22 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); if ( 0 == message->hdr.payloadLen ) { + U32 test = 0; // Fill message payload memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + test = service.lastServiceEpochDate + service.serviceIntervalSeconds; + memcpy( payloadPtr, &test, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &dgData.dgServiceRecord.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dgData.dgServiceRecord.serviceIntervalSeconds, sizeof( U32 ) ); + test = dgData.dgServiceRecord.lastServiceEpochDate + dgData.dgServiceRecord.serviceIntervalSeconds; + memcpy( payloadPtr, &test, sizeof( U32 ) ); + //memcpy( payloadPtr, &dgData.dgServiceRecord.serviceIntervalSeconds, sizeof( U32 ) ); } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -3411,8 +3415,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG; - // The payload length is U32 Request ID, U32 Type + msg.hdr.msgID = MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &status, sizeof( U32 ) ); @@ -3421,7 +3424,14 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_NOT_REQUIRED ); } -// MSG_ID_DG_START_STOP_HEAT_DISINFECT_ACTIVE_COOL +/*********************************************************************//** + * @brief + * The sendDGStopActiveCoolModeCommand function sends a request to stop + * active cool mode command + * @details Inputs: none + * @details Outputs: none + * @return TRUE if the command was serialized successfully + *************************************************************************/ BOOL sendDGStopActiveCoolModeCommand( void ) { BOOL result; @@ -3430,7 +3440,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT_ACTIVE_COOL; + msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT_ACTIVE_COOL; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( msg.payload, &start, sizeof( BOOL ) ); @@ -3441,15 +3451,24 @@ return result; } -// MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST +/*********************************************************************//** + * @brief + * The sendDGStartStopDGROPermeateSampleModeCommand function sends a request + * to start or stop RO permeate sample mode command + * @details Inputs: none + * @details Outputs: none + * @param start TRUE to star the RO permeate sample mode and FALSE to stop + * the RO permeate sample mode + * @return TRUE if the command was serialized successfully + *************************************************************************/ BOOL sendDGStartStopDGROPermeateSampleModeCommand( BOOL start ) { BOOL result; MESSAGE_T msg; // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST; + msg.hdr.msgID = MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( msg.payload, &start, sizeof( BOOL ) ); @@ -3460,7 +3479,48 @@ return result; } +/*********************************************************************//** + * @brief + * The sendRequestROPermeateSampleCollectionToDG function sends a request + * to collect RO permeate sample to DG + * @details Inputs: none + * @details Outputs: none + * @param status which could be dispense or cancel + * @return TRUE if the command was serialized successfully + *************************************************************************/ +BOOL sendRequestROPermeateSampleCollectionToDG( U32 status ) +{ + BOOL result; + MESSAGE_T msg; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_RO_PERMEATE_SAMPLE_DISPENSE_REQUEST_TO_DG; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( msg.payload, &status, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleReceiveROPermeateSampleReadyToDispenseFromDG function receives + * the signal from DG that it is ready to dispnese more in RO permeate sample + * mode + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void handleReceiveROPermeateSampleReadyToDispenseFromDG( void ) +{ + signalROPermeateSampleDGReadyToDispense(); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r41a41275952290677df1fb0d27db3f354be26dd8 -r43949bb09b178239911c2e46c6555bc31289090f --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 41a41275952290677df1fb0d27db3f354be26dd8) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 43949bb09b178239911c2e46c6555bc31289090f) @@ -553,6 +553,12 @@ // MSG_ID_DG_START_STOP_RO_PERMEATE_SAMPLE_MODE_CMD_REQUEST BOOL sendDGStartStopDGROPermeateSampleModeCommand( BOOL start ); +// MSG_ID_HD_SEND_RO_PERMEATE_SAMPLE_DISPENSE_REQUEST +BOOL sendRequestROPermeateSampleCollectionToDG( U32 status ); + +// MSG_ID_DG_SEND_RO_PERMEATE_SAMPLE_DISPENSE_READY_TO_HD +void handleReceiveROPermeateSampleReadyToDispenseFromDG( void ); + // *********** public test support message functions ********** // MSG_TESTER_LOG_IN