Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -84,6 +84,8 @@ #define BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE 12 ///< Blood leak embedded mode command queue maximum size. #define BLOOD_LEAK_EMB_MODE_ZERO_CMD_RQRD_Q 5 ///< Blood leak embedded mode zero command required queue count. #define BLOOD_LEAK_EMB_MODE_NUM_OF_RETRIES 3 ///< Blood leak embedded mode number of retries to enqueue. +#define BLOOD_LEAK_EMB_MODE_INFO_CMD_TIMOUE_MS ( 2 * MS_PER_SECOND ) ///< Blood leak embedded mode informative command timeout in milliseconds. +#define BLOOD_LEAK_EMB_MODE_NUM_OF_INFO_CMDS 3 ///< Blood leak embedded mode number of informative commands. #define BLOOD_LEAK_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Blood leak embedded mode FPGA error timeout in milliseconds. @@ -170,6 +172,8 @@ static U08 bloodLeakEmbModeCmdQCount; ///< Blood leak embedded mode command queue count. static BOOL bloodLeakEmbModeHasZeroBeenRqustd; ///< Blood leak embedded mode flag to indicate zero has been requested. static U32 bloodLeakEmbModeCmdEnqueueCount; ///< Blood leak embedded mode command enqueue count. +static U32 bloodLeakEmbModeInfoCmdEnqLastTimeStamp; ///< Blood leak embedded mode informative command (i.e. I, V, D) timer. +static U32 bloodLeakEmbModeInfoCmdCounter; ///< Blood leak embedded mode informative command counter. // ********** private function prototypes ********** @@ -192,6 +196,7 @@ static U08 dequeueEmbModeCmd( void ); static BOOL isEmbModeCmdQueueEmpty( void ); static U32 getAvailableEmbModeQueueCount( void ); +static void enqueueInfoEmbModeCmds( void ); /*********************************************************************//** * @brief @@ -202,39 +207,43 @@ * bloodLeakDataPublicationTimerCounter, bloodLeakEmbModeHasZeroBeenRqustd * bloodLeakEmbModeSubstate, bloodLeakEmbModeCmdEnqueueCount * bloodLeakPersistenceCtr, bloodLeakSignalEmbModeReq, - * bloodLeakEmbModeRqstedCmd, bloodLeakEmbModeOpsStartTime, bloodLeakEmbModeRespBuffer, - * bloodLeakEmbModeRespIndex, bloodLeakExitNormalRequested, - * bloodLeakEmbModeCmdSeqLength, bloodLeakEmbModeHasRxRqstBeenSent + * bloodLeakEmbModeRqstedCmd, bloodLeakEmbModeOpsStartTime, + * bloodLeakEmbModeRespBuffer, bloodLeakEmbModeRespIndex, + * bloodLeakExitNormalRequested, bloodLeakEmbModeCmdSeqLength, + * bloodLeakEmbModeHasRxRqstBeenSent, bloodLeakEmbModeInfoCmdEnqLastTimeStamp, + * bloodLeakEmbModeInfoCmdCounter * @return none *************************************************************************/ void initBloodLeak( void ) { // Initialize the embedded mode specifications initEmbModeSpecs(); - bloodLeakDataPublicationCounter = DATA_PUBLISH_COUNTER_START_COUNT; - bloodLeakState = BLOOD_LEAK_WAIT_FOR_POST_STATE; - bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.ovInitData = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.override = OVERRIDE_RESET; - bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; - bloodLeakUARTCmdIndex = 0; - bloodLeakSetPointSeqLength = 0; - bloodLeakPersistenceCtr = 0; - bloodLeakSignalEmbModeReq = FALSE; - bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; - bloodLeakEmbModeSubstate = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; - bloodLeakEmbModeOpsStartTime = 0; - bloodLeakEmbModeRespIndex = 0; - bloodLeakExitNormalRequested = FALSE; - bloodLeakEmbModeCmdSeqLength = 0; - bloodLeakEmbModeHasRxRqstBeenSent = FALSE; - bloodLeakEmbModeCmdQFrontIndex = 0; - bloodLeakEmbModeCmdQRearIndex = 0; - bloodLeakEmbModeCmdQCount = 0; - bloodLeakEmbModeHasZeroBeenRqustd = FALSE; - bloodLeakEmbModeCmdEnqueueCount = 0; + bloodLeakDataPublicationCounter = DATA_PUBLISH_COUNTER_START_COUNT; + bloodLeakState = BLOOD_LEAK_WAIT_FOR_POST_STATE; + bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.ovInitData = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.override = OVERRIDE_RESET; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; + bloodLeakUARTCmdIndex = 0; + bloodLeakSetPointSeqLength = 0; + bloodLeakPersistenceCtr = 0; + bloodLeakSignalEmbModeReq = FALSE; + bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; + bloodLeakEmbModeSubstate = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; + bloodLeakEmbModeOpsStartTime = 0; + bloodLeakEmbModeRespIndex = 0; + bloodLeakExitNormalRequested = FALSE; + bloodLeakEmbModeCmdSeqLength = 0; + bloodLeakEmbModeHasRxRqstBeenSent = FALSE; + bloodLeakEmbModeCmdQFrontIndex = 0; + bloodLeakEmbModeCmdQRearIndex = 0; + bloodLeakEmbModeCmdQCount = 0; + bloodLeakEmbModeHasZeroBeenRqustd = FALSE; + bloodLeakEmbModeCmdEnqueueCount = 0; + bloodLeakEmbModeInfoCmdEnqLastTimeStamp = getMSTimerCount(); + bloodLeakEmbModeInfoCmdCounter = 0; // Set the blood leak embedded mode command queue to zero memset( bloodLeakEmbModeCmdQ, 0x0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE ); @@ -300,6 +309,8 @@ break; } + enqueueInfoEmbModeCmds(); + checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_BLOOD_LEAK_SENSOR, getFPGABloodLeakRxErrorCount() ); // Publish blood leak data if due @@ -975,11 +986,11 @@ convertString2Integer( bloodLeakEmbModeRqstedCmd, length ); + sendBloodLeakEmbeddedModeCommandResponse( bloodLeakEmbModeRqstedCmd, length, bloodLeakEmbModeRespBuffer ); + // Done with receiving the data bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; state = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; - - sendBloodLeakEmbeddedModeCommandResponse( length, bloodLeakEmbModeRespBuffer ); } if ( TRUE == didTimeout( bloodLeakEmbModeOpsStartTime, commandTimeoutMS ) ) @@ -993,10 +1004,10 @@ convertString2Integer( bloodLeakEmbModeRqstedCmd, length ); + sendBloodLeakEmbeddedModeCommandResponse( bloodLeakEmbModeRqstedCmd, length, bloodLeakEmbModeRespBuffer ); + bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; state = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; - - sendBloodLeakEmbeddedModeCommandResponse( length, bloodLeakEmbModeRespBuffer ); } return state; @@ -1403,7 +1414,44 @@ return BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - bloodLeakEmbModeCmdQCount; } +/*********************************************************************//** + * @brief + * The enqueueInfoEmbModeCmds function enqueues the informative embedded + * mode commands. + * @details Inputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, + * bloodLeakEmbModeInfoCmdCounter + * @details Outputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, + * bloodLeakEmbModeInfoCmdCounter + * @return none + *************************************************************************/ +static void enqueueInfoEmbModeCmds( void ) +{ + if ( ( TRUE == didTimeout( bloodLeakEmbModeInfoCmdEnqLastTimeStamp, BLOOD_LEAK_EMB_MODE_INFO_CMD_TIMOUE_MS ) ) && + ( bloodLeakState >= BLOOD_LEAK_INIT_STATE ) ) + { + // Enqueue the next command. Make sure the blood leak state is greater than init state since in the post state and + // check for set point, other commands are being enqueued for checking + if ( 0 == bloodLeakEmbModeInfoCmdCounter ) + { + enqueueEmbModeCmd( I_EMB_MODE_CMD ); + } + else if ( 1 == bloodLeakEmbModeInfoCmdCounter ) + { + enqueueEmbModeCmd( V_EMB_MODE_CMD ); + } + else if ( 2 == bloodLeakEmbModeInfoCmdCounter ) + { + enqueueEmbModeCmd( D_EMB_MODE_CMD ); + } + // Set the timer for the next time out to enqueue + // Reset the counter. The counter starts from 0 + bloodLeakEmbModeInfoCmdEnqLastTimeStamp = getMSTimerCount(); + bloodLeakEmbModeInfoCmdCounter = INC_WRAP( bloodLeakEmbModeInfoCmdCounter, 0, BLOOD_LEAK_EMB_MODE_NUM_OF_INFO_CMDS - 1 ); + } +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -122,6 +122,7 @@ signalBloodPumpHardStop(); signalDialInPumpHardStop(); signalDialOutPumpHardStop(); + // TODO - turn off air pump // Ensure all valves are in safe position setValveAirTrap( STATE_CLOSED ); Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -156,16 +156,6 @@ postState = handlePOSTStatus( testStatus ); break; - case POST_STATE_WATCHDOG: - testStatus = execWatchdogTest(); - postState = handlePOSTStatus( testStatus ); - break; - - case POST_STATE_SAFETY_SHUTDOWN: - testStatus = execSafetyShutdownTest(); - postState = handlePOSTStatus( testStatus ); - break; - // NOTE: RTC's POST must go before NVDataMgmt case POST_STATE_RTC: testStatus = execRTCSelfTest(); @@ -180,6 +170,16 @@ // NOTE: all the actuators and sensors must execute their POST after NVDataMgmt // NVDataMgmt must load all the calibration data into RAM so the actuators // can query their corresponding calibration values successfully + case POST_STATE_WATCHDOG: + testStatus = execWatchdogTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_SAFETY_SHUTDOWN: + testStatus = execSafetyShutdownTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_BLOOD_FLOW: testStatus = execBloodFlowTest(); postState = handlePOSTStatus( testStatus ); Index: firmware/App/Modes/ModeService.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -15,11 +15,16 @@ * ***************************************************************************/ +#include "BloodFlow.h" #include "Buttons.h" +#include "DGInterface.h" +#include "DialInFlow.h" +#include "DialOutFlow.h" #include "ModeService.h" #include "OperationModes.h" #include "Switches.h" #include "SyringePump.h" +#include "Valves.h" /** * @addtogroup HDServiceMode @@ -58,6 +63,19 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); + // Start out with all actuators de-energized in service mode + cmdStopDGTrimmerHeater(); + stopSyringePump(); + signalBloodPumpHardStop(); + signalDialInPumpHardStop(); + signalDialOutPumpHardStop(); + // TODO - turn off air pump + setValveAirTrap( STATE_CLOSED ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + return 0; } Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r0444258d6627e442d76ae6519802a334c73a141d -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 0444258d6627e442d76ae6519802a334c73a141d) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -1,20 +1,21 @@ /************************************************************************** * -* Copyright (c) 2021-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2021-2023 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 SelfTests.c * -* @author (last) Dara Navaei -* @date (last) 14-Dec-2022 +* @author (last) Sean Nash +* @date (last) 04-Jan-2023 * * @author (original) Quang Nguyen * @date (original) 28-Jan-2021 * ***************************************************************************/ +#include "AirPump.h" #include "AirTrap.h" #include "BloodFlow.h" #include "BloodLeak.h" @@ -45,8 +46,8 @@ #define DIAL_IN_PUMP_PRESSURE_SELF_TEST_FLOW 400 #define SYRINGE_PUMP_OCCLUSION_CHECK_DELAY ( 1 * MS_PER_SECOND ) ///< Delay 1 second then check for syringe pump prime occlusion. -#define BLOOD_PUMP_RUN_TIME_PRESSURE_SELF_TEST ( 20 * MS_PER_SECOND ) ///< Pressure self-test time to run blood pump in ms. -#define DIAL_IN_PUMP_RUN_TIME_PRESSURE_SELF_TEST ( 20 * MS_PER_SECOND ) ///< Pressure self-test time to run dip in ms. +#define BLOOD_PUMP_RUN_TIME_PRESSURE_SELF_TEST ( 30 * MS_PER_SECOND ) ///< Pressure self-test time to run blood pump in ms. +#define VENOUS_PRESSURE_SELF_TEST_MAX_TEST_TIME ( 30 * MS_PER_SECOND ) ///< Pressure self-test time to run venous self test in ms. #define DECAY_PRESSURE_SELF_TEST_TIME ( 4 * MS_PER_SECOND ) ///< time to wait for pressure to decay in ms. #define STABILTY_PRESSURE_SELF_TEST_TIME ( 5 * MS_PER_SECOND ) ///< Time to wait for pressure to stabilize in ms. #define NORMALIZED_PRESSURE_SELF_TEST_TIME ( 20 * MS_PER_SECOND ) ///< Time to wait for pressure to normalize in ms. @@ -60,7 +61,7 @@ #define ARTERIAL_PRESSURE_SELF_TEST_LOW_LIMIT_MMHG -200.0F ///< Arterial pressure low limit after running blood pump. #define VENOUS_PRESSURE_SELF_TEST_HIGH_LIMIT_MMHG 200.0F ///< Venous pressure high limit after running blood pump. -#define VENOUS_PRESSURE_SELF_TEST_FIRST_PASS_LIMIT_MMHG 200.0F ///< Venous pressure high limit after running dpi in first test. +#define VENOUS_PRESSURE_SELF_TEST_FIRST_PASS_LIMIT_MMHG 250.0F ///< Venous pressure high limit after running air pump in first test. #define NORMAL_PRESSURE_DIFF_TOLERANCE_MMHG 20.0F ///< Difference in pressure readings after return to normal state tolerance (in mmHg). @@ -89,11 +90,12 @@ static NO_CART_SELF_TESTS_STATE_T currentNoCartSelfTestsState; ///< Current state of the no cartridge self-tests state machine. static U32 runPumpStartTime; ///< Beginning time when pumps start running -static BOOL havePumpsStarted; ///< Flag indicates pumps have started running for self-test. +static BOOL havePumpsStartedForNCST; ///< Flag indicates pumps have started running for no cartridge pumps self-test. +static BOOL pumpHomingRequestedForNCST; ///< Flag indicates pumps should be homed after running no cartridge pumps self-test. static DRY_SELF_TESTS_STATE_T currentDrySelfTestsState; ///< Current state of the dry self-tests state machine. static U32 pressureSelfTestBloodPumpRunStartTime; ///< Pressure dry self-test blood pump runs start time. -static U32 pressureSelfTestDialInPumpRunStartTime; ///< Pressure dry self-test dip runs start time. +static U32 pressureSelfTestVenousTestStartTime; ///< Pressure dry self-test dip runs start time. static U32 pressureSelfTestNormalizedStartTime; ///< Normalized pressure dry self-test start time. static U32 pressureSelfTestDecayStartTime; ///< Decay pressure dry self-test start time. static U32 pressureSelfTestStabilityStartTime; ///< Stability pressure dry self-test start time. @@ -253,7 +255,8 @@ currentNoCartSelfTestsState = NO_CART_SELF_TESTS_START_STATE; runPumpStartTime = 0; - havePumpsStarted = FALSE; + havePumpsStartedForNCST = FALSE; + pumpHomingRequestedForNCST = FALSE; selfTestStartTime = getMSTimerCount(); selfTestPreviousPublishDataTime = getMSTimerCount(); @@ -787,36 +790,41 @@ * @brief * The handleNoCartSelfTestPumpsState function runs blood, dialysate inlet, * dialysate outlet pumps for certain time to make sure no alarms occur. - * @details Inputs: none - * @details Outputs: Ran self-test for blood, dialysate in, dialysate out pumps + * @details Inputs: havePumpsStartedForNCST + * @details Outputs: pumpHomingRequestedForNCST, + * Ran self-test for blood, dialysate in, dialysate out pumps * @return the next state of no cartridge self-tests state machine *************************************************************************/ static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestPumpsState( void ) { NO_CART_SELF_TESTS_STATE_T state = NO_CART_SELF_TESTS_PUMPS_STATE; - if ( FALSE == havePumpsStarted ) + if ( FALSE == havePumpsStartedForNCST ) { - havePumpsStarted = TRUE; + havePumpsStartedForNCST = TRUE; setBloodPumpTargetFlowRate( PUMP_SELF_TEST_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( PUMP_SELF_TEST_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( PUMP_SELF_TEST_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); runPumpStartTime = getMSTimerCount(); } - if ( TRUE == didTimeout( runPumpStartTime, PUMP_RUN_SELF_TEST_TIME_MS ) ) + if ( TRUE == pumpHomingRequestedForNCST ) { - signalBloodPumpHardStop(); - signalDialInPumpHardStop(); - signalDialOutPumpHardStop(); - // Home pumps for cartridge installation homeBloodPump(); homeDialInPump(); homeDialOutPump(); state = NO_CART_SELF_TESTS_HOME_IDLE_STATE; } + else if ( TRUE == didTimeout( runPumpStartTime, PUMP_RUN_SELF_TEST_TIME_MS ) ) + { + // Request homing of pumps for cartridge installation + signalBloodPumpHardStop(); + signalDialInPumpHardStop(); + signalDialOutPumpHardStop(); + pumpHomingRequestedForNCST = TRUE; + } if ( TRUE == doesAlarmStatusIndicateStop() ) { @@ -872,7 +880,8 @@ if ( TRUE == selfTestsResumeRequested ) { selfTestsResumeRequested = FALSE; - havePumpsStarted = FALSE; + havePumpsStartedForNCST = FALSE; + pumpHomingRequestedForNCST = FALSE; doorClosedRequired( TRUE, TRUE ); state = NO_CART_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; } @@ -981,9 +990,28 @@ } else { - // Wait for reservoirs to drain before starting this test - if ( ( getLoadCellWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ) < MAX_EMPTY_RESERVOIR_WEIGHT_G ) && ( getLoadCellWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ) < MAX_EMPTY_RESERVOIR_WEIGHT_G ) ) +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE != getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) { + + // Wait for reservoirs to drain before starting this test + if ( ( getLoadCellWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ) < MAX_EMPTY_RESERVOIR_WEIGHT_G ) && ( getLoadCellWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ) < MAX_EMPTY_RESERVOIR_WEIGHT_G ) ) + { + // TODO - wait 1 sec before taking pressure readings and beginning pressure check + previousNormalArterialPressure = getFilteredArterialPressure(); + previousNormalVenousPressure = getFilteredVenousPressure(); + state = DRY_SELF_TESTS_PRESSURE_SENSORS_VENOUS_SETUP_STATE; + + // Check to see if sensor is within normal ranges before we execute pressure sensor tests + if ( ( fabs( previousNormalArterialPressure ) > PRESSURE_CHECK_START_PRESSURE_TOLERANCE_MMHG ) || ( fabs( previousNormalVenousPressure ) > PRESSURE_CHECK_START_PRESSURE_TOLERANCE_MMHG ) ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_PRE_TREATMENT_DRY_PRESSURE_TEST_FAILURE, previousNormalArterialPressure, previousNormalVenousPressure ); + } + } + } + else +#endif + { // TODO - wait 1 sec before taking pressure readings and beginning pressure check previousNormalArterialPressure = getFilteredArterialPressure(); previousNormalVenousPressure = getFilteredVenousPressure(); @@ -995,6 +1023,7 @@ SET_ALARM_WITH_2_F32_DATA( ALARM_ID_PRE_TREATMENT_DRY_PRESSURE_TEST_FAILURE, previousNormalArterialPressure, previousNormalVenousPressure ); } } + } return state; @@ -1005,7 +1034,7 @@ * The handleDrySelfTestPressureSensorsVenousSetupState function handles the setup * for the venous pressure sensor dry self-test. * @details Inputs: none - * @details Outputs: pressureSelfTestDialInPumpRunStartTime + * @details Outputs: pressureSelfTestVenousTestStartTime * @return the next state of dry self-tests state machine *************************************************************************/ static DRY_SELF_TESTS_STATE_T handleDrySelfTestPressureSensorsVenousSetupState( void ) @@ -1019,13 +1048,35 @@ } else { - setValvePosition( VDI, VALVE_POSITION_B_OPEN ); +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) + { +#endif + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); +#ifndef _RELEASE_ + } + else + { + setValvePosition( VDI, VALVE_POSITION_B_OPEN ); + } +#endif setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); setValveAirTrap( STATE_CLOSED ); - setDialInPumpTargetFlowRate( DIAL_IN_PUMP_PRESSURE_SELF_TEST_FLOW, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - pressureSelfTestDialInPumpRunStartTime = getMSTimerCount(); +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) + { +#endif + setAirPumpState( AIR_PUMP_STATE_ON ); +#ifndef _RELEASE_ + } + else + { + setDialInPumpTargetFlowRate( DIAL_IN_PUMP_PRESSURE_SELF_TEST_FLOW, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + } +#endif + pressureSelfTestVenousTestStartTime = getMSTimerCount(); } return state; @@ -1035,7 +1086,7 @@ * @brief * The handleDrySelfTestPressureSensorsVenousState function tests the readings of * the venous pressure sensor and verify they are in correct range. - * @details Inputs: pressureSelfTestDialInPumpRunStartTime + * @details Inputs: pressureSelfTestVenousTestStartTime * @details Outputs: none * @return the next state of dry self-tests state machine *************************************************************************/ @@ -1047,11 +1098,22 @@ // End the test when reaching target pressure or time out if ( VENOUS_PRESSURE_SELF_TEST_FIRST_PASS_LIMIT_MMHG <= venousPressure ) { - signalDialInPumpHardStop(); +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) + { +#endif + setAirPumpState( AIR_PUMP_STATE_OFF ); +#ifndef _RELEASE_ + } + else + { + signalDialInPumpHardStop(); + } +#endif state = DRY_SELF_TESTS_PRESSURE_SENSORS_ARTERIAL_SETUP_STATE; } - if ( TRUE == didTimeout( pressureSelfTestDialInPumpRunStartTime, DIAL_IN_PUMP_RUN_TIME_PRESSURE_SELF_TEST ) ) + if ( TRUE == didTimeout( pressureSelfTestVenousTestStartTime, VENOUS_PRESSURE_SELF_TEST_MAX_TEST_TIME ) ) { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_PRE_TREATMENT_DRY_PRESSURE_TEST_FAILURE, venousPressure, VENOUS_PRESSURE_SELF_TEST_HIGH_LIMIT_MMHG ); } Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rda7e8c1b71db9273f83e9d0ba7d20e74e758a8ad -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision da7e8c1b71db9273f83e9d0ba7d20e74e758a8ad) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -999,7 +999,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1147,7 +1147,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1185,7 +1185,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1206,7 +1206,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1242,7 +1242,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1263,7 +1263,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1299,7 +1299,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1335,7 +1335,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -1370,7 +1370,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2113,7 +2113,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2141,7 +2141,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2226,7 +2226,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2276,7 +2276,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2682,7 +2682,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2707,7 +2707,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2731,7 +2731,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2760,7 +2760,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2785,7 +2785,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2810,7 +2810,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2835,7 +2835,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2867,7 +2867,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2926,7 +2926,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2982,7 +2982,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -3039,7 +3039,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -3272,7 +3272,6 @@ *************************************************************************/ void handleUIConfirmationResponse( MESSAGE_T *message ) { - BOOL result = FALSE; U08* payloadPtr = message->payload; if ( message->hdr.payloadLen == 2 * sizeof(U32) ) @@ -3291,7 +3290,7 @@ } } - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } /*********************************************************************//** @@ -7520,11 +7519,12 @@ * the blood leak embedded mode command response. * @details Inputs: none * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param cmd: the command its response is being sent * @param responseLen: the length of the buffer * @param response: pointer to the response buffer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08* response ) { BOOL result; MESSAGE_T msg; @@ -7533,8 +7533,10 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) + responseLen; + msg.hdr.payloadLen = sizeof( U08 ) + sizeof( U32 ) + responseLen; + memcpy( payloadPtr, &cmd, sizeof( U08 ) ); + payloadPtr += sizeof( U08 ); memcpy( payloadPtr, &responseLen, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, response, responseLen ); Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r0444258d6627e442d76ae6519802a334c73a141d -r4bae2d153f4242a52c8602df3e5161d6f1f122ef --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 0444258d6627e442d76ae6519802a334c73a141d) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 4bae2d153f4242a52c8602df3e5161d6f1f122ef) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2023 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 SystemCommMessages.h * * @author (last) Dara Navaei -* @date (last) 14-Dec-2022 +* @date (last) 03-Jan-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -17,7 +17,8 @@ #ifndef __SYSTEM_COMM_MESSAGES_H__ #define __SYSTEM_COMM_MESSAGES_H__ - + +#include "AirPump.h" #include "AirTrap.h" #include "BloodFlow.h" #include "BloodLeak.h" @@ -854,6 +855,12 @@ // MSG_ID_HD_NV_RECORD_CRC_OVERRIDE void handleTestHDNVRecordCRCOverride( MESSAGE_T *message ); +// MSG_ID_HD_AIR_PUMP_PUBLISH_INTERVAL_OVERRIDE +void handleAirPumpIntervalOverrideRequest( MESSAGE_T* message ); + +// MSG_ID_HD_AIR_PUMP_SET_STATE +void handleAirPumpSetState( MESSAGE_T * message ); + /**@}*/ #endif