Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r71d7c6359103b2bd22b2317f7d740c954476a34f -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 71d7c6359103b2bd22b2317f7d740c954476a34f) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -19,6 +19,7 @@ #include "BloodFlow.h" #include "Bubbles.h" #include "Buttons.h" +#include "DDDefs.h" #include "DDInterface.h" #include "Messaging.h" #include "ModeInitPOST.h" @@ -44,19 +45,34 @@ #define USER_COMMAND_CANCEL 0 ///< Cancel treatment workflow command code. #define USER_COMMAND_INITIATE 1 ///< Initiate treatment workflow command code. +/// DD cleaning mode status data structure +typedef struct +{ + BOOL startCleaningMode; ///< Flag to indicate to start cleaning mode. + DD_COMMAND_T startRequestCmdID; ///< DD cleaning mode start request command ID. + ALARM_ID_T alarmID; ///< The informative alarm to trigger for each cleaning mode. + DD_OP_MODE_T ddOpMode; ///< DD operation mode. + 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 DD cleaning request command ID +} DD_CLEANING_MODE_STATUS_T; + // ********** private data ********** static TD_STANDBY_STATE_T currentStandbyState; ///< Current state (sub-mode) of standby mode. static BOOL treatStartReqReceived; ///< Flag indicates user has requested initiation of a treatment. static BOOL homingInitiated; ///< Flag indicates actuators have been homed. static FLUID_TYPE_T fluidType; ///< Fluid type assigned based on user selection. static TREATMENT_TYPE_T modality; ///< Modality from the treatment initiation. +static DD_CLEANING_MODE_STATUS_T currentDDCleaningMode; ///< Current DD cleaning mode status. // ********** private function prototypes ********** static TD_STANDBY_STATE_T handleStandbyModeStartState( void ); static TD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ); static void setStandbyWaitForTreatmentActuators( TD_STANDBY_STATE_T state ); +static void setRequestedCleaningMode( DD_OP_MODE_T opMode, BOOL isHeatDisPassiveCool ); +static TD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ); /*********************************************************************//** * @brief @@ -157,6 +173,10 @@ currentStandbyState = handleStandbyModeWaitForTreatmentState(); break; + case STANDBY_WAIT_FOR_DISINFECT_STATE: + currentStandbyState = handleStandbyModeWaitForDisinfectState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_STANDBY_INVALID_STATE, currentStandbyState ); currentStandbyState = STANDBY_START_STATE; @@ -297,6 +317,67 @@ /*********************************************************************//** * @brief + * The handleStandbyModeWaitForDisinfectState function handles wait for + * disinfect state. + * @details \b Inputs: flushStartReqReceived, heatDisinfectStartReqReceived, + * chemDisinfectStartReqReceived + * @details \b Outputs: none + * @return next state of the standby mode state machine + *************************************************************************/ +static TD_STANDBY_STATE_T handleStandbyModeWaitForDisinfectState( void ) +{ + TD_STANDBY_STATE_T state = STANDBY_WAIT_FOR_DISINFECT_STATE; + + if ( TRUE == currentDDCleaningMode.startCleaningMode ) + { + switch ( currentDDCleaningMode.ddOpMode ) + { + case DD_MODE_FLUS: + cmdStartDDFlush(); + break; + + case DD_MODE_HEAT: + if ( DD_CMD_START_HEAT_DISINFECT_ACTIVE_COOL == currentDDCleaningMode.startRequestCmdID ) + { + //cmdStartDDHeatDisinfectActiveCool(); + } + else + { + //cmdStartDDHeatDisinfectPassiveCool(); + } + break; + + case DD_MODE_HCOL: + //cmdStartDDActiveCool(); + break; + } + state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_CMD_RESPONSE_STATE; + } + else + { + switch ( getDDOpMode() ) + { + case DD_MODE_FLUS: + case DD_MODE_HEAT: + case DD_MODE_ROPS: + // This is for the situations that any of the disinfect modes are started using the proxy commands while the HD + // is in this state of the Standby Mode. + setRequestedCleaningMode( getDDOpMode(), FALSE ); + state = STANDBY_WAIT_FOR_DD_CLEANING_MODE_TO_START_STATE; + currentDDCleaningMode.startCleaningMode = FALSE; + break; + + default: + // Do nothing we are not in the cleaning mode + break; + } + } + + return state; +} + +/*********************************************************************//** + * @brief * The setStandbyWaitForTreatmentActuators function sets TD actuators to * the required Standby: Wait For Treatment state. * @details \b Inputs: none @@ -329,6 +410,7 @@ } /*********************************************************************//** + * @brief * The setFluidType function sets the fluid type based on the user's * treatment selection from the home screen. * @details \b Inputs: none @@ -351,6 +433,77 @@ /*********************************************************************//** * @brief + * The setRequestedCleaningMode function sets the variables for the requested + * DD cleaning mode. + * @details \b Inputs: currentDDCleaningMode + * @details \b Outputs: none + * @param opMode DD operation mode that has been requested (i.e. heat disinfect) + * @param isHeatDisPassiveCool boolean flag to indicate whether this is a passive + * cool heat disinfect or not. + * @return none + *************************************************************************/ +static void setRequestedCleaningMode( DD_OP_MODE_T opMode, BOOL isHeatDisPassiveCool ) +{ + switch ( opMode ) + { + case DD_MODE_FLUS: + currentDDCleaningMode.startCleaningMode = TRUE; + currentDDCleaningMode.startRequestCmdID = DD_CMD_START_FLUSH; + currentDDCleaningMode.ddOpMode = DD_MODE_FLUS; + currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_DISINFECT_FLUSH; + currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_WATERFLUSH; + break; + +// case DD_MODE_HEAT: +// currentDDCleaningMode.startCleaningMode = TRUE; +// currentDDCleaningMode.startRequestCmdID = ( FALSE == isHeatDisPassiveCool ? DD_CMD_START_HEAT_DISINFECT_ACTIVE_COOL : DD_CMD_START_HEAT_DISINFECT_PASSIVE_COOL ); +// currentDDCleaningMode.ddOpMode = DD_MODE_HEAT; +// currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_DISINFECT_HEAT; +// currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_HEAT; +// break; +// +// case DD_MODE_CHEM: +// currentDDCleaningMode.startCleaningMode = TRUE; +// currentDDCleaningMode.startRequestCmdID = DD_CMD_START_CHEM_DISINFECT; +// currentDDCleaningMode.ddOpMode = DD_MODE_CHEM; +// currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_DISINFECT_CHEM; +// currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_CHEMICAL; +// break; +// +// case DD_MODE_CHFL: +// currentDDCleaningMode.startCleaningMode = TRUE; +// currentDDCleaningMode.startRequestCmdID = DD_CMD_START_CHEM_DISINFECT_FLUSH; +// currentDDCleaningMode.ddOpMode = DD_MODE_CHFL; +// currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_DISINFECT_CHEM_FLUSH; +// currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_CHEMICAL_FLUSH; +// break; +// +// case DD_MODE_HCOL: +// currentDDCleaningMode.startCleaningMode = FALSE; +// currentDDCleaningMode.startRequestCmdID = DD_CMD_START_ACTIVE_COOL; +// currentDDCleaningMode.ddOpMode = DD_MODE_HCOL; +// currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_DISINFECT_HEAT_COOL; +// currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_ACTIVE_COOL; +// break; +// +// case DD_MODE_ROPS: +// currentDDCleaningMode.startCleaningMode = TRUE; +// currentDDCleaningMode.startRequestCmdID = DD_CMD_START_RO_PERMEATE_SAMPLE; +// currentDDCleaningMode.ddOpMode = DD_MODE_ROPS; +// currentDDCleaningMode.sampleRqstTrgrd = FALSE; +// currentDDCleaningMode.alarmID = ALARM_ID_TD_RO_PERMEATE_SAMPLE; +// currentDDCleaningMode.stopRequestCmdID = GENERIC_CONFIRM_ID_DISINFECT_STOP_RO_PERMEATE_SAMPLE; +// break; + } +} + +/*********************************************************************//** + * @brief * The getFluidType function returns the current fluid type assigned * based on the user's treatment selection. * @details \b Inputs: none @@ -546,7 +699,48 @@ } } +/*********************************************************************//** + * @brief + * The signalUserInitiateFlushMode function handles user initiation of flush + * mode. + * @details \b Inputs: currentStandbyState + * @details \b Outputs: currentStandbyState + * @return TRUE if signal accepted, FALSE if not + *************************************************************************/ +BOOL signalUserInitiateFlushMode( void ) +{ + BOOL result = FALSE; + REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + UI_RESPONSE_PAYLOAD_T response; + memset( &response, 0, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + if ( MODE_STAN == getCurrentOperationMode() ) + { + if ( ( STANDBY_WAIT_FOR_DISINFECT_STATE == currentStandbyState ) || ( STANDBY_WAIT_FOR_TREATMENT_STATE == currentStandbyState ) ) + { + if ( TRUE == isDDCommunicating() ) + { + setRequestedCleaningMode( DD_MODE_FLUS, FALSE ); + result = TRUE; + currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; + rejReason = REQUEST_REJECT_REASON_NONE; + } + else + { + rejReason = REQUEST_REJECT_REASON_DD_COMM_LOST; + } + } + } + + // Respond to request to start treatment. + response.accepted = result; + response.rejectionReason = rejReason; + sendMessage( MSG_ID_TD_DISINFECT_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*) &response, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r8345f0415ce34f2f47afcbf613a00216769f51c6 -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 8345f0415ce34f2f47afcbf613a00216769f51c6) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -47,6 +47,7 @@ BOOL signalUserInitiateTreatment( MESSAGE_T *message ); // User has initiated/cancelled treatment workflow void signalAlarmActionToStandbyMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Standby mode +BOOL signalUserInitiateFlushMode( void ); void setFluidType( TREATMENT_TYPE_T modality ); // Set a specific fluid type FLUID_TYPE_T getFluidType( void ); // Get a specific fluid type Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -r1b83a4555c4040a45cecfbea45b6570812ab281e -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 1b83a4555c4040a45cecfbea45b6570812ab281e) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "DDDefs.h" #include "DDInterface.h" #include "MessagePayloads.h" #include "Messaging.h" @@ -616,7 +617,8 @@ { dialysateDeliveryCmdSet.substitutionRate = qs; #ifndef TEST_UI_ONLY - sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); + sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, + (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); #endif } else @@ -625,7 +627,25 @@ } } +/*********************************************************************//** + * @brief + * The cmdStartDDFlush function sends a start flush command message to + * the DD. + * @details \b Inputs: none + * @details \b Outputs: start flush mode command sent to DD. + * @return none + *************************************************************************/ +void cmdStartDDFlush( void ) +{ + UI_RESPONSE_PAYLOAD_T response; + memset( &response, 0, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + response.accepted = TRUE; + ddCmdResp[ DD_CMD_START_FLUSH ].commandID = DD_CMD_NONE; + sendMessage( MSG_ID_TD_DD_FLUSH_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*) &response, sizeof( UI_RESPONSE_PAYLOAD_T ) ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/DDInterface.h =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -64,6 +64,7 @@ void cmdBypassDialyzer( BOOL bypass ); void cmdStopGenerateDialysate( void ); void cmdSubstitutionRate (F32 qs ); +void cmdStartDDFlush( void ); void handleDDCommandResponse( DD_CMD_RESPONSE_T *ddCmdRespPtr ); BOOL getDDCommandResponse( U32 commandID, DD_CMD_RESPONSE_T *cmdRespPtr ); Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rde6b47e92a4bffac2ae7238aba9d522bda3ae4df -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision de6b47e92a4bffac2ae7238aba9d522bda3ae4df) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -141,6 +141,7 @@ { 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_DISINFECT_REQUEST, &handleUIDisinfectRequest }, { MSG_ID_TD_SOFTWARE_RESET_REQUEST, &testTDSoftwareResetRequest }, { MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST, &testBubbleDetectOverride }, { MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBubblesDataPublishIntervalOverride }, @@ -785,6 +786,58 @@ /*********************************************************************//** * @brief + * The handleUIDisinfectRequest function handles a disinfect/flush user + * action command message from the UI. + * @details \b Inputs: none + * @details \b Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIDisinfectRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + + if ( DD_DISINFECT_FLUSH_STATE == cmd ) // Command 0 = Flush + { + result = signalUserInitiateFlushMode(); + } +// else if ( DD_DISINFECT_HEAT_STATE_ACTIVE_COOL == cmd ) // Command 1 = Heat disinfect active cool +// { +// result = signalUserInitiateHeatDisinfectActiveCoolMode(); +// } +// else if ( DD_DISINFECT_CHEM_STATE == cmd ) // Command 2 = chemical disinfect +// { +// result = signalUserInitiateChemicalDisinfectMode(); +// } +// else if ( DD_DISINFECT_CHEM_FLUSH_STATE == cmd ) // Command 3 = chemical disinfect flush +// { +// result = signalUserInitiateChemicalDisinfectFlushMode(); +// } +// else if ( DD_DISINFECT_RO_PERMEATE_SAMPLE_STATE == cmd ) // Command 4 = RO permeate sample +// { +// result = signalUserInitiateROPermeateSampleMode(); +// } +// else if ( DD_DISINFECT_HEAT_STATE_PASSIVE_COOL == cmd ) // Command 5 = Heat disinfect passive coode +// { +// result = signalUserInitiateHeatDisinfectPassiveCoolMode(); +// } +// else if ( DD_DISINFECT_ACTIVE_COOL == cmd ) // Command 6 = Active cool +// { +// result = signalUserInitiateActiveCoolMode(); +// } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, result ); +} + +/*********************************************************************//** + * @brief * The sendPOSTTestResult function sends the result of a single TD POST * test to the UI. * @details \b Message \b Sent: MSG_ID_TD_POST_SINGLE_TEST_RESULT Index: firmware/App/Services/Messaging.h =================================================================== diff -u -rde6b47e92a4bffac2ae7238aba9d522bda3ae4df -rf1b7fd13c6136989018e0907d037ab1c713620c6 --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision de6b47e92a4bffac2ae7238aba9d522bda3ae4df) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision f1b7fd13c6136989018e0907d037ab1c713620c6) @@ -144,6 +144,7 @@ BOOL handleTesterLogInRequest( MESSAGE_T *message ); BOOL handleUpdateAvailable( MESSAGE_T *message ); BOOL handleUIVersionResponse( MESSAGE_T *message ); +void handleUIDisinfectRequest( MESSAGE_T *message ); // Test send message helper functions BOOL sendEvent( TD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 );