Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r30b1f6126c37f7b99cf699f63b4bcee9d1a1745f -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 30b1f6126c37f7b99cf699f63b4bcee9d1a1745f) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -53,7 +53,7 @@ #define MIN_BLOOD_PUMP_PWM_DUTY_CYCLE 0.12 ///< Controller will error if PWM duty cycle < 10%, so set min to 12% /// Interval (ms/task time) at which the blood pump is controlled. -#define BP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) +static const U32 BP_CONTROL_INTERVAL = ( 10000 / TASK_GENERAL_INTERVAL ); #define BP_P_COEFFICIENT 0.00035 ///< P term for blood pump control #define BP_I_COEFFICIENT 0.00035 ///< I term for blood pump control @@ -69,13 +69,19 @@ #define BP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< Maximum difference between measured speed and speed implied by measured flow. #define BP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. #define BP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). -#define BP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. -#define BP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for flow vs. motor speed error condition. -#define BP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for motor off error condition. -#define BP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) motor speed error condition. -#define BP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) rotor speed error condition. -#define BP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) pump direction error condition. -#define BP_MAX_ROTOR_SPEED_ERROR_PERSIST ((1 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) blood pump rotor speed too fast error condition. +#define BP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. +/// Persist time (task intervals) for flow vs. motor speed error condition. +static const U32 BP_FLOW_VS_SPEED_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) for motor off error condition. +static const U32 BP_OFF_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) motor speed error condition. +static const U32 BP_MOTOR_SPEED_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) rotor speed error condition. +static const U32 BP_ROTOR_SPEED_ERROR_PERSIST = ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) pump direction error condition. +static const U32 BP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) blood pump rotor speed too fast error condition. +static const U32 BP_MAX_ROTOR_SPEED_ERROR_PERSIST = ((1 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); #define BP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped #define BP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< Motor controller current should always exceed this when pump should be running Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -49,7 +49,7 @@ TREATMENT_RESERVOIR_MGMT_FILL_RESERVOIR_STATE, ///< Wait for fill to complete. TREATMENT_RESERVOIR_MGMT_WAIT_FOR_FILL_SETTLE_STATE, ///< Wait a bit for filled reservoir to settle before getting baseline weight (volume). TREATMENT_RESERVOIR_MGMT_WAIT_FOR_RES_SWITCH_STATE, ///< Wait for active reservoir to be consumed and switch cmd given - then back to flush DG lines state. - TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE, ///< Wait for inactive reservoir to settle before getting final weight (volume) before starting to drain. + TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE, ///< Wait for inactive reservoir to settle before getting final weight (volume) before starting to drain. NUM_OF_TREATMENT_RESERVOIR_MGMT_STATES ///< Number of treatment reservoir mgmt. states. } TREATMENT_RESERVOIR_MGMT_STATE_T; @@ -201,6 +201,19 @@ resMgmtTimer = 0; resUseTimer = getMSTimerCount(); resUseVolumeMl = 0.0; +} + +/*********************************************************************//** + * @brief + * The dialysisResumed function initializes the reservoir re-use timer + * when dialysis is started/resumed so that dialysate usage can be tracked. + * @details Inputs: none + * @details Outputs: resUseTimer + * @return none + *************************************************************************/ +void dialysisResumed( void ) +{ + resUseTimer = getMSTimerCount(); } /*********************************************************************//** @@ -217,22 +230,22 @@ U32 dgSubMode = getDGSubMode(); U32 msSinceLastVolumeCalc = calcTimeSince( resUseTimer ); F32 flowRateMlPerMs = (F32)getTargetDialInFlowRate() / (F32)( MS_PER_SECOND * SEC_PER_MIN ); - + // Calculate volume used from active reservoir - do not accumulate if saline bolus in progress if ( SALINE_BOLUS_STATE_IN_PROGRESS != getSalineBolusState() ) { resUseVolumeMl += ( flowRateMlPerMs * msSinceLastVolumeCalc ); // TODO - should this calc be done and kept by Dialysis sub-mode? } - resUseTimer = getMSTimerCount(); - + resUseTimer = getMSTimerCount(); + // Treatment reservoir mgmt. state machine switch ( currentTrtResMgmtState ) { case TREATMENT_RESERVOIR_MGMT_START_STATE: currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_FLUSH_DG_LINES_STATE; break; - case TREATMENT_RESERVOIR_MGMT_FLUSH_DG_LINES_STATE: + case TREATMENT_RESERVOIR_MGMT_FLUSH_DG_LINES_STATE: if ( DG_MODE_CIRC == dgOpMode ) { if ( DG_RECIRCULATE_MODE_STATE_RECIRC_WATER == dgSubMode ) @@ -253,7 +266,7 @@ case TREATMENT_RESERVOIR_MGMT_DRAIN_RESERVOIR_STATE: if ( DG_MODE_CIRC == dgOpMode ) { - currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_WAIT_TO_FILL_STATE; + currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_WAIT_TO_FILL_STATE; } break; @@ -276,7 +289,7 @@ if ( DG_MODE_FILL == dgOpMode ) { currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_FILL_RESERVOIR_STATE; - } + } break; case TREATMENT_RESERVOIR_MGMT_FILL_RESERVOIR_STATE: @@ -323,8 +336,8 @@ // Reset to start state to restart drain, fill, switch process. currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; } - break; - + break; + default: // TODO - s/w fault currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -120,7 +120,8 @@ void execDGInterfaceMonitor( void ); void initTreatmentReservoirMgmt( void ); -void execTreatmentReservoirMgmt( void ); +void dialysisResumed( void ); +void execTreatmentReservoirMgmt( void ); DG_OP_MODE_T getDGOpMode( void ); U32 getDGSubMode( void ); Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r30b1f6126c37f7b99cf699f63b4bcee9d1a1745f -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 30b1f6126c37f7b99cf699f63b4bcee9d1a1745f) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -48,8 +48,9 @@ #define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< Max duty cycle change when ramping down ~ 300 mL/min/s. #define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< Controller will error if PWM duty cycle > 90%, so set max to 88%. #define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< Controller will error if PWM duty cycle < 10%, so set min to 12%. - -#define DIP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialIn pump is controlled + +/// Interval (ms/task time) at which the dialIn pump is controlled. +static const U32 DIP_CONTROL_INTERVAL = ( 10000 / TASK_GENERAL_INTERVAL ); #define DIP_P_COEFFICIENT 0.00035 ///< P term for dialIn pump control. #define DIP_I_COEFFICIENT 0.00035 ///< I term for dialIn pump control. @@ -64,12 +65,18 @@ #define DIP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< Maximum difference between measured motor speed and speed implied by measured flow. #define DIP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. #define DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). -#define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. -#define DIP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for flow vs. motor speed error condition. -#define DIP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for motor off error condition. -#define DIP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) motor speed error condition. -#define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) rotor speed error condition. -#define DIP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) pump direction error condition. +#define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. + +/// Persist time (task intervals) for flow vs. motor speed error condition. +static const U32 DIP_FLOW_VS_SPEED_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) for motor off error condition. +static const U32 DIP_OFF_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) motor speed error condition. +static const U32 DIP_MOTOR_SPEED_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) rotor speed error condition. +static const U32 DIP_ROTOR_SPEED_ERROR_PERSIST = ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) pump direction error condition. +static const U32 DIP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); #define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -57,11 +57,13 @@ #define VENOUS_PRESSURE_STALE_DATA 2 ///< Venous pressure status bits indicate data is stale (no new data since last fpga read). #define VENOUS_PRESSURE_DIAG_CONDITION 3 ///< Venous pressure status bits diagnostic condition (alarm). -#define MAX_TIME_BETWEEN_VENOUS_READINGS ( 500 / TASK_GENERAL_INTERVAL ) ///< Maximum time without fresh inline venous pressure reading. +static const U32 MAX_TIME_BETWEEN_VENOUS_READINGS = ( 500 / TASK_GENERAL_INTERVAL ); ///< Maximum time without fresh inline venous pressure reading. #define OCCLUSION_THRESHOLD 25000 ///< Threshold above which an occlusion is detected. #define CARTRIDGE_LOADED_THRESHOLD 5000 ///< Threshold above which a cartridge is considered loaded. +#define EMPTY_SALINE_BAG_THRESHOLD_MMHG -300.0 ///< Threshold below which the saline bag is considered empty (in mmHg). TODO - get real threshold from Systems +static const U32 EMPTY_SALINE_BAG_PERSISTENCE = ( 250 / TASK_GENERAL_INTERVAL ); ///< Time that saline bag looks empty before saying it is empty. TODO - use persistent alarm when updated /// Occlusion sensors minimum pressure reading limit when no cartridge is loaded. #define OCCLUSION_NO_CARTRIDGE_PRESSURE_READING_MIN 2000 /// Occlusion sensors maximum pressure reading limit when cartridge is considered loaded. @@ -100,6 +102,7 @@ static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate outlet pump occlusion pressure. static U32 staleVenousPressureCtr = 0; ///< Timer counter for stale venous pressure reading. +static U32 emptySalineBagCtr = 0; ///< Timer counter for empty bag detection. // ********** private function prototypes ********** @@ -154,6 +157,35 @@ return result; } +/*********************************************************************//** + * @brief + * The isSalineBagEmpty function determines whether the saline bag is empty. + * It is assumed that this function will only be called from mode handling + * (General Task) when pumping (BP) from the saline bag. + * Determination is based on pressure going below a negative threshold. + * @details Inputs: arterial line pressure + * @details Outputs: none + * @return TRUE if arterial line pressure is below threshold, FALSE if not. + *************************************************************************/ +BOOL isSalineBagEmpty( void ) +{ + BOOL result = FALSE; + + if ( getMeasuredArterialPressure() < EMPTY_SALINE_BAG_THRESHOLD_MMHG ) + { + if ( ++emptySalineBagCtr >= EMPTY_SALINE_BAG_PERSISTENCE ) + { + result = TRUE; + } + } + else + { + emptySalineBagCtr = 0; + } + + return result; +} + /*********************************************************************//** * @brief * The execPresOccl function executes the pressure and occlusion monitor. Index: firmware/App/Controllers/PresOccl.h =================================================================== diff -u -r69656450319bfcfdeffdc8f11e88084d4ea38d7d -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 69656450319bfcfdeffdc8f11e88084d4ea38d7d) +++ firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -73,6 +73,7 @@ U32 getMeasuredDialOutPumpOcclusion( void ); BOOL isCartridgeLoaded( void ); +BOOL isSalineBagEmpty( void ); BOOL testSetPresOcclDataPublishIntervalOverride( U32 value ); BOOL testResetPresOcclDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r2f1cd6becf82299dd06be00ec9881e4a64d817a6 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 2f1cd6becf82299dd06be00ec9881e4a64d817a6) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -87,13 +87,17 @@ #define MAX_DEVIATION_FROM_TARGET_IN_COUNTS 150 ///< Maximum deviation from target in counts #define MAX_DEVIATION_FROM_TRAGET_IN_POS_B 1000 ///< Maximum allowed deviation from position B in counts #define MAX_ALLOWED_FAILED_HOMINGS 3U ///< Maximum allowed failed homings -#define HOMING_EDGE_DETECTION_TIME_INTERVAL ( MS_PER_SECOND / ( 2 * TASK_PRIORITY_INTERVAL ) ) ///< The time that the valve must be at the edge to be considered for edge detection +/// The time that the valve must be at the edge to be considered for edge detection +static const U32 HOMING_EDGE_DETECTION_TIME_INTERVAL = ( MS_PER_SECOND / ( 2 * TASK_PRIORITY_INTERVAL ) ); #define VALVES_CURRENT_THRESHOLD_AMPS 1.0 ///< Valves current threshold -#define MAX_OVER_CURRENT_TIME_INTERVAL_COUNTER ( MS_PER_SECOND / ( TASK_PRIORITY_INTERVAL ) ) ///< Valves over current time interval counter -#define MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ( MS_PER_SECOND / ( TASK_PRIORITY_INTERVAL ) ) ///< Valves out of range time interval counter +/// Valves over current time interval counter +static const U32 MAX_OVER_CURRENT_TIME_INTERVAL_COUNTER = ( MS_PER_SECOND / ( TASK_PRIORITY_INTERVAL ) ); +/// Valves out of range time interval counter +static const U32 MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER = ( MS_PER_SECOND / ( TASK_PRIORITY_INTERVAL ) ); #define VALVE_TRANSITION_TIMEOUT_MS 3000U ///< Valves transition time out in ms -#define VALVES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Valve data publication time interval +/// Valve data publication time interval +#define VALVES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) #define VALVE_MAX_ALLOWED_PWM_PERCENT 100U ///< Valve maximum allowed PWM in percent #define VALVE_CW_PWM_TO_CNT_CONVERSION( pwm ) ( ( 20 * pwm ) + 2500 ) ///< Valve clockwise PWM to count conversion @@ -964,6 +968,7 @@ BOOL result = TRUE; #ifndef DISABLE_3WAY_VALVES +#ifndef DISABLE_VALVE_ALARMS // Get the status of the valves from FPGA U16 status = getFPGAValvesStatus(); @@ -1009,6 +1014,7 @@ } } #endif +#endif return result; } Index: firmware/App/HDCommon.h =================================================================== diff -u -rc539499ea2dee6d62194d573ac93b313d9e2936d -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision c539499ea2dee6d62194d573ac93b313d9e2936d) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -57,7 +57,9 @@ // #define READ_FPGA_ASYNC_DATA 1 // Test build reads non-priority register page every other time // #define EMC_TEST_BUILD 1 // EMC test build - HD/DG run separately but connected, HD pumps toggle on/off w/ stop button #define ALARMS_DEBUG 1 // Triggered alarms sent to debug UART - #define V1_5_SYSTEM 1 // Build for v1.5 system + #define SKIP_SELF_TESTS 1 // Skip Pre-treatment Self-tests + #define SKIP_PRIMING 1 // Skip Pre-treatment Prime +// #define V1_5_SYSTEM 1 // Build for v1.5 system #include #include Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -39,13 +39,11 @@ // ********** private definitions ********** #define MAX_UF_RATE_ML_PER_HOUR 2750.0 ///< Maximum ultrafiltration rate in mL/hour -#define MAX_UF_RATE_ACCURACY_ERROR_ML_HR 100.0 ///< Maximum ultrafiltration rate accuracy error in mL/hr over each hour of treatment. -#define MAX_UF_RATE_ACCURACY_ERROR_PCT 0.05 ///< Minimum ultrafilteration rate accuracy in percentage of set point (5%) over each hour of treatment. #define MAX_UF_ACCURACY_ERROR_ML 250.0 ///< Maximum ultrafiltration accuracy error in mL over the entire treatment. /// Saline bolus data broadcast interval (ms/task time) count. -#define SALINE_BOLUS_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +static const U32 SALINE_BOLUS_DATA_PUB_INTERVAL = ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); /// Ultrafiltration rate accuracy check interval count. -#define UF_ACCURACY_CHECK_INTERVAL ((1 * MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND) / TASK_GENERAL_INTERVAL) +static const U32 UF_ACCURACY_CHECK_INTERVAL = ((1 * MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND) / TASK_GENERAL_INTERVAL); #define MAX_SALINE_VOLUME_DELIVERED 800 ///< Maximum saline volume delivered for a treatment. #define SALINE_BOLUS_RATE_ML_MIN 150 ///< Fixed rate for saline bolus delivery. @@ -73,7 +71,6 @@ static U32 setDialysateFlowRate; ///< Currently set dialysate flow rate (from prescription). static F32 maxUFVolumeML; ///< Currently set total ultrafiltration volume for treatment (from prescription). static F32 setUFRate; ///< Currently set ultrafiltration rate (from prescription). -static F32 maxUFRateAccuracyError_Ml_hr; ///< Minimum ultrafiltration rate accuracy over 1 hour duration (5% or 100 mL, whichever is greater). static U32 salineBolusBroadcastTimerCtr; ///< Saline bolus data broadcast timer counter used to schedule when to transmit data. static BOOL salineBolusStartRequested; ///< Flag indicates a saline bolus start has been requested by user. @@ -136,7 +133,6 @@ setDialysateFlowRate = 0; maxUFVolumeML = 0.0; setUFRate = 0.0; - maxUFRateAccuracyError_Ml_hr = MAX_UF_RATE_ACCURACY_ERROR_ML_HR; salineBolusBroadcastTimerCtr = 0; totalSalineVolumeDelivered = 0.0; @@ -183,7 +179,38 @@ *************************************************************************/ void transitionToDialysis( void ) { - startAirTrapControl(); // TODO - do we need to start this sooner? After prime? + // Set last UF timestamp so UF ref is resumed from this time + lastUFTimeStamp = getMSTimerCount(); + // Send dialysate outlet pump latest UF volumes + setDialOutUFVolumes( refUFVolume, measUFVolume ); + + // Inform DG interface that dialysis has started/resumed + dialysisResumed(); + + // Set valves for dialysis + setValvePosition( VDI, VALVE_POSITION_B_OPEN ); + setValvePosition( VDO, VALVE_POSITION_B_OPEN ); + setValvePosition( VBA, VALVE_POSITION_B_OPEN ); + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + // Restart pumps +#ifndef RUN_PUMPS_OPEN_LOOP + setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); +#else + setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); +#endif + setDialOutPumpTargetRate( setDialysateFlowRate + (S32)setUFRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // TODO - Heparin pump + // Tell DG to start heating dialysate + cmdStartDGTrimmerHeater(); + + startAirTrapControl(); + + // 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 ); } /*********************************************************************//** @@ -205,8 +232,6 @@ setDialysateFlowRate = dPFlow; maxUFVolumeML = maxUFVol; setUFRate = uFRate; - maxUFRateAccuracyError_Ml_hr = MAX_UF_RATE_ACCURACY_ERROR_PCT * uFRate * (F32)MIN_PER_HOUR; - maxUFRateAccuracyError_Ml_hr = MAX( maxUFRateAccuracyError_Ml_hr, MAX_UF_RATE_ACCURACY_ERROR_ML_HR ); if ( TREATMENT_DIALYSIS_STATE == getTreatmentState() ) { @@ -223,41 +248,6 @@ /*********************************************************************//** * @brief - * The startDialysis function starts/resumes dialysis. This function - * will be called by Treatment Mode when beginning or resuming dialysis - * treatment. - * @details Inputs: none - * @details Outputs: Dialysis module prepared for immediate resumption. - * @return none - *************************************************************************/ -void startDialysis( void ) -{ - // Set last UF timestamp so UF ref is resumed from this time - lastUFTimeStamp = getMSTimerCount(); - // Send dialysate outlet pump latest UF volumes - setDialOutUFVolumes( refUFVolume, measUFVolume ); - - // Set valves for dialysis - setValvePosition( VDI, VALVE_POSITION_B_OPEN ); - setValvePosition( VDO, VALVE_POSITION_B_OPEN ); - setValvePosition( VBA, VALVE_POSITION_B_OPEN ); - setValvePosition( VBV, VALVE_POSITION_B_OPEN ); - // Restart pumps -#ifndef RUN_PUMPS_OPEN_LOOP - setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); -#else - setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialInPumpTargetFlowRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); -#endif - setDialOutPumpTargetRate( setDialysateFlowRate + (S32)setUFRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - // TODO - Heparin pump - // Tell DG to start heating dialysate - cmdStartDGTrimmerHeater(); -} - -/*********************************************************************//** - * @brief * The stopDialysis function stops dialysis. This function will be called * by Treatment Mode when an alarm occurs or the user pressed the stop button. * Dialysis may be resumed later. @@ -733,7 +723,7 @@ updateUFVolumes(); // If we have reached target UF volume, UF is complete - if ( measUFVolume >= maxUFVolumeML ) + if ( refUFVolume >= maxUFVolumeML ) { result = UF_COMPLETED_STATE; } @@ -940,6 +930,7 @@ { SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, 0.0 ); // TODO - give data supporting empty bag detection errorFound = TRUE; + result = SALINE_BOLUS_STATE_IDLE; } #endif @@ -1001,7 +992,7 @@ currentUFState = UF_RUNNING_STATE; } // Resume dialysis - startDialysis(); + transitionToDialysis(); } } @@ -1063,22 +1054,19 @@ { F32 uFMeasRate = measUFVolume - lastUFVolumeChecked; // Volumes are at start/end of 1 hour period, so implied rate is per hour - // Check UF rate diff from target in last hour - if ( uFMeasRate > maxUFRateAccuracyError_Ml_hr ) + // Check UF rate over last hour + if ( uFMeasRate > MAX_UF_RATE_ML_PER_HOUR ) { #ifndef DISABLE_UF_ALARMS SET_ALARM_WITH_1_F32_DATA( ALARM_ID_UF_RATE_TOO_HIGH_ERROR, uFMeasRate ); #endif } - // If actively performing ultrafiltration right now, increment timer and see if time to start another 1 hour check period - if ( UF_RUNNING_STATE == currentUFState ) + // Increment timer and see if time to start another 1 hour check period + if ( ++uFAccuracyCheckTimerCtr >= UF_ACCURACY_CHECK_INTERVAL ) { - if ( ++uFAccuracyCheckTimerCtr >= UF_ACCURACY_CHECK_INTERVAL ) - { - // Reset for next check interval - lastUFVolumeChecked = measUFVolume; - uFAccuracyCheckTimerCtr = 0; - } + // Reset for next check interval + lastUFVolumeChecked = measUFVolume; + uFAccuracyCheckTimerCtr = 0; } // Check total UF volume error Index: firmware/App/Modes/Dialysis.h =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -24,7 +24,11 @@ /** * @defgroup Dialysis Dialysis - * @brief Dialysis sub-mode of treatment mode. + * @brief Dialysis sub-mode of treatment mode. The dialysis sub-mode is where + * dialysis and (optionally) ultrafiltration are being provided by the system. + * Heparin is added to the blood when appropriate. A saline bolus may be requested + * by the user; however, dialysis and ultrafiltration would not be provided during + * a saline bolus. * * @addtogroup Dialysis * @{ @@ -52,7 +56,6 @@ void execDialysis( void ); void setDialysisParams( U32 bPFlow, U32 dPFlow, F32 maxUFVol, F32 uFRate ); -void startDialysis( void ); void stopDialysis( void ); void signalStartSalineBolus( void ); Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -16,6 +16,7 @@ ***************************************************************************/ #include "AlarmMgmt.h" +#include "Buttons.h" #include "FPGA.h" #include "ModePreTreat.h" #include "OperationModes.h" @@ -94,6 +95,13 @@ *************************************************************************/ U32 execPreTreatmentMode( void ) { + BOOL stop = isStopButtonPressed(); + + if ( TRUE == stop ) + { + activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); + } + // execute mode state machine switch ( currentPreTreatmentState ) { Index: firmware/App/Modes/PreTreatmentRecirc.c =================================================================== diff -u -r68f18c1952d37f75f27b7ca45969af2202729bb5 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 68f18c1952d37f75f27b7ca45969af2202729bb5) +++ firmware/App/Modes/PreTreatmentRecirc.c (.../PreTreatmentRecirc.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -35,13 +35,13 @@ // ********** private data ********** static HD_PRE_TREATMENT_RECIRC_STATE_T currentPreTreatmentRecircState; ///< Current state of the pre-treatment recirculate state machine. +static BOOL recircStopRequested; ///< Flag indicates alarm requesting to stop pre-treatment recirculate. static BOOL recircResumeRequested; ///< Flag indicates alarm requesting to resume pre-treatment recirculate. // ********** private function prototypes ********** static void resetPreTreatmentRecircFlags( void ); -static void setupPreTreatmentRecirculate( void ); - +static void handlePreTreatmentRecirculateStartState( void ); static HD_PRE_TREATMENT_RECIRC_STATE_T handlePreTreatmentRecirculateState( void ); static HD_PRE_TREATMENT_RECIRC_STATE_T handlePreTreatmentRecirculateStoppedState( void ); @@ -70,7 +70,7 @@ void transitionToPreTreatmentRecirc( void ) { initPreTreatmentRecirc(); - setupPreTreatmentRecirculate(); + handlePreTreatmentRecirculateStartState(); } /*********************************************************************//** @@ -105,32 +105,45 @@ /*********************************************************************//** * @brief - * The getPreTreatmentRecircState function returns the current state of - * pre-treatment re-circulate sub-mode. - * @details Inputs: currentPreTreatmentRecircState - * @details Outputs: none - * @return current pre-treatment re-circ state + * The signalResumePreTreatmentRecirc function signals the pre-treatment + * recirculate sub-mode to resume. + * @details Inputs: none + * @details Outputs: recircResumepRequested + * @return none *************************************************************************/ -U32 getPreTreatmentRecircState( void ) +void signalResumePreTreatmentRecirc( void ) { - return currentPreTreatmentRecircState; + recircResumeRequested = TRUE; } /*********************************************************************//** * @brief - * The signalResumePreTreatmentRecirc function signals the pre-treatment - * recirculate sub-mode to resume. + * The signalStopPreTreatmentRecirc function signals the pre-treatment + * recirculate sub-mode to stop when an alarm with stop property has been triggered. * @details Inputs: none - * @details Outputs: recircResumepRequested + * @details Outputs: recircStopRequested * @return none *************************************************************************/ -void signalResumePreTreatmentRecirc( void ) +void signalStopPreTreatmentRecirc( void ) { - recircResumeRequested = TRUE; + recircStopRequested = TRUE; } /*********************************************************************//** * @brief + * The isPatientConnectionRequested function returns the status of patient connection request. + * @details Inputs: none + * @details Outputs: none + * @return TRUE if patient connection requested, otherwise FALSE + *************************************************************************/ +BOOL isPatientConnectionRequested( void ) +{ + // TODO Add handler to UI interaction + return TRUE; +} + +/*********************************************************************//** + * @brief * The resetPreTreatmentRecircFlags function resets all pre-treatment recirculate * signal flags. * @details Inputs: none @@ -139,18 +152,19 @@ *************************************************************************/ static void resetPreTreatmentRecircFlags( void ) { + recircStopRequested = FALSE; recircResumeRequested = FALSE; } /*********************************************************************//** * @brief - * The setupPreTreatmentRecirculate function setups valves and + * The handlePreTreatmentRecirculateStartState function changes valves and * heater settings for pre-treatment recirculate sub-mode. * @details Inputs: none * @details Outputs: controlled valves and pumps * @return none *************************************************************************/ -static void setupPreTreatmentRecirculate( void ) +static void handlePreTreatmentRecirculateStartState( void ) { setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); @@ -177,13 +191,14 @@ { HD_PRE_TREATMENT_RECIRC_STATE_T state = PRE_TREATMENT_RECIRC_STATE; - if ( TRUE == doesAlarmStatusIndicateStop() ) + if ( TRUE == recircStopRequested ) { signalDialOutPumpHardStop(); signalDialInPumpHardStop(); signalBloodPumpHardStop(); cmdStopDGTrimmerHeater(); + recircStopRequested = FALSE; state = PRE_TREATMENT_RECIRC_STOPPED_STATE; } @@ -205,8 +220,8 @@ if ( TRUE == recircResumeRequested ) { recircResumeRequested = FALSE; + handlePreTreatmentRecirculateStartState(); state = PRE_TREATMENT_RECIRC_STATE; - setupPreTreatmentRecirculate(); } return state; Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -rd3afa76096a5835e791b1e1b380065c4db3d81a1 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision d3afa76096a5835e791b1e1b380065c4db3d81a1) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -84,8 +84,7 @@ static BOOL noCartSelfTestsResult; ///< Result of no cartridge self-tests. 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 hasPumpsStarted; ///< Flag indicates pumps have started running for self-test. -static BOOL areValvesAndPumpsHomed; ///< Flag indicates valves and pumps have been homed. +static BOOL hasPumpsStarted; ///< Flag indicates if pumps have started running for self-test. static BOOL drySelfTestsResult; ///< Result of dry self-tests. static DRY_SELF_TESTS_STATE_T currentDrySelfTestsState; ///< Current state of the dry self-tests state machine. @@ -103,6 +102,7 @@ static BOOL isValvesSettingSent; ///< Flag indicates valve setting change has been send to DG. static BOOL selfTestsResumeRequested; ///< Flag indicates user requesting self-tests resume. +static BOOL selfTestsStopRequested; ///< Flag indicates alarm requesting to stop self-test. // ********** private function prototypes ********** @@ -112,8 +112,8 @@ static void handleNoCartSelfTestsStopRequest( void ); static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestsWaitForClosedDoor( void ); static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestPumpsState( void ); -static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestLeakDetectorsState( SELF_TEST_STATUS_T *result ); static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestHomeValvesAndPumpState( void ); +static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestLeakDetectorsState( SELF_TEST_STATUS_T *result ); static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestStoppedState( void ); static void handleDrySelfTestsStopRequest( void ); @@ -163,6 +163,19 @@ /*********************************************************************//** * @brief + * The signalStopPrime function signals self-tests to stop when an + * alarm with stop property has been triggered. + * @details Inputs: none + * @details Outputs: primeStopRequested + * @return none + *************************************************************************/ +void signalStopSelfTests( void ) +{ + selfTestsStopRequested = TRUE; +} + +/*********************************************************************//** + * @brief * The resetSelfTestsFlags function resets all self-tests signal flags. * @details Inputs: none * @details Outputs: signal flags set to FALSE @@ -171,6 +184,7 @@ static void resetSelfTestsFlags( void ) { selfTestsResumeRequested = FALSE; + selfTestsStopRequested = FALSE; } /*********************************************************************//** @@ -202,7 +216,6 @@ currentNoCartSelfTestsState = NO_CART_SELF_TESTS_START_STATE; runPumpStartTime = 0; hasPumpsStarted = FALSE; - areValvesAndPumpsHomed = FALSE; resetSelfTestsFlags(); } @@ -283,6 +296,13 @@ currentNoCartSelfTestsState = handleNoCartSelfTestHomeValvesAndPumpState(); break; + case NO_CART_SELF_TESTS_HOME_IDLE_STATE: + if ( ( FALSE == isDialInPumpRunning() ) && ( FALSE == isDialOutPumpRunning() ) && ( FALSE == isBloodPumpRunning() ) ) + { + currentNoCartSelfTestsState = NO_CART_SELF_TESTS_COMPLETE_STATE; + } + break; + case NO_CART_SELF_TESTS_STOPPED_STATE: currentNoCartSelfTestsState = handleNoCartSelfTestStoppedState(); break; @@ -311,19 +331,6 @@ /*********************************************************************//** * @brief - * The getNoCartSelfTestsState function returns the current state of no - * cartridge self-tests sub-mode. - * @details Inputs: currentNoCartSelfTestsState - * @details Outputs: none - * @return current no cartridge self-tests state - *************************************************************************/ -U32 getNoCartSelfTestsState( void ) -{ - return (U32)currentNoCartSelfTestsState; -} - -/*********************************************************************//** - * @brief * The isNoCartSelfTestsPassed function returns the status of no cartridge self-tests. * @details Inputs: none * @details Outputs: none @@ -434,19 +441,6 @@ /*********************************************************************//** * @brief - * The getDrySelfTestsState function returns the current state of dry self-tests sub-mode. - * @details Inputs: currentDrySelfTestsState - * @details Outputs: none - * @return current dry self-tests state - *************************************************************************/ -U32 getDrySelfTestsState( void ) -{ - return (U32)currentDrySelfTestsState; -} - - -/*********************************************************************//** - * @brief * The isDrySelfTestsPassed function returns the status of dry self-tests. * @details Inputs: none * @details Outputs: none @@ -575,11 +569,12 @@ *************************************************************************/ static void handleNoCartSelfTestsStopRequest( void ) { - if ( TRUE == doesAlarmStatusIndicateStop() ) + if ( TRUE == selfTestsStopRequested ) { - currentNoCartSelfTestsState = NO_CART_SELF_TESTS_STOPPED_STATE; - setupForSelfTestsStop(); + + currentNoCartSelfTestsState = NO_CART_SELF_TESTS_STOPPED_STATE; + selfTestsStopRequested = FALSE; } } @@ -644,60 +639,48 @@ /*********************************************************************//** * @brief - * The handleNoCartSelfTestLeakDetectorsState function verify leak detectors status. + * The handleNoCartSelfTestHomeValvesAndPumpState function homes all valves + * and pumps. * @details Inputs: none * @details Outputs: none - * @param result self-test result * @return the next state of no cartridge self-tests state machine *************************************************************************/ -static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestLeakDetectorsState( SELF_TEST_STATUS_T *result ) +static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestHomeValvesAndPumpState( void ) { - NO_CART_SELF_TESTS_STATE_T state = NO_CART_SELF_TESTS_LEAK_DETECTORS_STATE; + VALVE_T valve; - if ( TRUE == getFPGABloodLeakDetectorStatus() ) + for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) { - setFPGASensorTest( BLOOD_LEAK_NORMAL_OPERATION ); - state = NO_CART_SELF_TESTS_BOARD_TEMPERATURE_STATE; + homeValve( valve ); } - else - { - *result = SELF_TEST_STATUS_FAILED; - } - return state; + homeBloodPump(); + homeDialInPump(); + homeDialOutPump(); + + return NO_CART_SELF_TESTS_HOME_IDLE_STATE; } /*********************************************************************//** * @brief - * The handleNoCartSelfTestHomeValvesAndPumpState function homes all valves - * and pumps. + * The handleNoCartSelfTestLeakDetectorsState function verify leak detectors status. * @details Inputs: none * @details Outputs: none + * @param result self-test result * @return the next state of no cartridge self-tests state machine *************************************************************************/ -static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestHomeValvesAndPumpState( void ) +static NO_CART_SELF_TESTS_STATE_T handleNoCartSelfTestLeakDetectorsState( SELF_TEST_STATUS_T *result ) { - NO_CART_SELF_TESTS_STATE_T state = NO_CART_SELF_TESTS_HOME_VALVES_AND_PUMPS_STATE; + NO_CART_SELF_TESTS_STATE_T state = NO_CART_SELF_TESTS_LEAK_DETECTORS_STATE; - if ( FALSE == areValvesAndPumpsHomed ) + if ( TRUE == getFPGABloodLeakDetectorStatus() ) { - VALVE_T valve; - - for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) - { - homeValve( valve ); - } - - homeBloodPump(); - homeDialInPump(); - homeDialOutPump(); - - areValvesAndPumpsHomed = TRUE; + setFPGASensorTest( BLOOD_LEAK_NORMAL_OPERATION ); + state = NO_CART_SELF_TESTS_BOARD_TEMPERATURE_STATE; } - - if ( ( FALSE == isDialInPumpRunning() ) && ( FALSE == isDialOutPumpRunning() ) && ( FALSE == isBloodPumpRunning() ) ) + else { - state = NO_CART_SELF_TESTS_COMPLETE_STATE; + *result = SELF_TEST_STATUS_FAILED; } return state; @@ -734,11 +717,12 @@ *************************************************************************/ static void handleDrySelfTestsStopRequest( void ) { - if ( TRUE == doesAlarmStatusIndicateStop() ) + if ( TRUE == selfTestsStopRequested ) { setupForSelfTestsStop(); currentDrySelfTestsState = DRY_SELF_TESTS_STOPPED_STATE; + selfTestsStopRequested = FALSE; } } @@ -930,11 +914,12 @@ *************************************************************************/ static void handleWetSelfTestsStopRequest( void ) { - if ( TRUE == doesAlarmStatusIndicateStop() ) + if ( TRUE == selfTestsStopRequested ) { setupForSelfTestsStop(); currentWetSelfTestsState = WET_SELF_TESTS_STOPPED_STATE; + selfTestsStopRequested = FALSE; } } @@ -985,7 +970,7 @@ } } -#ifdef SKIP_WET_SELF_TESTS +#ifdef SKIP_SELF_TESTS state = WET_SELF_TESTS_COMPLETE_STATE; #endif Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -rbc8403b288e167f51c9e991c2a07bb455c77c19a -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision bc8403b288e167f51c9e991c2a07bb455c77c19a) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -81,7 +81,8 @@ BOOL noResume; ///< Treatment may not be resumed at this time BOOL noRinseback; ///< Rinseback may not be initiated at this time BOOL noEndTreatment; ///< Ending the treatment is not an option at this time - BOOL noNewTreatment; ///< No new treatments may be started even if current treatment is ended + BOOL noNewTreatment; ///< No new treatments may be started even if current treatment is ended + BOOL noDialRecirc; ///< No dialysate re-circulation allowed at this time BOOL usrACKRequired; ///< The user must acknowledge top alarm BOOL lampOn; ///< The alarm lamp is on } COMP_ALARM_STATUS_T; @@ -238,11 +239,17 @@ SW_FAULT_ID_MODE_PRE_TREATMENT_PRIME_INVALID_STATE, SW_FAULT_ID_SYSTEM_COMM_INVALID_FRAME_SIZE, SW_FAULT_ID_SYSTEM_CMMM_CAN_TRANSMIT_REJECTED, // 95 + SW_FAULT_ID_BLOOD_PRIME_INVALID_STATE, + SW_FAULT_ID_RINSEBACK_INVALID_STATE, + SW_FAULT_ID_TREATMENT_END_INVALID_STATE, + SW_FAULT_ID_TREATMENT_RECIRC_INVALID_STATE, + SW_FAULT_ID_TREATMENT_STOP_INVALID_STATE, // 100 + SW_FAULT_ID_MODE_PRIME_INVALID_ALARM_ACTION, SW_FAULT_ID_HD_INVALID_NO_CARTRIDGE_SELF_TEST_STATE, SW_FAULT_ID_HD_INVALID_DRY_SELF_TEST_STATE, SW_FAULT_ID_HD_INVALID_WET_SELF_TEST_STATE, - SW_FAULT_ID_HD_INVALID_PRE_TREATMENT_RECIRC_STATE, - SW_FAULT_ID_HD_INVALID_COMMAND_RESPONSE_ID, // 100 + SW_FAULT_ID_HD_INVALID_PRE_TREATMENT_RECIRC_STATE, // 105 + SW_FAULT_ID_HD_INVALID_COMMAND_RESPONSE_ID, SW_FAULT_ID_HD_INVALID_RESERVOIR_ID, SW_FAULT_ID_HD_INVALID_VALVE_SETTING_ID, NUM_OF_SW_FAULT_IDS @@ -259,9 +266,12 @@ void clearAlarm( ALARM_ID_T alarm ); void clearAlarmCondition( ALARM_ID_T alarm ); void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); -void signalAlarmSilence( U32 cmd ); +void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ); void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); BOOL isAlarmActive( ALARM_ID_T alarm ); +BOOL isAnyAlarmActive( void ); +BOOL isDialysateRecircBlocked( void ); +BOOL doesAlarmStatusIndicateStop( void ); ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ); BOOL isAlarmRecoverable( ALARM_ID_T alarm ); void setAlarmAudioVolume( U32 volumeLevel ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -27,12 +27,15 @@ #include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" -#include "ModeTreatmentParams.h" -#include "PresOccl.h" +#include "ModeTreatmentParams.h" +#include "OperationModes.h" +#include "PresOccl.h" #include "RTC.h" #include "SafetyShutdown.h" #include "SystemComm.h" -#include "SystemCommMessages.h" +#include "SystemCommMessages.h" +#include "TreatmentEnd.h" +#include "TreatmentRecirc.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -361,8 +364,8 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - +} + /*********************************************************************//** * @brief * The sendChangeBloodDialysateRateChangeResponse function constructs a change @@ -1117,28 +1120,19 @@ * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: treatment state msg constructed and queued - * @param subMode Current state (sub-mode) of treatment - * @param uFState Current state of ultrafiltration - * @param salineBolusState 1=saline bolus in progress, 0=not, 2=max bolus volume reached + * @param payload Record with treatment state data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastTreatmentState( U32 subMode, U32 uFState, U32 salineBolusState ) +BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - TREATMENT_STATE_DATA_T payload; - // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_STATE; msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); - payload.treatmentSubMode = subMode; - payload.uFState = uFState; - payload.salineBolusState = salineBolusState; - payload.heparinState = 0; // TODO - add this later - memcpy( payloadPtr, &payload, sizeof( TREATMENT_STATE_DATA_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -1260,6 +1254,124 @@ /***********************************************************************//** * @brief + * The broadcastTreatmentStopData function constructs a treatment stop data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment stop data msg constructed and queued + * @param timeout treatment stop timeout (in sec) + * @param countdown treatment stop timeout count down (in sec) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastTreatmentStopData( U32 timeout, U32 countdown ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_STOP_TIMER_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &countdown, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastRinsebackData function constructs a rinseback data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: rinseback data msg constructed and queued + * @param data rinseback data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RINSEBACK_PROGRESS; + msg.hdr.payloadLen = sizeof( RINSEBACK_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( RINSEBACK_DATA_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastRecircData function constructs a treatment re-circ data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment re-circ data msg constructed and queued + * @param timeout re-circulation timeout (in sec) + * @param countdown re-circulation timeout count down (in sec) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastRecircData( U32 timeout, U32 countdown ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_PROGRESS; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &timeout, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &countdown, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastBloodPrimeData function constructs a blood prime data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: blood prime data msg constructed and queued + * @param data blood prime data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_BLOOD_PRIME_PROGRESS; + msg.hdr.payloadLen = sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief * The broadcastAirTrapData function constructs an HD air trap data msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -1445,7 +1557,7 @@ memcpy( &cmd, payloadPtr, sizeof( U32 ) ); - signalAlarmSilence( cmd ); + signalAlarmSilence( (ALARM_SILENCE_CMD_T)cmd ); } else { @@ -1984,7 +2096,7 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } } - + /*********************************************************************//** * @brief * The handleChangeBloodDialysateRateChangeRequest function handles a blood @@ -2103,7 +2215,177 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The handlRinsebackCmd function handles a rinseback user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handlRinsebackCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalRinsebackUserAction( (REQUESTED_RINSEBACK_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendRinsebackCmdResponse function constructs a rinseback user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Rinseback command response msg constructed and queued. + * @param accepted T/F - was rinseback user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRinsebackCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RINSEBACK_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleTreatmentRecircCmd function handles a treatment re-circ user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentRecircCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentRecircUserAction( (REQUESTED_TREATMENT_RECIRC_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentRecircCmdResponse function constructs a treatment re-circulation + * user action response to the UI and queues the msg for transmit on the appropriate + * CAN channel. + * @details Inputs: none + * @details Outputs: Treatment re-circ command response msg constructed and queued. + * @param accepted T/F - was re-circ user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentRecircCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } + +/*********************************************************************//** + * @brief + * The handleTreatmentEndCmd function handles a treatment end user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentEndCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentEndUserAction( (REQUESTED_TREATMENT_END_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentEndCmdResponse function constructs a treatment end + * user action response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment end command response msg constructed and queued. + * @param accepted T/F - was user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentEndCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TX_END_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} /*********************************************************************//** * @brief @@ -3459,6 +3741,31 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestTreatmentTimeRemainingOverrideRequest function handles a treatment + * time remaining override request message. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentTimeRemainingOverrideRequest( MESSAGE_T *message ) +{ + U32 payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(U32) ); + result = testSetTreatmentTimeRemainingOverride( payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestHDSafetyShutdownOverrideRequest function handles a @@ -3589,84 +3896,6 @@ /*********************************************************************//** * @brief - * The handleSetAccelCalibration function handles a request to set - * accelerometer calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetAccelCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) - { - ACCEL_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); - result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleSetBloodFlowCalibration function handles a request to set - * blood flow calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetBloodFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); - result = setBloodFlowCalibration( payload.gain, payload.offset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleSetDialysateFlowCalibration function handles a request to set - * dialysate flow calibration factors. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetDialysateFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); - result = setDialInFlowCalibration( payload.gain, payload.offset ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleTestSetTreatmentParameter function handles a request to set * a specific treatment parameter value. * @details Inputs: none @@ -3941,9 +4170,8 @@ * @brief * The handleTestBloodPumpHomeRequest function handles a request to home * the blood pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3964,9 +4192,8 @@ * @brief * The handleTestDialInPumpHomeRequest function handles a request to home * the dialysate inlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3987,9 +4214,8 @@ * @brief * The handleTestDialOutPumpHomeRequest function handles a request to home * the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -4010,9 +4236,8 @@ * @brief * The handleTestSuperClearAlarmsRequest function handles a request to clear * all active alarms. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -4026,8 +4251,31 @@ memcpy( &key, message->payload, sizeof(U32) ); result = testClearAllAlarms( key ); + } - result = TRUE; + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSetOpModeRequest function handles a request to set the + * HD operation mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetOpModeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 mode; + + memcpy( &mode, message->payload, sizeof(U32) ); + result = testSetOperationMode( (HD_OP_MODE_T)mode ); } // Respond to request Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r981de1f5228152ec6877aceae3d66ebf5efc7101 -r27f3db92495948d4c1192421c1b0c20338c4a034 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) @@ -21,6 +21,7 @@ #include "HDCommon.h" #include "AirTrap.h" #include "BloodFlow.h" +#include "BloodPrime.h" #include "DGInterface.h" #include "DialInFlow.h" #include "DialOutFlow.h" @@ -30,6 +31,7 @@ #include "MsgQueues.h" #include "NVDataMgmt.h" #include "PresOccl.h" +#include "Rinseback.h" #include "Valves.h" /** @@ -136,9 +138,12 @@ // MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ); +// MSG_ID_TREATMENT_TIME_REMAINING_OVERRIDE: +void handleTestTreatmentTimeRemainingOverrideRequest( MESSAGE_T *message ); + // MSG_ID_TREATMENT_PARAM_CHANGE_RANGES BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ); - + // MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ); @@ -157,6 +162,24 @@ // MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE BOOL sendPressureLimitsChangeResponse( PRESSURE_LIMIT_CHANGE_RESPONSE_T *data ); +// MSG_ID_UI_RINSEBACK_CMD +void handlRinsebackCmd( MESSAGE_T *message ); + +// MSG_ID_HD_RINSEBACK_CMD_RESPONSE +BOOL sendRinsebackCmdResponse( BOOL accepted, U32 rejReason ); + +// MSG_ID_UI_RECIRC_CMD +void handleTreatmentRecircCmd( MESSAGE_T *message ); + +// MSG_ID_HD_RECIRC_CMD_RESPONSE +BOOL sendTreatmentRecircCmdResponse( BOOL accepted, U32 rejReason ); + +// MSG_ID_UI_TX_END_CMD: +void handleTreatmentEndCmd( MESSAGE_T *message ); + +// MSG_ID_HD_RECIRC_CMD_RESPONSE +BOOL sendTreatmentEndCmdResponse( BOOL accepted, U32 rejReason ); + // MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS BOOL sendDialysateTempTargetsToDG( F32 primary, F32 trimmer ); @@ -224,7 +247,7 @@ BOOL broadcastTreatmentTime( U32 secsTotTreatment, U32 secsElapsed, U32 secsRemaining ); // MSG_ID_TREATMENT_STATE -BOOL broadcastTreatmentState( U32 subMode, U32 uFState, U32 salineBolusState ); +BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ); // MSG_ID_POWER_OFF_WARNING BOOL broadcastPowerOffWarning( void ); @@ -238,6 +261,18 @@ // MSG_ID_SALINE_BOLUS_DATA BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ); +// MSG_ID_HD_TREATMENT_STOP_TIMER_DATA +BOOL broadcastTreatmentStopData( U32 timeout, U32 countdown ); + +// MSG_ID_HD_RINSEBACK_PROGRESS +BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ); + +// MSG_ID_HD_RECIRC_PROGRESS +BOOL broadcastRecircData( U32 timeout, U32 countdown ); + +// MSG_ID_HD_BLOOD_PRIME_PROGRESS +BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data ); + // MSG_ID_HD_AIR_TRAP_DATA BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ); @@ -389,15 +424,6 @@ // MSG_ID_HD_ACCEL_SEND_INTERVAL_OVERRIDE: void handleTestHDAccelBroadcastIntervalOverrideRequest( MESSAGE_T *message ); -// MSG_ID_HD_ACCEL_SET_CALIBRATION: -void handleSetAccelCalibration( MESSAGE_T *message ); - -// MSG_ID_HD_BLOOD_FLOW_SET_CALIBRATION: -void handleSetBloodFlowCalibration( MESSAGE_T *message ); - -// MSG_ID_HD_DIALYSATE_FLOW_SET_CALIBRATION: -void handleSetDialysateFlowCalibration( MESSAGE_T *message ); - // MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER void handleTestSetTreatmentParameter( MESSAGE_T *message ); @@ -442,12 +468,9 @@ // MSG_ID_SUPER_CLEAR_ALARMS_CMD void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ); -// MSG_ID_HD_REQUEST_CALIBRATION_DATA -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ); +// MSG_ID_HD_SET_OP_MODE_REQUEST +void handleTestSetOpModeRequest( MESSAGE_T *message ); -// MSG_ID_HD_ERASE_CALIBRATION_DATA -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ); - /**@}*/ #endif