Index: firmware/App/Modes/StateTxBloodPrime.c =================================================================== diff -u -r1abc0349c736a70fb56db6895947abfbba0eee22 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision 1abc0349c736a70fb56db6895947abfbba0eee22) +++ firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -71,7 +71,6 @@ static BOOL pendingResumeRequest; ///< Flag indicating UI has requested blood prime resume. static BOOL pendingFlowChangeRequest; ///< Flag indicating UI has requested blood prime flow change static BOOL fluidBolusRequested; ///< Flag indicating fluid bolus has been requested by user. -static BOOL bolusStarted; ///< Flag indicating fluid bolus start signal has been sent. static F32 bloodPrimeRampFlowRate_mL_min; ///< Current blood pump ramp flow rate. static F32 bloodPrimeRampStep_mL; ///< Blood pump volume step size for ramping. @@ -136,7 +135,6 @@ bloodPrimeStartMS = 0; fluidBolusRequested = FALSE; - bolusStarted = FALSE; } /*********************************************************************//** @@ -197,7 +195,6 @@ pendingResumeRequest = FALSE; pendingFlowChangeRequest = FALSE; fluidBolusRequested = FALSE; - bolusStarted = FALSE; } /*********************************************************************//** @@ -316,6 +313,8 @@ fluidBolusRequested = FALSE; bloodPrimeResumeState = bloodPrimeState; lastBloodPrimeFlowRate_mL_min = getTargetBloodFlowRate(); + // Start bolus and transition to bolus state + signalStartFluidBolus( lastBloodPrimeFlowRate_mL_min ); result = BLOOD_PRIME_FLUID_BOLUS_STATE; } else @@ -379,6 +378,8 @@ fluidBolusRequested = FALSE; bloodPrimeResumeState = bloodPrimeState; lastBloodPrimeFlowRate_mL_min = getTargetBloodFlowRate(); + // Start bolus and transition to bolus state + signalStartFluidBolus( lastBloodPrimeFlowRate_mL_min ); result = BLOOD_PRIME_FLUID_BOLUS_STATE; } else @@ -428,18 +429,12 @@ { BLOOD_PRIME_STATE_T result = BLOOD_PRIME_FLUID_BOLUS_STATE; - // Start fluid bolus if not started - if ( FALSE == bolusStarted ) - { - bolusStarted = signalStartFluidBolus( lastBloodPrimeFlowRate_mL_min ); - } // Restore actuators and return to pre-bolus sub-state upon bolus complete or abort - else if ( FALSE == isFluidBolusActive() ) + if ( FALSE == isFluidBolusActive() ) { setValvePosition( H1_VALV, VALVE_POSITION_B_OPEN ); setValvePosition( H19_VALV, VALVE_POSITION_B_OPEN ); setBloodPumpTargetFlowRate( lastBloodPrimeFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - bolusStarted = FALSE; result = bloodPrimeResumeState; } Index: firmware/App/Modes/StateTxDialysis.c =================================================================== diff -u -r1abc0349c736a70fb56db6895947abfbba0eee22 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Modes/StateTxDialysis.c (.../StateTxDialysis.c) (revision 1abc0349c736a70fb56db6895947abfbba0eee22) +++ firmware/App/Modes/StateTxDialysis.c (.../StateTxDialysis.c) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -53,7 +53,6 @@ static BOOL ufResumeRequested; ///< Flag indicates UF resume has been requested by user. static BOOL autoResumeUF; ///< Flag indicates UF should be auto-resumed after saline bolus completes. static BOOL fluidBolusRequested; ///< Flag indicating fluid bolus has been requested by user. -static BOOL bolusStarted; ///< Flag indicating fluid bolus start signal has been sent. // ********** private function prototypes ********** @@ -93,7 +92,6 @@ ufResumeRequested = FALSE; autoResumeUF = FALSE; fluidBolusRequested = FALSE; - bolusStarted = FALSE; } /*********************************************************************//** @@ -173,6 +171,8 @@ dialysisResumeState = currentDialysisState; cmdBypassDialyzer( TRUE ); cmdChangeQuf( 0.0F ); + // Start bolus and transition to bolus state + signalStartFluidBolus( setBloodFlowRate ); break; default: @@ -463,25 +463,19 @@ * The handleDialysisFluidBolusState function handles the fluid bolus * sub-state of the Dialysis state machine. Signals the fluid bolus * service to start. - * @details \b Inputs: dialysisResumeState, bolusStarted - * @details \b Outputs: bolusStarted + * @details \b Inputs: dialysisResumeState + * @details \b Outputs: none * @return next dialysis state. *************************************************************************/ static DIALYSIS_STATE_T handleDialysisFluidBolusState( void ) { DIALYSIS_STATE_T result = DIALYSIS_UF_FLUID_BOLUS_STATE; - // Start fluid bolus if not started - if ( FALSE == bolusStarted ) - { - bolusStarted = signalStartFluidBolus( setBloodFlowRate ); - } // Restore actuators and return to pre-bolus sub-state upon bolus complete or abort - else if ( FALSE == isFluidBolusActive() ) + if ( FALSE == isFluidBolusActive() ) { cmdBypassDialyzer( FALSE ); transitionToDialysisState( dialysisResumeState ); - bolusStarted = FALSE; result = dialysisResumeState; } Index: firmware/App/Modes/StateTxPaused.c =================================================================== diff -u -r1abc0349c736a70fb56db6895947abfbba0eee22 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision 1abc0349c736a70fb56db6895947abfbba0eee22) +++ firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -51,7 +51,6 @@ static OVERRIDE_U32_T treatmentPausedPublishInterval; ///< Interval (in task intervals) at which to publish treatment paused state data to CAN bus. static TREATMENT_PAUSED_STATE_T pauseBolusResumeState; ///< Treatment pause sub-state prior to bolus. static BOOL fluidBolusRequested; ///< Flag indicating fluid bolus has been requested by user. -static BOOL bolusStarted; ///< Flag indicating fluid bolus start signal has been sent. // ********** private function prototypes ********** @@ -85,7 +84,6 @@ treatmentPausedPublishInterval.override = OVERRIDE_RESET; fluidBolusRequested = FALSE; - bolusStarted = FALSE; } /*********************************************************************//** @@ -137,9 +135,6 @@ // coming back to stop state via non-alarm path, so no audio - just want alarm for its options signalAlarmSilence( ALARM_SILENCE_CMD_CANCEL ); } - - // Set if bolus is permitted or not. - setBolusPermitted( isBolusAllowedByActiveAlarms() ); } /*********************************************************************//** @@ -155,13 +150,6 @@ { TREATMENT_PAUSED_STATE_T priorSubState = currentTxPausedState; - if ( TRUE == fluidBolusRequested ) - { - fluidBolusRequested = FALSE; - pauseBolusResumeState = currentTxPausedState; - currentTxPausedState = TREATMENT_PAUSED_FLUID_BOLUS_STATE; - } - switch ( currentTxPausedState ) { case TREATMENT_PAUSED_RECIRC_STATE: @@ -315,54 +303,48 @@ * the user requests a new bolus from the paused state. * Monitors the permitted alarm set every tick — aborts the bolus if a * non-permitted alarm becomes active. - * @details \b Inputs: bolusStarted - * @details \b Outputs: currentTxPausedState, bolusStarted + * @details \b Inputs: none + * @details \b Outputs: currentTxPausedState * @return next treatment paused state. *************************************************************************/ static TREATMENT_PAUSED_STATE_T handleTreatmentPausedFluidBolusState( void ) { - TREATMENT_PAUSED_STATE_T state = TREATMENT_PAUSED_FLUID_BOLUS_STATE; + TREATMENT_PAUSED_STATE_T result = TREATMENT_PAUSED_FLUID_BOLUS_STATE; - // Start fluid bolus if not started - if ( FALSE == bolusStarted ) + // Monitor permitted alarms every tick + if ( ( TRUE == isFluidBolusActive() ) && ( FALSE == isBolusAllowedByActiveAlarms() ) ) { - bolusStarted = signalStartFluidBolus( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ) ); + signalAbortFluidBolus(); + setBolusPermitted( FALSE ); } - else - { - // Monitor permitted alarms every tick - if ( ( TRUE == isFluidBolusActive() ) && ( FALSE == isBolusAllowedByActiveAlarms() ) ) - { - signalAbortFluidBolus(); - setBolusPermitted( FALSE ); - } - // Return to pre-bolus sub-state upon bolus complete or abort - if ( FALSE == isFluidBolusActive() ) - { - bolusStarted = FALSE; - state = pauseBolusResumeState; - transitionToTxPausedState( state ); - } + // Return to pre-bolus sub-state upon bolus complete or abort + if ( FALSE == isFluidBolusActive() ) + { + result = handleTreatmentPausedAlarmsAndSignals( pauseBolusResumeState ); } - return state; + return result; } /*********************************************************************//** * @brief * The signalPauseFluidBolusRequest function handles a fluid bolus request - * while in the Treatment Paused state. - * @details \b Inputs: none + * while in the Treatment Paused state. Bolus request is rejected while in + * Recover blood detect state. + * @details \b Inputs: currentTxPausedState * @details \b Outputs: fluidBolusRequested * @return TRUE if request is accepted, FALSE if rejected. *************************************************************************/ BOOL signalPauseTreatFluidBolusRequest( void ) { BOOL result = FALSE; - fluidBolusRequested = TRUE; - result = TRUE; + if ( TREATMENT_PAUSED_RECOVER_BLOOD_DETECT_STATE != currentTxPausedState ) + { + fluidBolusRequested = TRUE; + result = TRUE; + } return result; } @@ -429,8 +411,18 @@ } else { + // Handle fluid bolus request from any paused sub-state + if ( TRUE == fluidBolusRequested ) + { + fluidBolusRequested = FALSE; + // State prior to bolus + pauseBolusResumeState = state; + // Start fluid bolus if not started + signalStartFluidBolus( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ) ); + result = TREATMENT_PAUSED_FLUID_BOLUS_STATE; + } // Both unblocked and not in recirculate both state - if ( ( TREATMENT_PAUSED_NO_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) + else if ( ( TREATMENT_PAUSED_NO_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) { result = TREATMENT_PAUSED_RECIRC_STATE; transitionToTxPausedState( result ); Index: firmware/App/Services/AlarmMgmtTD.h =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -14,10 +14,10 @@ * @date (original) 01-Aug-2024 * ***************************************************************************/ - -#ifndef __ALARM_MGMT_TD_H__ -#define __ALARM_MGMT_TD_H__ - + +#ifndef __ALARM_MGMT_TD_H__ +#define __ALARM_MGMT_TD_H__ + #include "TDCommon.h" #include "AlarmDefs.h" #include "AlarmAudio.h" @@ -50,30 +50,30 @@ NUMBER_OF_ALARM_ACTIONS ///< Number of alarm actions } ALARM_ACTION_T; -#pragma pack(push, 4) -/// Record structure for detailing the properties of the current composite alarm status. -typedef struct -{ - ALARM_PRIORITY_T alarmsState; ///< Current alarm priority level - BOOL alarmsSilenced; ///< Alarms are currently silenced? - U32 alarmsSilenceStart; ///< Time stamp for when alarms were silenced (ms) +#pragma pack(push, 4) +/// Record structure for detailing the properties of the current composite alarm status. +typedef struct +{ + ALARM_PRIORITY_T alarmsState; ///< Current alarm priority level + BOOL alarmsSilenced; ///< Alarms are currently silenced? + U32 alarmsSilenceStart; ///< Time stamp for when alarms were silenced (ms) U32 alarmsSilenceExpiresIn; ///< Time until alarm silence expires (seconds) ALARM_ID_T alarmTop; ///< ID of current top alarm that will drive lamp/audio and UI should be displaying right now - BOOL topAlarmConditionDetected; ///< Condition for top alarm is still being detected - BOOL systemFault; ///< A system fault is active? - BOOL stop; ///< We should be in controlled stop right now - BOOL noClear; ///< No recovery will be possible - BOOL noResume; ///< Treatment may not be resumed at this time - BOOL noRinseback; ///< Rinseback may not be initiated at this time - BOOL noEndTreatment; ///< Ending the treatment is not an option at this time + BOOL topAlarmConditionDetected; ///< Condition for top alarm is still being detected + BOOL systemFault; ///< A system fault is active? + BOOL stop; ///< We should be in controlled stop right now + BOOL noClear; ///< No recovery will be possible + BOOL noResume; ///< Treatment may not be resumed at this time + BOOL noRinseback; ///< Rinseback may not be initiated at this time + BOOL noEndTreatment; ///< Ending the treatment is not an option at this time BOOL noBloodRecirc; ///< No blood re-circulation allowed at this time - BOOL noDialRecirc; ///< No dialysate re-circulation allowed at this time + BOOL noDialRecirc; ///< No dialysate re-circulation allowed at this time BOOL ok; ///< Display OK button instead of other options BOOL noMinimize; ///< Prevent user from minimizing the alarm window BOOL lampOn; ///< The alarm lamp is on BOOL unused; ///< Flag not used - available -} COMP_ALARM_STATUS_T; - +} COMP_ALARM_STATUS_T; + #pragma pack(pop) /// Enumeration of alarm button blockers. @@ -125,18 +125,18 @@ U32 activeAlarmList[ MAX_ALARM_LIST_SIZE ]; ///< Active Alarm List array. } ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T; -// ********** public function prototypes ********** - -void initAlarmMgmtTD( void ); +// ********** public function prototypes ********** + +void initAlarmMgmtTD( void ); void execAlarmMgmt( void ); void clearAlarmTD( ALARM_ID_T alarm ); -void activateAlarmNoData( ALARM_ID_T alarm ); -void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ); +void activateAlarmNoData( ALARM_ID_T alarm ); +void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ); void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ); - + void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); - + void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ); void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); @@ -153,14 +153,14 @@ BOOL handleAlarmConditionCleared( MESSAGE_T *message ); BOOL handleAlarmUserAction( MESSAGE_T *message ); BOOL handleActiveAlarmListRequest( MESSAGE_T *message ); -void handleResendActiveAlarmsRequest( void ); +void handleResendActiveAlarmsRequest( void ); void handleAutoResumeAlarm( ALARM_ID_T alarm ); BOOL testSetAlarmStartTimeOverride( MESSAGE_T *message ); BOOL testClearAllAlarms( MESSAGE_T *message ); BOOL testAlarmStatusPublishIntervalOverride( MESSAGE_T *message ); BOOL testAlarmInfoPublishIntervalOverride( MESSAGE_T *message ); - + /**@}*/ -#endif +#endif Index: firmware/App/Services/FluidBolus.c =================================================================== diff -u -r1abc0349c736a70fb56db6895947abfbba0eee22 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Services/FluidBolus.c (.../FluidBolus.c) (revision 1abc0349c736a70fb56db6895947abfbba0eee22) +++ firmware/App/Services/FluidBolus.c (.../FluidBolus.c) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -15,7 +15,6 @@ * ***************************************************************************/ -#include "AlarmMgmt.h" #include "AlarmMgmtTD.h" #include "BloodFlow.h" #include "DDInterface.h" @@ -210,18 +209,13 @@ * @details \b Outputs: fluidBolusStartRequested, targetBloodFlowMLPM * @return none *************************************************************************/ -BOOL signalStartFluidBolus( U32 flowRate ) +void signalStartFluidBolus( U32 flowRate ) { - BOOL result = FALSE; - if ( ( FLUID_BOLUS_IDLE_STATE == currentFluidBolusState ) && ( FALSE == fluidBolusStartRequested ) ) { fluidBolusStartRequested = TRUE; targetBloodFlowMLPM = flowRate; - result = TRUE; } - - return result; } /*********************************************************************//** @@ -611,7 +605,7 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_INVALID_PAYLOAD_LENGTH, (U32)message->hdr.payloadLen ); + //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_MESSAGE_PAYLOAD_LENGTH, (U32)message->hdr.payloadLen ); } response.accepted = result; Index: firmware/App/Services/FluidBolus.h =================================================================== diff -u -r1abc0349c736a70fb56db6895947abfbba0eee22 -r6b9b882169f108f9a5072dc60cdabbc1687aafcc --- firmware/App/Services/FluidBolus.h (.../FluidBolus.h) (revision 1abc0349c736a70fb56db6895947abfbba0eee22) +++ firmware/App/Services/FluidBolus.h (.../FluidBolus.h) (revision 6b9b882169f108f9a5072dc60cdabbc1687aafcc) @@ -63,7 +63,7 @@ FLUID_BOLUS_MEDIUM_T getFluidBolusMedium( void ); BOOL isFluidBolusActive( void ); -BOOL signalStartFluidBolus( U32 flowRate ); +void signalStartFluidBolus( U32 flowRate ); void signalAbortFluidBolus( void ); F32 getTotalFluidBolusVolumeDelivered( void );