Index: firmware/App/Controllers/HemoDiaFiltration.c =================================================================== diff -u -rfc697848283d289571f9d365b28acf44beb0883e -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Controllers/HemoDiaFiltration.c (.../HemoDiaFiltration.c) (revision fc697848283d289571f9d365b28acf44beb0883e) +++ firmware/App/Controllers/HemoDiaFiltration.c (.../HemoDiaFiltration.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -15,15 +15,15 @@ * ***************************************************************************/ -#include "PIControllers.h" -#include "Pressures.h" +#include "BloodFlow.h" +#include "DDInterface.h" +#include "HemoDiaFiltration.h" #include "Messaging.h" #include "OperationModes.h" +#include "PIDControllers.h" +#include "Pressures.h" #include "TaskGeneral.h" #include "TestSupport.h" -#include "DDInterface.h" -#include "BloodFlow.h" -#include "HemoDiaFiltration.h" /** * @addtogroup Hemodiafiltration @@ -32,21 +32,15 @@ // ********** private definitions ********** -#define HDF_DATA_PUBLISH_INTERVAL ( 1000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the hemodiafiltration data published. -#define SECONDS_PER_MINUTE 60 ///< seconds per minute -#define HDF_CONTROL_PERIOD_SECONDS 2 ///< Interval at which the hemodiafiltration flow rate adjustment is executed in seconds -#define HDF_CONTROL_PERIOD_MS ( HDF_CONTROL_PERIOD_SECONDS * MS_PER_SECOND ) ///< Interval at which the hemodiafiltration flow rate adjustment is executed in milliseconds +#define HDF_DATA_PUBLISH_INTERVAL ( 1000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the hemodiafiltration data published. +#define SECONDS_PER_MINUTE 60 ///< seconds per minute +#define HDF_CONTROL_PERIOD_SECONDS 2 ///< Interval at which the hemodiafiltration flow rate adjustment is executed in seconds +#define HDF_CONTROL_PERIOD_MS ( HDF_CONTROL_PERIOD_SECONDS * MS_PER_SECOND ) ///< Interval at which the hemodiafiltration flow rate adjustment is executed in milliseconds #define HDF_CONTROL_INTERVAL ( HDF_CONTROL_PERIOD_MS / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the peroidic hemodiafiltration flow rate is calculated. #define ZERO_RATE 0.0F ///< Zero value. #define SUB_PUMP_PRESSURE_CONTROL_P_COEFFICIENT 0.5F ///< P term for Sub pump pressure control. #define SUB_PUMP_PRESSURE_CONTROL_I_COEFFICIENT 5.0F ///< I term for Sub pump pressure control. -// Parameters that will be set in some other place , set here for testing -#define HDF_MAX_FILTRATION_FRACTION 0.35F ///< HDF maximum filtration fraction (Qs+Quf)/Qb -#define HDF_MAX_TMP 400.0F ///< HDF maximum TMP - trans-membrane pressure = (Pb - Pd) -#define HDF_MAX_RATE 200.0F ///< Maximum substitution flow rate - - // ********** private data ********** static HDF_EXEC_STATE_T hdfExecState; ///< Current hemodiafiltration executive state. @@ -62,8 +56,6 @@ static BOOL isHDFRateUpdated; ///< flag indicating to update HDF rate needed. static BOOL reachedMaximumHDFVolume; ///< flag indicating that the current HDF volume has reached the maximum volume. static F32 hdfMaxFiltrationFraction; ///< Current HDF maximum filtration fraction. -static F32 hdfMaxTMP; ///< Current HDF maximum TMP in mmHg. -static F32 hdfMaxRate; ///< Current HDF maximum flow rate in ml/min. static OVERRIDE_U32_T hdfDataPublishInterval; ///< Hemodiafiltration data publish interval. // ********** private function prototypes ********** @@ -84,7 +76,7 @@ void initHemodiafiltration( void ) { // Initialize substitution pump PI controller to target pressure - initializePIController( PI_CONTROLLER_ID_SUB_PUMP_PRES, ZERO_RATE, SUB_PUMP_PRESSURE_CONTROL_P_COEFFICIENT, SUB_PUMP_PRESSURE_CONTROL_I_COEFFICIENT, + initializePIDController( PID_CONTROLLER_ID_SUB_PUMP_PRES, ZERO_RATE, SUB_PUMP_PRESSURE_CONTROL_P_COEFFICIENT, SUB_PUMP_PRESSURE_CONTROL_I_COEFFICIENT, 0.0F, ZERO_RATE, HDF_MAX_RATE, FALSE, 0 ); hdfExecState = TD_HDF_PAUSED; @@ -102,8 +94,6 @@ hdfCurrentVolume = 0.0; reachedMaximumHDFVolume = FALSE; hdfMaxFiltrationFraction = HDF_MAX_FILTRATION_FRACTION; - hdfMaxTMP = HDF_MAX_TMP; - hdfMaxRate = HDF_MAX_RATE; hdfDataPublicationTimerCounter = 0; isHDFRateUpdated = FALSE; } @@ -178,21 +168,23 @@ if ( FALSE == reachedMaximumHDFVolume && TRUE == isHemodiafiltrationRequested ) { + // manual rate set, use that as the proposed rate if ( hdfManualRate > ZERO_RATE ) - { // manual rate set, use that as the proposed rate + { hdfCurrentRate = CheckHDFRate( hdfManualRate ); - } - else - { // TMP control, resume with previous HDF rate - // TODO: make sure that hdfCurrentRate is not 0 if HDF is actually wanted (volume not > max) - hdfCurrentRate = CheckHDFRate( hdfCurrentRate ); - if ( hdfCurrentRate > ZERO_RATE ) - { - resetPIController( PI_CONTROLLER_ID_SUB_PUMP_PRES, hdfCurrentRate, 0.0F ); + } + else + { + // TMP control, resume with previous HDF rate + // TODO: make sure that hdfCurrentRate is not 0 if HDF is actually wanted (volume not > max) + hdfCurrentRate = CheckHDFRate( hdfCurrentRate ); + if ( hdfCurrentRate > ZERO_RATE ) + { + resetPIDController( PID_CONTROLLER_ID_SUB_PUMP_PRES, hdfCurrentRate, 0.0F ); hdfControlTimerCounter = 0; - } - } - isHDFRateUpdated = TRUE; + } + } + isHDFRateUpdated = TRUE; //Transition to run state state = TD_HDF_RUNNING; } @@ -210,7 +202,7 @@ *************************************************************************/ static HDF_EXEC_STATE_T handleHDFRunningState( void ) { - HDF_EXEC_STATE_T state = DD_HDF_RUNNING; + HDF_EXEC_STATE_T state = TD_HDF_RUNNING; if ( TRUE != isHemodiafiltrationRequested ) { @@ -229,19 +221,33 @@ * @brief * The setHemodiafiltrationParameters function sets the the hemodiafiltration requested * parameters for this treatment. - * @details \b Inputs: setHDFTMPTarget, setHDFManualRate, setHDFMaximumVolume - * @details \b Outputs: local variables set: hdfTMPTarget, hdfManualRate, setHDFMaximumVolume + * @details \b Inputs: setHDFTMPTarget, setHDFMaximumVolume + * @details \b Outputs: local variables set: hdfTMPTarget, setHDFMaximumVolume * @return none. *************************************************************************/ -void setHemodiafiltrationParameters( F32 setHDFTMPTarget, F32 setHDFManualRate, F32 setHDFMaximumVolume) +void setHemodiafiltrationParameters( F32 setHDFTMPTarget, F32 setHDFMaximumVolume ) { hdfTMPTarget = setHDFTMPTarget; // mmHg - hdfManualRate = setHDFManualRate; // ml/min hdfMaximumVolume = setHDFMaximumVolume; // ml + } /*********************************************************************//** * @brief + * The setHemoDiafiltrationManualRate function sets the the hemodiafiltration open + * loop rate for this treatment. + * @details \b Inputs: setHDFManualRate + * @details \b Outputs: local variables set: hdfManualRate + * @return none. + *************************************************************************/ +void setHemoDiafiltrationManualRate( F32 setHDFManualRate ) +{ + hdfManualRate = setHDFManualRate; + +} + +/*********************************************************************//** + * @brief * The StartHemodiafiltration function starts or resumes hemodiafiltration flow * @details \b Inputs: None * @details \b Outputs: Hemodiafiltration is running @@ -305,22 +311,25 @@ static void UpdateHDFRateAndVolume( void ) { + F32 new_rate = 0.0F; + if ( ( ++hdfControlTimerCounter >= HDF_CONTROL_INTERVAL ) ) { // get new rate from PI controller if ( ZERO_RATE == hdfManualRate ) - { - F32 new_rate = runPIController( PI_CONTROLLER_ID_SUB_PUMP_PRES, hdfTMP_target, getLongFilteredTMPPressure() ); - hdfCurrentRate = CheckHDFRate( new_rate ); - } + { + new_rate = runPIDController( PID_CONTROLLER_ID_SUB_PUMP_PRES, hdfTMPTarget, getLongFilteredTMPPressure() ); + hdfCurrentRate = CheckHDFRate( new_rate ); + } // update and check volume - hdfCurrentvolume += ((F32) HDF_CONTROL_PERIOD_SECONDS / (F32) SECONDS_PER_MINUTE) * hdfCurrentRate; //ml - if ( currentHDFvolume > hdfMaximumVolume ) + hdfCurrentVolume += ((F32) HDF_CONTROL_PERIOD_SECONDS / (F32) SECONDS_PER_MINUTE) * hdfCurrentRate; //ml + + if ( hdfCurrentVolume > hdfMaximumVolume ) { reachedMaximumHDFVolume = TRUE; - // Done delivering HDF, turn off pump and go to pause state - hdfCurrentRate = ZERO_RATE; - hdfExecState = TD_HDF_PAUSED; + // Done delivering HDF, turn off pump and go to pause state + hdfCurrentRate = ZERO_RATE; + hdfExecState = TD_HDF_PAUSED; } hdfControlTimerCounter = 0; isHDFRateUpdated = TRUE; //Some rate updates could be avoided by checking new rate against old rate @@ -342,6 +351,19 @@ /*********************************************************************//** * @brief + * The getCurrentHDFRate function returns the current rate + * of the hemodiafiltration. + * @details \b Inputs: hdfCurrentRate + * @details \b Outputs: none + * @return the current state of HDF rate. + *************************************************************************/ +F32 getCurrentHDFRate( void ) +{ + return hdfCurrentRate; +} + +/*********************************************************************//** + * @brief * The publishHemodiafiltrationData function broadcasts the hemodiafiltration * data at defined interval. * @details \b Inputs: hdfDataPublicationTimerCounter @@ -364,7 +386,7 @@ data.isHDFRequested = (U32)isHemodiafiltrationRequested; data.hdfRequestedVolume = hdfMaximumVolume; data.hdfTotalVolume = hdfCurrentVolume; - broadcastData( MSG_ID_TD_HDF_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( HDF_DATA_T ) ); + broadcastData( MSG_ID_TD_HEMODIAFILTRATION_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( HDF_DATA_T ) ); hdfDataPublicationTimerCounter = 0; } @@ -385,12 +407,36 @@ * (in ms) to override the TD hemodiafiltration data publish interval to. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testDDHDFDataPublishIntervalOverride( MESSAGE_T *message ) +BOOL testTDHDFDataPublishIntervalOverride( MESSAGE_T *message ) { BOOL result = u32BroadcastIntervalOverride( message, &hdfDataPublishInterval, TASK_GENERAL_INTERVAL ); return result; } +BOOL testTDHDFStartStopHDFOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + HDF_START_PAYLOAD_T payload; + // If testing is activated and payload size is valid + if ( ( TRUE == isTestingActivated() ) && ( message->hdr.payloadLen == sizeof(HDF_START_PAYLOAD_T) ) ) + { + memcpy( &payload, message->payload, sizeof(HDF_START_PAYLOAD_T) ); + + setHemodiafiltrationParameters( payload.hdfTMPTgt, payload.hdfVolume ); + setHemoDiafiltrationManualRate( payload.hdfRate ); + + if( TRUE == payload.hdfStart ) + { + StartHemodiafiltration(); + } + else + { + StopHemodiafiltration(); + } + result = TRUE; + } + return result; +} /**@}*/ Index: firmware/App/Controllers/HemoDiaFiltration.h =================================================================== diff -u -rfc697848283d289571f9d365b28acf44beb0883e -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Controllers/HemoDiaFiltration.h (.../HemoDiaFiltration.h) (revision fc697848283d289571f9d365b28acf44beb0883e) +++ firmware/App/Controllers/HemoDiaFiltration.h (.../HemoDiaFiltration.h) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -31,31 +31,53 @@ // ********** public definitions ********** +#define HDF_MAX_FILTRATION_FRACTION 0.35F ///< HDF maximum filtration fraction (Qs+Quf)/Qb +#define HDF_MAX_TMP 400.0F ///< HDF maximum TMP - trans-membrane pressure = (Pb - Pd) +#define HDF_MAX_RATE 200.0F ///< Maximum substitution flow rate + +/// hemodiafiltration states +typedef enum +{ + TD_HDF_PAUSED, ///< HDF Paused + TD_HDF_RUNNING, ///< HDF Running + NUM_OF_TD_HDF_STATES, +} HDF_EXEC_STATE_T; + /// hemodiafiltration data structure typedef struct { - U32 hdfExecState; ///< Hemodiafiltration execution state - F32 hdfRequestedRate; ///< Hemodiafiltration requested manual rate - F32 hdfTargetTMP; ///< Hemodiafiltration requested target TMP - F32 hdfCurrentRate; ///< Hemodiafiltration current set rate - F32 hdfCurrentTMP; ///< Hemodiafiltration current TMP (trans-membrane pressure) - F32 hdfRequestedVolume; ///< Hemodiafiltration requested maximum volume - F32 hdfTotalVolume; ///< Hemodiafiltration total volume delivered - U32 isHDFRequested; ///< Hemodiafiltration run or pause request + U32 hdfExecState; ///< Hemodiafiltration execution state + F32 hdfRequestedRate; ///< Hemodiafiltration requested manual rate + F32 hdfTargetTMP; ///< Hemodiafiltration requested target TMP + F32 hdfCurrentRate; ///< Hemodiafiltration current set rate + F32 hdfCurrentTMP; ///< Hemodiafiltration current TMP (trans-membrane pressure) + F32 hdfRequestedVolume; ///< Hemodiafiltration requested maximum volume + F32 hdfTotalVolume; ///< Hemodiafiltration total volume delivered + U32 isHDFRequested; ///< Hemodiafiltration run or pause request } HDF_DATA_T; +typedef struct +{ + U32 hdfStart; ///< HDF start stop boolean. + F32 hdfTMPTgt; ///< HDF target pressure to control. + F32 hdfVolume; ///< HDF Target volume. + F32 hdfRate; ///< HDF open loop rate. +} HDF_START_PAYLOAD_T; + // ********** public function prototypes ********** -void initHemodiafiltration( void ); // Initialize hemodiafiltration unit -void transitionToHemodiafiltration( void ); // Prepares for transition to hemodiafiltration execution -U32 execHDFControl( void ); // Execute the hemodiafiltration state machine -HDF_EXEC_STATE_T getCurrentHDFExecState( void ); // Get the current state of the hemodifiltration execution +void initHemodiafiltration( void ); // Initialize hemodiafiltration unit +void transitionToHemodiafiltration( void ); // Prepares for transition to hemodiafiltration execution +U32 execHDFControl( void ); // Execute the hemodiafiltration state machine +HDF_EXEC_STATE_T getCurrentHDFExecState( void ); // Get the current state of the hemodifiltration execution +F32 getCurrentHDFRate( void ); -BOOL testTDHDFDataPublishIntervalOverride( MESSAGE_T *message ); // To override the HDF data publish interval -void setHemodiafiltrationParameters( F32 setHDFTMPTarget, F32 setHDFManualRate, F32 setHDFMaximumVolume); +void setHemodiafiltrationParameters( F32 setHDFTMPTarget, F32 setHDFMaximumVolume); +void setHemoDiafiltrationManualRate( F32 setHDFManualRate ); void StartHemodiafiltration( void ); void StopHemodiafiltration( void ); +BOOL testTDHDFDataPublishIntervalOverride( MESSAGE_T *message ); // To override the HDF data publish interval /**@}*/ #endif Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r2f282113c1540be57b9d00833224d7ce93d460cd -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 2f282113c1540be57b9d00833224d7ce93d460cd) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -18,6 +18,7 @@ #include "BloodFlow.h" #include "Buttons.h" #include "DDInterface.h" +#include "HemoDiaFiltration.h" #include "ModePreTreat.h" #include "OperationModes.h" #include "StatePreTxRecirculate.h" @@ -334,7 +335,7 @@ presUFVolumeL = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ); presUFRateMlMin = ( presUFVolumeL * (F32)ML_PER_LITER ) / (F32)getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); // Direct DD to generate dialysate and bypass while priming blood - cmdStartGenerateDialysate( (F32)getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presUFRateMlMin, + cmdStartGenerateDialysate( (F32)getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presUFRateMlMin, 0.0, getTreatmentParameterF32( TREATMENT_PARAM_DIALYSATE_TEMPERATURE ), TRUE, getTreatmentParameterF32( TREATMENT_PARAM_ACID_CONCENTRATE_CONV_FACTOR ), bicarbConvFactor, Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -21,6 +21,7 @@ #include "Buttons.h" #include "DDInterface.h" #include "FluidBolus.h" +#include "HemoDiaFiltration.h" #include "Messaging.h" #include "ModeService.h" #include "ModeTreatment.h" @@ -209,7 +210,7 @@ bicarbConvFactor = BICARBONATE_CONVERSION_FACTOR; // Direct DD to generate dialysate and bypass while priming blood - cmdStartGenerateDialysate( (F32)getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presUFRateMlMin, + cmdStartGenerateDialysate( (F32)getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presUFRateMlMin, HDF_MAX_RATE, getTreatmentParameterF32( TREATMENT_PARAM_DIALYSATE_TEMPERATURE ), TRUE, getTreatmentParameterF32( TREATMENT_PARAM_ACID_CONCENTRATE_CONV_FACTOR ), bicarbConvFactor, Index: firmware/App/Modes/StateTxDialysis.c =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Modes/StateTxDialysis.c (.../StateTxDialysis.c) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Modes/StateTxDialysis.c (.../StateTxDialysis.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -20,6 +20,7 @@ #include "BloodFlow.h" #include "Buttons.h" #include "DDInterface.h" +#include "HemoDiaFiltration.h" #include "FluidBolus.h" #include "Messaging.h" #include "ModeTreatment.h" @@ -112,6 +113,7 @@ F32 bicarbConvFactor = BICARBONATE_CONVERSION_FACTOR; U32 sodium = getTreatmentParameterU32( TREATMENT_PARAM_SODIUM ); U32 bicarbonate = getTreatmentParameterU32( TREATMENT_PARAM_BICARBONATE ); + F32 hdfRate = getCurrentHDFRate(); doorClosedRequired( TRUE ); @@ -121,10 +123,15 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); // Set actuators as appropriate for state - cmdStartGenerateDialysate( setDialysateFlowRate, setUFRateMlMin, dialTemp, FALSE, - acidConvFactor, bicarbConvFactor, sodium, bicarbonate ); + cmdStartGenerateDialysate( setDialysateFlowRate, setUFRateMlMin, hdfRate, dialTemp, FALSE, + acidConvFactor, bicarbConvFactor, sodium, bicarbonate ); transitionToDialysisState( currentDialysisState ); + if ( hdfRate > 0.0F ) + { + StartHemodiafiltration(); + } + // Set substate for event setCurrentSubState( (U32)currentDialysisState ); } Index: firmware/App/Modes/StateTxPaused.c =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -21,6 +21,7 @@ #include "Common.h" #include "DDInterface.h" #include "FluidBolus.h" +#include "HemoDiaFiltration.h" #include "Messaging.h" #include "ModeTreatment.h" //#include "NVDataMgmt.h" @@ -97,7 +98,7 @@ void transitionToTreatmentPaused( void ) { initTreatmentPaused(); - + StopHemodiafiltration(); setCurrentSubState( (U32)currentTxPausedState ); setCurrent4thLevelState( NO_SUB_STATE ); // Set user alarm recovery actions allowed in this sub-mode Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r2f282113c1540be57b9d00833224d7ce93d460cd -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 2f282113c1540be57b9d00833224d7ce93d460cd) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -197,6 +197,7 @@ SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE = 166, SW_FAULT_ID_INVALID_FLUID_BOLUS_STATE = 167, SW_FAULT_ID_PRE_TX_RECIRC_INVALID_STATE = 168, + SW_FAULT_ID_HDF_INVALID_EXEC_STATE = 169, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -rfc697848283d289571f9d365b28acf44beb0883e -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision fc697848283d289571f9d365b28acf44beb0883e) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -114,7 +114,6 @@ dialysateDeliveryCmdSet.start = FALSE; dialysateDeliveryCmdSet.dialRate = 0.0F; dialysateDeliveryCmdSet.ufRate = 0.0F; - dialysateDeliveryCmdSet.hdfRate = 0.0F; dialysateDeliveryCmdSet.dialTemp = 0.0F; dialysateDeliveryCmdSet.bypassDialyzer = TRUE; dialysateDeliveryCmdSet.acidConvFactor = 0.0F; @@ -383,7 +382,7 @@ * @details \b Message \b Sent: Start/continue generate dialysate command. * @param qd Target dialysate flow rate (Qd). * @param quf Target ultrafiltration rate (Quf) (in mL/min). - * @param qhdf Hemodiafiltration rate (Qhdf) (in mL/min). + * @param qsub Hemodiafiltration rate (QSub) (in mL/min). * @param dialTemp Target dialysate temperature in deg C. * @param bypass Flag indicating whether dialyzer should be bypassed. * @param acidConvFactor Conversion factor for the acid used. @@ -392,19 +391,18 @@ * @param bicarbonate Level of bicarbonate used in mEq/L. * @return none *************************************************************************/ -void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 qhdf, F32 dialTemp, BOOL bypass, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ) +void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 qsub, F32 dialTemp, BOOL bypass, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ) { dialysateDeliveryCmdSet.start = TRUE; dialysateDeliveryCmdSet.dialRate = qd; dialysateDeliveryCmdSet.ufRate = quf; - dialysateDeliveryCmdSet.hdfRate = qhdf; dialysateDeliveryCmdSet.dialTemp = dialTemp; dialysateDeliveryCmdSet.bypassDialyzer = bypass; dialysateDeliveryCmdSet.acidConvFactor = acidConvFactor; dialysateDeliveryCmdSet.bicarbConvFactor = bicarbConvFactor; dialysateDeliveryCmdSet.sodium = sodium; dialysateDeliveryCmdSet.bicarbonate = bicarbonate; - dialysateDeliveryCmdSet.substitutionRate = 0.0F; + dialysateDeliveryCmdSet.substitutionRate = qsub; #ifndef TEST_UI_ONLY sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); @@ -476,7 +474,7 @@ { if ( TRUE == dialysateDeliveryCmdSet.start ) { - dialysateDeliveryCmdSet.hdfRate = qhdf; + dialysateDeliveryCmdSet.substitutionRate = qhdf; #ifndef TEST_UI_ONLY sendMessage( MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&dialysateDeliveryCmdSet), sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); #endif @@ -653,7 +651,19 @@ } } +/*********************************************************************//** + * @brief + * The getTDUFRate function gets the last set UF rate. + * @details \b Inputs: dialysateDeliveryCmdSet.ufRate + * @details \b Outputs: none + * @return Latest uf rate. + *************************************************************************/ +F32 getTDUFRate( void ) +{ + return dialysateDeliveryCmdSet.ufRate; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/DDInterface.h =================================================================== diff -u -rfc697848283d289571f9d365b28acf44beb0883e -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision fc697848283d289571f9d365b28acf44beb0883e) +++ firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -52,16 +52,17 @@ U32 getDDSubMode( void ); F32 getDialysatePressure( void ); BOOL getDialysateGoodToDeliverStatus( void ); +F32 getTDUFRate( void ); BOOL setDDOpMode( MESSAGE_T *message ); BOOL setDialysateData( MESSAGE_T *message ); BOOL setDialysatePressure( MESSAGE_T *message ); void cmdStartPreGenerateDialysate( F32 qd, F32 dialTemp, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ); -void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 qhdf, F32 dialTemp, BOOL bypass, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ); +void cmdStartGenerateDialysate( F32 qd, F32 quf, F32 qsub, F32 dialTemp, BOOL bypass, F32 acidConvFactor, F32 bicarbConvFactor, U32 sodium, U32 bicarbonate ); void cmdChangeQd( F32 qd ); void cmdChangeQuf( F32 quf ); -void cmdChangeQhdf( F32 qhdf ); +void cmdChangeQhdf( F32 qsub ); void cmdBypassDialyzer( BOOL bypass ); void cmdStopGenerateDialysate( void ); void cmdSubstitutionRate (F32 qs ); Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -rfff7eb3560421130e0cd4788f84bce0a8ee7ff44 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision fff7eb3560421130e0cd4788f84bce0a8ee7ff44) @@ -19,6 +19,7 @@ #include "AirTrap.h" #include "BloodFlow.h" #include "Ejector.h" +#include "HemoDiaFiltration.h" #include "Messaging.h" #include "OperationModes.h" #include "Pressures.h" @@ -119,6 +120,9 @@ // Control Air Pump execAirPumpController(); + // Control HDF + execHDFControl(); + // Monitor/Control fan // execFan();