Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 -red21c935443549b87ab6665e76ce1d32d9867082 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision ed21c935443549b87ab6665e76ce1d32d9867082) @@ -32,6 +32,7 @@ #include "LevelSensors.h" #include "Messaging.h" #include "ModeInitPOST.h" +#include "ModePostTreat.h" #include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" @@ -116,7 +117,6 @@ { MSG_ID_UI_VERSION_INFO_RESPONSE, &handleUIVersionResponse }, { MSG_ID_DD_GEN_DIALYSATE_MODE_DATA, &setDialysateData }, { MSG_ID_DD_PRESSURES_DATA, &setDialysatePressure }, - { MSG_ID_UI_PATIENT_DISCONNECT_CONFIRM_REQUEST, &handlePatientDisconnectionConfirmCmd }, { MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE, &validateAndSetTreatmentParameters }, { MSG_ID_UI_TREATMENT_UF_VOLUME_VALIDATE_REQUEST, &validateAndSetUFVolume }, { MSG_ID_UI_ULTRAFILTRATION_CHANGE_CONFIRM_REQUEST, &signalUserConfirmationOfUFVolume }, @@ -142,7 +142,9 @@ { MSG_ID_FFU_SIGNAL_TD_UPDATE_AVAILABLE, &handleUpdateAvailable }, { MSG_ID_UI_FLUID_BOLUS_REQUEST, &handleFluidBolusRequest }, { MSG_ID_UI_GENERIC_CONFIRMATION_RESULT_RESPONSE, &handleUIConfirmationResponse }, + { MSG_ID_UI_PATIENT_DISCONNECT_CONFIRM_REQUEST, &handlePatientDisconnectionConfirmCmd }, { MSG_ID_UI_POST_TREATMENT_DISPOSABLE_REMOVAL_CONFIRM_REQUEST, &handleDisposableRemovalConfirmCmd }, + { MSG_ID_UI_POST_TREATMENT_DISINFECTION_SELECTION_REQUEST, &handleDisinfectionConfirmCmd }, { MSG_ID_TD_SOFTWARE_RESET_REQUEST, &testTDSoftwareResetRequest }, { MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST, &testBubbleDetectOverride }, { MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBubblesDataPublishIntervalOverride }, @@ -557,47 +559,147 @@ } /*********************************************************************//** - * @brief - * The handlePatientDisconnectionConfirmCmd function handles user confirms - * patient disconnection. - * @details \b Inputs: none - * @details \b Outputs: message handled - * @param message a pointer to the message to handle - * @return none. + * @brief + * The handlePatientDisconnectionConfirmCmd function handles user + * confirmation of patient disconnection. + * @details \b Inputs: Patient disconnection confirmation message. + * @details \b Outputs: Acceptance response and patient disconnection signal. + * @param message Pointer to the message to handle. + * @return TRUE if the confirmation is accepted, FALSE otherwise. *************************************************************************/ -void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ) +static BOOL handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ) { + BOOL result = FALSE; + BOOL modeValid = FALSE; + TD_OP_MODE_T mode = getCurrentOperationMode(); + UI_RESPONSE_PAYLOAD_T response; + + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + if ( 0 == message->hdr.payloadLen ) { - signalUserConfirmPatientDisconnection(); + modeValid = ( MODE_POST == mode ) ? TRUE : FALSE; + + if ( ( TRUE != modeValid ) ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + } + else + { + signalUserConfirmPatientDisconnection(); + result = TRUE; + } } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } + + response.accepted = result; + sendMessage( MSG_ID_TD_PATIENT_DISCONNECT_CONFIRM_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; } /*********************************************************************//** - * @brief - * The handleDisposableRemovalConfirmCmd function handles user confirms - * disposable removal. - * @details \b Inputs: none - * @details \b Outputs: message handled - * @param message a pointer to the message to handle - * @return none. + * @brief + * The handleDisposableRemovalConfirmCmd function handles user confirmation + * of disposable removal. + * @details \b Inputs: Disposable removal confirmation message. + * @details \b Outputs: Acceptance response and disposable removal signal. + * @param message Pointer to the message to handle. + * @return TRUE if the confirmation is accepted, FALSE otherwise. *************************************************************************/ -void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ) +static BOOL handleDisposableRemovalConfirmCmd( MESSAGE_T *message ) { + BOOL result = FALSE; + BOOL modeValid = FALSE; + TD_OP_MODE_T mode = getCurrentOperationMode(); + UI_RESPONSE_PAYLOAD_T response; + + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + if ( 0 == message->hdr.payloadLen ) { - signalUserConfirmDisposableRemoval(); + modeValid = ( MODE_POST == mode ) ? TRUE : FALSE; + + if ( FALSE == modeValid ) + { + response.rejectionReason = + REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + } + else + { + signalUserConfirmDisposableRemoval(); + result = TRUE; + } } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); + response.rejectionReason = + REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } + + response.accepted = result; + + sendMessage( MSG_ID_TD_POST_TREATMENT_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE, + COMM_BUFFER_OUT_CAN_TD_2_UI, + (U08 *)&response, + sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; } +/*********************************************************************//** + * @brief + * The handleDisinfectionConfirmCmd function handles user confirmation + * of the disinfection selection. + * @details \b Inputs: Disinfection confirmation message. + * @details \b Outputs: Acceptance response and disinfection confirmation signal. + * @param message Pointer to the message to handle. + * @return TRUE if the confirmation is accepted, FALSE otherwise. + *************************************************************************/ +static BOOL handleDisinfectionConfirmCmd( MESSAGE_T *message ) +{ + BOOL result = FALSE; + BOOL modeValid = FALSE; + TD_OP_MODE_T mode = getCurrentOperationMode(); + UI_RESPONSE_PAYLOAD_T response; + + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + + if ( 0 == message->hdr.payloadLen ) + { + modeValid = ( MODE_POST == mode ) ? TRUE : FALSE; + + if ( FALSE == modeValid ) + { + response.rejectionReason = + REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + } + else + { + signalUserConfirmDisinfection(); + result = TRUE; + } + } + else + { + response.rejectionReason = + REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + response.accepted = result; + + sendMessage( MSG_ID_TD_POST_TREATMENT_DISINFECTION_SELECTION_RESPONSE, + COMM_BUFFER_OUT_CAN_TD_2_UI, + (U08 *)&response, + sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // ***********************************************************************