Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rfbb180e9b4830dd5f890f4f33f022ce375ff4012 -r74be223d47ea7bb0ac7d814e74d3627d830a5fac --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision fbb180e9b4830dd5f890f4f33f022ce375ff4012) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 74be223d47ea7bb0ac7d814e74d3627d830a5fac) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file SyringePump.c +* @file SyringePump.c * -* @author (last) Sean Nash -* @date (last) 02-Mar-2021 +* @author (last) Sean Nash +* @date (last) 13-Aug-2021 * -* @author (original) Sean Nash -* @date (original) 02-Mar-2021 +* @author (original) Sean Nash +* @date (original) 04-Mar-2021 * ***************************************************************************/ #include @@ -196,8 +196,10 @@ static S32 syringePumpLastPositions[ SYRINGE_PUMP_SPEED_CALC_BUFFER_LEN ]; ///< Last encoder positions for the syringe pump. static U32 syringePumpMotorSpeedCalcIdx; ///< Index into 1 second buffer of syringe pump encoder positions. static U32 syringePumpSpeedCalcTimerCounter; ///< Used to calculate measured rate from change in position over time. +#ifndef DISABLE_SYRINGE_PUMP_ALARMS static MOTOR_DIR_T syringePumpControllerMeasuredDirection; ///< Measured direction of syringe pump per controller. static MOTOR_DIR_T syringePumpEncoderMeasuredDirection; ///< Measured direction of syringe pump per encoder position relative to previous. +#endif static BOOL syringePumpRetractRequested; ///< Flag indicates a retract operation is requested. static BOOL syringePumpSeekRequested; ///< Flag indicates a plunger seek operation is requested. @@ -224,7 +226,6 @@ static void resetSyringePumpRequestFlags( void ); static void execSyringePumpMonitor( void ); -static U32 getPublishSyringePumpDataInterval( void ); static S32 getSyringePumpPosition( void ); static F32 getSyringePumpMeasRate( void ); static F32 getSyringePumpSyringeDetectorV( void ); @@ -276,8 +277,10 @@ syringePumpVolumeStartPosition = 0; syringePumpHomePositionOffset = 0; syringePumpLastPosition = 0; +#ifndef DISABLE_SYRINGE_PUMP_ALARMS syringePumpControllerMeasuredDirection = MOTOR_DIR_FORWARD; syringePumpEncoderMeasuredDirection = MOTOR_DIR_FORWARD; +#endif syringePumpDataPublicationTimerCounter = 0; syringePumpSpeedCalcTimerCounter = 0; @@ -625,26 +628,6 @@ /*********************************************************************//** * @brief - * The getPublishSyringePumpDataInterval function gets the syringe pump data - * publication interval. - * @details Inputs: syringePumpDataPublishInterval - * @details Outputs: none - * @return the current syringe pump data publication interval (in task intervals). - *************************************************************************/ -static U32 getPublishSyringePumpDataInterval( void ) -{ - U32 result = syringePumpDataPublishInterval.data; - - if ( OVERRIDE_KEY == syringePumpDataPublishInterval.override ) - { - result = syringePumpDataPublishInterval.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getSyringePumpVolumeDelivered function gets the current syringe pump * volume delivered. * @details Inputs: syringePumpVolumeDelivered @@ -986,10 +969,12 @@ calcSafetyVolumeDelivered(); // Calculate measured rate (mL/hr) calcMeasRate(); +#ifndef DISABLE_SYRINGE_PUMP_ALARMS // Get measured direction syringePumpControllerMeasuredDirection = ( ( getSyringePumpEncoderStatus() & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); // Calculate direction from encoder position relative to last syringePumpEncoderMeasuredDirection = ( getSyringePumpPosition() - syringePumpLastPosition >= 0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); +#endif // Check if syringe pump is on while BP is off { @@ -1640,13 +1625,13 @@ static BOOL checkMeasRate( BOOL stopPump, F32 pctMargin ) { BOOL result = stopPump; +#ifndef DISABLE_SYRINGE_PUMP_ALARMS F32 rate = getSyringePumpMeasRate(); F32 max = MAX( rate, syringePumpSetRate ); F32 min = MIN( rate, syringePumpSetRate ); - F32 delta = max - min; F32 error = ( max > 0.0 ? ( 1.0 - fabs( min / max ) ) : 0.0 ); + F32 delta = max - min; -#ifndef DISABLE_SYRINGE_PUMP_ALARMS // Alarm on rate if off by more than 5% or 0.1 mL/hr, whichever is greater if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, ( ( error > pctMargin ) && ( delta > SYRINGE_PUMP_MAX_RATE_ERROR_ML_HR ) ) ) ) { @@ -1837,7 +1822,7 @@ static void publishSyringePumpData( void ) { // Publish syringe pump data on interval - if ( ++syringePumpDataPublicationTimerCounter >= getPublishSyringePumpDataInterval() ) + if ( ++syringePumpDataPublicationTimerCounter >= getU32OverrideValue( &syringePumpDataPublishInterval ) ) { SYRINGE_PUMP_DATA_PAYLOAD_T data; @@ -1856,8 +1841,8 @@ ( (U32)getSyringePumpADCandDACStatus() << SHIFT_8_BITS_FOR_BYTE_SHIFT ) | ( (U32)getSyringePumpADCReadCounter() ); - broadcastSyringePumpData( data ); - broadcastHeparinData( data.syringePumpVolumeDelivered ); + broadcastData( MSG_ID_HD_SYRINGE_PUMP_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ) ); + broadcastData( MSG_ID_HD_HEPARIN_DATA_BROADCAST, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data.syringePumpVolumeDelivered, sizeof( F32 ) ); syringePumpDataPublicationTimerCounter = 0; } }