Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rce16d7d7928d8653f88c629d17afb709d74111cf -rb7d279735312c0f04dd53d8903bf21c520b2beee --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision ce16d7d7928d8653f88c629d17afb709d74111cf) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision b7d279735312c0f04dd53d8903bf21c520b2beee) @@ -7,8 +7,8 @@ * * @file SyringePump.c * -* @author (last) Hung Nguyen -* @date (last) 15-Feb-2022 +* @author (last) Darren Cox +* @date (last) 10-Mar-2022 * * @author (original) Sean Nash * @date (original) 04-Mar-2021 @@ -124,6 +124,8 @@ // Stepper motor toggle time for zero speed (stopped) #define SYRINGE_PUMP_MICROSTEP_TOGGLE_TIME_FOR_STOP 0xFFFFFFFF ///< Syringe pump microstep toggle time setting to indicate zero speed (stopped). +#define DATA_PUBLISH_COUNTER_START_COUNT 10 ///< Data publish counter start count. + /// Control bits to run syringe pump in reverse direction static const U08 SYRINGE_PUMP_CONTROL_RUN_REVERSE = SYRINGE_PUMP_CONTROL_SLEEP_OFF | SYRINGE_PUMP_CONTROL_NOT_RESET | @@ -197,10 +199,8 @@ static S32 syringePumpLastPositions[ SYRINGE_PUMP_SPEED_CALC_BUFFER_LEN ]; ///< Last encoder positions for the syringe pump. static U32 syringePumpMotorSpeedCalcIdx; ///< Index into 1 second buffer of syringe pump encoder positions. static U32 syringePumpSpeedCalcTimerCounter; ///< Used to calculate measured rate from change in position over time. -#ifndef DISABLE_SYRINGE_PUMP_ALARMS static MOTOR_DIR_T syringePumpControllerMeasuredDirection; ///< Measured direction of syringe pump per controller. static MOTOR_DIR_T syringePumpEncoderMeasuredDirection; ///< Measured direction of syringe pump per encoder position relative to previous. -#endif static BOOL syringePumpRetractRequested; ///< Flag indicates a retract operation is requested. static BOOL syringePumpSeekRequested; ///< Flag indicates a plunger seek operation is requested. @@ -258,7 +258,6 @@ static BOOL checkVolumeVsSafetyVolume( BOOL stopPump, F32 pctMargin ); static BOOL checkForStall( BOOL stopPump ); static void publishSyringePumpData( void ); -static BOOL processCalibrationData( void ); /*********************************************************************//** * @brief @@ -280,12 +279,13 @@ syringePumpVolumeStartPosition = 0; syringePumpHomePositionOffset = 0; syringePumpLastPosition = 0; -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - syringePumpControllerMeasuredDirection = MOTOR_DIR_FORWARD; - syringePumpEncoderMeasuredDirection = MOTOR_DIR_FORWARD; -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) + { + syringePumpControllerMeasuredDirection = MOTOR_DIR_FORWARD; + syringePumpEncoderMeasuredDirection = MOTOR_DIR_FORWARD; + } - syringePumpDataPublicationTimerCounter = 0; + syringePumpDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; syringePumpSpeedCalcTimerCounter = 0; syringePumpRampTimerCtr = 0; @@ -478,15 +478,16 @@ *************************************************************************/ BOOL retractSyringePump( void ) { -#ifndef ALWAYS_ALLOW_SYRINGE_PUMP_CMDS - if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( heparinDeliveryState != HEPARIN_STATE_OFF ) ) -#else - heparinDeliveryState = HEPARIN_STATE_STOPPED; - if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) ) -#endif + if ( ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( heparinDeliveryState != HEPARIN_STATE_OFF ) ) || + ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_SYRINGE_PUMP_CMDS ) ) == SW_CONFIG_ENABLE_VALUE ) { - syringePumpSetRate = SYRINGE_PUMP_RETRACT_RATE; - syringePumpRetractRequested = TRUE; + heparinDeliveryState = HEPARIN_STATE_STOPPED; + if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) ) + { + syringePumpSetRate = SYRINGE_PUMP_RETRACT_RATE; + syringePumpRetractRequested = TRUE; + } + } return syringePumpRetractRequested; @@ -568,9 +569,10 @@ } else { -#ifndef DISABLE_SYRINGE_PUMP - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_BOLUS_CMD, tgtRate ) -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_BOLUS_CMD, syringePumpSetRate ) + } } return syringePumpBolusRequested; @@ -598,9 +600,10 @@ } else { -#ifndef DISABLE_SYRINGE_PUMP - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_CONT_CMD, flowRate ) -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_HD_SYRINGE_INVALID_CONT_CMD, flowRate ) + } } return syringePumpContinuousRequested; @@ -904,7 +907,8 @@ if ( TRUE == isNewCalibrationRecordAvailable() ) { // Get the new calibration data and check its validity - processCalibrationData(); + getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), + 0, ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); } S32 encPosition = getFPGASyringePumpEncoderPosition(); @@ -939,12 +943,13 @@ calcSafetyVolumeDelivered(); // Calculate measured rate (mL/hr) calcMeasRate(); -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - // Get measured direction - syringePumpControllerMeasuredDirection = ( ( getSyringePumpEncoderStatus() & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); - // Calculate direction from encoder position relative to last - syringePumpEncoderMeasuredDirection = ( getSyringePumpPosition() - syringePumpLastPosition >= 0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) + { + // Get measured direction + syringePumpControllerMeasuredDirection = ( ( getSyringePumpEncoderStatus() & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); + // Calculate direction from encoder position relative to last + syringePumpEncoderMeasuredDirection = ( getSyringePumpPosition() - syringePumpLastPosition >= 0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + } // Check if syringe pump is on while BP is off { @@ -962,9 +967,10 @@ if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_ADC_ERROR, ( ( getCurrentOperationMode() > MODE_INIT ) && ( lastSyringePumpADCReadCtr == getSyringePumpADCReadCounter() ) ) ) ) { -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - activateAlarmNoData( ALARM_ID_HD_SYRINGE_PUMP_ADC_ERROR ); -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) + { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_PUMP_ADC_ERROR ); + } } lastSyringePumpADCReadCtr = getSyringePumpADCReadCounter(); @@ -1053,7 +1059,8 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), + 0, ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -1104,14 +1111,13 @@ { SYRINGE_PUMP_STATE_T result = SYRINGE_PUMP_OFF_STATE; -#ifndef DISABLE_SYRINGE_PUMP_ALARMS // Check position is not changing while stopped - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_NOT_STOPPED_ERROR, ( syringePumpLastPosition != getSyringePumpPosition() ) ) ) + if ( ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_NOT_STOPPED_ERROR, ( syringePumpLastPosition != getSyringePumpPosition() ) ) ) && + ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) ) { activateAlarmNoData( ALARM_ID_HD_SYRINGE_PUMP_NOT_STOPPED_ERROR ); activateSafetyShutdown(); } -#endif // Check for request flags if ( TRUE == syringePumpRetractRequested ) @@ -1269,9 +1275,10 @@ } else { -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM, syringeVol, txVolume ); -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM, syringeVol, txVolume ); + } } } @@ -1479,18 +1486,19 @@ { BOOL result = stopPump; -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR, ( syringePumpEncoderMeasuredDirection != expDir ) ) ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) { - result = TRUE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR, (U32)syringePumpEncoderMeasuredDirection, (U32)syringePumpState ); + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR, ( syringePumpEncoderMeasuredDirection != expDir ) ) ) + { + result = TRUE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR, (U32)syringePumpEncoderMeasuredDirection, (U32)syringePumpState ); + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, ( syringePumpControllerMeasuredDirection != expDir ) ) ) + { + result = TRUE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, (U32)syringePumpControllerMeasuredDirection, (U32)syringePumpState ); + } } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, ( syringePumpControllerMeasuredDirection != expDir ) ) ) - { - result = TRUE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, (U32)syringePumpControllerMeasuredDirection, (U32)syringePumpState ); - } -#endif return result; } @@ -1616,20 +1624,22 @@ static BOOL checkMeasRate( BOOL stopPump, F32 pctMargin ) { BOOL result = stopPump; -#ifndef DISABLE_SYRINGE_PUMP_ALARMS - F32 rate = getSyringePumpMeasRate(); - F32 max = MAX( rate, syringePumpSetRate ); - F32 min = MIN( rate, syringePumpSetRate ); - F32 error = ( max > 0.0 ? ( 1.0 - fabs( min / max ) ) : 0.0 ); - F32 delta = max - min; - // Alarm on rate if off by more than 5% or 0.1 mL/hr, whichever is greater - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, ( ( error > pctMargin ) && ( delta > SYRINGE_PUMP_MAX_RATE_ERROR_ML_HR ) ) ) ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) { - result = TRUE; - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, syringePumpSetRate, rate ) + F32 rate = getSyringePumpMeasRate(); + F32 max = MAX( rate, syringePumpSetRate ); + F32 min = MIN( rate, syringePumpSetRate ); + F32 error = ( max > 0.0 ? ( 1.0 - fabs( min / max ) ) : 0.0 ); + F32 delta = max - min; + + // Alarm on rate if off by more than 5% or 0.1 mL/hr, whichever is greater + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, ( ( error > pctMargin ) && ( delta > SYRINGE_PUMP_MAX_RATE_ERROR_ML_HR ) ) ) ) + { + result = TRUE; + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, syringePumpSetRate, rate ) + } } -#endif return result; } @@ -1807,7 +1817,7 @@ * The publishSyringePumpData function publishes syringe pump data at the * set interval. * @details Inputs: latest syringe pump data, syringePumpDataPublicationTimerCounter - * @details Outputs: Syringe pump data are published to CAN bus. + * @details Outputs: syringePumpDataPublicationTimerCounter * @return none *************************************************************************/ static void publishSyringePumpData( void ) @@ -1838,49 +1848,12 @@ } } -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: forceSensorCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ - // Get the calibration record from NVDataMgmt - HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T calData = getHDHeparinForceSensorCalibrationRecord(); - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the heparin force sensors data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.hdHeparinForceSensor.calibrationTime ) - { -#ifndef SKIP_CAL_CHECK - activateAlarmNoData( ALARM_ID_HD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - forceSensorCalRecord.hdHeparinForceSensor.fourthOrderCoeff = calData.hdHeparinForceSensor.fourthOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.thirdOrderCoeff = calData.hdHeparinForceSensor.thirdOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.secondOrderCoeff = calData.hdHeparinForceSensor.secondOrderCoeff; - forceSensorCalRecord.hdHeparinForceSensor.gain = calData.hdHeparinForceSensor.gain; - forceSensorCalRecord.hdHeparinForceSensor.offset = calData.hdHeparinForceSensor.offset; - - return status; -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - /*********************************************************************//** * @brief * The testSetSyringePumpDataPublishIntervalOverride function overrides the Index: firmware/App/Modes/ConsumableSelfTest.c =================================================================== diff -u -r1e3ec545fa8f81372dca1672efb2e1648203e155 -rb7d279735312c0f04dd53d8903bf21c520b2beee --- firmware/App/Modes/ConsumableSelfTest.c (.../ConsumableSelfTest.c) (revision 1e3ec545fa8f81372dca1672efb2e1648203e155) +++ firmware/App/Modes/ConsumableSelfTest.c (.../ConsumableSelfTest.c) (revision b7d279735312c0f04dd53d8903bf21c520b2beee) @@ -8,7 +8,7 @@ * @file ConsumableSelfTest.c * * @author (last) Dara Navaei -* @date (last) 04-Jan-2022 +* @date (last) 22-Mar-2022 * * @author (original) Quang Nguyen * @date (original) 06-Mar-2021 @@ -18,6 +18,7 @@ #include "ConsumableSelfTest.h" #include "DGInterface.h" #include "ModePreTreat.h" +#include "NVDataMgmt.h" #include "Reservoirs.h" /** @@ -75,18 +76,23 @@ switch( currentConsumableSelfTestState ) { case CONSUMABLE_SELF_TESTS_INSTALL_STATE: -#ifdef SKIP_UI_INTERACTION - consumableInstallConfirmed = TRUE; -#endif + + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) ) + { + consumableInstallConfirmed = TRUE; + } // TODO: Check for DG straw door status to be open once DG door driver implemented if ( TRUE == consumableInstallConfirmed ) { consumableInstallConfirmed = FALSE; -#ifndef SKIP_CONSUMABLE_TESTS - currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_FILL_CMD_STATE; -#else - currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_COMPLETE_STATE; -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CONSUMABLES_TESTS ) != SW_CONFIG_ENABLE_VALUE ) + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_FILL_CMD_STATE; + } + else + { + currentConsumableSelfTestState = CONSUMABLE_SELF_TESTS_COMPLETE_STATE; + } } break; Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r5420b3e1f4260d8fbdce3f4f495f19f1a6f05b7e -rb7d279735312c0f04dd53d8903bf21c520b2beee --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 5420b3e1f4260d8fbdce3f4f495f19f1a6f05b7e) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision b7d279735312c0f04dd53d8903bf21c520b2beee) @@ -7,8 +7,8 @@ * * @file ModePostTreat.c * -* @author (last) Behrouz NematiPour -* @date (last) 04-Jan-2022 +* @author (last) Darren Cox +* @date (last) 22-Mar-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -360,15 +360,17 @@ static HD_POST_TREATMENT_STATE_T handlePostTreatmentPatientDisconnectionState( void ) { F32 const bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); - F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); + F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; VALVE_T valve; - if ( STATE_CLOSED == getFPGADoorState() ) + if (( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) && (STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ))) { -#ifdef SKIP_UI_INTERACTION - patientDisconnectionConfirmed = TRUE; -#endif + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) ) + { + patientDisconnectionConfirmed = TRUE; + } + if ( TRUE == patientDisconnectionConfirmed ) { patientDisconnectionConfirmed = FALSE; @@ -409,9 +411,10 @@ { HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; -#ifdef SKIP_UI_INTERACTION - disposableRemovalConfirmed = TRUE; -#endif + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_INTERACTION ) ) + { + disposableRemovalConfirmed = TRUE; + } if ( TRUE == disposableRemovalConfirmed ) { @@ -425,40 +428,38 @@ /*********************************************************************//** * @brief * The handlePostTreatmentVerifyState function verifies cartridge removed, - * syringe removed, and doors are closed before transition to standby mode. + * syringe removed before transition to standby mode. * @details Inputs: doors' status, syringe status, occlusion sensors value * @details Outputs: requested transition to standby mode * @return current state (sub-mode) *************************************************************************/ static HD_POST_TREATMENT_STATE_T handlePostTreatmentVerifyState( void ) { -#ifndef SKIP_CARTRIDGE_REMOVAL - BOOL isCartridgeRemoved = isCartridgeUnloaded(); -#else + // Assuming the cartridge door is removed already. + // This is used when the disable cartridge removal step software configuration is enabled BOOL isCartridgeRemoved = TRUE; + +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_CARTRIDGE_REMOVAL_STEP ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + isCartridgeRemoved = isCartridgeUnloaded(); + } - if ( STATE_CLOSED == getFPGADoorState() ) + if ( FALSE == isCartridgeRemoved ) { - if ( FALSE == isCartridgeRemoved ) - { - activateAlarmNoData( ALARM_ID_CARTRIDGE_REMOVAL_FAILURE ); - } + activateAlarmNoData( ALARM_ID_CARTRIDGE_REMOVAL_FAILURE ); + } - if ( TRUE == isSyringeDetected() ) - { - activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); - } - // Wait for cartridge and syringe to be removed and for DG to finish any drains/fills. - if ( ( TRUE == isCartridgeRemoved ) && ( FALSE == isSyringeDetected() ) ) - { - cmdStopDG(); - requestNewOperationMode( MODE_STAN ); - } + if ( TRUE == isSyringeDetected() ) + { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); } - else + // Wait for cartridge and syringe to be removed and for DG to finish any drains/fills. + if ( ( TRUE == isCartridgeRemoved ) && ( FALSE == isSyringeDetected() ) ) { - activateAlarmNoData( ALARM_ID_CARTRIDGE_DOOR_OPENED ); + cmdStopDG(); + requestNewOperationMode( MODE_STAN ); } return HD_POST_TREATMENT_VERIFY_STATE; Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r1177293b3166db6a2bc6e19c6fdf488d064fd13c -rb7d279735312c0f04dd53d8903bf21c520b2beee --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 1177293b3166db6a2bc6e19c6fdf488d064fd13c) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision b7d279735312c0f04dd53d8903bf21c520b2beee) @@ -7,8 +7,8 @@ * * @file SelfTests.c * -* @author (last) Hung Nguyen -* @date (last) 15-Feb-2022 +* @author (last) Darren Cox +* @date (last) 17-Mar-2022 * * @author (original) Quang Nguyen * @date (original) 28-Jan-2021 @@ -72,25 +72,6 @@ /// Multiplier to conver flow (mL/min) into volume (mL) for period of general task interval. static const F32 SELF_TEST_FLOW_INTEGRATOR = ( ( 1.0 * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ) ); -/// Wet self-tests state machine. -typedef enum Wet_Self_Tests_State -{ - WET_SELF_TESTS_START_STATE = 0, ///< Wet self-tests starting state. - WET_SELF_TESTS_SETUP_STATE, ///< Setup reservoirs for wet self-tests. - WET_SELF_TESTS_BUBBLES_STATE, ///< Wet self-test air bubble detectors state. - WET_SELF_TESTS_PRIME_CHECK_STATE, ///< Prime check wet self-tests state, checks for primed patient lines. - WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE, ///< Blood leak detector self-test state. - WET_SELF_TESTS_FIRST_DISPLACEMENT_SETUP_STATE, ///< Setup valve and start dialysate pump for first displacement. - WET_SELF_TESTS_FIRST_DISPLACEMENT_STATE, ///< Fill reservoir 2 with 100 mL of dialysate from reservoir 1 state. - WET_SELF_TESTS_FIRST_DISPLACEMENT_VERIFY_STATE, ///< After first displacement completed verify state. - WET_SELF_TESTS_SECOND_DISPLACEMENT_SETUP_STATE, ///< Setup valve and start dialysate pump for second displacement. - WET_SELF_TESTS_SECOND_DISPLACEMENT_STATE, ///< Fill reservoir 1 with 300 mL of dialysate from reservoir 2 state. - WET_SELF_TESTS_SECOND_DISPLACEMENT_VERIFY_STATE, ///< After first displacement completed verify state. - WET_SELF_TESTS_STOPPED_STATE, ///< Wet self-test stopped state. - WET_SELF_TESTS_COMPLETE_STATE, ///< Wet self-test complete state. - NUM_OF_WET_SELF_TESTS_STATES ///< Number of wet self-tests states. -} WET_SELF_TESTS_STATE_T; - // ********** private data ********** static NO_CART_SELF_TESTS_STATE_T currentNoCartSelfTestsState; ///< Current state of the no cartridge self-tests state machine. @@ -235,11 +216,15 @@ F32 const bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); F32 const hepRate = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ); -#ifndef DISABLE_SYRINGE_PUMP - useHeparin = ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ? TRUE : FALSE ); -#else - useHeparin = FALSE; -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) + { + useHeparin = ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ? TRUE : FALSE ); + } + else + { + useHeparin = FALSE; + } + currentNoCartSelfTestsState = NO_CART_SELF_TESTS_START_STATE; runPumpStartTime = 0; havePumpsStarted = FALSE; @@ -281,7 +266,7 @@ break; case NO_CART_SELF_TESTS_DIALYSATE_FLOW_METERS_STATE: - execDialInFlowTest(); + // TODO as of now, the dialysate flow self test only gets the calibration record so it is only called in POST currentNoCartSelfTestsState = NO_CART_SELF_TESTS_BOARD_TEMPERATURE_STATE; break; @@ -395,13 +380,15 @@ // Ensure occlusion sensor has time to settle after cartridge insertion before starting dry self-tests if ( TRUE == didTimeout( selfTestStartTime, CARTRIDGE_INSERT_PRESSURE_SETTLE_TIME_MS ) ) { - setOcclusionInstallLevel(); // Record occlusion pressure level after a new cartridge is installed. -#ifdef SKIP_DRY_SELF_TESTS - // TODO: Remove once dry self-test is ready to use - currentDrySelfTestsState = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; -#else - currentDrySelfTestsState = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; -#endif + setOcclusionInstallLevel(); // Record occlusion pressure level after a new cartridge is installed + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRY_SELF_TESTS ) ) + { + currentDrySelfTestsState = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; + } + else + { + currentDrySelfTestsState = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; + } } break; @@ -632,7 +619,7 @@ selfTestStartTime = getMSTimerCount(); // TODO: Use appropriate sensor driver - if ( STATE_CLOSED == getFPGADoorState() ) + if (( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) && (STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) )) { state = NO_CART_SELF_TESTS_OCCLUSION_SENSORS_STATE; } @@ -816,7 +803,7 @@ selfTestStartTime = getMSTimerCount(); // TODO: Use appropriate sensor driver - if ( STATE_CLOSED == getFPGADoorState() ) + if (( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) && (STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) )) { state = DRY_SELF_TESTS_USED_CARTRIDGE_CHECK_STATE; setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); @@ -845,7 +832,6 @@ static DRY_SELF_TESTS_STATE_T handleDrySelfTestUsedCartridgeCheckState( void ) { DRY_SELF_TESTS_STATE_T state = DRY_SELF_TESTS_USED_CARTRIDGE_CHECK_STATE; - BUBBLE_STATUS_T const ADVBubbleStatus = getBubbleStatus( ADV ); if ( ( BUBBLE_DETECTED == ADVBubbleStatus ) && @@ -1082,11 +1068,14 @@ if ( TRUE == selfTestsResumeRequested ) { selfTestsResumeRequested = FALSE; -#ifndef SKIP_DRY_SELF_TESTS - state = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; -#else - state = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRY_SELF_TESTS ) != SW_CONFIG_ENABLE_VALUE ) + { + state = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; + } + else + { + state = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; + } } return state; @@ -1226,11 +1215,18 @@ BUBBLE_STATUS_T const ADVBubbleStatus = getBubbleStatus( ADV ); -#ifndef SKIP_AIR_BUBBLE_CHECK - if ( ( BUBBLE_NOT_DETECTED == ADABubbleStatus ) && ( BUBBLE_NOT_DETECTED == ADVBubbleStatus ) ) -#endif + + if ( BUBBLE_NOT_DETECTED == ADVBubbleStatus ) { - zeroBloodLeak(); +#ifndef _RELEASE_ + // TODO do we need both of these? + if ( ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) != SW_CONFIG_ENABLE_VALUE ) && + ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SELF_TESTS_AIR_BUBBLE_CHECK ) != SW_CONFIG_ENABLE_VALUE ) ) +#endif + { + zeroBloodLeak(); + } + state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; *result = SELF_TEST_STATUS_PASSED; } @@ -1256,7 +1252,8 @@ { WET_SELF_TESTS_STATE_T state = WET_SELF_TESTS_BLOOD_LEAK_DETECTOR_STATE; - if ( SELF_TEST_STATUS_PASSED == getBloodLeakSelfTestStatus() ) + if ( ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) != SW_CONFIG_ENABLE_VALUE ) || + ( SELF_TEST_STATUS_PASSED == getBloodLeakSelfTestStatus() ) ) { settleStartTime = getMSTimerCount(); state = WET_SELF_TESTS_FIRST_DISPLACEMENT_SETUP_STATE;