Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 -ra16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision a16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef) @@ -56,6 +56,8 @@ static BOOL flushStartReqReceived; ///< Flag indicates user has requested initiation of flush mode. static BOOL heatDisinfectStartReqReceived; ///< Flag indicates user has requested initiation of heat disinfect mode. static BOOL chemDisinfectStartReqReceived; ///< Flag indicates user has requested initiation of chemical disinfect mode. +static BOOL disinfectCancelReqPending; ///< Flag indicates user has requested cancel disinfect mode. +static U32 disinfectCancelReqID; ///< ID of requested cancel disinfect mode. static DG_DISINFECT_STATE_T dgDisinfectState; ///< DG disinfect state to be boadcast to UI. static U32 dataPublishCounter = 0; ///< Disinfects data publish counter. @@ -99,6 +101,8 @@ dataPublishCounter = 0; heatDisinfectStartReqReceived = FALSE; chemDisinfectStartReqReceived = FALSE; + disinfectCancelReqPending = FALSE; + disinfectCancelReqID = 0; dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; } @@ -159,7 +163,40 @@ U32 execStandbyMode( void ) { BOOL stop = isStopButtonPressed(); + CONFIRMATION_REQUEST_STATUS_T confirm_status; + if ( ( STANDBY_DG_FLUSH_IN_PROGRESS_STATE == currentStandbyState ) || + ( STANDBY_DG_HEAT_DISINFECT_IN_PROGRESS_STATE == currentStandbyState ) || + ( STANDBY_DG_CHEM_DISINFECT_IN_PROGRESS_STATE == currentStandbyState ) ) + { + if ( TRUE == stop ) + { + // Send message to UI to indicate user request to cancel disinfect + disinfectCancelReqID = sendConfirmationRequest( CONFIRMATION_REQUEST_TYPE_OPEN, 0 ); + } + else if ( 0 != disinfectCancelReqID ) + { + confirm_status = checkConfirmationRequestStatus( disinfectCancelReqID ); + switch ( confirm_status ) + { + case CONFIRMATION_REQUEST_STATUS_ACCEPTED : + // TODO cancel disinfect mode + disinfectCancelReqPending = TRUE; + disinfectCancelReqID = 0; + break; + + case CONFIRMATION_REQUEST_STATUS_TIMEOUT : + // send a cancel to UI + break; + + case CONFIRMATION_REQUEST_STATUS_REJECTED : + default : + // nothing to do + break; + } + } + } + #ifndef RUN_WITHOUT_DG // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 -ra16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision a16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef) @@ -1141,6 +1141,10 @@ handleUIServiceModeRequest( message ); break; + case MSG_ID_UI_CONFIRMATION_RESULT: + handleUIConfirmationResponse( message ); + 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 -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 -ra16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef) @@ -36,6 +36,7 @@ #include "SystemComm.h" #include "SystemCommMessages.h" #include "Temperatures.h" +#include "Timers.h" #include "TreatmentEnd.h" #include "TreatmentRecirc.h" #include "TreatmentStop.h" @@ -52,6 +53,7 @@ // ********** private definitions ********** #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. +#define NUM_CONFIRM_REQUESTS 4 ///< Number of available confirmation requests. #pragma pack(push,1) /// Payload record structure for block message transmission request. @@ -67,6 +69,11 @@ static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. /// List of message IDs that are requested not to be transmitted. static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; +static CONFIRMATION_REQUEST_T confirmRequests[NUM_CONFIRM_REQUESTS] = + { 0, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, + 0, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, + 0, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, + 0, 0, CONFIRMATION_REQUEST_STATUS_UNUSED, }; // ********** private function prototypes ********** @@ -76,6 +83,93 @@ /*********************************************************************//** * @brief + * The checkConfrimRequestStatus function checks the status of a confirmation request + * @details Inputs: confirmRequests[] + * @details Outputs: confirmRequests[] cleared if read. + * @param request ID + * @return CONFIRMATION_REQUEST_STATUS_T + *************************************************************************/ +CONFIRMATION_REQUEST_STATUS_T checkConfirmationRequestStatus( U32 request_id ) +{ + U08 i; + CONFIRMATION_REQUEST_STATUS_T status = CONFIRMATION_REQUEST_STATUS_PENDING; + + for ( i=0; ihdr.payloadLen == 2 * sizeof(U32) ) + { + U32 request_id; + CONFIRMATION_REQUEST_STATUS_T status; + U08 i; + + memcpy( &request_id, message->payload, sizeof(U32) ); + memcpy( &status, ( message->payload + sizeof(U32) ), sizeof(U32) ); + + for ( i=0; ihdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 -ra16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision a16225ab0fc1c575ad857ccf1dcccdb7a3aa8eef) @@ -66,6 +66,36 @@ #define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. #define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. +/// TODO - should this be in HDDefs? MsgDefs or other common?. +#define CONFIRMATION_REQUEST_TIMEOUT_MS ( SEC_PER_MIN * MS_PER_SECOND ) +/// List of confirmation status. +typedef enum Confirmation_Status +{ + CONFIRMATION_REQUEST_STATUS_REJECTED = 0, ///< Confirmation status rejected + CONFIRMATION_REQUEST_STATUS_ACCEPTED, ///< Confirmation status accepted + CONFIRMATION_REQUEST_STATUS_TIMEOUT, ///< Confirmation status timeout + CONFIRMATION_REQUEST_STATUS_PENDING, ///< Confirmation status pending response + CONFIRMATION_REQUEST_STATUS_UNUSED, ///< Confirmation status Unused + NUM_OF_CONFIRMATION_REQUEST_STATUS ///< Number of confirmation status +} CONFIRMATION_REQUEST_STATUS_T; + +/// List of confirmation status. +typedef enum Confirmation_Request_Type +{ + CONFIRMATION_REQUEST_TYPE_OPEN = 0, ///< Confirmation type open + CONFIRMATION_REQUEST_TYPE_CLOSE, ///< Confirmation type close + CONFIRMATION_REQUEST_TYPE_REJECT, ///< Confirmation type cancel + NUM_OF_CONFIRMATION_TYPE ///< Number of confirmation types +} CONFIRMATION_REQUEST_TYPE_T; + +/// Structure for confirmation request. +typedef struct +{ + U32 requestID; ///< Request ID + U32 timeStamp; ///< Timestamp for request + CONFIRMATION_REQUEST_STATUS_T status; ///< Request status (pending, accepted, rejected) +} CONFIRMATION_REQUEST_T; + // ********** public function prototypes ********** // Serialize message @@ -813,6 +843,11 @@ // MSG_ID_HD_SEND_ALARMS_COMMAND void handleResendAllAlarmsCommand( MESSAGE_T* message ); +// MSG_ID_UI_CONFIRMATION_RESULT +void handleUIConfirmationResponse( MESSAGE_T *message ); +CONFIRMATION_REQUEST_STATUS_T checkConfirmationRequestStatus( U32 request_id ); +U32 sendConfirmationRequest( CONFIRMATION_REQUEST_TYPE_T request_type, U32 reject_reason ); + /**@}*/ #endif