Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r2f0638084613eee8d9dcce98d62dce1eaf910f29 -r8e7158d8231435496fcf1d5649e51babf859ccc7 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2f0638084613eee8d9dcce98d62dce1eaf910f29) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8e7158d8231435496fcf1d5649e51babf859ccc7) @@ -1,14 +1,14 @@ /************************************************************************** * -* 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 SystemCommMessages.c * * @author (last) Sean Nash -* @date (last) 07-Jul-2020 +* @date (last) 01-Dec-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -17,25 +17,25 @@ #include // for memcpy() +#include "reg_system.h" + #include "Accel.h" #include "AlarmLamp.h" -#include "BloodFlow.h" #include "Buttons.h" #include "DGInterface.h" -#include "DialInFlow.h" -#include "Dialysis.h" #include "FPGA.h" -#include "MessagePayloads.h" +#include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "PresOccl.h" +#include "RTC.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "SystemCommMessages.h" -#include "Utilities.h" +#include "Utilities.h" +#include "Valves.h" #include "WatchdogMgmt.h" -#include "RTC.h" /** * @addtogroup SystemCommMessages @@ -69,9 +69,8 @@ * bit of the sequence # is set if ACK is required per parameter. A sync byte * is inserted at the beginning of the message and an 8-bit CRC is appended to * the end of the message. The message is queued for transmission in the given buffer. - * @details - * Inputs : none - * Outputs : given data array populated with serialized message data and queued for transmit. + * @details Inputs: none + * @details Outputs: given data array populated with serialized message data and queued for transmit. * @param msg message to serialize * @param buffer outgoing buffer that message should be queued in * @param ackReq is an acknowledgement from receiver required? @@ -151,9 +150,8 @@ * @brief * The sendACKMsg function constructs and queues for transmit an ACK message * for a given received message. - * @details - * Inputs : none - * Outputs : ACK message queued for transmit on broadcast CAN channel. + * @details Inputs: none + * @details Outputs: ACK message queued for transmit on broadcast CAN channel. * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ @@ -182,9 +180,8 @@ * The sendTestAckResponseMsg function constructs a simple response * message for a handled test message and queues it for transmit on the * appropriate UART channel. - * @details - * Inputs : none - * Outputs : response message constructed and queued for transmit. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param buffer outgoing buffer that message should be queued in * @param ack TRUE if test message was handled successfully, FALSE if not @@ -215,9 +212,8 @@ * @brief * The sendOffButtonMsgToUI function constructs an off button msg to the UI * and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Off button msg constructed and queued. + * @details Inputs: none + * @details Outputs: Off button msg constructed and queued. * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -243,9 +239,8 @@ * The sendChangeUFSettingsResponse function constructs a UF change settings * response to the UI and queues the msg for transmit on the appropriate CAN * channel. - * @details - * Inputs : none - * Outputs : UF change settings response msg constructed and queued. + * @details Inputs: none + * @details Outputs: UF change settings response msg constructed and queued. * @param accepted T/F - are settings ok? * @param reason reason rejected (if not accepted) * @param volume_mL UF volume (in mL) @@ -287,16 +282,15 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - +} + /*********************************************************************//** * @brief * The sendChangeUFSettingsResponse function constructs a UF change settings * option response to the UI and queues the msg for transmit on the appropriate CAN * channel. - * @details - * Inputs : none - * Outputs : UF change settings option response msg constructed and queued. + * @details Inputs: none + * @details Outputs: UF change settings option response msg constructed and queued. * @param accepted T/F - are settings ok? * @param reason reason rejected (if not accepted) * @param volume_mL UF volume (in mL) @@ -336,9 +330,8 @@ * The sendChangeTreatmentDurationResponse function constructs a treatment * duration change response to the UI and queues the msg for transmit on the * appropriate CAN channel. - * @details - * Inputs : none - * Outputs : treatment duration change settings response msg constructed and queued. + * @details Inputs: none + * @details Outputs: treatment duration change settings response msg constructed and queued. * @param accepted T/F - are settings ok? * @param reason reason rejected (if not accepted) * @param time_min treatment duration (in minutes) @@ -375,9 +368,8 @@ * The sendChangeBloodDialysateRateChangeResponse function constructs a change * blood and dialysate rate settings response to the UI and queues the msg for * transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Blood & dialysate rate change response msg constructed and queued. + * @details Inputs: none + * @details Outputs: Blood & dialysate rate change response msg constructed and queued. * @param accepted T/F - are settings ok? * @param reason reason code for rejection or unused if accepted * @param bloodRate new blood flow rate @@ -407,15 +399,43 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - +} + +/*********************************************************************//** + * @brief + * The sendPressureLimitsChangeResponse function constructs a change + * pressure limits response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Pressure limits change response msg constructed and queued. + * @param data response data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPressureLimitsChangeResponse( PRESSURE_LIMIT_CHANGE_RESPONSE_T *data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ); + + memcpy( payloadPtr, (U08*)data, sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief * The sendTreatmentParamsRangesToUI function constructs a treatment parameter * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Treatment parameter ranges msg constructed and queued. + * @details Inputs: none + * @details Outputs: Treatment parameter ranges msg constructed and queued. * @param minTime Minimum treatment duration (in minutes) * @param maxTime Maximum treatment duration (in minutes) * @param minUFVol Minimum ultrafiltration volume (in mL) @@ -457,9 +477,8 @@ * @brief * The sendDialysateTempTargetsToDG function constructs a dialysate temperature * set points message for DG and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Dialysate temperature set points msg constructed and queued. + * @details Inputs: none + * @details Outputs: Dialysate temperature set points msg constructed and queued. * @param primary temperature set point for primary heater * @param trimmer temperature set point for trimmer heater * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -489,9 +508,8 @@ * @brief * The sendDGSwitchReservoirCommand function constructs a DG set active * reservoir message for DG and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG set active reservoir msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG set active reservoir msg constructed and queued. * @param activeReservoir reservoir ID to set as active * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -518,9 +536,8 @@ * @brief * The sendDGFillCommand function constructs a DG fill command message * and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG fill command msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG fill command msg constructed and queued. * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -547,9 +564,8 @@ * @brief * The sendDGDrainCommand function constructs a DG drain command message * and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG drain command msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG drain command msg constructed and queued. * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -576,9 +592,8 @@ * @brief * The sendDGStartStopCommand function constructs a DG start/stop command * message and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG start/stop command msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG start/stop command msg constructed and queued. * @param start TRUE indicates start DG, FALSE indicates stop DG * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -606,9 +621,8 @@ * The sendDGStartStopTrimmerHeaterCommand function constructs a DG start/stop * trimmer heater command message and queues the msg for transmit on the * appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG start/stop trimmer heater command msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. * @param start TRUE indicates start heater, FALSE indicates stop heater * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -635,9 +649,8 @@ * @brief * The sendDGSampleWaterCommand function constructs a DG sample water command * message and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG sample water command msg constructed and queued. + * @details Inputs: none + * @details Outputs: DG sample water command msg constructed and queued. * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGSampleWaterCommand( void ) @@ -660,9 +673,8 @@ * @brief * The broadcastAccelData function constructs an accelerometer data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : accelerometer data broadcast msg constructed and queued. + * @details Inputs: none + * @details Outputs: accelerometer data broadcast msg constructed and queued. * @param x X axis vector magnitude (in g) * @param y Y axis vector magnitude (in g) * @param z Z axis vector magnitude (in g) @@ -707,9 +719,8 @@ * @brief * The broadcastAlarmStatus function constructs an alarm status msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : alarm status msg constructed and queued. + * @details Inputs: none + * @details Outputs: alarm status msg constructed and queued. * @param almStatus alarm status record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -737,7 +748,8 @@ payload.alarmsFlags |= ( almStatus.noNewTreatment ? BIT_BY_POS(6) : 0 ); payload.alarmsFlags |= ( almStatus.bypassDialyzer ? BIT_BY_POS(7) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(8) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); + payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(10) : 0 ); memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); @@ -751,9 +763,8 @@ * @brief * The broadcastAlarmTriggered function constructs an alarm triggered msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : alarm triggered msg constructed and queued. + * @details Inputs: none + * @details Outputs: alarm triggered msg constructed and queued. * @param alarm ID of alarm triggered * @param almData1 1st data associated with alarm * @param almData2 2nd data associated with alarm @@ -790,9 +801,8 @@ * @brief * The broadcastAlarmCleared function constructs an alarm cleared msg to be * broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : alarm cleared msg constructed and queued. + * @details Inputs: none + * @details Outputs: alarm cleared msg constructed and queued. * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -819,40 +829,24 @@ * @brief * The broadcastBloodFlowData function constructs a blood flow data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : blood flow data msg constructed and queued. - * @param flowStPt Current set point for blood flow - * @param measFlow Latest measured blood flow - * @param measRotorSpd Latest measured blood pump rotoro speed - * @param measSpd Latest measured blood pump speed - * @param measMCspd Latest measured blood pump motor controller speed - * @param measSpd Latest measured blood pump motor controller current - * @param pwmDC Latest PWM duty cycle % + * @details Inputs: none + * @details Outputs: blood flow data msg constructed and queued. + * @param bloodData blood pump and flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastBloodFlowData( U32 flowStPt, F32 measFlow, F32 measRotorSpd, F32 measSpd, F32 measMCSpd, F32 measMCCurr, F32 pwmDC ) +BOOL broadcastBloodFlowData( BLOOD_PUMP_STATUS_PAYLOAD_T *bloodData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - PERISTALTIC_PUMP_STATUS_PAYLOAD_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_BLOOD_FLOW_DATA; - msg.hdr.payloadLen = sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ); - payload.setPoint = flowStPt; - payload.measFlow = measFlow; - payload.measRotorSpd = measRotorSpd; - payload.measPumpSpd = measSpd; - payload.measMCSpd = measMCSpd; - payload.measMCCurr = measMCCurr; - payload.pwmDC = pwmDC; + memcpy( payloadPtr, bloodData, sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ) ); - memcpy( payloadPtr, &payload, sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); @@ -863,40 +857,24 @@ * @brief * The broadcastDialInFlowData function constructs a dialysate flow data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : dialysate flow data msg constructed and queued. - * @param flowStPt Current set point for dialysate flow - * @param measFlow Latest measured dialysate flow - * @param measRotorSpd Latest measured dialysate pump rotor speed - * @param measSpd Latest measured dialysate pump speed - * @param measMCspd Latest measured dialysate pump motor controller speed - * @param measSpd Latest measured dialysate pump motor controller current - * @param pwmDC Latest PWM duty cycle % + * @details Inputs: none + * @details Outputs: dialysate flow data msg constructed and queued. + * @param dialInData Dialysate inlet pump and flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastDialInFlowData( U32 flowStPt, F32 measFlow, F32 measRotorSpd, F32 measSpd, F32 measMCSpd, F32 measMCCurr, F32 pwmDC ) +BOOL broadcastDialInFlowData( DIALIN_PUMP_STATUS_PAYLOAD_T *dialInData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - PERISTALTIC_PUMP_STATUS_PAYLOAD_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DIALYSATE_FLOW_DATA; - msg.hdr.payloadLen = sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ); - payload.setPoint = flowStPt; - payload.measFlow = measFlow; - payload.measRotorSpd = measRotorSpd; - payload.measPumpSpd = measSpd; - payload.measMCSpd = measMCSpd; - payload.measMCCurr = measMCCurr; - payload.pwmDC = pwmDC; + memcpy( payloadPtr, dialInData, sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ) ); - memcpy( payloadPtr, &payload, sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); @@ -907,9 +885,8 @@ * @brief * The broadcastDialInFlowData function constructs a dialysate outlet flow data * msg to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : dialysate out flow data msg constructed and queued. + * @details Inputs: none + * @details Outputs: dialysate out flow data msg constructed and queued. * @param dialOutFlowData Pointer to the dialysate out flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -936,36 +913,24 @@ * @brief * The broadcastPresOcclData function constructs a pres/occl data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : pressure/occlusion data msg constructed and queued. - * @param artPres Latest measured arterial pressure - * @param venPres Latest measured venous pressure - * @param bpOccl Latest measured blood pump occlusion pressure - * @param diOccl Latest measured dialysate inlet pump occlusion pressure - * @param doOccl Latest measured dialysate outlet pump occlusion pressure + * @details Inputs: none + * @details Outputs: pressure/occlusion data msg constructed and queued. + * @param data Latest measured pressures and occlusion values. * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastPresOcclData( F32 artPres, F32 venPres, F32 bpOccl, F32 diOccl, F32 doOccl ) +BOOL broadcastPresOcclData( PRESSURE_OCCLUSION_DATA_T data ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - PRESSURE_OCCLUSION_DATA_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_PRESSURE_OCCLUSION_DATA; msg.hdr.payloadLen = sizeof( PRESSURE_OCCLUSION_DATA_T ); - payload.arterialPressure = artPres; - payload.venousPressure = venPres; - payload.bldPumpOcclusion = bpOccl; - payload.diPumpOcclusion = diOccl; - payload.doPumpOcclusion = doOccl; + memcpy( payloadPtr, &data, sizeof( PRESSURE_OCCLUSION_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( PRESSURE_OCCLUSION_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); @@ -976,9 +941,8 @@ * @brief * The broadcastRTCEpoch function constructs an epoch msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : RTC time and date in epoch + * @details Inputs: none + * @details Outputs: RTC time and date in epoch * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -1005,9 +969,8 @@ * @brief * The broadcastTreatmentTime function constructs a treatment time msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : treatment time data msg constructed and queued + * @details Inputs: none + * @details Outputs: treatment time data msg constructed and queued * @param secsTotTreatment Total treatment time prescribed (in seconds) * @param secsElapsed Treatment time elapsed (in seconds) * @param secsRemaining Treatment time remaining (in seconds) @@ -1041,9 +1004,8 @@ * @brief * The broadcastTreatmentState function constructs a treatment state msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : treatment state msg constructed and queued + * @details Inputs: none + * @details Outputs: treatment state msg constructed and queued * @param subMode Current state (sub-mode) of treatment * @param uFState Current state of ultrafiltration * @param salineBolusState 1=saline bolus in progress, 0=not, 2=max bolus volume reached @@ -1077,9 +1039,8 @@ * @brief * The broadcastPowerOffWarning function constructs a power off warning msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : power off warning msg constructed and queued + * @details Inputs: none + * @details Outputs: power off warning msg constructed and queued * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastPowerOffWarning( void ) @@ -1102,9 +1063,8 @@ * @brief * The broadcastHDOperationMode function constructs an HD operation mode * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : HD operation mode msg constructed and queued + * @details Inputs: none + * @details Outputs: HD operation mode msg constructed and queued * @param mode current HD operation mode * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -1127,8 +1087,93 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; -} +} + +/***********************************************************************//** + * @brief + * The broadcastHDValves function constructs an HD valves msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD valves msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; + msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); + + memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} +/***********************************************************************//** + * @brief + * The broadcastSalineBolusData function constructs a saline bolus data msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: saline bolus data msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; + msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief + * The broadcastAirTrapData function constructs an HD air trap data msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: air trap data msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 lower = (U32)lowerLevel; + U32 upper = (U32)upperLevel; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &lower, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &upper, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -1157,9 +1202,8 @@ /*********************************************************************//** * @brief * The handleDGCheckIn function handles a check-in from the DG. - * @details - * Inputs : none - * Outputs : check in the DG with the SystemComm module. + * @details Inputs: none + * @details Outputs: check in the DG with the SystemComm module. * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1171,9 +1215,8 @@ /*********************************************************************//** * @brief * The handleUICheckIn function handles a check-in from the UI. - * @details - * Inputs : none - * Outputs : check in the UI with the SystemComm module. + * @details Inputs: none + * @details Outputs: check in the UI with the SystemComm module. * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1185,9 +1228,8 @@ /*********************************************************************//** * @brief * The handleAlarmTriggered function handles a triggered alarm event message. - * @details - * Inputs : none - * Outputs : alarm triggered. + * @details Inputs: none + * @details Outputs: alarm triggered. * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1219,9 +1261,8 @@ /*********************************************************************//** * @brief * The handleAlarmCleared function handles a cleared alarm event message. - * @details - * Inputs : none - * Outputs : alarm cleared. + * @details Inputs: none + * @details Outputs: alarm cleared. * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1245,9 +1286,8 @@ * @brief * The handleOffButtonConfirmMsgFromUI function handles a response to an * off button message to the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1266,9 +1306,8 @@ * @brief * The handleLoadCellReadingsFromDG function handles a load cell readings * broadcast message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1291,9 +1330,8 @@ * @brief * The handleDGTemperatureData function handles a temperature readings * broadcast message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1314,9 +1352,8 @@ * @brief * The handleROPumpData function handles an RO pump data broadcast * message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1336,9 +1373,8 @@ * @brief * The handleDrainPumpData function handles a drain pump broadcast * message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1358,9 +1394,8 @@ * @brief * The handleDGPressuresData function handles a DG pressure sensor readings * broadcast message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1380,9 +1415,8 @@ * @brief * The handleDGReservoirData function handles a reservoir data broadcast * message from the DG. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1402,9 +1436,8 @@ * @brief * The handleUFPauseResumeRequest function handles a ultrafiltration pause * or resume request message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1432,11 +1465,45 @@ /*********************************************************************//** * @brief + * The sendUFPauseResumeResponse function constructs a UF pause/resume + * response to the UI and queues the msg for transmit on the appropriate CAN + * channel. + * @details Inputs: none + * @details Outputs: UF pause/resume response msg constructed and queued. + * @param accepted was pause/resume request accepted + * @param reason reason rejected (if not accepted) + * @param ufState new UF state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUFPauseResumeResponse( BOOL accepted, U32 reason, U32 ufState ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &ufState, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The handleUIStartTreatmentMsg function handles a treatment start/cancel * message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1460,7 +1527,7 @@ } else if ( 2 == cmd ) // start treatment { - // TODO - handle when pre-treatment mode is ready for this + result = signalUserBeginningTreatment(); } } @@ -1472,9 +1539,8 @@ * The sendTreatmentStartResponseMsg function constructs a treatment start * request response message to the UI and queues the msg for transmit on * the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Treatment start response msg constructed and queued. + * @details Inputs: none + * @details Outputs: Treatment start response msg constructed and queued. * @param accepted T/F - request accepted? * @param reason reason code if rejected * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -1504,9 +1570,8 @@ * @brief * The handleUIUserEndTreatmentRequest function handles a treatment end * request message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1527,9 +1592,8 @@ * The sendTreatmentEndResponseMsg function constructs a treatment end * request response message to the UI and queues the msg for transmit on * the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Treatment end response msg constructed and queued. + * @details Inputs: none + * @details Outputs: Treatment end response msg constructed and queued. * @param accepted T/F - request accepted? * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -1556,9 +1620,8 @@ * @brief * The handleTreatmentParametersFromUI function handles a treatment parameters * set and validate request message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1582,19 +1645,28 @@ * @brief * The handleUIUserConfirmTreatmentParameters function handles a user confirmation * of treatment parameters message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleUIUserConfirmTreatmentParameters( MESSAGE_T *message ) { BOOL result = FALSE; - if ( 0 == message->hdr.payloadLen ) + if ( message->hdr.payloadLen == sizeof( BOOL ) ) { - result = signalUserConfirmationOfTreatmentParameters(); + BOOL confirmed; + + memcpy( &confirmed, message->payload, sizeof( BOOL ) ); + if ( TRUE == confirmed ) + { + result = signalUserConfirmationOfTreatmentParameters(); + } + else + { + result = signalUserRejectionOfTreatmentParameters(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); @@ -1604,15 +1676,14 @@ * @brief * The sendTreatmentParametersResponseMsg function constructs a treatment parameters * response to the UI and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : Treatment parameters response msg constructed and queued. - * @param accepted T/F - are settings ok? + * @details Inputs: none + * @details Outputs: Treatment parameters response msg constructed and queued. + * @param rejected T/F - are settings rejected? * @param rejectReasons reasons each parameter was rejected (if not accepted) * @param byteLength number of bytes that array of reject reasons takes * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentParametersResponseMsg( BOOL accepted, U08 *rejectReasons, U32 byteLength ) +BOOL sendTreatmentParametersResponseMsg( BOOL rejected, U08 *rejectReasons, U32 byteLength ) { BOOL result; MESSAGE_T msg; @@ -1623,7 +1694,7 @@ msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + memcpy( payloadPtr, &rejected, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, rejectReasons, byteLength ); @@ -1637,9 +1708,8 @@ * @brief * The handleChangeUFSettingsRequest function handles a ultrafiltration * change settings request message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1663,9 +1733,8 @@ * @brief * The handleChangeUFSettingsConfirmation function handles a ultrafiltration * change setting confirmation message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1689,9 +1758,8 @@ * @brief * The handleChangeTreatmentDurationRequest function handles a treatment * duration setting change message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1715,9 +1783,8 @@ * @brief * The handleChangeBloodDialysateRateChangeRequest function handles a blood * and dialysate rate settings change message from the UI. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1739,20 +1806,110 @@ { sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } +} + +/*********************************************************************//** + * @brief + * The handleChangePressureLimitsRequest function handles a pressure limits + * change message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangePressureLimitsRequest( MESSAGE_T *message ) +{ + if ( sizeof( PRESSURE_LIMIT_CHANGE_REQUEST_T ) == message->hdr.payloadLen ) + { + PRESSURE_LIMIT_CHANGE_REQUEST_T data; + + memcpy( &data, &message->payload[0], sizeof(PRESSURE_LIMIT_CHANGE_REQUEST_T) ); + + verifyPressureLimitsChange( &data ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleSalineBolusRequest function handles a saline bolus request + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSalineBolusRequest( MESSAGE_T *message ) +{ + if ( sizeof(BOOL) == message->hdr.payloadLen ) + { + SALINE_CMD_T cmd; + + memcpy( &cmd, &message->payload[0], sizeof(BOOL) ); + + if ( SALINE_CMD_START == cmd ) + { + signalStartSalineBolus(); + } + else + { + signalAbortSalineBolus(); + } + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendSalineBolusResponse function constructs a saline bolus start/abort + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameters response msg constructed and queued. + * @param accepted T/F - was saline bolus request accepted? + * @param rejReason reason why request was rejected (or zero if accepted) + * @param bolusVol volume (in mL) currently set for saline bolus + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendSalineBolusResponse( BOOL accepted, U32 rejReason, U32 bolusVol ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &bolusVol, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } /*********************************************************************//** * @brief * The handleDGOpMode function handles a DG broadcast of it's current mode. - * @details - * Inputs : none - * Outputs : message handled, response constructed and queued for transmit. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. * @param message a pointer to the message to handle. * @return none *************************************************************************/ void handleDGOpMode( MESSAGE_T *message ) { - U32 payloadSize = sizeof(U32) + sizeof(U32); + U32 payloadSize = sizeof(U32) + sizeof(U32); if ( message->hdr.payloadLen == payloadSize ) { @@ -1773,9 +1930,8 @@ /*********************************************************************//** * @brief * The handleFWVersionRequest function handles a request for HD f/w version. - * @details - * Inputs : none - * Outputs : message handled, response constructed and queued for transmit. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. * @param message a pointer to the message to handle. * @return none *************************************************************************/ @@ -1815,8 +1971,8 @@ * @brief * The sendDebugData function sends debug data out to the PC port. * @details - * Inputs : none - * Outputs : PC serial port + * @details Inputs: none + * @details Outputs: PC serial port * @param dbgData Pointer to debug data * @param len number of bytes of debug data * @return TRUE if debug data was successfully queued for transmit, FALSE if not @@ -1835,8 +1991,8 @@ * @brief * The sendDebugDataToUI function sends debug string to the UI for logging. * @details - * Inputs : none - * Outputs : Message constructed and queued for transmit + * @details Inputs: none + * @details Outputs: Message constructed and queued for transmit * @param str Pointer to debug string * @return none *************************************************************************/ @@ -1864,9 +2020,8 @@ * @brief * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. - * @details - * Inputs : testerLoggedIn - * Outputs : none + * @details Inputs: testerLoggedIn + * @details Outputs: none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) @@ -1879,9 +2034,8 @@ * The sendTestAckResponseMsg function constructs a simple response * message for a handled test message and queues it for transmit on the * appropriate UART channel. - * @details - * Inputs : none - * Outputs : response message constructed and queued for transmit. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param ack TRUE if test message was handled successfully, FALSE if not * @return TRUE if response message successfully queued for transmit, FALSE if not @@ -1907,9 +2061,8 @@ * @brief * The handleTesterLogInRequest function handles a request to login as a * tester. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1934,9 +2087,8 @@ * @brief * The handleTestOffButtonStateOverrideRequest function handles a request to * override the state of the off button. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1968,9 +2120,8 @@ * @brief * The handleTestStopButtonStateOverrideRequest function handles a request to * override the stop button state. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2001,9 +2152,8 @@ * @brief * The handleTestAlarmLampPatternOverrideRequest function handles a request to * override the alarm lamp pattern. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2034,9 +2184,8 @@ * @brief * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2067,9 +2216,8 @@ * @brief * The handleTestAlarmStateOverrideRequest function handles a request to * override the active status of a given alarm. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2100,9 +2248,8 @@ * @brief * The handleTestAlarmTimeOverrideRequest function handles a request to * override the time since activation of a given alarm. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2133,9 +2280,8 @@ * @brief * The handleTestAlarmStatusBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for alarm status. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2166,9 +2312,8 @@ * @brief * The handleTestBloodFlowSetPointOverrideRequest function handles a request to * override the set point for the blood flow rate (mL/min). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2181,14 +2326,7 @@ if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetTargetBloodFlowRateOverride( payload.setPt, payload.ctrlMode ); - } - else - { - result = testResetTargetBloodFlowRateOverride(); - } + result = testSetTargetBloodFlowRateOverride( payload.setPt, payload.ctrlMode ); } // respond to request @@ -2199,9 +2337,8 @@ * @brief * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to * override the measured blood flow rate (mL/min). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2227,14 +2364,45 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowSignalStrengthOverrideRequest function handles a + * request to override the measured blood flow signal strength (%). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredBloodFlowSignalStrengthOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodFlowSignalStrengthOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} /*********************************************************************//** * @brief * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump rotor speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2265,9 +2433,8 @@ * @brief * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2298,9 +2465,8 @@ * @brief * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump motor controller speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2331,9 +2497,8 @@ * @brief * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to * override the measured blood pump motor controller current (mA). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2364,9 +2529,8 @@ * @brief * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for blood flow data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2397,9 +2561,8 @@ * @brief * The handleTestDialInFlowSetPointOverrideRequest function handles a request to * override the set point for the dialysate inlet flow rate (mL/min). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2412,14 +2575,7 @@ if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetTargetDialInFlowRateOverride( payload.setPt, payload.ctrlMode ); - } - else - { - result = testResetTargetDialInFlowRateOverride(); - } + result = testSetTargetDialInFlowRateOverride( payload.setPt, payload.ctrlMode ); } // respond to request @@ -2430,9 +2586,8 @@ * @brief * The handleTestDialOutFlowSetPointOverrideRequest function handles a request to * override the set point for the dialysate outlet flow rate (mL/min). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2445,14 +2600,7 @@ if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetTargetDialOutFlowRateOverride( payload.setPt, payload.ctrlMode ); - } - else - { - result = testResetTargetDialOutFlowRateOverride(); - } + result = testSetTargetDialOutFlowRateOverride( payload.setPt, payload.ctrlMode ); } // respond to request @@ -2463,9 +2611,8 @@ * @brief * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to * override the measured dialysate inlet flow rate (mL/min). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2491,14 +2638,45 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowSignalStrengthOverrideRequest function handles a + * request to override the measured dialysate inlet flow signal strength (%). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialInFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredDialInFlowSignalStrengthOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInFlowSignalStrengthOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} /*********************************************************************//** * @brief * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump rotor speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2529,9 +2707,8 @@ * @brief * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2562,9 +2739,8 @@ * @brief * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump motor controller speed (RPM). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2595,9 +2771,8 @@ * @brief * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to * override the measured dialysate inlet pump motor controller current (mA). - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2628,9 +2803,8 @@ * @brief * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for dialysate inlet flow data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2661,9 +2835,8 @@ * @brief * The handleTestArterialPressureOverrideRequest function handles a request to * override the arterial pressure. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2694,9 +2867,8 @@ * @brief * The handleTestVenousPressureOverrideRequest function handles a request to * override the venous pressure. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2727,9 +2899,8 @@ * @brief * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to * override the blood pump occlusion sensor. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2760,9 +2931,8 @@ * @brief * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to * override the dialysate inlet pump occlusion sensor. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2793,9 +2963,8 @@ * @brief * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to * override the dialysate outlet pump occlusion sensor. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2826,9 +2995,8 @@ * @brief * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for pressure/occlusion data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2859,9 +3027,8 @@ * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2890,9 +3057,8 @@ * @brief * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for dialysate outlet pump data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2924,9 +3090,8 @@ * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a * request to override the ultrafiltration reference volume for the dialysate * outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2958,9 +3123,8 @@ * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a * request to override the ultrafiltration measured volume for the dialysate * outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -2992,9 +3156,8 @@ * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a * request to override the measured motor controller speed for the dialysate * outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3026,9 +3189,8 @@ * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a * request to override the measured motor controller current for the dialysate * outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3059,9 +3221,8 @@ * @brief * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a * request to override the measured speed for the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3092,9 +3253,8 @@ * @brief * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a * request to override the measured rotor speed for the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3125,9 +3285,8 @@ * @brief * The handleTestDialOutLoadCellWeightOverrideRequest function handles a * request to override the measured load cell weight for the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3158,9 +3317,8 @@ * @brief * The handleTestHDSafetyShutdownOverrideRequest function handles a * request to override the safety shutdown signal. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3191,9 +3349,8 @@ * @brief * The handleTestHDAccelOverrideRequest function handles a request to * override the measured accelerometer sensor readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3224,9 +3381,8 @@ * @brief * The handleTestHDAccelMaxOverrideRequest function handles a request to * override the measured accelerometer sensor maximum readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3257,9 +3413,8 @@ * @brief * The handleTestHDAccelBroadcastIntervalOverrideRequest function handles a * request to override the broadcast interval for accelerometer data messages. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3290,16 +3445,16 @@ * @brief * The handleSetAccelCalibration function handles a request to set * accelerometer calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetAccelCalibration( MESSAGE_T *message ) { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) { ACCEL_CAL_PAYLOAD_T payload; @@ -3316,16 +3471,16 @@ * @brief * The handleSetBloodFlowCalibration function handles a request to set * blood flow calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetBloodFlowCalibration( MESSAGE_T *message ) { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3342,16 +3497,16 @@ * @brief * The handleSetDialysateFlowCalibration function handles a request to set * dialysate flow calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDialysateFlowCalibration( MESSAGE_T *message ) { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3364,20 +3519,20 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** +/************************************************************************* * @brief - * The handleSetDialysateFlowCalibration function handles a request to set - * dialysate flow calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * The handleTestSetTreatmentParameter function handles a request to set + * a specific treatment parameter value. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTestSetTreatmentParameter( MESSAGE_T *message ) { BOOL result = FALSE; + // verify payload length if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) { CRITICAL_DATAS_T payload[2]; @@ -3390,4 +3545,414 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleHomeHDValve function handles a request to home an HD valve + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHomeHDValve( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 valve; + + memcpy( &valve, message->payload, sizeof(U32) ); + homeValve( (VALVE_T)valve ); + + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDValvesBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for HD valves data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDValvesBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetValvesDataPublishInterval( (U32)(payload.state.u32) ); + } + else + { + result = testResetValvesDataPublishInterval(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetAirTrapValve function handles a request to set the HD air + * (blood) trap valve to open or close + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAirTrapValve( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 valveState; + + memcpy( &valveState, message->payload, sizeof(U32) ); + setValveAirTrap( (OPN_CLS_STATE_T)valveState ); + + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetHDValvePositionOverrideRequest function handles a request to + * override the position of a valve + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDValvePositionOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetValvesPositionOverride( payload.index, (BOOL)(payload.state.u32) ); + } + else + { + result = testResetValvesPositionOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +#ifdef DEBUG_ENABLED +/*********************************************************************//** + * @brief + * The handleSetHDValvePWMOverrideRequest function handles a request to + * override the PWM of a valve + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDValvePWMOverrideRequest( MESSAGE_T *message ) +{ + OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetValvePWMOverride( payload.valve, payload.pwm, payload.direction ); + } + else + { + result = testResetValvePWMOverride( payload.valve ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} +#endif + +/************************************************************************* + * @brief + * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a + * request to override the air trap data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAirTrapBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetAirTrapDataPublishIntervalOverride( (U32)(payload.state.u32) ); + } + else + { + result = testResetAirTrapDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to + * override an air trap level sensor. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAirTrapLevelSensorOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)(payload.state.u32) ); + } + else + { + result = testResetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleHDSoftwareResetRequest function handles a request to reset the + * HD firmware processor. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHDSoftwareResetRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // tester must be logged in + if ( TRUE == isTestingActivated() ) + { // s/w reset of processor + result = TRUE; // reset will prevent this from getting transmitted though +#ifndef _VECTORCAST_ + systemREG1->SYSECR = (0x2) << 14; // reset processor +#endif + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpHomeRequest function handles a request to home + * the blood pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeBloodPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpHomeRequest function handles a request to home + * the dialysate inlet pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialInPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeDialInPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpHomeRequest function handles a request to home + * the dialysate outlet pump. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialOutPumpHomeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = homeDialOutPump(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSuperClearAlarmsRequest function handles a request to clear + * all active alarms. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 key; + + memcpy( &key, message->payload, sizeof(U32) ); + result = testClearAllAlarms( key ); + + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDCalibrationDataRequest function handles a request for + * HD calibration data. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + CALIBRATION_DATA_T cal; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // get calibration data + result = getCalibrationData( &cal ); + if ( TRUE == result ) + { + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; + msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); + + memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestEraseHDCalibrationDataRequest function handles a request for + * HD calibration data erasure. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 key; + + memcpy( &key, message->payload, sizeof(U32) ); + + result = testResetCalibrationData( key ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/