Index: firmware/App/Modes/StateTxBloodPrime.c =================================================================== diff -u -r2fe1bfe77e53e5b92dae1b89c726c59b7b95939f -rcc925371f5081d8b486e65f942d9608e6e0b8d31 --- firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision 2fe1bfe77e53e5b92dae1b89c726c59b7b95939f) +++ firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision cc925371f5081d8b486e65f942d9608e6e0b8d31) @@ -1,29 +1,35 @@ /************************************************************************** * -* Copyright (c) 2021-2025 Diality Inc. - All Rights Reserved. +* Copyright (c) 2026-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file BloodPrime.c +* @file StateTxBloodPrime.c * -* @author (last) Varshini Nagabooshanam -* @date (last) 26-Dec-2025 +* @author (last) Raghu Kallala +* @date (last) 20-Feb-2026 * * @author (original) Varshini Nagabooshanam -* @date (original) 22-Dec-2025 +* @date (original) 09-Jan-2026 * ***************************************************************************/ -#include #include "AirTrap.h" #include "BloodFlow.h" +#include "Buttons.h" +#include "DDInterface.h" +#include "Messaging.h" #include "ModeTreatment.h" -#include "ModeTxParams.h" +#include "TxParams.h" #include "OperationModes.h" +#include "StateTxBloodPrime.h" +#include "Switches.h" #include "TaskGeneral.h" +#include "Timers.h" #include "Utilities.h" #include "Valves.h" +#include "Valve3Way.h" /** * @addtogroup StateTxBloodPrime @@ -47,16 +53,26 @@ /// Multiplier to convert flow (mL/min) into volume (mL) for period of general task interval. static const F32 BLOOD_PRIME_FLOW_INTEGRATOR = 1.0F / (F32)( SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); +/// Tubing portion of blood prime volume to prime the blood side circuit (in mL). +#define TUBING_BLOOD_PRIME_VOLUME_ML 126 + // ********** private data ********** static BLOOD_PRIME_STATE_T bloodPrimeState; ///< Current state of the blood prime sub-mode. +static BLOOD_PRIME_STATE_T bloodPrimeResumeState; ///< Blood prime sub-state prior to pause. +static BOOL pendingPauseRequest; ///< Flag indicating UI has requested blood prime pause. +static BOOL pendingResumeRequest; ///< Flag indicating UI has requested blood prime resume. +static BOOL pendingFlowChangeRequest; ///< Flag indicating UI has requested blood prime flow change static F32 bloodPrimeRampFlowRate_mL_min; ///< Current blood pump ramp flow rate. static F32 bloodPrimeRampStep_mL; ///< Blood pump volume step size for ramping. static F32 bloodPrimeTargetVolume_mL; ///< Calculated target blood prime volume (based on selected dialyzer and fixed tubing volume). static U32 bloodPrimeRampControlTimerCtr; ///< Timer counter for determining interval for controlling BP ramp. static U32 bloodPrimePublishTimerCtr; ///< Timer counter for determining interval for blood prime status to be published. +static U32 lastBloodPrimeFlowRate_mL_min; ///< Flow rate prior to pausing blood prime. +static U32 requestedBloodFlowRate_mL_min; ///< Requested blood flow rate from UI. +static U32 bloodPrimeStartMS = 0; ///< Start time of Blood Prime (ms timer count) /// Interval (in task intervals) at which to publish blood prime data to CAN bus. static OVERRIDE_U32_T bloodPrimePublishInterval = { BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, 0 }; @@ -68,15 +84,15 @@ static void resetBloodPrimeFlags( void ); static F32 getBloodPrimeVolume( void ); static BLOOD_PRIME_STATE_T handleBloodPrimeRampState( void ); +static BLOOD_PRIME_STATE_T handleBloodPrimeRunState( void ); +static BLOOD_PRIME_STATE_T handleBloodPrimePausedState( void ); static void publishBloodPrimeData( void ); /*********************************************************************//** * @brief - * The initBloodPrime function initializes the Blood Prime sub-mode - * module. Calling this function will reset blood prime and therefore should - * only be called when a new blood prime is due to begin. - * @details Inputs: none - * @details Outputs: Blood prime sub-mode module initialized. + * The initBloodPrime function initializes the Blood Prime state unit. + * @details \b Inputs: none + * @details \b Outputs: Blood prime state unit initialized. * @return none *************************************************************************/ void initBloodPrime( void ) @@ -86,12 +102,13 @@ F32 estRampSeconds = 0.0F; bloodPrimeState = BLOOD_PRIME_RAMP_STATE; + bloodPrimeResumeState = BLOOD_PRIME_RAMP_STATE; bloodPrimeRampControlTimerCtr = 0; bloodPrimePublishTimerCtr = BLOOD_PRIME_DATA_PUBLISH_INTERVAL - 2; // setup so publish will occur time after next cumulativeBloodPrimeVolume_mL.data = 0.0; resetBloodPrimeFlags(); - bloodPrimeTargetVolume_mL = (F32)getTreatmentParameterU32( TUBING_BLOOD_PRIME_VOLUME_ML ) + getDialyzerBloodVolume( getTreatmentParameterU32( TREATMENT_PARAM_DIALYZER_TYPE ) ); + bloodPrimeTargetVolume_mL = TUBING_BLOOD_PRIME_VOLUME_ML + (F32)( getDialyzerBloodVolume( getTreatmentParameterU32( TREATMENT_PARAM_DIALYZER_TYPE ) ) ); bloodPrimeRampFlowRate_mL_min = (F32)BLOOD_PRIME_INIT_BP_FLOW_RATE_ML_MIN; // Calculate BP ramp step size @@ -103,67 +120,74 @@ estRampSeconds = (F32)MIN_RAMP_TIME_SEC; } bloodPrimeRampStep_mL = rampRateSpan / estRampSeconds; + bloodPrimeStartMS = getMSTimerCount(); } /*********************************************************************//** * @brief * The transitionToBloodPrime function prepares for transition to blood prime - * sub-mode. This function will reset only what is required for resuming a + * state. This function will reset only what is required for resuming a * blood prime that was paused (alarm) so if a blood prime is being restarted, * call the initialize function first to reset everything. - * @details Inputs: none - * @details Outputs: actuators set for initial state of blood prime sub-mode + * @details \b Inputs: none + * @details \b Outputs: actuators set for initial state of blood prime state * @return none *************************************************************************/ void transitionToBloodPrime( void ) { - doorClosedRequired( TRUE, TRUE ); + // Set user alarm recovery actions allowed in this state + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); + setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); - // Set valves + // Require BP door to be closed during this state + doorClosedRequired( TRUE ); + + // Set pinch valves setValvePosition( H1_VALV, VALVE_POSITION_B_OPEN ); // set arterial valve to pump blood from patient setValvePosition( H19_VALV, VALVE_POSITION_B_OPEN ); // set venous valve to open, allowing blood to return to patient - // Start air trap control - startAirTrapControl(); - - // Set valves + // Set air trap valves set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + // Start air trap control + startAirTrapControl(); - // Ensure dialysate outlet and Heparin pumps are stopped - //signalDialOutPumpHardStop(); - //stopSyringePump(); + // Ensure Heparin pump is stopped + //stopSyringePump(); // TODO - // start blood and dialysate inlet pumps + // start blood pump setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setCurrentSubState( (U32)bloodPrimeState ); + // Direct DD to bypass dialysate and perform no ultrafiltration + cmdBypassDialyzer( TRUE ); + cmdChangeQd( getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) ); + cmdChangeQuf( 0.0F ); - // Set user alarm recovery actions allowed in this sub-mode - setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); - setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); - setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + setCurrentSubState( (U32)bloodPrimeState ); } /*********************************************************************//** * @brief * The resetBloodPrimeFlags function resets the blood prime request flags. - * @details Inputs: none - * @details Outputs: Blood prime request flags reset to FALSE. + * @details \b Inputs: none + * @details \b Outputs: Blood prime request flags reset to FALSE. * @return none *************************************************************************/ static void resetBloodPrimeFlags( void ) { - // No flags for now + pendingPauseRequest = FALSE; + pendingResumeRequest = FALSE; + pendingFlowChangeRequest = FALSE; } /*********************************************************************//** * @brief * The getBloodPrimeVolume function gets the calculated blood prime volume * delivered. - * @details Inputs: cumulativeBloodPrimeVolume_mL - * @details Outputs: none + * @details \b Inputs: cumulativeBloodPrimeVolume_mL + * @details \b Outputs: none * @return the current blood prime volume delivered (in mL). *************************************************************************/ static F32 getBloodPrimeVolume( void ) @@ -180,9 +204,9 @@ /*********************************************************************//** * @brief - * The execBloodPrime function executes the Blood Prime sub-mode state machine. - * @details Inputs: bloodPrimeState - * @details Outputs: bloodPrimeState + * The execBloodPrime function executes the Blood Prime state machine. + * @details \b Inputs: bloodPrimeState + * @details \b Outputs: bloodPrimeState * @return none *************************************************************************/ void execBloodPrime( void ) @@ -193,6 +217,14 @@ bloodPrimeState = handleBloodPrimeRampState(); break; + case BLOOD_PRIME_RUN_STATE: + bloodPrimeState = handleBloodPrimeRunState(); + break; + + case BLOOD_PRIME_PAUSED_STATE: + bloodPrimeState = handleBloodPrimePausedState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_BLOOD_PRIME_INVALID_STATE, bloodPrimeState ); break; @@ -209,52 +241,141 @@ * @brief * The handleBloodPrimeRampState function handles the blood prime ramp * state operations. - * @details Inputs: flags - * @details Outputs: flags handled + * @details \b Inputs: flags + * @details \b Outputs: flags handled * @return next blood prime state *************************************************************************/ static BLOOD_PRIME_STATE_T handleBloodPrimeRampState( void ) { BLOOD_PRIME_STATE_T result = BLOOD_PRIME_RAMP_STATE; - // Update blood prime volume delivered so far + //Update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL.data += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); if ( TRUE == getTestConfigStatus( TEST_CONFIG_SKIP_BLOOD_PRIME ) ) { - // If the skip blood prime is enabled, set the cumulative volume to the target blood prime volume cumulativeBloodPrimeVolume_mL.data = bloodPrimeTargetVolume_mL; } - // Has blood prime completed? + // Volume reached to Dialysis if ( getBloodPrimeVolume() >= bloodPrimeTargetVolume_mL ) { - initBloodPrime(); // Reset blood prime so that we start anew next time we transition to this sub-mode - setBloodIsPrimed( TRUE ); // Signal treatment mode that blood prime is completed - signalBloodPrimeToDialysis(); // Signal treatment mode that it's time to start dialysis + initBloodPrime(); + setBloodIsPrimed( TRUE ); + signalBloodPrimeToDialysis(); } + // Soft pause from UI + else if ( TRUE == pendingPauseRequest ) + { + pendingPauseRequest = FALSE; + bloodPrimeResumeState = BLOOD_PRIME_RAMP_STATE; + lastBloodPrimeFlowRate_mL_min = (F32)getTargetBloodFlowRate(); + setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + // Close art/ven pinch valves + setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); + setValvePosition( H19_VALV, VALVE_POSITION_C_CLOSE ); + result = BLOOD_PRIME_PAUSED_STATE; + } + // When UI changes blood flow rate + else if ( TRUE == pendingFlowChangeRequest ) + { + pendingFlowChangeRequest = FALSE; + bloodPrimeRampFlowRate_mL_min = (F32)requestedBloodFlowRate_mL_min; + // To ensure resume returns to RUN state + bloodPrimeResumeState = BLOOD_PRIME_RUN_STATE; + result = BLOOD_PRIME_RUN_STATE; + } else { - // ramp blood pump on ramp interval + // Continue ramping if ( ++bloodPrimeRampControlTimerCtr >= BLOOD_PRIME_RAMPING_INTERVAL ) { - U32 setBPRate = getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ); - - bloodPrimeRampControlTimerCtr = 0; - bloodPrimeRampFlowRate_mL_min += bloodPrimeRampStep_mL; - setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + bloodPrimeRampControlTimerCtr = 0; + bloodPrimeRampFlowRate_mL_min += bloodPrimeRampStep_mL; + setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); } } + return result; +} + +/*********************************************************************//** + * @brief + * The handleBloodPrimeRunState function handles the blood prime run + * state operations. + * @details \b Inputs: cumulativeBloodPrimevolume_mL + * @details \b Outputs: cumulativeBloodPrimevolume_mL + * @return next blood prime state + *************************************************************************/ +static BLOOD_PRIME_STATE_T handleBloodPrimeRunState( void ) +{ + BLOOD_PRIME_STATE_T result = BLOOD_PRIME_RUN_STATE; + + // Update blood prime volume delivered so far + cumulativeBloodPrimeVolume_mL.data += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); + + // Volume reached to Dialysis + if ( getBloodPrimeVolume() >= bloodPrimeTargetVolume_mL ) + { + initBloodPrime(); + setBloodIsPrimed( TRUE ); + signalBloodPrimeToDialysis(); + } + // Soft pause from UI + else if ( TRUE == pendingPauseRequest ) + { + pendingPauseRequest = FALSE; + bloodPrimeResumeState = BLOOD_PRIME_RUN_STATE; + lastBloodPrimeFlowRate_mL_min = getTargetBloodFlowRate(); + setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + // Close art/ven pinch valves + setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); + setValvePosition( H19_VALV, VALVE_POSITION_C_CLOSE ); + result = BLOOD_PRIME_PAUSED_STATE; + } + // When UI changes blood flow rate + else if ( TRUE == pendingFlowChangeRequest ) + { + pendingFlowChangeRequest = FALSE; + setBloodPumpTargetFlowRate( requestedBloodFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + } + return result; } /*********************************************************************//** * @brief + * The handleBloodPrimePausedState function handles the blood prime paused + * state operations. + * @details \b Inputs: getCurrentOperationMode + * @details \b Outputs: flags handled + * @return none + *************************************************************************/ +static BLOOD_PRIME_STATE_T handleBloodPrimePausedState( void ) +{ + BLOOD_PRIME_STATE_T result = BLOOD_PRIME_PAUSED_STATE; + + // Soft resume from UI + if ( TRUE == pendingResumeRequest ) + { + pendingResumeRequest = FALSE; + setBloodPumpTargetFlowRate( (U32)lastBloodPrimeFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + // Open art/ven pinch valves + setValvePosition( H1_VALV, VALVE_POSITION_B_OPEN ); + setValvePosition( H19_VALV, VALVE_POSITION_B_OPEN ); + // Return to state prior to pause + result = bloodPrimeResumeState; + } + + return result; +} + +/*********************************************************************//** + * @brief * The getCurrentBloodPrimeState function returns the current state of the - * blood prime sub-mode. - * @details Inputs: bloodPrimeState - * @details Outputs: none + * blood prime state. + * @details \b Inputs: bloodPrimeState + * @details \b Outputs: none * @return bloodPrimeState *************************************************************************/ BLOOD_PRIME_STATE_T getCurrentBloodPrimeState( void ) @@ -263,22 +384,130 @@ } /*********************************************************************//** +* @brief +* The bloodPrimeHandleCmdRequest function handles the UI blood prime +* command request. +* @details \b Message \b Sent: MSG_ID_UI_BLOOD_PRIME_CMD_RESPONSE +* @details \b Inputs: message containing requested blood prime user action. +* @details \b Outputs: bloodPrimeRequestedAction updated if valid. +* @return TRUE if request is accepted, FALSE if rejected. +*************************************************************************/ +BOOL bloodPrimeHandleCmdRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 action = 0; + REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + UI_RESPONSE_PAYLOAD_T response; + + // Verify message payload length is valid + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &action, message->payload, sizeof( U32 ) ); + + if ( action < NUM_OF_REQUESTED_BLOOD_PRIME_USER_ACTIONS ) + { + result = TRUE; + rejReason = REQUEST_REJECT_REASON_NONE; + if ( REQUESTED_USER_ACTION_BLOOD_PRIME_PAUSE == action ) + { + pendingPauseRequest = TRUE; + } + else + { + pendingResumeRequest = TRUE; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_COMMAND; + } + } + + // Respond to request + response.accepted = result; + response.rejectionReason = rejReason; + sendMessage( MSG_ID_TD_BLOOD_PRIME_CMD_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** +* @brief +* The bloodPrimeHandleBloodFlowChangeRequest function handles the UI +* treatment blood flow change request. +* @details \b Message \b Sent: MSG_ID_TD_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RESPONSE +* @details \b Inputs: message containing requested blood flow rate. +* @details \b Outputs: pendingFlowChangeRequest set if valid. +* @return TRUE if request is accepted, FALSE if rejected. +*************************************************************************/ +BOOL bloodPrimeHandleBloodFlowChangeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 requestedRate = 0; + REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + UI_RESPONSE_PAYLOAD_T response; + + // Verify message payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &requestedRate, message->payload, sizeof( U32 ) ); + if ( ( MODE_TREA == getCurrentOperationMode() ) && ( TREATMENT_BLOOD_PRIME_STATE == getTreatmentState() ) ) + { + U32 lowerLimit = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_BLOOD_FLOW ); + U32 upperLimit = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_BLOOD_FLOW ); + + if ( ( requestedRate >= lowerLimit ) && ( requestedRate <= upperLimit ) ) + { + requestedBloodFlowRate_mL_min = requestedRate; + pendingFlowChangeRequest = TRUE; + result = TRUE; + rejReason = REQUEST_REJECT_REASON_NONE; + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_COMMAND; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; + } + } + + // Respond to request + response.accepted = result; + response.rejectionReason = rejReason; + sendMessage( MSG_ID_TD_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** * @brief - * The publishBloodPrimeData function publishes blood prime progress to UI - * at 1 Hz interval. - * @details Inputs: bloodPrimePublishTimerCtr - * @details Outputs: rinseback data published + * The publishBloodPrimeData function publishes blood prime data + * at interval. + * @details \b Message \b Sent: MSG_ID_TD_BLOOD_PRIME_PROGRESS_DATA + * @details \b Inputs: bloodPrimePublishTimerCtr, + * bloodPrimePublishInterval + * @details \b Outputs: blood prime data are published to CAN bus * @return none *************************************************************************/ static void publishBloodPrimeData( void ) { if ( ++bloodPrimePublishTimerCtr >= getU32OverrideValue( &bloodPrimePublishInterval ) ) { BLOOD_PRIME_DATA_PAYLOAD_T data; + U32 elapsedMS; + U32 elapsedSec; bloodPrimePublishTimerCtr = 0; data.targetBloodPrimeVolumeMl = bloodPrimeTargetVolume_mL; data.deliveredBloodPrimeVolumeMl = MAX( 0.0, getBloodPrimeVolume() ); + elapsedMS = calcTimeSince( bloodPrimeStartMS ); + elapsedSec = elapsedMS / 1000U; + data.bloodPrimeTimeoutSec = bloodPrimeStartMS; + data.bloodPrimeCountdownSec = elapsedSec; + broadcastData( MSG_ID_TD_BLOOD_PRIME_PROGRESS_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ) ); } } @@ -291,73 +520,34 @@ /*********************************************************************//** * @brief - * The testSetBloodPrimeVolumeOverride function sets or resets the override - * of calculated blood prime volume. - * @details Inputs: none - * @details Outputs: cumulativeBloodPrimeVolume_mL - * @param message Override message from Dialin + * The testBloodPrimePublishIntervalOverride function overrides the interval + * at which the TD blood prime data is published. + * @details \b Inputs: none + * @details \b Outputs: bloodPrimePublishInterval + * @param message Override message from Dialin which includes the interval + * to override the blood prime broadcast interval to. * @return TRUE if override request is successful, FALSE if not *************************************************************************/ -BOOL testSetBloodPrimeVolumeOverride( MESSAGE_T *message ) +BOOL testBloodPrimePublishIntervalOverride( MESSAGE_T *message ) { - BOOL result = FALSE; - BOOL enable = FALSE; - F32 volume = 0.0F; + BOOL result = u32BroadcastIntervalOverride( message, &bloodPrimePublishInterval, TASK_GENERAL_INTERVAL ); - if ( ( TRUE == isTestingActivated() ) && ( ( sizeof( BOOL ) + sizeof( F32 ) ) == message->hdr.payloadLen ) ) - { - result = TRUE; - memcpy( &enable, message->payload, sizeof( BOOL ) ); - memcpy( &volume, &message->payload[ sizeof( BOOL ) ], sizeof( F32 ) ); - - if ( TRUE == enable ) - { - cumulativeBloodPrimeVolume_mL.ovData = volume; - cumulativeBloodPrimeVolume_mL.override = OVERRIDE_KEY; - } - else - { - cumulativeBloodPrimeVolume_mL.override = OVERRIDE_RESET; - cumulativeBloodPrimeVolume_mL.ovData = cumulativeBloodPrimeVolume_mL.ovInitData; - } - } - return result; } /*********************************************************************//** * @brief - * The testSetBloodPrimePublishIntervalOverride function sets or resets the - * override of blood prime data publish interval. - * @details Inputs: none - * @details Outputs: bloodPrimePublishInterval - * @param message Override message from Dialin + * The testBloodPrimeVolumeOverride function override the blood prime volume. + * @details \b Inputs: none + * @details \b Outputs: cumulativeBloodPrimeVolume_mL + * @param message Override message from Dialin which includes the blood + * prime volume to override it to. * @return TRUE if override request is successful, FALSE if not *************************************************************************/ -BOOL testSetBloodPrimePublishIntervalOverride( MESSAGE_T *message ) +BOOL testBloodPrimeVolumeOverride( MESSAGE_T *message ) { - BOOL result = FALSE; - BOOL enable = FALSE; - U32 intervalMs = 0U; + BOOL result = f32Override( message, &cumulativeBloodPrimeVolume_mL ); - if ( ( TRUE == isTestingActivated() ) && ( ( sizeof( BOOL ) + sizeof( U32 ) ) == message->hdr.payloadLen ) ) - { - result = TRUE; - memcpy( &enable, message->payload, sizeof( BOOL ) ); - memcpy( &intervalMs, &message->payload[ sizeof( BOOL ) ], sizeof( U32 ) ); - - if ( TRUE == enable ) - { - bloodPrimePublishInterval.ovData = intervalMs / TASK_GENERAL_INTERVAL; - bloodPrimePublishInterval.override = OVERRIDE_KEY; - } - else - { - bloodPrimePublishInterval.override = OVERRIDE_RESET; - bloodPrimePublishInterval.ovData = bloodPrimePublishInterval.ovInitData; - } - } - return result; }