Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r99291dfcff27720fde696dfe4d262dc003d85d1a -re14e14eedeb52b901618222bb59320b955bf7f5a --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 99291dfcff27720fde696dfe4d262dc003d85d1a) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision e14e14eedeb52b901618222bb59320b955bf7f5a) @@ -369,26 +369,26 @@ /*********************************************************************//** * @brief - * The getDialysateTemperature function gets the latest dialysate temperature. - * @details Inputs: dgDialysateTemp + * The getDGDisinfectsStates function returns the DG disinfects readings. + * @details Inputs: none * @details Outputs: none - * @return the current dialysate temperature + * @return the current DG disinfects readings *************************************************************************/ -F32 getDialysateTemperature( void ) +DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) { - return dgDialysateTemp; + return disinfectsStatus; } /*********************************************************************//** * @brief - * The getDGDisinfectsStates function returns the DG disinfects readings. - * @details Inputs: none + * The getDialysateTemperature function gets the latest dialysate temperature. + * @details Inputs: dgDialysateTemp * @details Outputs: none - * @return the current DG disinfects readings + * @return the current dialysate temperature *************************************************************************/ -DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) +F32 getDialysateTemperature( void ) { - return disinfectsStatus; + return dgDialysateTemp; } /*********************************************************************//** @@ -883,6 +883,19 @@ /*********************************************************************//** * @brief + * The cmdSetDGToServiceMode function sends a request to DG to transition + * to service mode. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void cmdSetDGToServiceMode( void ) +{ + sendDGServiceModeRequest(); +} + +/*********************************************************************//** + * @brief * The handleDGCommandResponse function processes the latest DG command response. * @details Inputs: none * @details Outputs: process command response from DG Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r13b6bb9e3bbd6b07d5b51d46552a9f282b4f97e4 -re14e14eedeb52b901618222bb59320b955bf7f5a --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 13b6bb9e3bbd6b07d5b51d46552a9f282b4f97e4) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision e14e14eedeb52b901618222bb59320b955bf7f5a) @@ -22,7 +22,8 @@ #include "NVDataMgmt.h" #include "OperationModes.h" #include "PersistentAlarm.h" -#include "SystemCommMessages.h" +#include "SystemCommMessages.h" +#include "SelfTests.h" #include "TaskGeneral.h" #include "Temperatures.h" #include "Timers.h" @@ -70,6 +71,7 @@ #define PSI_TO_MMHG ( 51.7149F ) ///< Conversion factor for converting PSI to mmHg. +// The new arterial pressure sensor is the same as the venous pressure sensor #define VENOUS_PRESSURE_NORMAL_OP 0 ///< Venous pressure status bits indicate normal operation. #define VENOUS_PRESSURE_CMD_MODE 1 ///< Venous pressure status bits indicate sensor in command mode. #define VENOUS_PRESSURE_STALE_DATA 2 ///< Venous pressure status bits indicate data is stale (no new data since last fpga read). @@ -660,7 +662,7 @@ static void checkOcclusions( void ) { U32 bpOccl = getMeasuredBloodPumpOcclusion(); - BOOL outOfRange = ( bpOccl < MIN_OCCLUSION_COUNTS || bpOccl > MAX_OCCLUSION_COUNTS ? TRUE : FALSE ); + BOOL outOfRange = ( bpOccl < MIN_OCCLUSION_COUNTS || bpOccl > MAX_OCCLUSION_COUNTS ? TRUE : FALSE ); #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) @@ -678,14 +680,42 @@ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_OCCLUSION_OUT_OF_RANGE, bpOccl ); } - // Check for BP occlusion - if ( bpOccl > ( OCCLUSION_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + + // Check for occlusion in PreTreatment modes when the cartridge is installed + // and setOcclusionInstallLevel has been called. + if( MODE_PRET == getCurrentOperationMode() ) { - signalBloodPumpHardStop(); // Stop pump immediately - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) + // Check for BP occlusion + if ( bpOccl > ( OCCLUSION_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + { + if( getPreTreatmentSubState() > HD_PRE_TREATMENT_CART_INSTALL_STATE && getDrySelfTestsState() > DRY_SELF_TESTS_START_STATE ) + { + // Check for occlusion + if ( bpOccl > ( OCCLUSION_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + { + signalBloodPumpHardStop(); // Stop pump immediately + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) + } + } + } } - else + // Check for occlusion in PreTreatment modes where pumps are moving + else if( MODE_TREA == getCurrentOperationMode() ) { + if( TREATMENT_STOP_STATE != getTreatmentState()) + { + // Check for occlusion + if ( bpOccl > ( OCCLUSION_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + { + signalBloodPumpHardStop(); // Stop pump immediately + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) + } + } + } + + // Clear alarm regardless of op mode once conditions are met. + if ( bpOccl <= ( OCCLUSION_CLEAR_THRESHOLD_OFFSET + bloodPumpOcclusionAfterCartridgeInstall ) ) + { clearAlarmCondition( ALARM_ID_OCCLUSION_BLOOD_PUMP ); } Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r43ab88c9ad8435e0a0a3df0adde1de150c582305 -re14e14eedeb52b901618222bb59320b955bf7f5a --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 43ab88c9ad8435e0a0a3df0adde1de150c582305) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision e14e14eedeb52b901618222bb59320b955bf7f5a) @@ -92,6 +92,7 @@ /// Expected position of empty in relation to home position. #define SYRINGE_PUMP_EMPTY_POS ( SYRINGE_ENCODER_COUNTS_PER_ML * 10.84F ) + /// Margin of error for empty position determination. #define SYRINGE_PUMP_EMPTY_POS_MARGIN ( SYRINGE_ENCODER_COUNTS_PER_ML * 0.5F ) /// Minimum retract position. @@ -2000,6 +2001,7 @@ + /*********************************************************************//** * @brief * The testSetSyringePumpDataPublishIntervalOverride function overrides the Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -rad4d98e7d69ee6320a7ab573c353cd6ff92a76fe -re14e14eedeb52b901618222bb59320b955bf7f5a --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision ad4d98e7d69ee6320a7ab573c353cd6ff92a76fe) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision e14e14eedeb52b901618222bb59320b955bf7f5a) @@ -18,15 +18,16 @@ // ********** private definitions ********** -#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Allocated time to settle the filled reservoir in milliseconds. -#define RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS 8000 ///< Reservoir extra time in during the cycle for error in milliseconds. +#define RESERVOIR_SETTLE_TIME_MS 5000 ///< Allocated time to settle the filled reservoir in milliseconds. +#define RESERVOIR_CYCLE_EXTRA_MARGIN_TIME_MS 8000 ///< Reservoir extra time in during the cycle for error in milliseconds. #define MAX_RESERVOIR_VOLUME_ML 1950.0 ///< Maximum allowed fluid in a reservoir in milliliters. #define MAX_RESERVOIR_DILUTION 0.15F ///< Maximum reservoir dilution limit. #define MAX_RESERVOIR_RECIRCULATION 1.1F ///< Maximum reservoir recirculation limit. -#define MAX_RESERVOIR_DEPLETION_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum allowed depletion time in milliseconds. -#define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the reservoir data is published on the CAN bus. +#define MAX_RESERVOIR_DEPLETION_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum allowed depletion time in milliseconds. +#define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the reservoir data is published on the CAN bus. +#define RESERVOIR_DEPLETION_INTERVAL ( MAX_RESERVOIR_DEPLETION_TIME_MS / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) for maximum allowed depletion time. #define DIALYSATE_FLOW_RATE_350_ML_PER_MIN 0.35F ///< Dialysate flow rate 350 mL/min. #define DIALYSATE_FLOW_RATE_400_ML_PER_MIN 0.4F ///< Dialysate flow rate 400 mL/min. @@ -39,6 +40,10 @@ #define DIA_FLOW_TO_FILL_FLOW_FIRST_ORDER_COEFF 7.5F ///< Dialysate flow rate to fill flow rate first order coefficient. #define DIA_FLOW_TO_FILL_FLOW_CONSTANT 2.0F ///< Dialysate flow rate to fill flow rate constant. +#define DIA_FLOW_TO_FILL_FLOW_SECOND_ORDER_COEFF 10.0 ///< Dialysate flow rate to fill flow rate second order coefficient. +#define DIA_FLOW_TO_FILL_FLOW_FIRST_ORDER_COEFF 7.5 ///< Dialysate flow rate to fill flow rate first order coefficient. +#define DIA_FLOW_TO_FILL_FLOW_CONSTANT 2.0 ///< Dialysate flow rate to fill flow rate constant. + // ********** private data ********** /// States of the treatment reservoir management state machine. @@ -172,7 +177,13 @@ if ( ( TREATMENT_DIALYSIS_STATE == getTreatmentState() ) && ( getDialysisState() != DIALYSIS_SALINE_BOLUS_STATE ) ) { volSpentML += ( flowRateMLPerMS * msSinceLastVolumeCalc ); + + if ( TREATMENT_DIALYSIS_STATE == getTreatmentState()) + { + ++timeReservoirInUseMS; + } } + // Update the reservoir start time timeStartMS = getMSTimerCount(); @@ -238,13 +249,13 @@ static void checkReservoirDepletionTime( void ) { // Check if the time that the reservoir has been use has exceeded the limit - if ( TRUE == didTimeout( timeReservoirInUseMS, MAX_RESERVOIR_DEPLETION_TIME_MS ) ) + if ( timeReservoirInUseMS >= RESERVOIR_DEPLETION_INTERVAL ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RESERVOIRS_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_DEPLETION_TIME_OUT, calcTimeSince( timeReservoirInUseMS ) ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_ACTIVE_RESERVOIR_DEPLETION_TIME_OUT, timeReservoirInUseMS ) } } } @@ -514,7 +525,7 @@ // If the wait time has elapsed, trigger a fill command // TODO uncomment - //if ( timeWaitToFillMS <= 0 ) + if ( timeWaitToFillMS <= 0 ) // TODO uncomment { cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); @@ -649,7 +660,7 @@ setFinalReservoirVolume(); // Switched the active reservoir so reset the reservoir in use timer - timeReservoirInUseMS = getMSTimerCount(); + timeReservoirInUseMS = 0; // Reset to start state to restart drain, fill, switch process. state = TREATMENT_RESERVOIR_MGMT_START_STATE; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rfa09ed93f0786712108539a50370aae404335d5e -re14e14eedeb52b901618222bb59320b955bf7f5a --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision fa09ed93f0786712108539a50370aae404335d5e) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e14e14eedeb52b901618222bb59320b955bf7f5a) @@ -52,8 +52,7 @@ #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window #define MSG_NOT_ACKED_TIMEOUT_MS 150 ///< Maximum time for a Denali message that requires ACK to be ACK'd - -#define MSG_NOT_ACKED_TIMEOUT_MS_INIT 5000 ///< Maximum time for a Denali message that requires ACK to be ACK'd on the INIT state for the first (UI version request) message of the POST +#define MSG_NOT_ACKED_TIMEOUT_MS_INIT 5000 ///< Maximum time for a Denali message that requires ACK to be ACK'd on the INIT state for the first (UI version request) message of the POST #define MSG_NOT_ACKED_MAX_RETRIES 3 ///< Maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm #define PENDING_ACK_LIST_SIZE 25 ///< Maximum number of Denali messages that can be pending ACK at any given time @@ -1624,10 +1623,6 @@ handleTestSyringePumpHeprinBolusTargetRateOverrideRequest( message ); break; - case MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS: - handleTestCurrentTreamtmentParametersRequest( message ); - break; - case MSG_ID_HD_FANS_DUTY_CYCLE_OVERRIDE: handleSetFansDutyCycleOverrideRequest( message ); break; @@ -1664,6 +1659,11 @@ handleResendAllAlarmsCommand( message ); break; + case MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS: + handleTestCurrentTreamtmentParametersRequest( message ); + break; + + // The default cannot be reached in VectorCAST since the cases are run in a for loop default: // Unrecognized message ID received - ignore