Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rc1e18c14a172586f47ebcf027bce9669beded986 -rf8d418646b4dae23ed7694dfc5597dc5a5abf7ed --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision c1e18c14a172586f47ebcf027bce9669beded986) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision f8d418646b4dae23ed7694dfc5597dc5a5abf7ed) @@ -294,7 +294,6 @@ static void calcMeasRate( void ); static void calcSafetyVolumeDelivered( void ); -static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ); static void publishSyringePumpData( void ); /*********************************************************************//** @@ -446,6 +445,8 @@ * @brief * The execSyringePumpSelfTest function executes the state machine for the * syringe pump self-test. + * @details \b Alarms: ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD + * if the force sensor calibration record is invalid * @details \b Inputs: none * @details \b Outputs: forceSensorCalRecord * @return TRUE if the self test passed otherwise, FALSE @@ -478,16 +479,20 @@ /*********************************************************************//** * @brief * The userHeparinRequest function handles a command request from the user - * to pause or resume Heparin delivery. + * to pause or resume heparin delivery. + * @details \b Message \b Sent: MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE + * if changing heaprin delivery status * @details \b Inputs: none - * @details \b Outputs: heparinDeliveryState, syringePumpState, syringePumpContinuousRequested + * @details \b Outputs: heparinDeliveryState, syringePumpState, + * syringePumpContinuousRequested * @param cmd command from user * @return TRUE if request accepted, FALSE if not *************************************************************************/ BOOL userHeparinRequest( HEPARIN_CMD_T cmd ) { BOOL accepted = FALSE; REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; + UI_RESPONSE_PAYLOAD_T payload; // Check if the current mode is treatment mode. if ( MODE_TREA == getCurrentOperationMode() ) @@ -540,7 +545,10 @@ rejReason = REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE; } - sendHeparinCommandResponse( (U32)accepted, (U32)rejReason ); + 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 accepted; } @@ -754,6 +762,8 @@ * @brief * The checkForPrimeOcclusion function checks the force sensor for excessive * pressure. Would indicate occlusion or jam or empty syringe. + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION + * if occlusion is detected * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data, * forceAtEndOfSeek, syringePumpState * @details \b Outputs: alarm triggered if max force detected @@ -801,6 +811,8 @@ /*********************************************************************//** * @brief * The startHeparinBolus function requests Heparin bolus delivery. + * @details \b Alarms: ALARM_ID_TD_SOFTWARE_FAULT + * if heparin bolus command is invalid * @details \b Inputs: syringePumpState, syringePumpPrimeCompleted * @details \b Outputs: syringePumpSetRate, syringePumpBolusRequested, * heparinDeliveryState @@ -849,6 +861,8 @@ /*********************************************************************//** * @brief * The startHeparinContinuous function requests Heparin continuous delivery. + * @details \b Alarms: ALARM_ID_TD_SOFTWARE_FAULT + * if heparin continuous command is invalid * @details \b Inputs: syringePumpState * @details \b Outputs: syringePumpSetRate, syringePumpContinuousRequested, * heparinDeliveryState @@ -894,6 +908,8 @@ /*********************************************************************//** * @brief * The setSyringePumpDACVref function requests to set the DAC Vref setting. + * @details \b Alarms: ALARM_ID_TD_SOFTWARE_FAULT + * if force sensor vref value invalid * @details \b Inputs: forceSensorCalRecord.tdHeparinForceSensorDACVoltage, * syringePumpState * @details \b Outputs: syringePumpDACVrefSetRequested, syringePumpDACVref @@ -925,6 +941,8 @@ * syringe pump force sensor DAC has been calibrated and is reporting no force * as would be expected when fully retracted (caller should not call this function * until the syringe pump is homed first). + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_SELF_TEST_FAILURE + * if force sensor calibration value is invalid * @details \b Inputs: forceSensorCalRecord.tdHeparinForceSensorDACVoltage * @details \b Outputs: * @return none @@ -1066,8 +1084,9 @@ /*********************************************************************//** * @brief * The execSyringePumpMonitor function executes the syringe pump monitor. - * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR, - * ALARM_ID_TD_SYRINGE_PUMP_FAULT + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR + * if syringe pump is running while the blood pump is off + * ALARM_ID_TD_SYRINGE_PUMP_FAULT is syringe pump status is invalid * @details \b Inputs: FPGA syringe pump readings * @details \b Outputs: Alarm(s) may be triggered * @return none @@ -1167,6 +1186,7 @@ * The handleSyringePumpOffState function handles the off state * of the syringe pump control state machine. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_NOT_STOPPED_ERROR + * if the syringe pump is still running * @details \b Inputs: syringePumpRetractRequested, syringePumpPreloadRequested, * syringePumpSeekRequested, syringePumpPrimeRequested, syringePumpBolusRequested, * syringePumpContinuousRequested, syringePumpDACVrefSetRequested, @@ -1292,6 +1312,8 @@ * @brief * The handleSyringePumpRetractState function handles the retract state * of the syringe pump control state machine. + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_OVER_TRAVEL_ERROR + * if the syringe pump retracts beyond the minimum position * @details \b Inputs: syringePumpMeasHome.data, syringePumpPositionKnown, syringePumpPosition * @details \b Outputs: Syringe pump ramped up to retract rate, alarm conditions checked, * syringePumpPosition, syringePumpVolumeStartPosition, syringePumpPositionKnown, @@ -1416,6 +1438,8 @@ * @brief * The handleSyringePumpSeekState function handles the seek plunger state * of the syringe pump control state machine. + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM + * if the heaprin volume is if insufficient for the treatment needs * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition, syringePumpMeasForce, * treatmentParameters, * @details \b Outputs: Syringe pump ramped up to seek rate, alarm conditions checked, @@ -1487,7 +1511,7 @@ * @brief * The handleSyringePumpPrimeState function handles the prime state * of the syringe pump control state machine. - * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_PRIME_TIMEOUT + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_PRIME_TIMEOUT if priming state timeouts * @details \b Inputs: syringePumpVolumeDelivered, syringePumpStateStartTime, * syringePumpPosition * @details \b Outputs: Syringe pump ramped up to prime rate, alarm conditions checked, @@ -1511,7 +1535,9 @@ syringePumpVolumeDelivered.data = 0.0; syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; - resetPersistentAlarmTimer( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION ); // reset persistence after prime so ensured fresh start before continuous state + + // reset persistence after prime so ensured fresh start before continuous state + resetPersistentAlarmTimer( ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION ); } // Check for timeout @@ -1638,6 +1664,7 @@ * calibrate force sensor state of the syringe pump control state machine. * of the syringe pump control state machine. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_DAC_WRITE_ERROR + * if unable to calibrate the force sensor after retrying 5 times * @details \b Inputs: syringePumpADCandDACStatus, syringePumpDACRetryCount * @details \b Outputs: syringePumpDACVrefWriteInProgress, ADC read mode restored * syringePumpDACRetryCount, syringePumpDACRetryTimer @@ -1802,8 +1829,10 @@ * @brief * The checkDirection function checks the measured direction of the syringe * pump vs. the given expected direction. - * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR, + * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_ENCODER_DIRECTION_ERROR + * if syringe pump encoder direction is invalid * ALARM_ID_TD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR + * if syringe pump controller direction is invalid * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data, * syringePumpEncoderMeasuredDirection, syringePumpControllerMeasuredDirection * @details \b Outputs: alarm triggered if max force detected @@ -1848,6 +1877,7 @@ * The checkSyringeEmpty function checks the force sensor position * to determine if the syringe pump is empty. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_SYRINGE_EMPTY + * if the syringe is empty * @details \b Inputs: syringePumpMeasForce.data, syringePumpPosition.data * @details \b Outputs: alarm triggered if position is empty., * heparinDeliveryState @@ -1888,6 +1918,7 @@ * has been exceeded. This threshold is state dependent so the calling function * must provide the maximum position to apply. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_OVER_TRAVEL_ERROR + * if syringe pump extends beyond the maximum position * @details \b Inputs: syringePumpPosition.data * @details \b Outputs: alarm triggered if beyond given max position * @param stopPump flag passed in by caller indicating whether pump should be stopped @@ -1913,6 +1944,7 @@ * The checkMeasRate function checks whether the measured rate is within a * given margin of the set rate (in mL/hr). * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_SPEED_ERROR + * is the syringe pump speed is invalid * @details \b Inputs: syringePumpMeasRate.data, syringePumpSetRate * @details \b Outputs: alarm triggered if measured and set rates deviate too much * @param stopPump flag passed in by caller indicating whether pump should be stopped @@ -1951,6 +1983,7 @@ * is state dependent so the calling function must provide the tolerance (in +/- %) * to apply. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_VOLUME_ERROR + * if the heparin volume is invalid * @details \b Inputs: syringePumpVolumeDelivered.data, syringePumpSafetyVolumeDelivered * @details \b Outputs: alarm triggered if measured and expected volume deviate too much * @param stopPump flag passed in by caller indicating whether pump should be stopped @@ -1982,6 +2015,7 @@ * If stall detected, the ramp up will be restarted up to 3 times. * If cannot resolve the stall within 3 retries, a stall fault is triggered. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_STALL + * if the syringe pump stalls * @details \b Inputs: syringePumpMeasRate.data, syringePumpState, * syringePumpStallCtr, syringePumpStallRetryCount * @details \b Outputs: syringePumpStallCtr, syringePumpStallRetryCount, @@ -2168,30 +2202,6 @@ /*********************************************************************//** * @brief - * The sendHeparinCommandResponse function constructs a Heparin command response - * to the UI and queues the msg for transmit on the - * appropriate CAN channel. - * @details \b Message \b Sent: MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE - * @details \b Inputs: none - * @details \b 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; -} - -/*********************************************************************//** - * @brief * The publishSyringePumpData function publishes syringe pump data at the * set interval. * @details \b Inputs: latest syringe pump data, syringePumpDataPublicationTimerCounter,