Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r7c8ec681f8c5dc44674893b5c3924a6203f2c8d0 -rd5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 7c8ec681f8c5dc44674893b5c3924a6203f2c8d0) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b) @@ -1,177 +1,81 @@ -/************************************************************************** - * - * Copyright (c) 2019-2020 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 SystemComm.c - * - * @date 10-Oct-2019 - * @author S. Nash - * - * @brief SystemComm service module. Provides system message communication \n - * functionality. Messages can be queued for transmission. Incoming messages \n - * are processed. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2020 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) Dara Navaei +* @date (last) 05-Oct-2020 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ #include // for memcpy() - + +#include "Accel.h" #include "AlarmLamp.h" #include "BloodFlow.h" #include "Buttons.h" #include "DGInterface.h" #include "DialInFlow.h" -#include "Dialysis.h" -#include "ModeTreatment.h" +#include "Dialysis.h" +#include "FPGA.h" +#include "MessagePayloads.h" +#include "ModeStandby.h" +#include "ModeTreatment.h" +#include "ModeTreatmentParams.h" #include "PresOccl.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 + * @{ + */ + // ********** private definitions ********** -#define ACK_REQUIRED TRUE -#define ACK_NOT_REQUIRED FALSE +#define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. +#define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. + +#ifdef DEBUG_ENABLED + #define DEBUG_EVENT_MAX_TEXT_LEN 40 +#endif -#pragma pack(push,1) - -typedef struct -{ - U08 confirmed; // 1 = confirmed, 0 = rejected/timed out -} OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T; - -typedef struct -{ - U32 alarmState; // 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority - U32 alarmTop; // ID of top active alarm - U32 escalatesIn; // seconds - U32 silenceExpiresIn; // seconds - U16 alarmsFlags; // bit flags: 1 = true, 0 = false for each bit -} ALARM_COMP_STATUS_PAYLOAD_T; - -typedef struct -{ - U32 setPoint; - F32 measFlow; - F32 measRotorSpd; - F32 measPumpSpd; - F32 measMCSpd; - F32 measMCCurr; - F32 pwmDC; -} PERISTALTIC_PUMP_STATUS_PAYLOAD_T; - -typedef struct -{ - F32 arterialPressure; - F32 venousPressure; - F32 bldPumpOcclusion; - F32 diPumpOcclusion; - F32 doPumpOcclusion; -} PRESSURE_OCCLUSION_DATA_T; - -typedef struct -{ - U32 treatmentTimePrescribedinSec; - U32 treatmentTimeElapsedinSec; - U32 treatmentTimeRemaininginSec; -} TREATMENT_TIME_DATA_T; - -typedef struct -{ - U32 treatmentSubMode; - U32 uFState; - U32 salineBolusState; -} TREATMENT_STATE_DATA_T; - -typedef struct -{ - F32 res1PrimaryLoadCell; - F32 res1BackupLoadCell; - F32 res2PrimaryLoadCell; - F32 res2BackupLoadCell; -} LOAD_CELL_READINGS_PAYLOAD_T; - -typedef struct -{ - U32 setPtPSI; - F32 measFlowRateMlMin; - F32 setPWM; -} DG_RO_PUMP_DATA_PAYLOAD_T; - -typedef struct -{ - U32 setPtRPM; - F32 setPWM; -} DG_DRAIN_PUMP_DATA_PAYLOAD_T; - -typedef struct -{ - F32 roInPSI; - F32 roOutPSI; - F32 drainInPSI; - F32 drainOutPSI; -} DG_PRESSURES_DATA_PAYLOAD_T; - -typedef struct -{ - U32 resID; - U32 setFillToVolumeMl; - U32 setDrainToVolumeMl; -} DG_RESERVOIRS_DATA_PAYLOAD_T; - -typedef struct -{ - F32 volume_mL; - U32 adjustType; -} UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T; - -typedef struct -{ - F32 TPi; - F32 TPo; - F32 TD1; - F32 TD2; - F32 TRo; - F32 TDi; - F32 HtrPrimThermo; - F32 HtrTrimThermo; - F32 HtrPrimColdJunc; - F32 HtrTrimColdJunc; - F32 HtrPrimInternal; - F32 HtrTrimInternal; -} DG_TEMPERATURES_T; - -#pragma pack(pop) - // ********** private data ********** -static BOOL testerLoggedIn = FALSE; -static volatile U16 nextSeqNo = 1; +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. +static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. // ********** private function prototypes ********** static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); -/************************************************************************* - * @brief serializeMessage - * The serializeMessage function serializes a given message into a given \n - * array of bytes. A sequence # is added to the message here and the ACK \n - * bit of the sequence # is set if ACK is required per parameter. A sync byte \n - * is inserted at the beginning of the message and an 8-bit CRC is appended to \n +/*********************************************************************//** + * @brief + * The serializeMessage function serializes a given message into a given + * array of bytes. A sequence # is added to the message here and the ACK + * 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. - * @param msg : message to serialize - * @param buffer : outgoing buffer that message should be queued in - * @param ackReq : is an acknowledgement from receiver required? + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? * @return size (in bytes) of serialized message populated in given data array. *************************************************************************/ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) @@ -230,7 +134,7 @@ if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) { error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) } } #endif @@ -244,14 +148,14 @@ return result; } -/************************************************************************* - * @brief sendACKMsg - * The sendACKMsg function constructs and queues for transmit an ACK message \n +/*********************************************************************//** + * @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. - * @param message : message to send an ACK for + * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ BOOL sendACKMsg( MESSAGE_T *message ) @@ -274,17 +178,17 @@ return result; } -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n +/*********************************************************************//** + * @brief + * 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. - * @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 + * @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 * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) @@ -308,15 +212,14 @@ // ***************** Message Sending Helper Functions ******************** // *********************************************************************** -/************************************************************************* - * @brief sendOffButtonMsgToUI - * The sendOffButtonMsgToUI function constructs an off button msg to the UI \n +/*********************************************************************//** + * @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. - * @param cmd : 0=prompt user to confirm, 1=cancel prompt, 2=reject user off \n - * request. + * @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 *************************************************************************/ BOOL sendOffButtonMsgToUI( U08 cmd ) @@ -336,22 +239,22 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendChangeUFSettingsResponse function constructs a UF change settings \n - * response to the UI and queues the msg for transmit on the appropriate CAN \n + * 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. - * @param accepted : T/F - are settings ok? - * @param reason : reason rejected (if not accepted) - * @param volume_mL : UF volume (in mL) - * @param time_min : treatment duration (in minutes) - * @param ufRate_mL_min : UF rate (in mL/min) - * @param timeDiff : change in treatment duration (in minutes) - * @param rateDiff : change in UF rate (in mL/min) - * @param oldUFRate_mL_min : the UF rate prior to this change (in mL/min) + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @param time_min treatment duration (in minutes) + * @param ufRate_mL_min UF rate (in mL/min) + * @param timeDiff change in treatment duration (in minutes) + * @param rateDiff change in UF rate (in mL/min) + * @param oldUFRate_mL_min the UF rate prior to this change (in mL/min) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff, F32 oldUFRate_mL_min ) @@ -387,19 +290,19 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendChangeUFSettingsResponse function constructs a UF change settings \n - * option response to the UI and queues the msg for transmit on the appropriate CAN \n + * 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. - * @param accepted : T/F - are settings ok? - * @param reason : reason rejected (if not accepted) - * @param volume_mL : UF volume (in mL) - * @param time_min : treatment duration (in minutes) - * @param ufRate_mL_min : UF rate (in mL/min) + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @param time_min treatment duration (in minutes) + * @param ufRate_mL_min UF rate (in mL/min) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendChangeUFSettingsOptionResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min ) @@ -429,18 +332,18 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendChangeTreatmentDurationResponse function constructs a treatment \n - * duration change response to the UI and queues the msg for transmit on the \n + * 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. - * @param accepted : T/F - are settings ok? - * @param reason : reason rejected (if not accepted) - * @param time_min : treatment duration (in minutes). - * @param volume_mL : UF volume (in mL). + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param time_min treatment duration (in minutes) + * @param volume_mL UF volume (in mL) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ) @@ -468,18 +371,18 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendChangeBloodDialysateRateChangeResponse function constructs a change \n - * blood and dialysate rate settings response to the UI and queues the msg for \n + * 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. - * @param accepted : T/F - are settings ok? - * @param reason : reason code for rejection or unused if accepted - * @param bloodRate : new blood flow rate - * @param dialRate : new dialysate flow rate + * @param accepted T/F - are settings ok? + * @param reason reason code for rejection or unused if accepted + * @param bloodRate new blood flow rate + * @param dialRate new dialysate flow rate * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendChangeBloodDialysateRateChangeResponse( BOOL accepted, U32 reason, U32 bloodRate, U32 dialRate ) @@ -507,19 +410,19 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendTreatmentParamsRangesToUI function constructs a treatment parameter \n + * 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. - * @param minTime : Minimum treatment duration (in minutes). - * @param maxTime : Maximum treatment duration (in minutes). - * @param minUFVol : Minimum ultrafiltration volume (in mL). - * @param maxUFVol : Maximum ultrafiltration volume (in mL). - * @param minDialRate : Minimum dialysate flow rate (in mL/min). - * @param maxDialRate : Maximum dialysate flow rate (in mL/min). + * @param minTime Minimum treatment duration (in minutes) + * @param maxTime Maximum treatment duration (in minutes) + * @param minUFVol Minimum ultrafiltration volume (in mL) + * @param maxUFVol Maximum ultrafiltration volume (in mL) + * @param minDialRate Minimum dialysate flow rate (in mL/min) + * @param maxDialRate Maximum dialysate flow rate (in mL/min) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ) @@ -551,15 +454,15 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDialysateTempTargetsToDG function constructs a dialysate temperature \n + * 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. - * @param primary : temperature set point for primary heater. - * @param trimmer : temperature set point for trimmer heater. + * @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 *************************************************************************/ BOOL sendDialysateTempTargetsToDG( F32 primary, F32 trimmer ) @@ -583,14 +486,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGSwitchReservoirCommand function constructs a DG set active \n + * 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. - * @param activeReservoir : reservoir ID to set as active. + * @param activeReservoir reservoir ID to set as active * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGSwitchReservoirCommand( U32 activeReservoir ) @@ -612,14 +515,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGFillCommand function constructs a DG fill command message \n + * 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. - * @param fillToVolumeMl : volume (in mL) to fill inactive reservoir to. + * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGFillCommand( U32 fillToVolumeMl ) @@ -641,14 +544,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGDrainCommand function constructs a DG drain command message \n + * 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. - * @param drainToVolumeMl : volume (in mL) to drain the inactive reservoir to. + * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGDrainCommand( U32 drainToVolumeMl ) @@ -670,14 +573,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGStartStopCommand function constructs a DG start/stop command \n + * 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. - * @param start : TRUE indicates start DG, FALSE indicates stop DG. + * @param start TRUE indicates start DG, FALSE indicates stop DG * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGStartStopCommand( BOOL start ) @@ -699,15 +602,15 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGStartStopTrimmerHeaterCommand function constructs a DG start/stop \n - * trimmer heater command message and queues the msg for transmit on the \n + * 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. - * @param start : TRUE indicates start heater, FALSE indicates stop heater. + * @param start TRUE indicates start heater, FALSE indicates stop heater * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ) @@ -729,9 +632,9 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The sendDGSampleWaterCommand function constructs a DG sample water command \n + * The sendDGSampleWaterCommand function constructs a DG sample water command * message and queues the msg for transmit on the appropriate CAN channel. * @details * Inputs : none @@ -753,15 +656,62 @@ return result; } - -/************************************************************************* - * @brief broadcastAlarmStatus - * The broadcastAlarmStatus function constructs an alarm status msg to \n + +/*********************************************************************//** + * @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. + * @param x X axis vector magnitude (in g) + * @param y Y axis vector magnitude (in g) + * @param z Z axis vector magnitude (in g) + * @param xm max X axis vector magnitude (in g) + * @param ym max Y axis vector magnitude (in g) + * @param zm max Z axis vector magnitude (in g) + * @param xt X axis tilt (in degrees) + * @param yt Y axis tilt (in degrees) + * @param zt Z axis tilt (in degrees) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + ACCEL_DATA_PAYLOAD_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_ACCELEROMETER_DATA; + msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); + payload.x = x; + payload.y = y; + payload.z = z; + payload.xMax = xm; + payload.yMax = ym; + payload.zMax = zm; + payload.xTilt = xt; + payload.yTilt = yt; + payload.zTilt = zt; + + memcpy( payloadPtr, &payload, sizeof( ACCEL_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 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. - * @param almStatus : alarm status record + * @param almStatus alarm status record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) @@ -798,16 +748,16 @@ return result; } -/************************************************************************* - * @brief broadcastAlarmTriggered - * The broadcastAlarmTriggered function constructs an alarm triggered msg to \n +/*********************************************************************//** + * @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. - * @param alarm : ID of alarm triggered - * @param almData1 : 1st data associated with alarm - * @param almData2 : 2nd data associated with alarm + * @param alarm ID of alarm triggered + * @param almData1 1st data associated with alarm + * @param almData2 2nd data associated with alarm * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmTriggered( U16 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) @@ -819,28 +769,32 @@ // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - msg.hdr.payloadLen = sizeof( U16 ) + sizeof( ALARM_DATA_T ) + sizeof( ALARM_DATA_T ); + msg.hdr.payloadLen = sizeof( U16 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each memcpy( payloadPtr, &alarm, sizeof( U16 ) ); payloadPtr += sizeof( U16 ); - memcpy( payloadPtr, &almData1, sizeof( ALARM_DATA_T ) ); - payloadPtr += sizeof( ALARM_DATA_T ); - memcpy( payloadPtr, &almData2, sizeof( ALARM_DATA_T ) ); + memcpy( payloadPtr, &almData1.dataType, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData1.data, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData2.dataType, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData2.data, 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_ALARM, ACK_REQUIRED ); return result; } -/************************************************************************* - * @brief broadcastAlarmCleared - * The broadcastAlarmCleared function constructs an alarm cleared msg to be \n +/*********************************************************************//** + * @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. - * @param alarm : ID of alarm cleared + * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastAlarmCleared( U16 alarm ) @@ -862,20 +816,20 @@ return result; } -/************************************************************************* - * @brief broadcastBloodFlowData - * The broadcastBloodFlowData function constructs a blood flow data msg to \n +/*********************************************************************//** + * @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 % + * @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 % * @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 ) @@ -906,20 +860,20 @@ return result; } -/************************************************************************* - * @brief broadcastDialInFlowData - * The broadcastDialInFlowData function constructs a dialysate flow data msg to \n +/*********************************************************************//** + * @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 % + * @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 % * @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 ) @@ -950,14 +904,14 @@ return result; } -/************************************************************************* - * @brief broadcastDialInFlowData - * The broadcastDialInFlowData function constructs a dialysate outlet flow data \n +/*********************************************************************//** + * @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. - * @param dialOutFlowData : Pointer to the dialysate out flow data record. + * @param dialOutFlowData Pointer to the dialysate out flow data record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastDialOutFlowData( DIAL_OUT_FLOW_DATA_T *dialOutFlowData ) @@ -979,18 +933,18 @@ return result; } -/************************************************************************* - * @brief broadcastPresOcclData - * The broadcastPresOcclData function constructs a pres/occl data msg to \n +/*********************************************************************//** + * @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 + * @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 * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastPresOcclData( F32 artPres, F32 venPres, F32 bpOccl, F32 diOccl, F32 doOccl ) @@ -1019,14 +973,14 @@ return result; } -/************************************************************************* - * @brief broadcastRTCEpoch - * The broadcastRTCEpoch function constructs an epoch msg to \n +/*********************************************************************//** + * @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 - * @param epoch : Current time and date in epoch + * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastRTCEpoch( U32 epoch ) @@ -1048,16 +1002,16 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The broadcastTreatmentTime function constructs a treatment time msg to \n + * 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 - * @param secsTotTreatment : Total treatment time prescribed (in seconds). - * @param secsElapsed : Treatment time elapsed (in seconds). - * @param secsRemaining : Treatment time remaining (in seconds). + * @param secsTotTreatment Total treatment time prescribed (in seconds) + * @param secsElapsed Treatment time elapsed (in seconds) + * @param secsRemaining Treatment time remaining (in seconds) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastTreatmentTime( U32 secsTotTreatment, U32 secsElapsed, U32 secsRemaining ) @@ -1084,19 +1038,19 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The broadcastTreatmentState function constructs a treatment state msg to \n + * 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 - * @param subMode : Current state (sub-mode) of treatment. - * @param uFState : Current state of ultrafiltration. - * @param salineBolusState : TRUE if saline bolus in progress, FALSE if not. + * @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 * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastTreatmentState( U32 subMode, U32 uFState, BOOL salineBolusState ) +BOOL broadcastTreatmentState( U32 subMode, U32 uFState, U32 salineBolusState ) { BOOL result; MESSAGE_T msg; @@ -1120,9 +1074,9 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The broadcastPowerOffWarning function constructs a power off warning msg to \n + * 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 @@ -1145,14 +1099,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The broadcastHDOperationMode function constructs an HD operation mode \n + * 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 - * @param mode : current HD operation mode. + * @param mode current HD operation mode * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastHDOperationMode( U32 mode, U32 subMode ) @@ -1174,7 +1128,35 @@ 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 + * 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; +} #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) @@ -1201,42 +1183,101 @@ // **************** Message Handling Helper Functions ******************** // *********************************************************************** -/************************************************************************* - * @brief handleDGCheckIn +/*********************************************************************//** + * @brief * The handleDGCheckIn function handles a check-in from the DG. * @details * Inputs : none * Outputs : check in the DG with the SystemComm module. - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGCheckIn( MESSAGE_T *message ) { checkInFromDG(); } -/************************************************************************* - * @brief handleUICheckIn +/*********************************************************************//** + * @brief * The handleUICheckIn function handles a check-in from the UI. * @details * Inputs : none * Outputs : check in the UI with the SystemComm module. - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleUICheckIn( MESSAGE_T *message ) { checkInFromUI(); } + +/*********************************************************************//** + * @brief + * The handleAlarmTriggered function handles a triggered alarm event message. + * @details + * Inputs : none + * Outputs : alarm triggered. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmTriggered( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == ( sizeof( U16 ) + sizeof( U32 ) * 2 * 2 ) ) // 2 data records w/ 2 U32s each + { + U08 *payloadPtr = message->payload; + U16 alarmID; + ALARM_DATA_T alm1, alm2; + + memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + payloadPtr += sizeof( U16 ); + memcpy( &alm1.dataType, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( &alm1.data, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( &alm2.dataType, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( &alm2.data, payloadPtr, sizeof( U32 ) ); + + if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) + { + activateAlarm2Data( (ALARM_ID_T)alarmID, alm1, alm2 ); + } + } +} + +/*********************************************************************//** + * @brief + * The handleAlarmCleared function handles a cleared alarm event message. + * @details + * Inputs : none + * Outputs : alarm cleared. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmCleared( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U16 ) ) + { + U08 *payloadPtr = message->payload; + U16 alarmID; + + memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + + if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) + { + clearAlarm( (ALARM_ID_T)alarmID ); + } + } +} -/************************************************************************* - * @brief handleOffButtonConfirmMsgFromUI - * The handleOffButtonConfirmMsgFromUI function handles a response to an \n +/*********************************************************************//** + * @brief + * The handleOffButtonConfirmMsgFromUI function handles a response to an * off button message to the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) @@ -1250,14 +1291,14 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleLoadCellReadingsFromDG function handles a load cell readings \n + * The handleLoadCellReadingsFromDG function handles a load cell readings * broadcast message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleLoadCellReadingsFromDG( MESSAGE_T *message ) @@ -1270,19 +1311,19 @@ memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); result = setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); - } + } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleDGTemperatureData function handles a temperature readings \n + * The handleDGTemperatureData function handles a temperature readings * broadcast message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGTemperatureData( MESSAGE_T *message ) @@ -1298,14 +1339,14 @@ // TODO - how to know if DG stops sending these? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleROPumpData function handles an RO pump data broadcast \n + * The handleROPumpData function handles an RO pump data broadcast * message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleROPumpData( MESSAGE_T *message ) @@ -1320,14 +1361,14 @@ // TODO - what to do if invalid payload length? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleDrainPumpData function handles a drain pump broadcast \n + * The handleDrainPumpData function handles a drain pump broadcast * message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDrainPumpData( MESSAGE_T *message ) @@ -1342,14 +1383,14 @@ // TODO - what to do if invalid payload length? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleDGPressuresData function handles a DG pressure sensor readings \n + * The handleDGPressuresData function handles a DG pressure sensor readings * broadcast message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGPressuresData( MESSAGE_T *message ) @@ -1364,14 +1405,14 @@ // TODO - what to do if invalid payload length? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleDGReservoirData function handles a reservoir data broadcast \n + * The handleDGReservoirData function handles a reservoir data broadcast * message from the DG. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDGReservoirData( MESSAGE_T *message ) @@ -1386,14 +1427,14 @@ // TODO - what to do if invalid payload length? } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleUFPauseResumeRequest function handles a ultrafiltration pause \n + * The handleUFPauseResumeRequest function handles a ultrafiltration pause * or resume request message from the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleUFPauseResumeRequest( MESSAGE_T *message ) @@ -1413,18 +1454,222 @@ { result = resumeUF(); } - } + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } -/************************************************************************* +/*********************************************************************//** + * @brief + * The handleUIStartTreatmentMsg function handles a treatment start/cancel + * message from the UI. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIStartTreatmentMsg( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + + if ( 0 == cmd ) // initiate treatment (go to treatment params mode) + { + result = signalUserStartingTreatment(); + } + else if ( 1 == cmd ) // cancel treatment (return from aborted treatment params mode) + { + result = signalUserCancelTreatment(); + } + else if ( 2 == cmd ) // start treatment + { + // TODO - handle when pre-treatment mode is ready for this + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * 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. + * @param accepted T/F - request accepted? + * @param reason reason code if rejected + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentStartResponseMsg( BOOL accepted, U32 reason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, 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 handleUIUserEndTreatmentRequest function handles a treatment end + * request message from the UI. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIUserEndTreatmentRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == 0 ) + { + result = userRequestEndTreatment(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * 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. + * @param accepted T/F - request accepted? + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentEndResponseMsg( BOOL accepted ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_END_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + + // 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 handleTreatmentParametersFromUI function handles a treatment parameters + * set and validate request message from the UI. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentParametersFromUI( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(TREATMENT_PARAMS_DATA_PAYLOAD_T) ) + { + TREATMENT_PARAMS_DATA_PAYLOAD_T treatmentParams; + + memcpy( &treatmentParams, message->payload, sizeof(TREATMENT_PARAMS_DATA_PAYLOAD_T) ); + + result = validateAndSetTreatmentParameters( treatmentParams ); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The handleUIUserConfirmTreatmentParameters function handles a user confirmation + * of treatment parameters message from the UI. + * @details + * Inputs : none + * 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 ) + { + result = signalUserConfirmationOfTreatmentParameters(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @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? + * @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 result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, rejectReasons, byteLength ); + + // 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 handleChangeUFSettingsRequest function handles a ultrafiltration \n + * The handleChangeUFSettingsRequest function handles a ultrafiltration * change settings request message from the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleChangeUFSettingsRequest( MESSAGE_T *message ) @@ -1443,14 +1688,14 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleChangeUFSettingsConfirmation function handles a ultrafiltration \n + * The handleChangeUFSettingsConfirmation function handles a ultrafiltration * change setting confirmation message from the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleChangeUFSettingsConfirmation( MESSAGE_T *message ) @@ -1469,14 +1714,14 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleChangeTreatmentDurationRequest function handles a treatment \n + * The handleChangeTreatmentDurationRequest function handles a treatment * duration setting change message from the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleChangeTreatmentDurationRequest( MESSAGE_T *message ) @@ -1495,14 +1740,14 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleChangeBloodDialysateRateChangeRequest function handles a blood \n + * The handleChangeBloodDialysateRateChangeRequest function handles a blood * and dialysate rate settings change message from the UI. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) @@ -1525,13 +1770,13 @@ } } -/************************************************************************* +/*********************************************************************//** * @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. - * @param message : a pointer to the message to handle. + * @param message a pointer to the message to handle. * @return none *************************************************************************/ void handleDGOpMode( MESSAGE_T *message ) @@ -1554,37 +1799,36 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief * The handleFWVersionRequest function handles a request for HD f/w version. * @details * Inputs : none * Outputs : message handled, response constructed and queued for transmit. - * @param message : a pointer to the message to handle. + * @param message a pointer to the message to handle. * @return none *************************************************************************/ void handleFWVersionRequest( MESSAGE_T *message ) { - MESSAGE_T msg; - U08 major = (U08)HD_VERSION_MAJOR; - U08 minor = (U08)HD_VERSION_MINOR; - U08 micro = (U08)HD_VERSION_MICRO; - U16 build = (U16)HD_VERSION_BUILD; - U08 *payloadPtr = msg.payload; + MESSAGE_T msg; + HD_VERSIONS_T payload; + U08 *payloadPtr = msg.payload; + + // populate payload + payload.major = (U08)HD_VERSION_MAJOR; + payload.minor = (U08)HD_VERSION_MINOR; + payload.micro = (U08)HD_VERSION_MICRO; + payload.build = (U16)HD_VERSION_BUILD; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_VERSION; - msg.hdr.payloadLen = sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ); + msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); + + // fill message payload + memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); - memcpy( payloadPtr, &major, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &minor, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, µ, sizeof( U08 ) ); - payloadPtr += sizeof( U08 ); - memcpy( payloadPtr, &build, sizeof( U16 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } @@ -1595,53 +1839,80 @@ *************************************************************************/ -/************************************************************************* - * @brief sendDebugData - * The sendDebugData function sends debug data out to the PC port. - * @details - * Inputs : none - * Outputs : PC serial port - * @param dbgData : Pointer to debug data - * @param len : # of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ -#ifdef DEBUG_ENABLED -BOOL sendDebugData( U08 *dbgData, U32 len ) -{ - BOOL result; +#ifdef DEBUG_ENABLED + /*********************************************************************//** + * @brief + * The sendDebugData function sends debug data out to the PC port. + * @details + * Inputs : none + * 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 + *************************************************************************/ + BOOL sendDebugData( U08 *dbgData, U32 len ) + { + BOOL result; - // add serialized message data to appropriate comm buffer - result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); + // add serialized message data to appropriate comm buffer + result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); - return result; -} -#endif + return result; + } + + /*********************************************************************//** + * @brief + * The sendDebugDataToUI function sends debug string to the UI for logging. + * @details + * Inputs : none + * Outputs : Message constructed and queued for transmit + * @param str Pointer to debug string + * @return none + *************************************************************************/ + void sendDebugDataToUI( U08 *str ) + { + MESSAGE_T msg; + U32 txtLen = strlen( (char*)str ); + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_DEBUG_EVENT; + msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // add 1 byte for null terminator + if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) + { + memcpy( payloadPtr, str, txtLen + 1 ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); + } + } +#endif -/************************************************************************* - * @brief isTestingActivated - * The isTestingActivated function determines whether a tester has successfully \n +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. * @details * Inputs : testerLoggedIn * Outputs : none - * @param none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) { return testerLoggedIn; } -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n +/*********************************************************************//** + * @brief + * 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. - * @param msgID : ID of handled message that we are responding to - * @param ack : TRUE if test message was handled successfully, FALSE if not + * @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 *************************************************************************/ static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) @@ -1661,14 +1932,14 @@ return result; } -/************************************************************************* - * @brief handleTesterLogInRequest - * The handleTesterLogInRequest function handles a request to login as a \n +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a * tester. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) @@ -1678,6 +1949,7 @@ if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) { testerLoggedIn = TRUE; + checkInFromUI(); // allow tasks to begin normal processing when tester has logged in } else { @@ -1687,491 +1959,1615 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } -/************************************************************************* - * @brief handleTestHDMessageRequest - * The handleTestHDMessageRequest function handles a request to add an \n - * HD message to the received message queue. - * @details - * Inputs : none - * Outputs : message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestHDMessageRequest( MESSAGE_T *message ) -{ - MESSAGE_WRAPPER_T hdMessage; - U32 msgLen = (U32)(message->hdr.payloadLen); - U08 *msgBytes = (U08*)(&(hdMessage)); - BOOL result; - - memcpy( msgBytes, message->payload, msgLen ); - - // add HD message to received message queue - result = addToMsgQueue( MSG_Q_IN, &hdMessage ); - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/************************************************************************* - * @brief handleTestOffButtonStateOverrideRequest - * The handleTestOffButtonStateOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestOffButtonStateOverrideRequest function handles a request to * override the state of the off button. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( BUTTON_STATE_T, handleTestOffButtonStateOverrideRequest, testSetOffButtonStateOverride, testResetOffButtonStateOverride ) +void handleTestOffButtonStateOverrideRequest( 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 = testSetOffButtonStateOverride( payload.state.u32 ); + } + else + { + result = testResetOffButtonStateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestStopButtonStateOverrideRequest - * The handleTestStopButtonStateOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestStopButtonStateOverrideRequest function handles a request to * override the stop button state. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( BUTTON_STATE_T, handleTestStopButtonStateOverrideRequest, testSetStopButtonStateOverride, testResetStopButtonStateOverride ) +void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = 0; + + // 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 = testSetStopButtonStateOverride( payload.state.u32 ); + } + else + { + result = testResetStopButtonStateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestAlarmLampPatternOverrideRequest - * The handleTestAlarmLampPatternOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestAlarmLampPatternOverrideRequest function handles a request to * override the alarm lamp pattern. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( LAMP_PATTERN_T, handleTestAlarmLampPatternOverrideRequest, testSetCurrentLampPatternOverride, testResetCurrentLampPatternOverride ) +void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = 0; + + // 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 = testSetCurrentLampPatternOverride( payload.state.u32 ); + } + else + { + result = testResetCurrentLampPatternOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestWatchdogCheckInStateOverrideRequest - * The handleTestWatchdogCheckInStateOverrideRequest function handles a \n +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestWatchdogCheckInStateOverrideRequest, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride ) +void handleTestWatchdogCheckInStateOverrideRequest( 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 = testSetWatchdogTaskCheckInOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetWatchdogTaskCheckInOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestAlarmStateOverrideRequest - * The handleTestAlarmStateOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestAlarmStateOverrideRequest function handles a request to * override the active status of a given alarm. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestAlarmStateOverrideRequest, testSetAlarmStateOverride, testResetAlarmStateOverride ) +void handleTestAlarmStateOverrideRequest( 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 = testSetAlarmStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetAlarmStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestAlarmTimeOverrideRequest - * The handleTestAlarmTimeOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestAlarmTimeOverrideRequest function handles a request to * override the time since activation of a given alarm. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestAlarmTimeOverrideRequest, testSetAlarmStartOverride, testResetAlarmStartOverride ) +void handleTestAlarmTimeOverrideRequest( 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 = testSetAlarmStartOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetAlarmStartOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestAlarmStatusBroadcastIntervalOverrideRequest - * The handleTestAlarmStatusBroadcastIntervalOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestAlarmStatusBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for alarm status. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestAlarmStatusBroadcastIntervalOverrideRequest, testSetAlarmStatusPublishIntervalOverride, testResetAlarmStatusPublishIntervalOverride ) +void handleTestAlarmStatusBroadcastIntervalOverrideRequest( 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 = testSetAlarmStatusPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmStatusPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodFlowSetPointOverrideRequest - * The handleTestBloodFlowSetPointOverrideRequest function handles a request to \n +/*********************************************************************//** + * @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 - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestBloodFlowSetPointOverrideRequest, testSetTargetBloodFlowRateOverride, testResetTargetBloodFlowRateOverride ) +void handleTestBloodFlowSetPointOverrideRequest( MESSAGE_T *message ) +{ + OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + 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(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodFlowMeasuredOverrideRequest - * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to * override the measured blood flow rate (mL/min). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodFlowMeasuredOverrideRequest, testSetMeasuredBloodFlowRateOverride, testResetMeasuredBloodFlowRateOverride ) +void handleTestBloodFlowMeasuredOverrideRequest( 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 = testSetMeasuredBloodFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodPumpRotorMeasuredSpeedOverrideRequest - * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump rotor speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodPumpRotorMeasuredSpeedOverrideRequest, testSetMeasuredBloodPumpRotorSpeedOverride, testResetMeasuredBloodPumpRotorSpeedOverride ) +void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( 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 = testSetMeasuredBloodPumpRotorSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodPumpRotorSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodPumpMeasuredSpeedOverrideRequest - * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodPumpMeasuredSpeedOverrideRequest, testSetMeasuredBloodPumpSpeedOverride, testResetMeasuredBloodPumpSpeedOverride ) +void handleTestBloodPumpMeasuredSpeedOverrideRequest( 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 = testSetMeasuredBloodPumpSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodPumpSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodPumpMCMeasuredSpeedOverrideRequest - * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to * override the measured blood pump motor controller speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodPumpMCMeasuredSpeedOverrideRequest, testSetMeasuredBloodPumpMCSpeedOverride, testResetMeasuredBloodPumpMCSpeedOverride ) +void handleTestBloodPumpMCMeasuredSpeedOverrideRequest( 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 = testSetMeasuredBloodPumpMCSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodPumpMCSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodPumpMCMeasuredCurrentOverrideRequest - * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to * override the measured blood pump motor controller current (mA). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodPumpMCMeasuredCurrentOverrideRequest, testSetMeasuredBloodPumpMCCurrentOverride, testResetMeasuredBloodPumpMCCurrentOverride ) +void handleTestBloodPumpMCMeasuredCurrentOverrideRequest( 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 = testSetMeasuredBloodPumpMCCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredBloodPumpMCCurrentOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodFlowBroadcastIntervalOverrideRequest - * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for blood flow data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestBloodFlowBroadcastIntervalOverrideRequest, testSetBloodFlowDataPublishIntervalOverride, testResetBloodFlowDataPublishIntervalOverride ) +void handleTestBloodFlowBroadcastIntervalOverrideRequest( 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 = testSetBloodFlowDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetBloodFlowDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInFlowSetPointOverrideRequest - * The handleTestDialInFlowSetPointOverrideRequest function handles a request to \n +/*********************************************************************//** + * @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 - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDialInFlowSetPointOverrideRequest, testSetTargetDialInFlowRateOverride, testResetTargetDialInFlowRateOverride ) +void handleTestDialInFlowSetPointOverrideRequest( MESSAGE_T *message ) +{ + OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + 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(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInFlowMeasuredOverrideRequest - * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to \n +/*********************************************************************//** + * @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 + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDialOutFlowSetPointOverrideRequest( MESSAGE_T *message ) +{ + OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + 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(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to * override the measured dialysate inlet flow rate (mL/min). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialInFlowMeasuredOverrideRequest, testSetMeasuredDialInFlowRateOverride, testResetMeasuredDialInFlowRateOverride ) +void handleTestDialInFlowMeasuredOverrideRequest( 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 = testSetMeasuredDialInFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInPumpRotorMeasuredSpeedOverrideRequest - * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump rotor speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialInPumpRotorMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpRotorSpeedOverride, testResetMeasuredDialInPumpRotorSpeedOverride ) +void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( 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 = testSetMeasuredDialInPumpRotorSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInPumpRotorSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInPumpMeasuredSpeedOverrideRequest - * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialInPumpMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpSpeedOverride, testResetMeasuredDialInPumpSpeedOverride ) +void handleTestDialInPumpMeasuredSpeedOverrideRequest( 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 = testSetMeasuredDialInPumpSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInPumpSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInPumpMCMeasuredSpeedOverrideRequest - * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to * override the measured dialysate inlet pump motor controller speed (RPM). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialInPumpMCMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpMCSpeedOverride, testResetMeasuredDialInPumpMCSpeedOverride ) +void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( 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 = testSetMeasuredDialInPumpMCSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInPumpMCSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInPumpMCMeasuredCurrentOverrideRequest - * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to * override the measured dialysate inlet pump motor controller current (mA). * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialInPumpMCMeasuredCurrentOverrideRequest, testSetMeasuredDialInPumpMCCurrentOverride, testResetMeasuredDialInPumpMCCurrentOverride ) +void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( 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 = testSetMeasuredDialInPumpMCCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialInPumpMCCurrentOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialInFlowBroadcastIntervalOverrideRequest - * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for dialysate inlet flow data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDialInFlowBroadcastIntervalOverrideRequest, testSetDialInFlowDataPublishIntervalOverride, testResetDialInFlowDataPublishIntervalOverride ) +void handleTestDialInFlowBroadcastIntervalOverrideRequest( 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 = testSetDialInFlowDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDialInFlowDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestArterialPressureOverrideRequest - * The handleTestArterialPressureOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestArterialPressureOverrideRequest function handles a request to * override the arterial pressure. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestArterialPressureOverrideRequest, testSetArterialPressureOverride, testResetArterialPressureOverride ) +void handleTestArterialPressureOverrideRequest( 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 = testSetArterialPressureOverride( payload.state.f32 ); + } + else + { + result = testResetArterialPressureOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestVenousPressureOverrideRequest - * The handleTestVenousPressureOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestVenousPressureOverrideRequest function handles a request to * override the venous pressure. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestVenousPressureOverrideRequest, testSetVenousPressureOverride, testResetVenousPressureOverride ) +void handleTestVenousPressureOverrideRequest( 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 = testSetVenousPressureOverride( payload.state.f32 ); + } + else + { + result = testResetVenousPressureOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestBloodPumpOcclusionOverrideRequest - * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to * override the blood pump occlusion sensor. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestBloodPumpOcclusionOverrideRequest, testSetBloodPumpOcclusionOverride, testResetBloodPumpOcclusionOverride ) +void handleTestBloodPumpOcclusionOverrideRequest( 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 = testSetBloodPumpOcclusionOverride( payload.state.f32 ); + } + else + { + result = testResetBloodPumpOcclusionOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialysateInletPumpOcclusionOverrideRequest - * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to * override the dialysate inlet pump occlusion sensor. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialysateInletPumpOcclusionOverrideRequest, testSetDialInPumpOcclusionOverride, testResetDialInPumpOcclusionOverride ) +void handleTestDialysateInletPumpOcclusionOverrideRequest( 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 = testSetDialInPumpOcclusionOverride( payload.state.f32 ); + } + else + { + result = testResetDialInPumpOcclusionOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestDialysateOutletPumpOcclusionOverrideRequest - * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to * override the dialysate outlet pump occlusion sensor. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialysateOutletPumpOcclusionOverrideRequest, testSetDialOutPumpOcclusionOverride, testResetDialOutPumpOcclusionOverride ) +void handleTestDialysateOutletPumpOcclusionOverrideRequest( 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 = testSetDialOutPumpOcclusionOverride( payload.state.f32 ); + } + else + { + result = testResetDialOutPumpOcclusionOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleTestPresOcclBroadcastIntervalOverrideRequest - * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to \n +/*********************************************************************//** + * @brief + * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to * override the broadcast interval for pressure/occlusion data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestPresOcclBroadcastIntervalOverrideRequest, testSetPresOcclDataPublishIntervalOverride, testResetPresOcclDataPublishIntervalOverride ) +void handleTestPresOcclBroadcastIntervalOverrideRequest( 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 = testSetPresOcclDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetPresOcclDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* - * @brief handleSetRTCTimestamp +/*********************************************************************//** + * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetRTCTimestamp( MESSAGE_T *message ) { - BOOL result; - U08 seconds = message->payload[0]; - U08 minutes = message->payload[1]; - U08 hours = message->payload[2]; - U08 days = message->payload[3]; - U08 months = message->payload[4]; - U32 years; + BOOL result = FALSE; - memcpy(&years, &message->payload[5], sizeof(U32)); - result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); + if ( message->hdr.payloadLen == 9 ) // TODO - add payload structure to RTC.h and use a structure to import payload. + { + U08 seconds = message->payload[0]; + U08 minutes = message->payload[1]; + U08 hours = message->payload[2]; + U08 days = message->payload[3]; + U08 months = message->payload[4]; + U32 years; + memcpy(&years, &message->payload[5], sizeof(U32)); + result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles \n + * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for dialysate outlet pump data. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDialOutFlowBroadcastIntervalOverrideRequest, testSetDialOutPumpAndLoadCellDataPublishIntervalOverride, testResetDialOutPumpAndLoadCellDataPublishIntervalOverride ) +void handleTestDialOutFlowBroadcastIntervalOverrideRequest( 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 = testSetDialOutPumpAndLoadCellDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDialOutPumpAndLoadCellDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a \n - * request to override the ultrafiltration reference volume for the dialysate \n + * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a + * request to override the ultrafiltration reference volume for the dialysate * outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutUFReferenceVolumeOverrideRequest, testSetDialOutUFRefVolumeOverride, testResetDialOutUFRefVolumeOverride ) +void handleTestDialOutUFReferenceVolumeOverrideRequest( 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 = testSetDialOutUFRefVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetDialOutUFRefVolumeOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a \n - * request to override the ultrafiltration measured volume for the dialysate \n + * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a + * request to override the ultrafiltration measured volume for the dialysate * outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutUFMeasuredVolumeOverrideRequest, testSetDialOutUFTotVolumeOverride, testResetDialOutUFTotVolumeOverride ) +void handleTestDialOutUFMeasuredVolumeOverrideRequest( 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 = testSetDialOutUFTotVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetDialOutUFTotVolumeOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a \n - * request to override the measured motor controller speed for the dialysate \n + * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a + * request to override the measured motor controller speed for the dialysate * outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutPumpMCMeasuredSpeedOverrideRequest, testSetMeasuredDialOutPumpMCSpeedOverride, testResetMeasuredDialOutPumpMCSpeedOverride ) +void handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( 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 = testSetMeasuredDialOutPumpMCSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialOutPumpMCSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a \n - * request to override the measured motor controller current for the dialysate \n + * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a + * request to override the measured motor controller current for the dialysate * outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutPumpMCMeasuredCurrentOverrideRequest, testSetMeasuredDialOutPumpMCCurrentOverride, testResetMeasuredDialOutPumpMCCurrentOverride ) +void handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( 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 = testSetMeasuredDialOutPumpMCCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialOutPumpMCCurrentOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a \n + * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a * request to override the measured speed for the dialysate outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutPumpMeasuredSpeedOverrideRequest, testSetMeasuredDialOutPumpSpeedOverride, testResetMeasuredDialOutPumpSpeedOverride ) +void handleTestDialOutPumpMeasuredSpeedOverrideRequest( 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 = testSetMeasuredDialOutPumpSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialOutPumpSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a \n + * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a * request to override the measured rotor speed for the dialysate outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest, testSetMeasuredDialOutPumpRotorSpeedOverride, testResetMeasuredDialOutPumpRotorSpeedOverride ) +void handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( 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 = testSetMeasuredDialOutPumpRotorSpeedOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredDialOutPumpRotorSpeedOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestDialOutLoadCellWeightOverrideRequest function handles a \n + * The handleTestDialOutLoadCellWeightOverrideRequest function handles a * request to override the measured load cell weight for the dialysate outlet pump. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDialOutLoadCellWeightOverrideRequest, testSetDialOutLoadCellWeightOverride, testResetDialOutLoadCellWeightOverride ) +void handleTestDialOutLoadCellWeightOverrideRequest( 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 = testSetDialOutLoadCellWeightOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetDialOutLoadCellWeightOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestHDSafetyShutdownOverrideRequest function handles a \n + * The handleTestHDSafetyShutdownOverrideRequest function handles a * request to override the safety shutdown signal. * @details * Inputs : none * Outputs : message handled - * @param message : a pointer to the message to handle + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestHDSafetyShutdownOverrideRequest, testSetSafetyShutdownOverride, testResetSafetyShutdownOverride ) +void handleTestHDSafetyShutdownOverrideRequest( 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 = testSetSafetyShutdownOverride( payload.state.u32 ); + } + else + { + result = testResetSafetyShutdownOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDAccelOverrideRequest function handles a request to + * override the measured accelerometer sensor readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDAccelOverrideRequest( 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 = testSetAccelAxisOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelAxisOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDAccelMaxOverrideRequest function handles a request to + * override the measured accelerometer sensor maximum readings. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDAccelMaxOverrideRequest( 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 = testSetAccelMaxOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelMaxOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDAccelBroadcastIntervalOverrideRequest function handles a + * request to override the broadcast interval for accelerometer data messages. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDAccelBroadcastIntervalOverrideRequest( 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 = testSetAccelDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAccelDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetAccelCalibration function handles a request to set + * accelerometer calibration factors. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetAccelCalibration( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) + { + ACCEL_CAL_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); + result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBloodFlowCalibration function handles a request to set + * blood flow calibration factors. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBloodFlowCalibration( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) + { + LINEAR_F32_CAL_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); + result = setBloodFlowCalibration( payload.gain, payload.offset ); + } + + // respond to request + 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 + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetDialysateFlowCalibration( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) + { + LINEAR_F32_CAL_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(LINEAR_F32_CAL_PAYLOAD_T) ); + result = setDialInFlowCalibration( payload.gain, payload.offset ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleHomeHDValve function handles a request to home an HD valve + * @details + * Inputs: none + * Outputs: message handled + * @param message: a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHomeHDValve( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + 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 \n + * a request to override the broadcast interval for HD valves data. + * @details + * Inputs: none + * 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( (BOOL)(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 + * 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 + * 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 + * 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 handleSetDialysateFlowCalibration function handles a request to set + * dialysate flow calibration factors. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetTreatmentParameter( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) + { + CRITICAL_DATAS_T payload[2]; + + memcpy( &payload[0], message->payload, sizeof(CRITICAL_DATAS_T) * 2 ); + result = testSetTreatmentParameter( (TREATMENT_PARAM_T)payload[0].uInt, payload[1] ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/**@}*/