Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -60,7 +60,6 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); - } /*********************************************************************//** @@ -152,7 +151,7 @@ *************************************************************************/ void signalAlarmActionToFaultMode( ALARM_ACTION_T action ) { - + // fault mode is terminal and already in safe state - no alarm actions handled in this mode. } /**@}*/ Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -73,7 +73,7 @@ void transitionToInitAndPOSTMode( void ) { // set user alarm recovery actions allowed in this mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); } Index: firmware/App/Modes/ModeService.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -48,7 +48,7 @@ void transitionToServiceMode( void ) { // set user alarm recovery actions allowed in this mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -79,7 +79,7 @@ resetAirTrap(); // set user alarm recovery actions allowed in this mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -196,7 +196,69 @@ *************************************************************************/ void signalAlarmActionToTreatmentMode( ALARM_ACTION_T action ) { + switch( action ) + { + case ALARM_ACTION_STOP: + switch ( currentTreatmentState ) + { + case TREATMENT_START_STATE: + case TREATMENT_DIALYSIS_STATE: + stopDialysis(); + transitionToTreatmentStop(); + currentTreatmentState = TREATMENT_STOP_STATE; + break; + case TREATMENT_RINSEBACK_STATE: + // TODO - implement + break; + + case TREATMENT_RECIRC_STATE: + // TODO - implement + break; + + default: + // ignore + break; + } + break; + + case ALARM_ACTION_RESUME: + switch ( currentTreatmentState ) + { + case TREATMENT_STOP_STATE: + break; + + case TREATMENT_RINSEBACK_PAUSE_STATE: + // TODO - implement + break; + + case TREATMENT_RECIRC_PAUSE_STATE: + // TODO - implement + break; + + default: + // ignore + break; + } + break; + + case ALARM_ACTION_RINSEBACK: + // TODO - implement + break; + + case ALARM_ACTION_END_TREATMENT: + // TODO - temporary code - implement + currentTreatmentState = TREATMENT_END_STATE; + break; + + case ALARM_ACTION_ACK: + // nothing to be done here + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_INVALID_ALARM_ACTION, (U32)action ) + break; + } } /*********************************************************************//** Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -131,7 +131,7 @@ treatmentCancelled = FALSE; // set user alarm recovery actions allowed in this mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -94,7 +94,8 @@ static void updateAlarmsSilenceStatus( void ); static void handleAlarmEscalations( void ); static void updateAlarmsFlags( void ); - + +static void clearAllRecoverableAlarms( void ); static void resetAlarmPriorityFIFO( ALARM_PRIORITY_T priority ); static U32 getAlarmStartTime( ALARM_ID_T alarmID ); @@ -147,7 +148,7 @@ alarmStatus.noRinseback = FALSE; alarmStatus.noEndTreatment = FALSE; alarmStatus.noNewTreatment = FALSE; - alarmStatus.bypassDialyzer = FALSE; + alarmStatus.usrACKRequired = FALSE; } /*********************************************************************//** @@ -209,6 +210,11 @@ if ( TRUE == ALARM_TABLE[ alarm ].alarmConditionClearImmed ) { clearAlarmCondition( alarm ); + } + // if alarm has stop property, signal stop now + if ( TRUE == ALARM_TABLE[ alarm ].alarmStops ) + { + initiateAlarmAction( ALARM_ACTION_STOP ); } } } @@ -340,76 +346,6 @@ } } -/*********************************************************************//** - * @brief - * The setAlarmUserActionEnabled function enables/disables specific alarm - * recovery user actions while in specific modes. - * @details Inputs: none - * @details Outputs: - * @param action ID of user alarm recovery action to enable/disable - * @param enabled set to TRUE to enable action, FALSE to disable - * @return none - *************************************************************************/ -void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ) -{ - if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) - { - alarmUserRecoveryActionEnabled[ action ] = enabled; - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_USER_ACTION, (U32)action ) - } -} - -/*********************************************************************//** - * @brief - * The signalAlarmUserActionInitiated function clears all non-recoverable alarms - * and initiates selected user action. - * @details Inputs: none - * @details Outputs: - * @param action ID of user's selected action to initiate - * @return none - *************************************************************************/ -void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ) -{ - // validate given action - if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) - { - ALARM_ID_T a; - - // inactivate (clear) all active recoverable alarms - for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) - { - // is alarm recoverable? - if ( FALSE == ALARM_TABLE[ a ].alarmNoClear ) - { - clearAlarm( a ); - } - } - - // initiate user selected action - switch ( action ) - { - case ALARM_USER_ACTION_RESUME: - // TODO - break; - - case ALARM_USER_ACTION_RINSEBACK: - // TODO - break; - - case ALARM_USER_ACTION_END_TREATMENT: - // TODO - break; - - default: - // TODO - s/w fault? - break; - } - } -} - /*********************************************************************//** * @brief * The clearAlarm function clears a given alarm if it is recoverable. Also @@ -461,6 +397,89 @@ } } +/*********************************************************************//** + * @brief + * The setAlarmUserActionEnabled function enables/disables specific alarm + * recovery user actions while in specific modes. Ack option is always + * potentially enabled - automatically enabled as appropriate by updateAlarmsFlags(). + * @details Inputs: none + * @details Outputs: + * @param action ID of user alarm recovery action to enable/disable + * @param enabled set to TRUE to enable action, FALSE to disable + * @return none + *************************************************************************/ +void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ) +{ + if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) + { + alarmUserRecoveryActionEnabled[ action ] = enabled; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_USER_ACTION, (U32)action ) + } +} + +/*********************************************************************//** + * @brief + * The signalAlarmUserActionInitiated function clears all non-recoverable alarms + * and initiates selected user action. + * @details Inputs: none + * @details Outputs: + * @param action ID of user's selected action to initiate + * @return none + *************************************************************************/ +void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ) +{ + // validate given action + if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) + { + ALARM_ID_T a = alarmStatus.alarmTop; + + if ( ALARM_USER_ACTION_ACK == action ) + { + // if user acknowledged top alarm, just clear that alarm + if ( TRUE == ALARM_TABLE[ a ].alarmUserAckRequired ) + { + clearAlarm( a ); + } + // otherwise we must be in mode/state where ack was only option - so clear all like other options + else + { + clearAllRecoverableAlarms(); + } + } + else + { + clearAllRecoverableAlarms(); + } + } + + // initiate user selected action + switch ( action ) + { + case ALARM_USER_ACTION_RESUME: + initiateAlarmAction( ALARM_ACTION_RESUME ); + break; + + case ALARM_USER_ACTION_RINSEBACK: + initiateAlarmAction( ALARM_ACTION_RINSEBACK ); + break; + + case ALARM_USER_ACTION_END_TREATMENT: + initiateAlarmAction( ALARM_ACTION_END_TREATMENT ); + break; + + case ALARM_USER_ACTION_ACK: + initiateAlarmAction( ALARM_ACTION_ACK ); + break; + + default: + // TODO - s/w fault? + break; + } +} + /*********************************************************************//** * @brief * The isAlarmActive function determines whether a given alarm is currently @@ -815,7 +834,7 @@ BOOL noRinseback = FALSE; BOOL noEndTreatment = FALSE; BOOL noNewTreatment = FALSE; - BOOL bypassDialyzer = FALSE; + BOOL usrAckReq = FALSE; ALARM_ID_T a; // determine alarm flags @@ -827,7 +846,6 @@ stop = ( TRUE == ALARM_TABLE[ a ].alarmStops ? TRUE : stop ); noClear = ( TRUE == ALARM_TABLE[ a ].alarmNoClear ? TRUE : noClear ); noNewTreatment = ( TRUE == ALARM_TABLE[ a ].alarmNoNewTreatment ? TRUE : noNewTreatment ); - bypassDialyzer = ( TRUE == ALARM_TABLE[ a ].alarmDialyzerBypass ? TRUE : bypassDialyzer ); // set user alarm recovery actions allowed flags if ( TRUE == alarmUserRecoveryActionEnabled[ ALARM_USER_ACTION_RESUME ] ) { @@ -842,14 +860,18 @@ noEndTreatment = ( TRUE == ALARM_TABLE[ a ].alarmNoEndTreatment ? TRUE : noEndTreatment ); } } // if alarm active - } // alarm table loop + } // alarm table loop + + // if top alarm requires user ack or no other user options enabled for recoverable alarm, set user ack flag + if ( ( TRUE == ALARM_TABLE[ alarmStatus.alarmTop ].alarmUserAckRequired ) || + ( ( FALSE == alarmStatus.noClear ) && ( noResume ) && ( noRinseback ) && ( noEndTreatment ) ) ) + { + usrAckReq = TRUE; + noResume = TRUE; + noRinseback = TRUE; + noEndTreatment = TRUE; + } - // do not bypass dialyzer if stop or fault flag set - if ( ( TRUE == systemFault ) || ( TRUE == stop ) ) - { - bypassDialyzer = FALSE; - } - // set updated alarm flags alarmStatus.systemFault = systemFault; alarmStatus.stop = stop; @@ -858,7 +880,29 @@ alarmStatus.noRinseback = noRinseback; alarmStatus.noEndTreatment = noEndTreatment; alarmStatus.noNewTreatment = noNewTreatment; - alarmStatus.bypassDialyzer = bypassDialyzer; + alarmStatus.usrACKRequired = usrAckReq; +} + +/*********************************************************************//** + * @brief + * The clearAllRecoverableAlarms function clears all currently active + * recoverable alarms. + * @details Inputs: ALARM_TABLE[] + * @details Outputs: All currently active recoverable alarms are cleared + * @return none + *************************************************************************/ +static void clearAllRecoverableAlarms( void ) +{ + ALARM_ID_T a = alarmStatus.alarmTop; + + for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) + { + // is alarm recoverable? + if ( FALSE == ALARM_TABLE[ a ].alarmNoClear ) + { + clearAlarm( a ); + } + } } /*********************************************************************//** Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r0fce4283f8f28da957f9e82ec121efbc6ee55241 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 0fce4283f8f28da957f9e82ec121efbc6ee55241) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -43,10 +43,10 @@ typedef enum Alarm_Actions { ALARM_ACTION_STOP = 0, ///< Alarm state requests HD in safe state (pumps stopped, heater off, valves in safe state) - ALARM_ACTION_BYPASS_DIALYZER, ///< Alarm state requests dialysate re-circ while bypassing dialyzer ALARM_ACTION_RESUME, ///< User selected resume from alarm recovery options ALARM_ACTION_RINSEBACK, ///< User selected rinseback from alarm recovery options ALARM_ACTION_END_TREATMENT, ///< User selected end treatment from alarm recovery options + ALARM_ACTION_ACK, ///< User selected Ack from alarm recovery options NUMBER_OF_ALARM_ACTIONS ///< Number of alarm actions } ALARM_ACTION_T; @@ -80,7 +80,7 @@ BOOL noRinseback; ///< rinseback may not be initiated at this time BOOL noEndTreatment; ///< ending the treatment is not an option at this time BOOL noNewTreatment; ///< no new treatments may be started even if current treatment is ended - BOOL bypassDialyzer; ///< the dialyzer should be bypassed at this time + BOOL usrACKRequired; ///< the user must acknowledge top alarm BOOL lampOn; ///< the alarm lamp is on } COMP_ALARM_STATUS_T; @@ -193,8 +193,8 @@ SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL, // 50 SW_FAULT_ID_PI_CTRL_INVALID_CONTROLLER, SW_FAULT_ID_PI_CTRL_INVALID_SIGNAL, + SW_FAULT_ID_MODE_TREATMENT_INVALID_ALARM_ACTION, SW_FAULT_ID____AVAILABLE_1, - SW_FAULT_ID____AVAILABLE_2, SW_FAULT_ID_DIALYSIS_INVALID_STATE, // 55 SW_FAULT_ID_DIALYSIS_INVALID_UF_STATE, SW_FAULT_ID_NVDATAMGMT_INVALID_SELF_TEST_STATE, Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r85ab84d9a0668e1e3976b00eb29e79c38c81b651 -r7325348a8b5fce9101d0f68d89c791d48e1a3575 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 85ab84d9a0668e1e3976b00eb29e79c38c81b651) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 7325348a8b5fce9101d0f68d89c791d48e1a3575) @@ -750,7 +750,7 @@ payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RINSEBACK) : 0 ); payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_END_TREATMENT) : 0 ); payload.alarmsFlags |= ( almStatus.noNewTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_NEW_TREATMENT) : 0 ); - payload.alarmsFlags |= ( almStatus.bypassDialyzer ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_BYPASS_DIALYZER) : 0 ); + payload.alarmsFlags |= ( almStatus.usrACKRequired ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_USER_MUST_ACK) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_TO_ESCALATE) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_SILENCED) : 0 ); payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 0 );