Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r22293ecac97c3f374f90bb20e3c4cc03fbd27f9d -r2de8bd54fe7ce6557115820251069611b49aa0ab --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 22293ecac97c3f374f90bb20e3c4cc03fbd27f9d) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 2de8bd54fe7ce6557115820251069611b49aa0ab) @@ -17,10 +17,10 @@ #include // Used for fabs() functions -#include "AlarmMgmt.h" +#include "AlarmMgmtTD.h" #include "BloodFlow.h" #include "CpldInterface.h" -#include "FPGA.h" +#include "FpgaTD.h" #include "Messaging.h" #include "ModeTreatment.h" #include "OperationModes.h" @@ -295,6 +295,7 @@ static BOOL checkVolumeVsSafetyVolume( BOOL stopPump, F32 pctMargin ); static BOOL checkForStall( BOOL stopPump ); static void publishSyringePumpData( void ); +static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ); /*********************************************************************//** * @brief @@ -524,11 +525,11 @@ { if ( HEPARIN_STATE_INITIAL_BOLUS == heparinDeliveryState ) { - sendTreatmentLogEventData( HEPARIN_BOLUS_END_EVENT, syringePumpSetRate, 0.0 ); +// sendTreatmentLogEventData( HEPARIN_BOLUS_END_EVENT, syringePumpSetRate, 0.0 ); } else { - sendTreatmentLogEventData( HEPARIN_STOP_PAUSE_EVENT, syringePumpSetRate, 0.0 ); +// sendTreatmentLogEventData( HEPARIN_STOP_PAUSE_EVENT, syringePumpSetRate, 0.0 ); } heparinDeliveryState = HEPARIN_STATE_STOPPED; syringePumpSetRate = 0.0; @@ -672,7 +673,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_TD_SYRINGE_INVALID_BOLUS_CMD, syringePumpSetRate ) @@ -709,7 +710,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_TD_SYRINGE_INVALID_CONT_CMD, flowRate ) @@ -1061,12 +1062,12 @@ static void execSyringePumpMonitor( void ) { // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) - { +// if ( TRUE == isNewCalibrationRecordAvailable() ) +// { // Get the new calibration data and check its validity - getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), - 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); - } +// getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), +// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); +// } S32 encPosition = getFPGASyringePumpEncoderPosition(); @@ -1079,19 +1080,19 @@ // Get latest ADC data and convert to V syringePumpMeasHome.data = ( (F32)getFPGASyringePumpADCChannel2() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_DISABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_DISABLE_VALUE ) { syringePumpMeasSyringeDetectionSwitch.data = 0.0; // if syringe pump disabled, always report no detection } - else +// else #endif { syringePumpMeasSyringeDetectionSwitch.data = ( (F32)getFPGASyringePumpADCChannel1() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; } // Handle syringe detect alarm management #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); @@ -1140,7 +1141,7 @@ calcMeasRate(); #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { // Get measured direction @@ -1162,7 +1163,7 @@ if ( ( FALSE == syringePumpDACVrefWriteInProgress ) && ( getCurrentOperationMode() > MODE_INIT ) ) { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { checkFPGAPersistentAlarms( FPGA_PERS_ERROR_SYRINGE_PUMP_ADC, getSyringePumpADCReadCounter() ); @@ -1264,12 +1265,13 @@ SELF_TEST_STATUS_T execSyringePumpSelfTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + BOOL calStatus = FALSE; // Read/check force sensor calibration - BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), - 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); +// BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), +// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { if ( TRUE == calStatus ) @@ -1328,7 +1330,7 @@ if ( ( syringePumpStopLastPosition != getSyringePumpPosition() ) && ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_SYRINGE_PUMP_OFF_ERROR ) ) ) { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { activateAlarmNoData( ALARM_ID_TD_SYRINGE_PUMP_NOT_STOPPED_ERROR ); @@ -1368,13 +1370,13 @@ else if ( TRUE == syringePumpBolusRequested ) { heparinDeliveryState = HEPARIN_STATE_INITIAL_BOLUS; - sendTreatmentLogEventData( HEPARIN_BOLUS_START_EVENT, 0.0, syringePumpSetRate ); +// sendTreatmentLogEventData( HEPARIN_BOLUS_START_EVENT, 0.0, syringePumpSetRate ); result = SYRINGE_PUMP_HEP_BOLUS_STATE; } else if ( TRUE == syringePumpContinuousRequested ) { heparinDeliveryState = HEPARIN_STATE_DISPENSING; - sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, 0.0, syringePumpSetRate ); +// sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, 0.0, syringePumpSetRate ); result = SYRINGE_PUMP_HEP_CONTINUOUS_STATE; } else if ( ( TRUE == syringePumpDACVrefSetRequested ) || @@ -1574,7 +1576,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM, syringeVol, txVolume ); @@ -1822,7 +1824,7 @@ BOOL result = stopPump; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { // Check direction if rate >= minimum for alarm @@ -1991,7 +1993,7 @@ BOOL result = stopPump; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { F32 rate = getSyringePumpMeasRate(); @@ -2221,6 +2223,26 @@ } } +/*********************************************************************//** + * @brief + * The sendHeparinCommandResponse function constructs a Heparin command response + * to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Heparin command response msg constructed and queued. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ) +{ + BOOL result; + UI_RESPONSE_PAYLOAD_T payload; + payload.accepted = accepted; + payload.rejectionReason = rejReason; + result = sendMessage( MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + return result; +} /************************************************************************* * TEST SUPPORT FUNCTIONS