Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rbb144484d4d22e3f24a280eda9c8abf9570a443a -r42b82bcd2bb2c2fa07349108e6b2bd9995173fa4 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision bb144484d4d22e3f24a280eda9c8abf9570a443a) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 42b82bcd2bb2c2fa07349108e6b2bd9995173fa4) @@ -203,12 +203,13 @@ static OVERRIDE_F32_T syringePumpMeasHome = { 0.0, 0.0, 0.0, 0 }; ///< Measured optical home (in V). static OVERRIDE_S32_T syringePumpPosition = { 0, 0, 0, 0 }; ///< Encoder based position (in steps). static OVERRIDE_F32_T syringePumpVolumeDelivered = { 0.0, 0.0, 0.0, 0 }; ///< Measured volume delivered (in mL). -static OVERRIDE_F32_T heparinBolusTargetRate = { HEPARIN_BOLUS_TARGET_RATE, 0.0, HEPARIN_BOLUS_TARGET_RATE, 0 }; ///< Target rate of the heprin bolus in mL/hour +static OVERRIDE_F32_T heparinBolusTargetRate = { HEPARIN_BOLUS_TARGET_RATE, 0.0, HEPARIN_BOLUS_TARGET_RATE, 0 }; ///< Target rate of the heparin bolus in mL/hour static OVERRIDE_U32_T syringePumpStatus = {0, 0, 0, 0}; ///< Syringe pump status reported by FPGA. static OVERRIDE_U32_T syringePumpEncoderStatus = {0, 0, 0, 0}; ///< Syringe pump encoder status reported by FPGA. static OVERRIDE_U32_T syringePumpADCandDACStatus = {0, 0, 0, 0}; ///< Syringe pump ADC and DAC status reported by FPGA. static OVERRIDE_U32_T syringePumpADCReadCtr = {0, 0, 0, 0}; ///< Syringe pump ADC read counter reported by FPGA. +static OVERRIDE_F32_T syringePumpDACVref = { 0.0, 0.0, 0.0, 0 };; ///< DAC Vref setting for force sensor. static BOOL requireSyringeDetection; ///< Flag indicating whether syringe detection is required in the current state. static BOOL prevSyringeDetected; ///< Flag saving last state of syringe detection @@ -247,8 +248,8 @@ static U32 syringePumpStateStartTime; ///< Time current syringe pump state started. static BOOL syringePumpDACVrefWriteInProgress; ///< Flag indicates DAC Vref write is in progress. -static F32 syringePumpDACVref; ///< DAC Vref setting for force sensor. + static U32 syringePumpStallCtr; ///< Counts time when position is not changing during ramp. static U32 syringePumpStallRetryCount; ///< Counts pump ramp up stall retries. static TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T forceSensorCalRecord; ///< TD heparin force sensor calibration record. @@ -276,7 +277,7 @@ static F32 getSyringePumpSyringeDetectorV( void ); static F32 getSyringePumpHomeDetectorV( void ); static F32 getSyringePumpForceV( void ); -static F32 getHeprinBolusTargetRate( void ); +static F32 getHeparinBolusTargetRate( void ); static U08 getSyringePumpStatus( void ); static U08 getSyringePumpEncoderStatus( void ); static U08 getSyringePumpADCReadCounter( void ); @@ -802,7 +803,7 @@ // if user set a Heparin bolus volume and not complete, start now if ( ( bolusVol > 0.0F ) && ( getSyringePumpVolumeDelivered() < bolusVol ) ) { - syringePumpSetRate = getHeprinBolusTargetRate(); + syringePumpSetRate = getHeparinBolusTargetRate(); syringePumpBolusRequested = TRUE; } } @@ -876,7 +877,7 @@ { // Cannot set DAC value if pump is busy or calibration values have not been provided yet if ( ( SYRINGE_PUMP_OFF_STATE == syringePumpState ) && ( forceSensorCalRecord.calibrationTime != 0 ) ) { - syringePumpDACVref = vRef; + syringePumpDACVref.data = vRef; syringePumpDACVrefSetRequested = TRUE; } } @@ -1287,7 +1288,8 @@ else if ( ( TRUE == syringePumpDACVrefSetRequested ) || ( ( syringePumpDACRetryCount > 0 ) && ( syringePumpDACRetryTimer > SYRINGE_PUMP_DAC_TIMER ) ) ) { - U16 vRef = (U16)( ( syringePumpDACVref / SYRINGE_PUMP_ADC_REF_V ) * SYRINGE_PUMP_DAC_FULL_SCALE_BITS ); + F32 sPumpDACVref = getF32OverrideValue( &syringePumpDACVref ); + U16 vRef = (U16)( ( sPumpDACVref / SYRINGE_PUMP_ADC_REF_V ) * SYRINGE_PUMP_DAC_FULL_SCALE_BITS ); setFPGASyringePumpDACOutputLevel( vRef ); setFPGASyringePumpADCandDACControlFlags( SYRINGE_PUMP_ADC_DAC_CONTROL_ENABLE_DAC ); @@ -1780,19 +1782,17 @@ /*********************************************************************//** * @brief - * The getHeprinBolusTargetRate function gets the heprin bolus target + * The getHeparinBolusTargetRate function gets the heparin bolus target * flow rate. - * @details \b Inputs: getHeprinBolusTargetRate - * @details \b Outputs: getHeprinBolusTargetRate - * @return the current target heprin bolus flow rate (in mL/hour). + * @details \b Inputs: getHeparinBolusTargetRate + * @details \b Outputs: getHeparinBolusTargetRate + * @return the current target heparin bolus flow rate (in mL/hour). *************************************************************************/ -static F32 getHeprinBolusTargetRate( void ) +static F32 getHeparinBolusTargetRate( void ) { return getF32OverrideValue( &heparinBolusTargetRate ); } - - /*********************************************************************//** * @brief * The getSyringePumpStatus function gets the current syringe pump status. @@ -2286,13 +2286,19 @@ * @param opParams record containing the requested operation and its parameters * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSyringePumpOperationRequest( SYRINGE_PUMP_OP_PAYLOAD_T opParams ) +BOOL testSyringePumpOperationRequest( MESSAGE_T *message ) { BOOL result = FALSE; + SYRINGE_PUMP_OP_PAYLOAD_T opParams; + SYRINGE_PUMP_OPERATION_T op; - if ( TRUE == isTestingActivated() ) + // If testing is activated and payload size is valid + if ( ( TRUE == isTestingActivated() ) && + ( message->hdr.payloadLen == sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ) ) { - SYRINGE_PUMP_OPERATION_T op = (SYRINGE_PUMP_OPERATION_T)(opParams.syringePumpOp); + // From the message payload, extract the syringe pump operation to be executed + memcpy( &opParams, message->payload, sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ); + op = (SYRINGE_PUMP_OPERATION_T)(opParams.syringePumpOp); switch ( op ) { @@ -2370,22 +2376,6 @@ /*********************************************************************//** * @brief - * The testHeprinBolusTargetRateOverride function overrides the - * heprine bolus target rate. - * @details \b Inputs: heprinBolusTargetRate - * @details \b Outputs: heprinBolusTargetRate - * @param: value : override heprinBolusTargetRate (in mL/hour) - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testHeprinBolusTargetRateOverride( MESSAGE_T *message ) -{ - BOOL result = f32Override( message, &heparinBolusTargetRate ); - - return result; -} - -/*********************************************************************//** - * @brief * The testSyringePumpMeasuredForceOverride function overrides the measured * force analog signal of the syringe pump. * @details \b Inputs: none @@ -2468,14 +2458,14 @@ /*********************************************************************//** * @brief - * The testSyringePumpStatus function overrides the syringe pump + * The testSyringePumpStatusOverride function overrides the syringe pump * status. * @details \b Inputs: none * @details \b Outputs: syringePumpStatus * @param status override syringe pump status with this value * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSyringePumpStatus( MESSAGE_T *message ) +BOOL testSyringePumpStatusOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &syringePumpStatus, 0, 255 ); @@ -2484,14 +2474,14 @@ /*********************************************************************//** * @brief - * The testSyringePumpEncoderStatus function overrides the syringe + * The testSyringePumpEncoderStatusOverride function overrides the syringe * pump encoder status. * @details \b Inputs: none * @details \b Outputs: syringePumpEncoderStatus * @param status override syringe pump encoder status with this value * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSyringePumpEncoderStatus( MESSAGE_T *message ) +BOOL testSyringePumpEncoderStatusOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &syringePumpEncoderStatus, 0, 255 ); @@ -2500,14 +2490,14 @@ /*********************************************************************//** * @brief - * The testSyringePumpADCandDACStatus function overrides the syringe + * The testSyringePumpADCandDACStatusOverride function overrides the syringe * pump ADC and DAC status. * @details \b Inputs: none * @details \b Outputs: syringePumpADCandDACStatus * @param status override syringe pump ADC and DAC status with this value * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSyringePumpADCandDACStatus( MESSAGE_T *message ) +BOOL testSyringePumpADCandDACStatusOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &syringePumpADCandDACStatus, 0, 255 ); @@ -2516,18 +2506,50 @@ /*********************************************************************//** * @brief - * The testSyringePumpADCReadCounter function overrides the syringe + * The testSyringePumpADCReadCounterOverride function overrides the syringe * pump ADC read counter. * @details \b Inputs: none * @details \b Outputs: syringePumpADCReadCtr * @param ctr override syringe pump ADC read counter with this value * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSyringePumpADCReadCounter( MESSAGE_T *message ) +BOOL testSyringePumpADCReadCounterOverride( MESSAGE_T *message ) { BOOL result = u32Override( message, &syringePumpADCReadCtr, 0, 255 ); return result; } +/*********************************************************************//** + * @brief + * The testSyringePumpDACVrefOverride function overrides the syringe + * pumpDAC Vref setting. + * @details \b Inputs: none + * @details \b Outputs: syringePumpDACVref + * @param vref override syringePumpDACVref with this value + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSyringePumpDACVrefOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &syringePumpDACVref ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testHeparinBolusTargetRateOverride function overrides the + * heparine bolus target rate. + * @details \b Inputs: heparinBolusTargetRate + * @details \b Outputs: heparinBolusTargetRate + * @param: value : override heparinBolusTargetRate (in mL/hour) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testHeparinBolusTargetRateOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &heparinBolusTargetRate ); + + return result; +} + /**@}*/ Index: firmware/App/Controllers/SyringePump.h =================================================================== diff -u -rbb144484d4d22e3f24a280eda9c8abf9570a443a -r42b82bcd2bb2c2fa07349108e6b2bd9995173fa4 --- firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision bb144484d4d22e3f24a280eda9c8abf9570a443a) +++ firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision 42b82bcd2bb2c2fa07349108e6b2bd9995173fa4) @@ -148,19 +148,20 @@ BOOL isSyringePumpPreLoaded( void ); F32 getSyringePumpVolumeDelivered( void ); -BOOL testSyringePumpOperationRequest( SYRINGE_PUMP_OP_PAYLOAD_T opParams ); +BOOL testSyringePumpOperationRequest( MESSAGE_T *message ); BOOL testSyringePumpDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredRateOverride( MESSAGE_T *message ); -BOOL testHeprinBolusTargetRateOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredForceOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredSyringeDetectOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredHomeOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredPositionOverride( MESSAGE_T *message ); BOOL testSyringePumpMeasuredVolumeOverride( MESSAGE_T *message ); -BOOL testSyringePumpStatus( MESSAGE_T *message ); -BOOL testSyringePumpEncoderStatus( MESSAGE_T *message ); -BOOL testSyringePumpADCandDACStatus( MESSAGE_T *message ); -BOOL testSyringePumpADCReadCounter( MESSAGE_T *message ); +BOOL testSyringePumpStatusOverride( MESSAGE_T *message ); +BOOL testSyringePumpEncoderStatusOverride( MESSAGE_T *message ); +BOOL testSyringePumpADCandDACStatusOverride( MESSAGE_T *message ); +BOOL testSyringePumpADCReadCounterOverride( MESSAGE_T *message ); +BOOL testSyringePumpDACVrefOverride( MESSAGE_T *message ); +BOOL testHeparinBolusTargetRateOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -re9e339870c5ed01230963f00d400331ab879c91f -r42b82bcd2bb2c2fa07349108e6b2bd9995173fa4 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision e9e339870c5ed01230963f00d400331ab879c91f) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 42b82bcd2bb2c2fa07349108e6b2bd9995173fa4) @@ -39,6 +39,7 @@ #include "StateTxDialysis.h" #include "StateTxPaused.h" #include "Switches.h" +#include "SyringePump.h" #include "SystemCommTD.h" #include "Temperatures.h" #include "TxParams.h" @@ -183,6 +184,20 @@ { MSG_ID_TD_BLOOD_PRIME_VOLUME_OVERRIDE, &testBloodPrimeVolumeOverride }, { MSG_ID_TD_BLOOD_PRIME_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBloodPrimePublishIntervalOverride }, { MSG_ID_TD_ENABLE_VENOUS_BUBBLE_ALARM, &testEnableVenousBubbleAlarm }, + { MSG_ID_TD_SYRINGE_PUMP_OPERATION_REQUEST, &testSyringePumpOperationRequest }, + { MSG_ID_HD_SYRINGE_PUMP_PUBLISH_INTERVAL_OVERRIDE, &testSyringePumpDataPublishIntervalOverride }, + { MSG_ID_TD_SYRINGE_PUMP_RATE_OVERRIDE_REQUEST, &testSyringePumpMeasuredRateOverride }, + { MSG_ID_TD_SYRINGE_PUMP_FORCE_OVERRIDE_REQUEST, &testSyringePumpMeasuredForceOverride }, + { MSG_ID_TD_SYRINGE_PUMP_SYRINGE_DETECT_OVERRIDE_REQUEST, &testSyringePumpMeasuredSyringeDetectOverride }, + { MSG_ID_TD_SYRINGE_PUMP_HOME_OVERRIDE_REQUEST, &testSyringePumpMeasuredHomeOverride }, + { MSG_ID_TD_SYRINGE_PUMP_POSITION_OVERRIDE_REQUEST, &testSyringePumpMeasuredPositionOverride }, + { MSG_ID_TD_SYRINGE_PUMP_VOLUME_OVERRIDE_REQUEST, &testSyringePumpMeasuredVolumeOverride }, + { MSG_ID_TD_SYRINGE_PUMP_STATUS_OVERRIDE_REQUEST, &testSyringePumpStatusOverride }, + { MSG_ID_TD_SYRINGE_PUMP_ENCODER_STATUS_OVERRIDE_REQUEST, &testSyringePumpEncoderStatusOverride }, + { MSG_ID_TD_SYRINGE_PUMP_ADC_DAC_STATUS_OVERRIDE_REQUEST, &testSyringePumpADCandDACStatusOverride }, + { MSG_ID_TD_SYRINGE_PUMP_ADC_READ_COUNTER_OVERRIDE_REQUEST, &testSyringePumpADCReadCounterOverride }, + { MSG_ID_TD_SYRINGE_PUMP_FORCE_SENSOR_DAC_OVERRIDE_REQUEST, &testSyringePumpDACVrefOverride }, + { MSG_ID_TD_HEPARIN_BOLUS_TARGET_RATE_OVERRIDE_REQUEST, &testHeparinBolusTargetRateOverride }, }; #define NUM_OF_FUNCTION_HANDLERS (sizeof(MSG_FUNCTION_HANDLER_LOOKUP) / sizeof(MSG_HANDLER_LOOKUP_T))