Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r1d07de4e970f54f2ae1786ef546cf5567df9ba8e -r08cb5828a2843c39298df7119c3a1c0789c91f99 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 1d07de4e970f54f2ae1786ef546cf5567df9ba8e) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 08cb5828a2843c39298df7119c3a1c0789c91f99) @@ -46,6 +46,7 @@ static U32 recircTimerCtr; ///< Timer counter (in GP task intervals) counts time spent in re-circulation sub-mode. static U32 recircPublishTimerCtr; ///< Timer counter (in GP task intervals) counts time to next status broadcast. +static BOOL recircStartRecircRequested; ///< Flag indicates user requesting to start recirculating (confirming disconnected). static BOOL recircReconnectRequested; ///< Flag indicates user requesting re-circulate stop so they can re-connect. static BOOL recircBackToTreatmenRequested; ///< Flag indicates user requesting to go back to treatment (confirming re-connected). static BOOL recircResumeRequested; ///< Flag indicates user requesting resumption of re-circulating. @@ -58,13 +59,16 @@ static void setupForRecirculationState( void ); static void setupForRecirculationStopState( void ); +static TREATMENT_RECIRC_STATE_T handleRecircDisconnectPatientState( void ); static TREATMENT_RECIRC_STATE_T handleRecircRecircState( void ); static TREATMENT_RECIRC_STATE_T handleRecircStoppedState( void ); +static TREATMENT_RECIRC_STATE_T handleRecircReconnectPatientState( void ); static BOOL handleRecircReconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static BOOL handleRecicConfirmReconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static BOOL handleRecircResumeUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static BOOL handleRecircEndTreatmentUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); +static BOOL handleRecircConfirmDisconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static void publishTreatmentRecircData( void ); @@ -93,6 +97,7 @@ *************************************************************************/ static void resetTreatmentRecircFlags( void ) { + recircStartRecircRequested = FALSE; recircReconnectRequested = FALSE; recircBackToTreatmenRequested = FALSE; recircResumeRequested = FALSE; @@ -190,6 +195,10 @@ switch ( treatmentRecircState ) { + case TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE: + treatmentRecircState = handleRecircDisconnectPatientState(); + break; + case TREATMENT_RECIRC_RECIRC_STATE: treatmentRecircState = handleRecircRecircState(); break; @@ -198,6 +207,10 @@ treatmentRecircState = handleRecircStoppedState(); break; + case TREATMENT_RECIRC_RECONNECT_PATIENT_STATE: + treatmentRecircState = handleRecircReconnectPatientState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_TREATMENT_RECIRC_INVALID_STATE, treatmentRecircState ); break; @@ -216,6 +229,26 @@ /*********************************************************************//** * @brief + * The handleRecircDisconnectPatientState function handles the re-circulation + * disconnect patient state operations. + * @details Inputs: flags + * @details Outputs: flags handled + * @return next Treatment re-circulation state + *************************************************************************/ +static TREATMENT_RECIRC_STATE_T handleRecircDisconnectPatientState( void ) +{ + TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE; + + if ( TRUE == recircStartRecircRequested ) + { + result = TREATMENT_RECIRC_RECIRC_STATE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The handleRecircRecircState function handles the re-circulating state * operations. * @details Inputs: flags @@ -226,12 +259,18 @@ { TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_RECIRC_STATE; - // Is alarm stop or user reconnect requested? - if ( ( TRUE == recircReconnectRequested ) || ( TRUE == doesAlarmStatusIndicateStop() ) ) + // Is alarm stop? + if ( TRUE == doesAlarmStatusIndicateStop() ) { setupForRecirculationStopState(); result = TREATMENT_RECIRC_STOPPED_STATE; } + // Is user reconnect requested? + else if ( TRUE == recircReconnectRequested ) + { + setupForRecirculationStopState(); + result = TREATMENT_RECIRC_RECONNECT_PATIENT_STATE; + } // Is end treatment requested? else if ( TRUE == recircEndTreatmentRequested ) { @@ -254,6 +293,33 @@ { TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_STOPPED_STATE; + // Is end treatment requested? + if ( TRUE == recircEndTreatmentRequested ) + { + signalEndTreatment(); + } + // Is re-circ resume requested? + else if ( TRUE == recircResumeRequested ) + { + setupForRecirculationState(); + result = TREATMENT_RECIRC_RECIRC_STATE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleRecircReconnectPatientState function handles the re-circulation + * reconnect patient state operations. + * @details Inputs: flags + * @details Outputs: flags handled + * @return next Treatment re-circulation state + *************************************************************************/ +static TREATMENT_RECIRC_STATE_T handleRecircReconnectPatientState( void ) +{ + TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_RECONNECT_PATIENT_STATE; + // Is back to treatment requested? if ( TRUE == recircBackToTreatmenRequested ) { @@ -262,7 +328,8 @@ // Is end treatment requested? else if ( TRUE == recircEndTreatmentRequested ) { - signalEndTreatment(); + setupForRecirculationStopState(); + signalEndTreatment(); // signal end Tx sub-mode } // Is re-circ resume requested? else if ( TRUE == recircResumeRequested ) @@ -271,6 +338,7 @@ result = TREATMENT_RECIRC_RECIRC_STATE; } + return result; } @@ -309,6 +377,10 @@ accepted = handleRecircEndTreatmentUserAction( &rejReason ); break; + case REQUESTED_USER_ACTION_TX_RECIRC_CONFIRM_DISCONNECT: + accepted = handleRecircConfirmDisconnectUserAction( &rejReason ); + break; + default: rejReason = REQUEST_REJECT_REASON_INVALID_COMMAND; break; @@ -410,7 +482,7 @@ /*********************************************************************//** * @brief - * The handleRecircEndTreatmentUserAction function handles an e reatment + * The handleRecircEndTreatmentUserAction function handles an end treatment * user action request. It is assumed that the calling function will set * the reject reason parameter to None beforehand. * @details Inputs: treatmentRecircState @@ -437,6 +509,33 @@ /*********************************************************************//** * @brief + * The handleRecircConfirmDisconnectUserAction function handles a confirm + * patient disconnect user action request. It is assumed that the calling + * function will set the reject reason parameter to None beforehand. + * @details Inputs: treatmentRecircState + * @details Outputs: confirming patient disconnect action handled + * @param rejReason Code indicating reason for rejection + * @return TRUE if user action accepted, FALSE if not + *************************************************************************/ +static BOOL handleRecircConfirmDisconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ) +{ + BOOL result = FALSE; + + if ( TREATMENT_RECIRC_DISCONNECT_PATIENT_STATE == treatmentRecircState ) + { + result = TRUE; + recircStartRecircRequested = TRUE; + } + else + { + *rejReason = REQUEST_REJECT_REASON_ACTION_DISABLED_IN_CURRENT_STATE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getCurrentTreatmentRecircState function returns the current state of the * treatment re-circulate sub-mode. * @details Inputs: treatmentRecircState