Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb01542f8e4ef5a29e9b08fc0d465478de516bf02 -r43e59e505bbea87c76822c51a3273eec3f4addaa --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b01542f8e4ef5a29e9b08fc0d465478de516bf02) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 43e59e505bbea87c76822c51a3273eec3f4addaa) @@ -1,408 +1,570 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 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 +* @file SystemCommMessages.c * -* @author (last) Sean Nash -* @date (last) 14-Oct-2020 +* @author (last) Dara Navaei +* @date (last) 14-Jun-2022 * -* @author (original) Dara Navaei -* @date (original) 05-Nov-2019 +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 * ***************************************************************************/ - -#include // for memcpy() -#include "reg_system.h" +#include // For memcpy() -#include "Accel.h" -#include "AlarmLamp.h" -#include "Buttons.h" -#include "DGInterface.h" +#include "reg_system.h" // Used to access system register to reset processor on request + +#include "Accel.h" +#include "AlarmLamp.h" +#include "Battery.h" +#include "Buttons.h" +#include "Compatible.h" +#include "ConsumableSelfTest.h" +#include "Fans.h" #include "FPGA.h" -#include "ModePreTreat.h" -#include "ModeStandby.h" -#include "ModeTreatment.h" -#include "ModeTreatmentParams.h" -#include "PresOccl.h" +#include "ModeStandby.h" +#include "OperationModes.h" #include "RTC.h" -#include "SafetyShutdown.h" -#include "SystemComm.h" -#include "SystemCommMessages.h" +#include "SampleWater.h" +#include "SafetyShutdown.h" +#include "SystemComm.h" +#include "SystemCommMessages.h" +#include "Temperatures.h" +#include "TreatmentEnd.h" +#include "TreatmentRecirc.h" +#include "TreatmentStop.h" #include "Utilities.h" -#include "Valves.h" -#include "WatchdogMgmt.h" - +#include "Valves.h" +#include "WatchdogMgmt.h" +#include "HDDefs.h" + /** * @addtogroup SystemCommMessages * @{ */ -// ********** private definitions ********** - -#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. +// ********** private definitions ********** -#ifdef DEBUG_ENABLED - #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif - -// ********** private data ********** - -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 - * 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 - * @details Outputs: given data array populated with serialized message data and queued for transmit. - * @param msg message to serialize - * @param buffer outgoing buffer that message should be queued in - * @param ackReq is an acknowledgement from receiver required? - * @return size (in bytes) of serialized message populated in given data array. - *************************************************************************/ -static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) -{ - BOOL result = 0; - BOOL error = FALSE; - U32 msgSize = 0; - U32 sizeMod, sizePad; - U32 i; - U08 crc; - U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data - - // prefix data with message sync byte - data[ msgSize++ ] = MESSAGE_SYNC_BYTE; - - // set sequence # and ACK bit (unless this is an ACK to a received message) - if ( msg.hdr.msgID != MSG_ID_ACK ) - { - // thread protect next sequence # access & increment - _disable_IRQ(); - msg.hdr.seqNo = nextSeqNo; - nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); - _enable_IRQ(); - if ( TRUE == ackReq ) - { - msg.hdr.seqNo *= -1; - } - } - - // calculate message CRC - crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - - // serialize message header data - memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); - msgSize += sizeof( MESSAGE_HEADER_T ); - - // serialize message payload (only used bytes per payloadLen field) - memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); - msgSize += msg.hdr.payloadLen; - - // add 8-bit CRC - data[ msgSize++ ] = crc; - - // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) - sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; - sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); - for ( i = 0; i < sizePad; i++ ) - { - data[ msgSize++ ] = 0; - } - -#ifndef DISABLE_ACK_ERRORS - // if ACK required, add to pending ACK list - if ( TRUE == ackReq ) - { - if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) - { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) - } - } -#endif - - if ( FALSE == error ) - { - // add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The sendACKMsg function constructs and queues for transmit an ACK message - * for a given received message. - * @details Inputs: none - * @details Outputs: ACK message queued for transmit on broadcast CAN channel. - * @param message message to send an ACK for - * @return TRUE if ACK message queued successfully, FALSE if not - *************************************************************************/ -BOOL sendACKMsg( MESSAGE_T *message ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - // send ACK back with same seq. #, but w/o ACK bit - msg.hdr.seqNo = message->hdr.seqNo * -1; - // ACK messages always have this ID - msg.hdr.msgID = MSG_ID_ACK; - // ACK messages always have no payload - msg.hdr.payloadLen = 0; - - // serialize and queue the message for transmit on broadcast channel - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @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 - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param buffer outgoing buffer that message should be queued in - * @param ack TRUE if test message was handled successfully, FALSE if not - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); - - return result; -} - -// *********************************************************************** -// ***************** Message Sending Helper Functions ******************** -// *********************************************************************** - -/*********************************************************************//** - * @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 - * @details Outputs: Off button msg constructed and queued. - * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 cmd ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = cmd; - - // 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_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * 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 - * @details Outputs: UF change settings response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param volume_mL UF volume (in mL) - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); - payloadPtr += sizeof( S32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); - - // 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; +#define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. + +#pragma pack(push,1) +/// Payload record structure for block message transmission request. +typedef struct +{ + U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; +} BLOCKED_MSGS_DATA_T; +#pragma pack(pop) + +// ********** private data ********** + +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. +/// List of message IDs that are requested not to be transmitted. +static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// ********** private function prototypes ********** + +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); +static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ); + +/*********************************************************************//** + * @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: blockedMessagesForXmit + * @details Outputs: given data array populated with serialized message data and queued for transmit. + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? + * @return size (in bytes) of serialized message populated in given data array. + *************************************************************************/ +U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) +{ + BOOL result = 0; + BOOL error = FALSE; + BOOL blocked = FALSE; + U32 msgSize = 0; + U32 sizeMod, sizePad; + U32 i; + U08 crc; + U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data + + // Check to see if tester has requested this message not be transmited + if ( TRUE == isTestingActivated() ) + { + U32 i; + + for ( i = 0; i < MAX_MSGS_BLOCKED_FOR_XMIT; i++ ) + { + if ( msg.hdr.msgID == blockedMessagesForXmit.blockedMessages[ i ] ) + { + blocked = TRUE; + break; + } + } + } + // Serialize and queue message for transmission unless this message is blocked + if ( blocked != TRUE ) + { + // Prefix data with message sync byte + data[ msgSize++ ] = MESSAGE_SYNC_BYTE; + + // Set sequence # and ACK bit (unless this is an ACK to a received message) + if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) + { + // Thread protect next sequence # access & increment + _disable_IRQ(); + msg.hdr.seqNo = nextSeqNo; + nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); + _enable_IRQ(); + if ( TRUE == ackReq ) + { + msg.hdr.seqNo *= -1; + } + } + + // Calculate message CRC + crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); + + // Serialize message header data + memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); + msgSize += sizeof( MESSAGE_HEADER_T ); + + // Serialize message payload (only used bytes per payloadLen field) + memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); + msgSize += msg.hdr.payloadLen; + + // Add 8-bit CRC + data[ msgSize++ ] = crc; + + // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; + sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); + for ( i = 0; i < sizePad; i++ ) + { + data[ msgSize++ ] = 0; + } + +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ACK_ERRORS ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // If ACK required, add to pending ACK list + if ( TRUE == ackReq ) + { + if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + { + error = TRUE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + } + } + } + + if ( FALSE == error ) + { + // Add serialized message data to appropriate out-going comm buffer + result = addToCommBuffer( buffer, data, msgSize ); + } + } + else + { + result = TRUE; // If message blocked, return successful transmission + } + + return result; } -/*********************************************************************//** - * @brief - * The sendChangeUFSettingsResponse function constructs a UF change settings - * option response to the UI and queues the msg for transmit on the appropriate CAN - * channel. - * @details Inputs: none - * @details Outputs: UF change settings option response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param volume_mL UF volume (in mL) - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - - // 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 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 - * @details Outputs: treatment duration change settings response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param time_min treatment duration (in minutes) - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - - // 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 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 - * @details Outputs: Blood & dialysate rate change response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason code for rejection or unused if accepted - * @param bloodRate new blood flow rate - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dialRate, 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 sendACKMsg function constructs and queues for transmit an ACK message + * for a given received message. + * @details Inputs: none + * @details Outputs: ACK message queued for transmit on broadcast CAN channel. + * @param message message to send an ACK for + * @return TRUE if ACK message queued successfully, FALSE if not + *************************************************************************/ +BOOL sendACKMsg( MESSAGE_T *message ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + // Send ACK back with same seq. #, but w/o ACK bit + msg.hdr.seqNo = message->hdr.seqNo * -1; + // ACK messages always have this ID + msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; + // ACK messages always have no payload + msg.hdr.payloadLen = 0; + + // Serialize and queue the message for transmit on broadcast channel + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } /*********************************************************************//** * @brief + * The sendAckResponseMsg function constructs a simple response + * message for a handled message and queues it for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param buffer outgoing buffer that message should be queued in + * @param ack TRUE if test message was handled successfully, FALSE if not + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendUIResponseMsg function constructs an UI response message for a + * handled UI message and queues it for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param accepted T/F - request accepted? + * @param reason reason code if rejected + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + 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; +} + + +// *********************************************************************** +// ***************** Message Sending Helper Functions ******************** +// *********************************************************************** + + +/*********************************************************************//** + * @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 + * @details Outputs: Off button msg constructed and queued. + * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendOffButtonMsgToUI( U08 cmd ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = cmd; + + // 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 sendUIVersionRequest function constructs a UI version request msg + * to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: UI version request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUIVersionRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_UI_VERSION_INFO_REQUEST; + msg.hdr.payloadLen = 0; + + // 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 sendDGPOSTResultRequest function constructs a POST result request msg + * to the DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG POST result request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGPOSTResultRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_DG_POST_RESULT_REQUEST; + msg.hdr.payloadLen = 0; + + // 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendEvent function constructs an DG event message to the UI and + * queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG event msg constructed and queued. + * @param event Enumeration of event type that occurred + * @param dat1 First data associated with event + * @param dat2 Second data associated with event + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendEvent( HD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 e = (U32)event; + // Convert the two data types enums to U32. The enums are interpreted as a U08 by the compiler + U32 dataType1 = (U32)dat1.dataType; + U32 dataType2 = (U32)dat2.dataType; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_EVENT; + // The payload length is the event ID, 2 event datas and the events data types for each of the event data + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 ); + + memcpy( payloadPtr, &e, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dataType1, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dat1.data, sizeof( EVENT_DATAS_T ) ); + payloadPtr += sizeof( EVENT_DATAS_T ); + memcpy( payloadPtr, &dataType2, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dat2.data, sizeof( EVENT_DATAS_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * 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 + * @details Outputs: UF change settings response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); + payloadPtr += sizeof( S32 ); + memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); + + // 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 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 + * @details Outputs: UF change settings option response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + + // 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 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 + * @details Outputs: treatment duration change settings response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param time_min treatment duration (in minutes) + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + + // 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 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 + * @details Outputs: Blood & dialysate rate change response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason code for rejection or unused if accepted + * @param bloodRate new blood flow rate + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dialRate, 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 sendPressureLimitsChangeResponse function constructs a change * pressure limits response to the UI and queues the msg for transmit on the * appropriate CAN channel. @@ -417,816 +579,1487 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ); memcpy( payloadPtr, (U08*)data, sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; } -/*********************************************************************//** - * @brief - * The sendTreatmentParamsRangesToUI function constructs a treatment parameter - * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Treatment parameter ranges msg constructed and queued. - * @param minTime Minimum treatment duration (in minutes) - * @param maxTime Maximum treatment duration (in minutes) - * @param minUFVol Minimum ultrafiltration volume (in mL) - * @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 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &minTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxDialRate, 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 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 - * @details Outputs: Dialysate temperature set points msg constructed and queued. - * @param primary temperature set point for primary heater - * @param trimmer temperature set point for trimmer heater - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDialysateTempTargetsToDG( F32 primary, F32 trimmer ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; - msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &primary, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &trimmer, sizeof( F32 ) ); - - // 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGSwitchReservoirCommand function constructs a DG set active - * reservoir message for DG and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG set active reservoir msg constructed and queued. - * @param activeReservoir reservoir ID to set as active - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGSwitchReservoirCommand( U32 activeReservoir ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &activeReservoir, 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGFillCommand function constructs a DG fill command message - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG fill command msg constructed and queued. - * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGFillCommand( U32 fillToVolumeMl ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FILL_CMD; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &fillToVolumeMl, 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGDrainCommand function constructs a DG drain command message - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG drain command msg constructed and queued. - * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGDrainCommand( U32 drainToVolumeMl ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &drainToVolumeMl, 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGStartStopCommand function constructs a DG start/stop command - * message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG start/stop command msg constructed and queued. - * @param start TRUE indicates start DG, FALSE indicates stop DG - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGStartStopCommand( BOOL start ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &start, 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * 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 - * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. - * @param start TRUE indicates start heater, FALSE indicates stop heater - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &start, 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_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGSampleWaterCommand function constructs a DG sample water command - * message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG sample water command msg constructed and queued. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGSampleWaterCommand( void ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; - msg.hdr.payloadLen = 0; - - // 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_DG, ACK_REQUIRED ); - - return result; -} +/*********************************************************************//** + * @brief + * The sendHeparinCommandResponse function constructs a Heparin command response + * to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Heparin command response msg constructed and queued. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) * 2; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &rejReason, 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 broadcastAccelData function constructs an accelerometer data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * The sendAlarmAudioVolumeSetResponse function constructs an alarm audio + * volume set request response to the UI and queues the msg for transmit on the + * appropriate CAN channel. * @details Inputs: none - * @details Outputs: accelerometer data broadcast msg constructed and queued. - * @param x X axis vector magnitude (in g) - * @param y Y axis vector magnitude (in g) - * @param z Z axis vector magnitude (in g) - * @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) + * @details Outputs: Alarm audio volume set. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code * @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 sendAlarmAudioVolumeSetResponse( U32 accepted, U32 rejReason ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - ACCEL_DATA_PAYLOAD_T payload; - // create a message record + // 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; + msg.hdr.msgID = MSG_ID_HD_ALARM_AUDIO_VOLUME_SET_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) * 2; - memcpy( payloadPtr, &payload, sizeof( ACCEL_DATA_PAYLOAD_T ) ); + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + // 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 broadcastAlarmStatus function constructs an alarm status msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm status msg constructed and queued. - * @param almStatus alarm status record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - ALARM_COMP_STATUS_PAYLOAD_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_STATUS; - msg.hdr.payloadLen = sizeof( ALARM_COMP_STATUS_PAYLOAD_T ); - payload.alarmState = (U32)almStatus.alarmsState; - payload.alarmTop = (U32)almStatus.alarmTop; - payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; - payload.escalatesIn = almStatus.alarmsEscalatesIn; - payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(0) : 0 ); - payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(1) : 0 ); - payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(2) : 0 ); - payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(3) : 0 ); - payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(4) : 0 ); - payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(5) : 0 ); - payload.alarmsFlags |= ( almStatus.noNewTreatment ? BIT_BY_POS(6) : 0 ); - payload.alarmsFlags |= ( almStatus.bypassDialyzer ? BIT_BY_POS(7) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(8) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); - payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(10) : 0 ); - - memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_ALARM, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @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 - * @details Outputs: alarm triggered msg constructed and queued. - * @param alarm ID of alarm triggered - * @param almData1 1st data associated with alarm - * @param almData2 2nd data associated with alarm - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmTriggered( U16 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - 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.dataType, sizeof( U32 ) ); +/*********************************************************************//** + * @brief + * The sendTreatmentParamsRangesToUI function constructs a treatment parameter + * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameter ranges msg constructed and queued. + * @param minTime Minimum treatment duration (in minutes) + * @param maxTime Maximum treatment duration (in minutes) + * @param minUFVol Minimum ultrafiltration volume (in mL) + * @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 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &minTime, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.data, sizeof( U32 ) ); + memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData2.dataType, sizeof( U32 ) ); + memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &minDialRate, 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 - * 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 - * @details Outputs: alarm cleared msg constructed and queued. - * @param alarm ID of alarm cleared - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmCleared( U16 alarm ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_CLEARED; - msg.hdr.payloadLen = sizeof( U16 ); - - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); - - // 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 - * The broadcastBloodFlowData function constructs a blood flow data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. + memcpy( payloadPtr, &maxDialRate, 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 sendTreatmentPeriodicDataToUI function constructs a treatment periodic + * data message to the UI and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none - * @details Outputs: blood flow data msg constructed and queued. - * @param bloodData blood pump and flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodFlowData( BLOOD_PUMP_STATUS_PAYLOAD_T *bloodData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_BLOOD_FLOW_DATA; - msg.hdr.payloadLen = sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ); - - memcpy( payloadPtr, bloodData, sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @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 - * @details Outputs: dialysate flow data msg constructed and queued. - * @param dialInData Dialysate inlet pump and flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDialInFlowData( DIALIN_PUMP_STATUS_PAYLOAD_T *dialInData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DIALYSATE_FLOW_DATA; - msg.hdr.payloadLen = sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ); - - memcpy( payloadPtr, dialInData, sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @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 - * @details Outputs: dialysate out flow data msg constructed and queued. - * @param dialOutFlowData Pointer to the dialysate out flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDialOutFlowData( DIAL_OUT_FLOW_DATA_T *dialOutFlowData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DIALYSATE_OUT_FLOW_DATA; - msg.hdr.payloadLen = sizeof( DIAL_OUT_FLOW_DATA_T ); - - memcpy( payloadPtr, dialOutFlowData, sizeof( DIAL_OUT_FLOW_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The 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 - * @details Outputs: pressure/occlusion data msg constructed and queued. - * @param data Latest measured pressures and occlusion values. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPresOcclData( PRESSURE_OCCLUSION_DATA_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_PRESSURE_OCCLUSION_DATA; - msg.hdr.payloadLen = sizeof( PRESSURE_OCCLUSION_DATA_T ); - - memcpy( payloadPtr, &data, sizeof( PRESSURE_OCCLUSION_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @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 - * @details Outputs: RTC time and date in epoch - * @param epoch Current time and date in epoch - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRTCEpoch( U32 epoch ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RTC_EPOCH; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &epoch, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastTreatmentTime function constructs a treatment time msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment time data msg constructed and queued - * @param secsTotTreatment Total treatment time prescribed (in seconds) - * @param secsElapsed Treatment time elapsed (in seconds) - * @param secsRemaining Treatment time remaining (in seconds) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentTime( U32 secsTotTreatment, U32 secsElapsed, U32 secsRemaining ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - TREATMENT_TIME_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_TIME; - msg.hdr.payloadLen = sizeof( TREATMENT_TIME_DATA_T ); - - payload.treatmentTimePrescribedinSec = secsTotTreatment; - payload.treatmentTimeElapsedinSec = secsElapsed; - payload.treatmentTimeRemaininginSec = secsRemaining; - - memcpy( payloadPtr, &payload, sizeof( TREATMENT_TIME_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastTreatmentState function constructs a treatment state msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment state msg constructed and queued - * @param subMode Current state (sub-mode) of treatment - * @param uFState Current state of ultrafiltration - * @param salineBolusState 1=saline bolus in progress, 0=not, 2=max bolus volume reached - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentState( U32 subMode, U32 uFState, U32 salineBolusState ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - TREATMENT_STATE_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); - - payload.treatmentSubMode = subMode; - payload.uFState = uFState; - payload.salineBolusState = salineBolusState; - - memcpy( payloadPtr, &payload, sizeof( TREATMENT_STATE_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The 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 - * @details Outputs: power off warning msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPowerOffWarning( void ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_POWER_OFF_WARNING; - msg.hdr.payloadLen = 0; - - // 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 broadcastHDOperationMode function constructs an HD operation mode - * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: HD operation mode msg constructed and queued - * @param mode current HD operation mode - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHDOperationMode( U32 mode, U32 subMode ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_OP_MODE; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &mode, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &subMode, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; + * @details Outputs: Treatment parameter ranges msg constructed and queued. + * @param periodDataPtr treatment log period data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentPeriodicDataToUI( TREATMENT_LOG_DATA_PERIODIC_T * periodDataPtr ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_PERIODIC_DATA; + msg.hdr.payloadLen = sizeof( TREATMENT_LOG_DATA_PERIODIC_T ); + + memcpy( payloadPtr, periodDataPtr, sizeof( TREATMENT_LOG_DATA_PERIODIC_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } -/***********************************************************************//** +/*********************************************************************//** + * @brief + * The handlePatientDisconnectionConfirmCmd function handles user confirms + * patient disconnection. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmPatientDisconnection(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleDisposableRemovalConfirmCmd function handles user confirms + * disposable removal. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmDisposableRemoval(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** * @brief - * The broadcastHDValves function constructs an HD valves msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * The sendDisposableRemovalConfirmResponse function constructs a disposable + * removal confirm user action response to the UI and queues the msg for + * transmit on the appropriate CAN channel. * @details Inputs: none - * @details Outputs: HD valves msg constructed and queued + * @details Outputs: Disposable removal confirm response msg constructed and queued. + * @param accepted T/F - was disposable removal confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) +BOOL sendDisposableRemovalConfirmResponse( BOOL accepted, U32 reason ) { + return sendUIResponseMsg( MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleUITreatmentLogDataRequest function handles UI treatment log data request. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleUITreatmentLogDataRequest( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + sendTreatmentLogDataToUI(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogData function constructs a treatment log data message + * for UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log data msg constructed and queued. + * @param accepted T/F - was treatment log request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @param logDataPtr treatment log data record pointer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogData( BOOL accepted, U32 reason, TREATMENT_LOG_DATA_PAYLOAD_T *logDataPtr ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, logDataPtr, sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The handleUIDisinfectRequest function handles a disinfect/flush user + * action command message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIDisinfectRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + + if ( 0 == cmd ) // Command 0 = Flush + { + result = signalUserInitiateFlushMode(); + } + else if ( 1 == cmd ) // Command 1 = Heat disinfect + { + result = signalUserInitiateHeatDisinfectMode(); + } + else if ( 2 == cmd ) // Command 2 = chemical disinfect + { + result = signalUserInitiateChemicalDisinfectMode(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendDisinfectConfirmResponse function constructs a disinfect or flush + * confirm user action response to the UI and queues the msg for + * transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Disposable removal confirm response msg constructed + * and queued. + * @param accepted T/F - was disinfect or flush confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDisinfectConfirmResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_DISINFECT_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleSetHDStandbyDisinfectSubmode function handles setting the + * standby submode to wait for disisnfect state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetHDStandbyDisinfectSubmodeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // The payload should be 0 in this case because there is mode in this command + if ( 0 == message->hdr.payloadLen ) + { + signalInitiateStandbyDisinfectSubmode(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetHDStandbyDisinfectSubmodeResponse function constructs a + * standby submode change to wait for disinfect confirm user action response + * to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Disposable removal confirm response msg constructed + * and queued. + * @param accepted T/F - was set standby submode confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSetHDStandbyDisinfectSubmodeResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_SET_STANDBY_DISINFECT_SUB_MODE_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleFlushUIStateReadingFromDG function handles the readings of DG + * flush mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFlushUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_FLUSH_DATA_T) ) + { + MODE_FLUSH_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_FLUSH_DATA_T) ); + + uiStates.heatDisinfectUIState = 0; + uiStates.chemDisinfectUIState = 0; + uiStates.flushUIState = payload.flushUIState; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * @brief + * The handleHeatDisinfectUIStateReadingFromDG function handles the readings + * of DG heat disinfect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHeatDisinfectUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_HEAT_DISINFECT_DATA_T) ) + { + MODE_HEAT_DISINFECT_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_HEAT_DISINFECT_DATA_T) ); + + uiStates.heatDisinfectUIState = payload.heatDisinfectUIState; + uiStates.chemDisinfectUIState = 0; + uiStates.flushUIState = 0; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * @brief + * The handleUIActiveAlarmsListRequest function handles UI active alarms list request. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleUIActiveAlarmsListRequest( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + handleActiveAlarmListRequest(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChemDisinfectUIStateReadingFromDG function handles the readings + * of DG chemical disinfect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChemDisinfectUIStateReadingFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ) + { + MODE_CHEMICAL_DISINFECT_DATA_T payload; + DG_DISINFECT_UI_STATES_T uiStates; + + memcpy( &payload, message->payload, sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ); + + uiStates.heatDisinfectUIState = 0; + uiStates.chemDisinfectUIState = payload.chemDisinfectUIState; + uiStates.flushUIState = 0; + + setDGDisinfectsStates( uiStates ); + } +} + +/*********************************************************************//** + * @brief + * The sendActiveAlarmsList function constructs a treatment log data message + * for UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log data msg constructed and queued. + * @details Outputs: Treatment log data msg constructed and queued. + * @param accepted T/F - was treatment log request accepted? + * @param alarmList pointer to active alarms list record + * @param size the size of active alarms list + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendActiveAlarmsList( BOOL accepted, U32 reason, U32 *alarmList, U32 size ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + size; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, alarmList, size ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogAlarmEventData function constructs a treatment log + * alarm event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log alarm event data msg constructed and queued. + * @param alarmID ID of the occurred alarm + * @param almData1 data associates with the alarm + * @param almData1 data associates with the alarm + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogAlarmEventData( ALARM_ID_T alarmID, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 id = (U32)alarmID; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_ALARM_EVENT; + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( F32 ); + + memcpy( payloadPtr, &id, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &almData1.data, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &almData2.data, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentLogEventData function constructs a treatment log parameter + * change event data message for UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment log event data msg constructed and queued. + * @param event ID of parameter change event + * @param oldValue parameter change event old data value + * @param newValue parameter change event new data value + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentLogEventData( TX_EVENT_ID_T event, F32 oldValue, F32 newValue ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 eventID = (U32)event; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_EVENT; + msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( F32 ); + + memcpy( payloadPtr, &eventID, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &oldValue, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &newValue, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The handleSampleWaterCmd function handles a sample water user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleSampleWaterCmd( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof( U32 ) ); + signalSampleWaterUserAction( (REQUESTED_SAMPLE_WATER_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendSampleWaterCmdResponse function constructs a sample water user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Sample water command response msg constructed and queued. + * @param accepted T/F - was sample water request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendSampleWaterCmdResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleSampleWaterCmd function handles a sample water result msg from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleSampleWaterResult( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 result; + + memcpy( &result, &message->payload[0], sizeof( U32 ) ); + setSampleWaterResult( (BOOL) result ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleConsumableInstallConfirm function handles a consumable install + * confirm msg from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleConsumableInstallConfirm( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmConsumableInstall(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendConsumableInstallCmdResponse function constructs a Consumable Install Confirm user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Consumable Install Confirm command response msg constructed and queued. + * @param accepted T/F - was Consumable Install Confirm request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendConsumableInstallCmdResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_UI_INSTALLATION_CONFIRM_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleInstallationConfirm function handles user confirms disposable + * installation msg from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleInstallationConfirm( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmInstallation(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handlePrimingStartCmd function handles user confirms disposable + * installation msg from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleStartPrimeCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalStartPrime(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendStartPrimeCmdResponse function constructs a start prime user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Start prime command response msg constructed and queued. + * @param accepted T/F - was start prime request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendStartPrimeCmdResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_START_PRIME_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleContinueToTreatmentCmd function handles user request to continue + * to treatment. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleContinueToTreatmentCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserContinueToTreatment(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendContinueToTreatmentCmdResponse function constructs a continue to treatment + * user action response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Continue to treatment request response msg constructed and queued. + * @param accepted T/F - was continue to treatment request accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendContinueToTreatmentCmdResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_PATIENT_CONNECTION_BEGIN_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handlePatientConnectionConfirmCmd function handles user confirms + * patient connection. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handlePatientConnectionConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmPatientConnection(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendPatientConnectionConfirmCmdResponse function constructs a patient connection confirm + * user action response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Patient connection confirm response msg constructed and queued. + * @param accepted T/F - was patient connection confirm accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPatientConnectionConfirmCmdResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_PATIENT_CONNECTION_CONFIRM_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The handleStartTreatmentRequest function handles user requests to start treatment. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleStartTreatmentRequest( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserStartTreatment(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendStartTreatmentResponse function constructs a start treatment user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Patient connection confirm response msg constructed and queued. + * @param accepted T/F - was patient connection confirm accepted? + * @param reason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendStartTreatmentResponse( BOOL accepted, U32 reason ) +{ + return sendUIResponseMsg( MSG_ID_HD_START_TREATMENT_RESPONSE, accepted, reason ); +} + +/*********************************************************************//** + * @brief + * The sendDialysateTempTargetsAndReservoirCycleTimeToDG function constructs a + * dialysate temperature set points message and the active reservoir cycle time + * for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Dialysate temperature set points msg constructed and queued. + * @param trimmer temperature set point for trimmer heater + * @param rsrvrCycleTime active reservoir cycle time in milliseconds + * @param rsrvrWait2Switch time to switch the inactive and active reservoirs in milliseconds + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ) +{ BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; - msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); + msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; + msg.hdr.payloadLen = sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ); - memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_T ) ); + memcpy( payloadPtr, params, sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_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 ); + // 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_DG, ACK_REQUIRED ); return result; } - -/***********************************************************************//** + +/*********************************************************************//** * @brief - * The broadcastSalineBolusData function constructs a saline bolus data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * 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 - * @details Outputs: saline bolus data msg constructed and queued + * @details Outputs: DG set active reservoir msg constructed and queued. + * @param activeReservoir reservoir ID to set as active * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) +BOOL sendDGSwitchReservoirCommand( U32 activeReservoir ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; - msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); + msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; + msg.hdr.payloadLen = sizeof( U32 ); - memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ) ); + memcpy( payloadPtr, &activeReservoir, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + // 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_DG, ACK_REQUIRED ); return result; } -/***********************************************************************//** +/*********************************************************************//** * @brief - * The broadcastAirTrapData function constructs an HD air trap data msg to \n + * The sendDGChangeValveSettingCommand function constructs a DG change valve + * setting message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG change valve setting msg constructed and queued. + * @param valveSettingCmd valve setting ID to change to + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGChangeValveSettingCommand( U32 valveSettingCmd ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CHANGE_VALVE_SETTING_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &valveSettingCmd, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGFillCommand function constructs a DG fill command message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG fill command msg constructed and queued. + * @param cmd start or stop fill command + * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to + * @param targetFlowLRatePM target fill flow rate in L/min + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FILL_CMD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &cmd, sizeof( U32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &targetFlowRateLPM, sizeof( F32 ) ); + + // 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGDrainCommand function constructs a DG drain command message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG drain command msg constructed and queued. + * @param drainCmdPtr drain command data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; + msg.hdr.payloadLen = sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ); + + memcpy( payloadPtr, drainCmdPtr, sizeof( DRAIN_RESERVOIR_CMD_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_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartStopCommand function constructs a DG start/stop command + * message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start/stop command msg constructed and queued. + * @param start TRUE indicates start DG, FALSE indicates stop DG + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartStopCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &start, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * 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 + * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. + * @param start TRUE indicates start heater, FALSE indicates stop heater + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &start, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGSampleWaterCommand function constructs a DG sample water command + * message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG sample water command msg constructed and queued. + * @param cmd sample water sub-command + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSampleWaterCommand( SAMPLE_WATER_CMD_T cmd ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( msg.payload, &cmd, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGCmdResp function handles a DG command response message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGCmdResp( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + { + DG_CMD_RESPONSE_T dgCmdResponse; + + result = TRUE; + memcpy( &dgCmdResponse, message->payload, sizeof( DG_CMD_RESPONSE_T ) ); + handleDGCommandResponse( &dgCmdResponse ); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); +} + +/*********************************************************************//** + * @brief + * The handleUIClockSyncRequest function handles a UI clock sync message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIClockSyncRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 epoch; + + memcpy( &epoch, message->payload, sizeof( U32 ) ); + result = setRTCEpoch( epoch ); + if ( FALSE == result ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Create a response message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_UI_SET_RTC_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payloadPtr, &result, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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 ); + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The handleDGOpMode function handles a DG broadcast of its current mode. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGOpMode( MESSAGE_T *message ) +{ + U32 payloadSize = sizeof(U32) + sizeof(U32); + + if ( message->hdr.payloadLen == payloadSize ) + { + U32 mode, subMode; + + memcpy( &mode, message->payload, sizeof(U32) ); + memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); + + setDGOpMode( mode, subMode ); + checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast + } +} + +/*********************************************************************//** + * @brief + * The sendDGStartFlushModeCommand function constructs a DG start/stop + * flush mode command message and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start flush mode command msg constructed and queued. + * @param start TRUE indicates start flush mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartFlushModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_FLUSH; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartHeatDisinfectModeCommand function constructs a DG start/stop + * heat disinfect mode command message and queues the msg for transmit on + * the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start heat disinfect mode command msg constructed + * and queued. + * @param start TRUE indicates start heat disinfect mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartHeatDisinfectModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartChemicalDisinfectModeCommand function constructs a DG + * start/stop chemical disinfect mode command message and queues the msg + * for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start chemical disinfect mode command msg + * constructed and queued. + * @param start TRUE indicates start chemical disinfect mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartChemicalDisinfectModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_CHEM_DISINFECT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( msg.payload, &start, 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_DG, ACK_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 - * @details Outputs: air trap data msg constructed and queued + * @details Outputs: alarm status msg constructed and queued. + * @param almStatus alarm status record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) +BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) { BOOL result; + ALARM_COMP_STATUS_PAYLOAD_T payload; + + payload.alarmState = (U32)almStatus.alarmsState; + payload.alarmTop = (U32)almStatus.alarmTop; + payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; + payload.escalatesIn = almStatus.alarmsEscalatesIn; + + payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_SYSTEM_FAULT) : 0 ); + payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_STOP) : 0 ); + payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_CLEAR) : 0 ); + payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RESUME) : 0 ); + payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RINSEBACK) : 0 ); + payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_END_TREATMENT) : 0 ); + payload.alarmsFlags |= ( almStatus.ok ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_OK_BUTTON_ONLY) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_TO_ESCALATE) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_SILENCED) : 0 ); + payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 0 ); + payload.alarmsFlags |= ( almStatus.noBloodRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_BLOOD_RECIRC) : 0 ); + payload.alarmsFlags |= ( almStatus.noDialRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_DIALYSATE_RECIRC) : 0 ); + payload.alarmsFlags |= ( almStatus.noMinimize ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_MINIMIZE) : 0 ); + payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); + + result = broadcastData( MSG_ID_ALARM_STATUS, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendHDCalibrationRecord function sends out the HD calibration + * record. + * @details Inputs: none + * @details Outputs: HD calibration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param calRcrdAddress: start address of the calibration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDCalibrationRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* calRcrdAddress ) +{ + BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - U32 lower = (U32)lowerLevel; - U32 upper = (U32)upperLevel; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + msg.hdr.msgID = MSG_ID_HD_SEND_CALIBRATION_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; - memcpy( payloadPtr, &lower, sizeof( U32 ) ); + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &upper, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, calRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendHDSystemRecord function sends out the HD system record. + * @details Inputs: none + * @details Outputs: HD system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param sysRcrdAddress: start address of the system record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDSystemRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* sysRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_SYSTEM_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, sysRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendHDServiceRecord function sends out the HD service record. + * @details Inputs: none + * @details Outputs: HD system record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param srvcRcrdAddress: start address of the service record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDServiceRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* srvcRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_SERVICE_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, srvcRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGConcentrateMixingRatiosRequest function constructs a request msg + * to the DG to request the concentrate ratios and queues the msg for transmit + * on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG POST result request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGConcentrateMixingRatiosRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_CONCENTRATE_MIXING_RATIOS; + msg.hdr.payloadLen = 0; + + // 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_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGMixingRatios function handles a concentrate mixing ratios and + * prepare fill time broadcast from DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGMixingRatios( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( DG_MIXING_RATIOS_T ) ) + { + DG_MIXING_RATIOS_T payload; + + memcpy( &payload, message->payload, sizeof( DG_MIXING_RATIOS_T ) ); + + setDGMixingRatios( payload ); + } +} + + +#ifdef EMC_TEST_BUILD +/*********************************************************************//** + * @brief + * The broadcastCANErrorCount function handles the CAN error count + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +BOOL broadcastCANErrorCount( U32 count ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &count, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; } +#endif -#ifdef EMC_TEST_BUILD -BOOL broadcastCANErrorCount( U32 count ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &count, sizeof( U32 ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} -#endif - -// *********************************************************************** -// **************** Message Handling Helper Functions ******************** -// *********************************************************************** - -/*********************************************************************//** - * @brief - * The handleDGCheckIn function handles a check-in from the DG. - * @details Inputs: none - * @details Outputs: check in the DG with the SystemComm module. - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGCheckIn( MESSAGE_T *message ) -{ - checkInFromDG(); -} - -/*********************************************************************//** - * @brief - * The handleUICheckIn function handles a check-in from the UI. - * @details Inputs: none - * @details Outputs: check in the UI with the SystemComm module. - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleUICheckIn( MESSAGE_T *message ) -{ - checkInFromUI(); -} +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** /*********************************************************************//** * @brief + * The handleDGCheckIn function handles a check-in from the DG. + * @details Inputs: none + * @details Outputs: check in the DG with the SystemComm module. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGCheckIn( MESSAGE_T *message ) +{ + checkInFromDG(); +} + +/*********************************************************************//** + * @brief + * The handleUICheckIn function handles a check-in from the UI. + * @details Inputs: none + * @details Outputs: check in the UI with the SystemComm module. + * @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 * @details Outputs: alarm triggered. @@ -1235,14 +2068,14 @@ *************************************************************************/ void handleAlarmTriggered( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == ( sizeof( U16 ) + sizeof( U32 ) * 2 * 2 ) ) // 2 data records w/ 2 U32s each + if ( message->hdr.payloadLen == ( sizeof( U32 ) + sizeof( U32 ) * 2 * 2 ) ) // 2 data records w/ 2 U32s each { U08 *payloadPtr = message->payload; - U16 alarmID; + U32 alarmID; ALARM_DATA_T alm1, alm2; - memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); - payloadPtr += sizeof( U16 ); + memcpy( &alarmID, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); memcpy( &alm1.dataType, payloadPtr, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( &alm1.data, payloadPtr, sizeof( U32 ) ); @@ -1260,360 +2093,431 @@ /*********************************************************************//** * @brief - * The handleAlarmCleared function handles a cleared alarm event message. + * The handleAlarmCleared function handles a cleared alarm condition event message. * @details Inputs: none - * @details Outputs: alarm cleared. + * @details Outputs: alarm condition is cleared. * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleAlarmCleared( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof( U16 ) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U08 *payloadPtr = message->payload; - U16 alarmID; + U32 alarmID; - memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + memcpy( &alarmID, payloadPtr, sizeof( U32 ) ); if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) { - clearAlarm( (ALARM_ID_T)alarmID ); + clearAlarmCondition( (ALARM_ID_T)alarmID ); } } } - -/*********************************************************************//** - * @brief - * The handleOffButtonConfirmMsgFromUI function handles a response to an - * off button message to the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) -{ - OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T payload; - - if ( message->hdr.payloadLen == sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ) - { - memcpy( &payload, message->payload, sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ); - userConfirmOffButton( payload.confirmed ); - } -} - -/*********************************************************************//** - * @brief - * The handleLoadCellReadingsFromDG function handles a load cell readings - * broadcast message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleLoadCellReadingsFromDG( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) - { - LOAD_CELL_READINGS_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); - result = setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); + +/*********************************************************************//** + * @brief + * The handleUIAlarmSilenceRequest function handles an alarm silence request + * message. + * @details Inputs: none + * @details Outputs: alarm silence command is handled. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIAlarmSilenceRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 cmd; + + memcpy( &cmd, payloadPtr, sizeof( U32 ) ); + signalAlarmSilence( (ALARM_SILENCE_CMD_T)cmd ); } - // 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 - * broadcast message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGTemperatureData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_TEMPERATURES_T) ) - { - DG_TEMPERATURES_T payload; - - memcpy( &payload, message->payload, sizeof(DG_TEMPERATURES_T) ); - setDialysateTemperatureReadings( payload.TDi, payload.TRo ); - } - // TODO - what to do if invalid payload length? - // TODO - how to know if DG stops sending these? -} - -/*********************************************************************//** - * @brief - * The handleROPumpData function handles an RO pump data broadcast - * message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleROPumpData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ) - { - DG_RO_PUMP_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ); - setDGROPumpData( payload.setPtPSI, payload.measFlowRateMlMin ); - } - // TODO - what to do if invalid payload length? -} - -/*********************************************************************//** - * @brief - * The handleDrainPumpData function handles a drain pump broadcast - * message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDrainPumpData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ) - { - DG_DRAIN_PUMP_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ); - setDGDrainPumpData( payload.setPtRPM ); - } - // TODO - what to do if invalid payload length? -} - -/*********************************************************************//** - * @brief - * The handleDGPressuresData function handles a DG pressure sensor readings - * broadcast message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGPressuresData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ) - { - DG_PRESSURES_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ); - setDGPressures( payload.roInPSI, payload.roOutPSI, payload.drainInPSI, payload.drainOutPSI ); - } - // TODO - what to do if invalid payload length? -} - -/*********************************************************************//** - * @brief - * The handleDGReservoirData function handles a reservoir data broadcast - * message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGReservoirData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_RESERVOIRS_DATA_PAYLOAD_T) ) - { - DG_RESERVOIRS_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_RESERVOIRS_DATA_PAYLOAD_T) ); - setDGReservoirsData( (DG_RESERVOIR_ID_T)payload.resID, payload.setFillToVolumeMl, payload.setDrainToVolumeMl ); - } - // TODO - what to do if invalid payload length? -} - -/*********************************************************************//** - * @brief - * The handleUFPauseResumeRequest function handles a ultrafiltration pause - * or resume request message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleUFPauseResumeRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 cmd; - - memcpy( &cmd, message->payload, sizeof(U32) ); - if ( UF_CMD_PAUSE == cmd ) - { - result = pauseUF(); - } - else if ( UF_CMD_RESUME == cmd ) - { - result = resumeUF(); - } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); -} - +} + /*********************************************************************//** * @brief - * The sendUFPauseResumeResponse function constructs a UF pause/resume - * response to the UI and queues the msg for transmit on the appropriate CAN - * channel. + * The handleAlarmUserAction function handles a user alarm action event message. * @details Inputs: none - * @details Outputs: UF pause/resume response msg constructed and queued. - * @param accepted was pause/resume request accepted - * @param reason reason rejected (if not accepted) - * @param ufState new UF state + * @details Outputs: selected action initiated. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmUserAction( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 action; + + memcpy( &action, payloadPtr, sizeof( U32 ) ); + + if ( (ALARM_USER_ACTION_T)action < NUMBER_OF_ALARM_USER_ACTIONS ) + { + signalAlarmUserActionInitiated( (ALARM_USER_ACTION_T)action ); + } + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendPOSTTestResult function constructs an HD POST test result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST test result msg constructed and queued. + * @param test ID of HD POST test + * @param passed TRUE if POST test passed, FALSE if not * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendUFPauseResumeResponse( BOOL accepted, U32 reason, U32 ufState ) +BOOL sendPOSTTestResult( HD_POST_STATE_T test, BOOL passed ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; + U32 testID = (U32)test; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); + msg.hdr.msgID = MSG_ID_HD_POST_SINGLE_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + memcpy( payloadPtr, &passed, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &ufState, sizeof( U32 ) ); + memcpy( payloadPtr, &testID, sizeof( U32) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 ); // TODO - make ack required when UI ready + + return result; + +} + +/*********************************************************************//** + * @brief + * The sendPOSTFinalResult function constructs an HD POST final result message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD POST final result msg constructed and queued. + * @param passed TRUE if HD POST passed, FALSE if not + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendPOSTFinalResult( BOOL passed ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_POST_FINAL_TEST_RESULT; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &passed, 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_BROADCAST, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDGPOSTFinalResult function handles a DG POST final result message. + * @details Inputs: none + * @details Outputs: DG POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + signalDGPOSTFinalResult( passed ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendUIRequestPOSTFinalResult function constructs a reqeust for UI POST + * final result message and queues the msg for transmit on the appropriate + * CAN channel. + * @details Inputs: none + * @details Outputs: request for UI POST final result msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUIRequestPOSTFinalResult( void ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_UI_FINAL_POST_RESULT; + msg.hdr.payloadLen = 0; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; + } /*********************************************************************//** * @brief - * The handleUIStartTreatmentMsg function handles a treatment start/cancel - * message from the UI. + * The handleUIPOSTFinalResult function handles a UI POST final result message. * @details Inputs: none + * @details Outputs: UI POST final result delivered to InitPOST mode. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIPOSTFinalResult( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( BOOL ) ) + { + U08 *payloadPtr = message->payload; + BOOL passed; + + memcpy( &passed, payloadPtr, sizeof( BOOL ) ); + signalUIPOSTFinalResult( passed ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleOffButtonConfirmMsgFromUI function handles a response to an + * off button message to the UI. + * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleUIStartTreatmentMsg( MESSAGE_T *message ) +void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) { + OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T payload; + + if ( message->hdr.payloadLen == sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ) + { + memcpy( &payload, message->payload, sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ); + userConfirmOffButton( payload.confirmed ); + } +} + +/*********************************************************************//** + * @brief + * The handleLoadCellReadingsFromDG function handles a load cell readings + * broadcast message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleLoadCellReadingsFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) + { + LOAD_CELL_READINGS_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); + setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); + } +} + +/*********************************************************************//** + * @brief + * The handleDGTemperatureData function handles a temperature readings + * broadcast message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGTemperatureData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( TEMPERATURE_SENSORS_DATA_T ) ) + { + TEMPERATURE_SENSORS_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + } + // TODO - what to do if invalid payload length? + // TODO - how to know if DG stops sending these? +} + +/*********************************************************************//** + * @brief + * The handleDialysateFlowData function handles dialysate flow data broadcast + * message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDialysateFlowData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( DIALYSATE_FLOW_METER_DATA_T ) ) + { + DIALYSATE_FLOW_METER_DATA_T payload; + + memcpy( &payload, message->payload, sizeof( DIALYSATE_FLOW_METER_DATA_T ) ); + setDialysateFlowData( payload.measuredDialysateFlowRate ); + } +} + +/*********************************************************************//** + * @brief + * The handleDGReservoirData function handles a reservoir data broadcast + * message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGReservoirData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ) + { + DG_RESERVOIRS_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ); + setDGReservoirsData( (DG_RESERVOIR_ID_T)payload.resID, payload.setFillToVolumeMl, payload.setDrainToVolumeMl ); + } +} + +/*********************************************************************//** + * @brief + * The handleUFPauseResumeRequest function handles a ultrafiltration pause + * or resume request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUFPauseResumeRequest( MESSAGE_T *message ) +{ BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(U32) ) { - U32 cmd; + U32 cmd; memcpy( &cmd, message->payload, sizeof(U32) ); - - if ( 0 == cmd ) // initiate treatment (go to treatment params mode) + if ( UF_CMD_PAUSE == cmd ) { - result = signalUserStartingTreatment(); + result = pauseUF(); } - else if ( 1 == cmd ) // cancel treatment (return from aborted treatment params mode) + else if ( UF_CMD_RESUME == cmd ) { - result = signalUserCancelTreatment(); + result = resumeUF(); } - else if ( 2 == cmd ) // start treatment - { - result = signalUserBeginningTreatment(); - } } 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. + * The sendUFPauseResumeResponse function constructs a UF pause/resume + * response to the UI and queues the msg for transmit on the appropriate CAN + * channel. * @details Inputs: none - * @details Outputs: Treatment start response msg constructed and queued. - * @param accepted T/F - request accepted? - * @param reason reason code if rejected + * @details Outputs: UF pause/resume response msg constructed and queued. + * @param accepted was pause/resume request accepted + * @param reason reason rejected (if not accepted) + * @param ufState new UF state * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentStartResponseMsg( BOOL accepted, U32 reason ) +BOOL sendUFPauseResumeResponse( BOOL accepted, U32 reason, U32 ufState ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &ufState, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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. + * The handleInitiateTreatmentRequest function handles a treatment initiate/cancel + * message from the UI. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleUIUserEndTreatmentRequest( MESSAGE_T *message ) +void handleInitiateTreatmentRequest( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == 0 ) + if ( message->hdr.payloadLen == sizeof(U32) ) { - result = userRequestEndTreatment(); + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + + if ( 0 == cmd ) // Cancel treatment (return from aborted treatment params mode) + { + result = signalUserCancelTreatment(); + } + else if ( 1 == cmd ) // Initiate treatment (go to treatment params mode) + { + result = signalUserInitiateTreatment(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } /*********************************************************************//** * @brief - * The sendTreatmentEndResponseMsg function constructs a treatment end + * 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 - * @details Outputs: Treatment end response msg constructed and queued. + * @details Outputs: Treatment start response msg constructed and queued. * @param accepted T/F - request accepted? + * @param reason reason code if rejected * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentEndResponseMsg( BOOL accepted ) +BOOL sendInitiateTreatmentResponseMsg( 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_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; + return sendUIResponseMsg( MSG_ID_HD_INITIATE_TREATMENT_RESPONSE, accepted, reason ); } /*********************************************************************//** @@ -1678,32 +2582,92 @@ * response to the UI and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: Treatment parameters response msg constructed and queued. - * @param rejected T/F - are settings rejected? + * @param accepted T/F - are settings accepted? * @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 rejected, U08 *rejectReasons, U32 byteLength ) +BOOL sendTreatmentParametersResponseMsg( BOOL accepted, U08 *rejectReasons, U32 byteLength ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; + msg.hdr.payloadLen = sizeof( BOOL ) + ( sizeof( U32 ) * byteLength ); - memcpy( payloadPtr, &rejected, sizeof( BOOL ) ); + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, rejectReasons, byteLength ); + memcpy( payloadPtr, rejectReasons, sizeof( U32 ) * byteLength ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 handleUFVolumeSetRequest function handles a UF volume treatment parameter + * set and validate request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUFVolumeSetRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(F32) ) + { + F32 uFVolumeMl; + + memcpy( &uFVolumeMl, message->payload, sizeof(F32) ); + + result = validateAndSetUFVolume( uFVolumeMl ); + setUserSetUFVolumeStatus( result ); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendUFVolumeSetResponseMsg function constructs a UF volume treatment parameter + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: UF volume treatment parameter response msg constructed and queued. + * @param accepted T/F - is UF volume setting accepted? + * @param rejectReasons reason UF volume setting was rejected (if not accepted) + * @param uFVolumeMl UF volume (in mL) value that is now in place + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUFVolumeSetResponseMsg( BOOL accepted, U32 reason, F32 uFVolumeMl ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SET_UF_VOLUME_PARAMETER_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &uFVolumeMl, sizeof( F32 ) ); + + // 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 @@ -1767,18 +2731,17 @@ { if ( message->hdr.payloadLen == sizeof(U32) ) { - U32 timeInMin; + U32 timeInMin; memcpy( &timeInMin, message->payload, sizeof(U32) ); - verifyTreatmentDurationSettingChange( timeInMin ); } else { sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } } - + /*********************************************************************//** * @brief * The handleChangeBloodDialysateRateChangeRequest function handles a blood @@ -1835,6 +2798,56 @@ /*********************************************************************//** * @brief + * The handleHeparinCommandRequest function handles a Heparin command + * request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHeparinCommandRequest( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, &message->payload[0], sizeof( U32 ) ); + + userHeparinRequest( (HEPARIN_CMD_T)payload ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleAlarmAudioVolumeSetCmd function handles a alarm audio volume + * set request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmAudioVolumeSetCmd( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, &message->payload[0], sizeof( U32 ) ); + + setAlarmAudioVolume( payload ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief * The handleSalineBolusRequest function handles a saline bolus request * message from the UI. * @details Inputs: none @@ -1882,7 +2895,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); @@ -1893,211 +2906,451 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &bolusVol, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} - -/*********************************************************************//** - * @brief - * The handleDGOpMode function handles a DG broadcast of it's current mode. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -void handleDGOpMode( MESSAGE_T *message ) -{ - U32 payloadSize = sizeof(U32) + sizeof(U32); - - if ( message->hdr.payloadLen == payloadSize ) - { - U32 mode, subMode; - - memcpy( &mode, message->payload, sizeof(U32) ); - memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); - - setDGOpMode( mode, subMode ); - checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, FALSE ); - } -} - -/*********************************************************************//** - * @brief - * The handleFWVersionRequest function handles a request for HD f/w version. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -void handleFWVersionRequest( MESSAGE_T *message ) -{ +} + +/*********************************************************************//** + * @brief + * The handlRinsebackCmd function handles a rinseback user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handlRinsebackCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalRinsebackUserAction( (REQUESTED_RINSEBACK_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendRinsebackCmdResponse function constructs a rinseback user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Rinseback command response msg constructed and queued. + * @param accepted T/F - was rinseback user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRinsebackCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; 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( HD_VERSIONS_T ); + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RINSEBACK_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); - // fill message payload - memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); - - // 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 ); -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - -#ifdef DEBUG_ENABLED - /*********************************************************************//** - * @brief - * The sendDebugData function sends debug data out to the PC port. - * @details - * @details Inputs: none - * @details Outputs: PC serial port - * @param dbgData Pointer to debug data - * @param len number of bytes of debug data - * @return TRUE if debug data was successfully queued for transmit, FALSE if not - *************************************************************************/ - 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 ); - - return result; - } + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - /*********************************************************************//** - * @brief - * The sendDebugDataToUI function sends debug string to the UI for logging. - * @details - * @details Inputs: none - * @details Outputs: Message constructed and queued for transmit - * @param str Pointer to debug string - * @return none - *************************************************************************/ - void sendDebugDataToUI( U08 *str ) + // 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 handleTreatmentRecircCmd function handles a treatment re-circ user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentRecircCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) { - MESSAGE_T msg; - U32 txtLen = strlen( (char*)str ); - U08 *payloadPtr = msg.payload; + U32 cmd; - // create a message record + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentRecircUserAction( (REQUESTED_TREATMENT_RECIRC_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentRecircCmdResponse function constructs a treatment re-circulation + * user action response to the UI and queues the msg for transmit on the appropriate + * CAN channel. + * @details Inputs: none + * @details Outputs: Treatment re-circ command response msg constructed and queued. + * @param accepted T/F - was re-circ user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentRecircCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RECIRC_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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 handleTreatmentEndCmd function handles a treatment end user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTreatmentEndCmd( MESSAGE_T *message ) +{ + if ( sizeof(U32) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof(U32) ); + + signalTreatmentEndUserAction( (REQUESTED_TREATMENT_END_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendTreatmentEndCmdResponse function constructs a treatment end + * user action response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment end command response msg constructed and queued. + * @param accepted T/F - was user action accepted? + * @param rejReason reason why action was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentEndCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_TX_END_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, 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 handleFWVersionRequest function handles a request for HD f/w version. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleFWVersionRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + HD_VERSIONS_T payload; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( UI_VERSIONS_T ) ) + { + // Get UI version data from this request msg and have it recorded + handleUIVersionResponse( message ); + + // Populate payload for response + payload.major = (U08)HD_VERSION_MAJOR; + payload.minor = (U08)HD_VERSION_MINOR; + payload.micro = (U08)HD_VERSION_MICRO; + payload.build = (U16)HD_VERSION_BUILD; + payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); + + // 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 ); + msg.hdr.msgID = MSG_ID_HD_VERSION; + msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); - // 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 - * The isTestingActivated function determines whether a tester has successfully - * logged in to activate testing functionality. - * @details Inputs: testerLoggedIn - * @details Outputs: none - * @return TRUE if a tester has logged in to activate testing, FALSE if not - *************************************************************************/ -BOOL isTestingActivated( void ) -{ - return testerLoggedIn; -} - -/*********************************************************************//** - * @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 - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param ack TRUE if test message was handled successfully, FALSE if not - * @return TRUE if response message successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // 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_PC, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleTesterLogInRequest function handles a request to login as a - * tester. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTesterLogInRequest( MESSAGE_T *message ) -{ - // verify pass code - // TODO - placeholder - how do we want to authenticate tester? - 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 - { - testerLoggedIn = FALSE; - } - // respond to would be tester - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); -} - -/*********************************************************************//** - * @brief - * The handleTestOffButtonStateOverrideRequest function handles a request to - * override the state of the off button. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + // Fill message payload + memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); + } + + // 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 ); +} + +/*********************************************************************//** + * @brief + * The handleUIVersionResponse function handles a response to request for + * UI version information. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIVersionResponse( MESSAGE_T *message ) +{ + // Get UI version data and have it recorded + if ( sizeof(UI_VERSIONS_T) == message->hdr.payloadLen ) + { + UI_VERSIONS_T uiVersion; + + memcpy( &uiVersion, &message->payload[0], sizeof(UI_VERSIONS_T) ); + signalUIVersion( uiVersion ); + } +} + +/*********************************************************************//** + * @brief + * The handleHDSerialNumberRequest function handles a request for HD serial + * number request. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued + * for transmit. + * @return none + *************************************************************************/ +void handleHDSerialNumberRequest( void ) +{ + MESSAGE_T msg; + HD_SYSTEM_RECORD_T system; + + // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record + // has been already checked in POST + getNVRecord2Driver( GET_SYS_RECORD, (U08*)&system, sizeof( HD_SYSTEM_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SERIAL_NUMBER; + + // Add 1 byte for null terminator + msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; + + // Fill message payload + memcpy( payloadPtr, &system.topLevelSN, sizeof( U08 ) * MAX_TOP_LEVEL_SN_CHARS ); + payloadPtr += MAX_TOP_LEVEL_SN_CHARS; + *payloadPtr = 0; + + // 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 ); +} + +/*********************************************************************//** + * @brief + * The handleDGVersionResponse function handles a response for DG f/w version. + * @details Inputs: none + * @details Outputs: message handled, DG version info recorded. + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGVersionResponse( MESSAGE_T *message ) +{ + // Get DG version data from this response msg and have it recorded + if ( sizeof(DG_VERSIONS_T) == message->hdr.payloadLen ) + { + DG_VERSIONS_T dgVersion; + + memcpy( &dgVersion, &message->payload[0], sizeof(DG_VERSIONS_T) ); + signalDGVersion( dgVersion ); + } +} + +/*********************************************************************//** + * @brief + * The handleHDServiceScheduleRequest function handles a request for HD + * service information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleHDServiceScheduleRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + HD_SERVICE_RECORD_T service; + + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( HD_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + // Fill message payload + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + } + + // 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 ); +} + +/*********************************************************************//** + * @brief + * The handleHDUsageInfoRequest function handles a request for HD + * usage information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleHDUsageInfoRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + U32 payload = 0; // TODO update this one implemented + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_USAGE_DATA; + msg.hdr.payloadLen = sizeof( U32 ); + + // Fill message payload + memcpy( payloadPtr, &payload, sizeof( U32 ) ); + + // 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 ); +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully + * logged in to activate testing functionality. + * @details Inputs: testerLoggedIn + * @details Outputs: none + * @return TRUE if a tester has logged in to activate testing, FALSE if not + *************************************************************************/ +BOOL isTestingActivated( void ) +{ + return testerLoggedIn; +} + +/*********************************************************************//** + * @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 + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param ack TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a + * tester. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTesterLogInRequest( MESSAGE_T *message ) +{ + // Verify pass code + // TODO - placeholder - how do we want to authenticate tester? + 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 + { + testerLoggedIn = FALSE; + } + // Respond to would be tester + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); +} + +/*********************************************************************//** + * @brief + * The handleTestOffButtonStateOverrideRequest function handles a request to + * override the state of the off button. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2112,25 +3365,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestStopButtonStateOverrideRequest function handles a request to - * override the stop button state. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestStopButtonStateOverrideRequest function handles a request to + * override the stop button state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2144,25 +3397,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmLampPatternOverrideRequest function handles a request to - * override the alarm lamp pattern. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmLampPatternOverrideRequest function handles a request to + * override the alarm lamp pattern. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2176,25 +3429,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestWatchdogCheckInStateOverrideRequest function handles a - * request to override the check-in status of a given task. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a + * request to override the check-in status of a given task. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2208,25 +3461,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmStateOverrideRequest function handles a request to - * override the active status of a given alarm. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmStateOverrideRequest function handles a request to + * override the active status of a given alarm. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2240,25 +3493,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmTimeOverrideRequest function handles a request to - * override the time since activation of a given alarm. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmTimeOverrideRequest function handles a request to + * override the time since activation of a given alarm. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmTimeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2272,146 +3525,146 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmStatusBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for alarm status. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestAlarmStatusBroadcastIntervalOverrideRequest( MESSAGE_T *message ) + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowSetPointOverrideRequest function handles a request to + * override the set point for the blood flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +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) ); + result = testSetTargetBloodFlowRateOverride( payload.setPt, payload.ctrlMode ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to + * override the measured blood flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodFlowMeasuredOverrideRequest( MESSAGE_T *message ) +{ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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 ); + result = testSetMeasuredBloodFlowRateOverride( payload.state.f32 ); } else { - result = testResetAlarmStatusPublishIntervalOverride(); + result = testResetMeasuredBloodFlowRateOverride(); } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowSetPointOverrideRequest function handles a request to - * override the set point for the blood flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -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) ); - result = testSetTargetBloodFlowRateOverride( payload.setPt, payload.ctrlMode ); - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to - * override the measured blood flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestBloodFlowMeasuredOverrideRequest( MESSAGE_T *message ) +/*********************************************************************//** + * @brief + * The handleHDBloodPumpRotorCountOverrideRequest function handles a request to + * override the blood pump rotor count. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHDBloodPumpRotorCountOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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 ); + result = testSetBloodPumpRotorCountOverride( payload.state.u32 ); } else { - result = testResetMeasuredBloodFlowRateOverride(); + result = testResetBloodPumpRotorCountOverride(); } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief - * The handleTestBloodFlowSignalStrengthOverrideRequest function handles a - * request to override the measured blood flow signal strength (%). + * The handleHDSetArterialPressureOffsetRequest function handles a request to + * set the arterial pressure offset. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestBloodFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +void handleHDSetArterialPressureOffsetRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { - result = testSetMeasuredBloodFlowSignalStrengthOverride( payload.state.f32 ); + result = testSetArterialPressureOffsetOverride( payload.state.f32 ); } else { - result = testResetMeasuredBloodFlowSignalStrengthOverride(); + result = testResetArterialPressureOffsetOverride(); } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump rotor speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump rotor speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2425,25 +3678,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2457,25 +3710,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump motor controller speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump motor controller speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2489,25 +3742,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to - * override the measured blood pump motor controller current (mA). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to + * override the measured blood pump motor controller current (mA). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2521,25 +3774,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for blood flow data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for blood flow data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2553,35 +3806,35 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInFlowSetPointOverrideRequest function handles a request to - * override the set point for the dialysate inlet flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowSetPointOverrideRequest function handles a request to + * override the set point for the dialysate inlet flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowSetPointOverrideRequest( MESSAGE_T *message ) { OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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) ); result = testSetTargetDialInFlowRateOverride( payload.setPt, payload.ctrlMode ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - + /*********************************************************************//** * @brief * The handleTestDialOutFlowSetPointOverrideRequest function handles a request to @@ -2596,32 +3849,32 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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) ); result = testSetTargetDialOutFlowRateOverride( payload.setPt, payload.ctrlMode ); } - // respond to request + // 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 - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to + * override the measured dialysate inlet flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowMeasuredOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2635,57 +3888,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief - * The handleTestDialInFlowSignalStrengthOverrideRequest function handles a - * request to override the measured dialysate inlet flow signal strength (%). + * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump rotor speed (RPM). * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestDialInFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetMeasuredDialInFlowSignalStrengthOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredDialInFlowSignalStrengthOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump rotor speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2699,25 +3920,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2731,25 +3952,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump motor controller speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump motor controller speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2763,25 +3984,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to - * override the measured dialysate inlet pump motor controller current (mA). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to + * override the measured dialysate inlet pump motor controller current (mA). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2795,25 +4016,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for dialysate inlet flow data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for dialysate inlet flow data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2827,25 +4048,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestArterialPressureOverrideRequest function handles a request to - * override the arterial pressure. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestArterialPressureOverrideRequest function handles a request to + * override the arterial pressure. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestArterialPressureOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2859,25 +4080,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestVenousPressureOverrideRequest function handles a request to - * override the venous pressure. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestVenousPressureOverrideRequest function handles a request to + * override the venous pressure. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestVenousPressureOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2891,183 +4112,119 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to - * override the blood pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to + * override the blood pump occlusion sensor. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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 ); + result = testSetBloodPumpOcclusionOverride( payload.state.u32 ); } else { result = testResetBloodPumpOcclusionOverride(); } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to - * override the dialysate inlet pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -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 - * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to - * override the dialysate outlet pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialysateOutletPumpOcclusionOverrideRequest( MESSAGE_T *message ) +/*********************************************************************//** + * @brief + * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for pressure/occlusion data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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 ); + result = testSetPresOcclDataPublishIntervalOverride( payload.state.u32 ); } else { - result = testResetDialOutPumpOcclusionOverride(); + result = testResetPresOcclDataPublishIntervalOverride(); } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for pressure/occlusion data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ) + +/*********************************************************************//** + * @brief + * The handleSetRTCTimestamp function handles a request to write time and + * date to RTC + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetRTCTimestamp( MESSAGE_T *message ) { - TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length - if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + if ( message->hdr.payloadLen == 9 ) // TODO - add payload structure to RTC.h and use a structure to import payload. { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetPresOcclDataPublishIntervalOverride( payload.state.u32 ); - } - else - { - result = testResetPresOcclDataPublishIntervalOverride(); - } + 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 + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleSetRTCTimestamp function handles a request to write time and - * date to RTC - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetRTCTimestamp( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - 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 - * a request to override the broadcast interval for dialysate outlet pump data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for dialysate outlet pump data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3081,26 +4238,26 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a - * request to override the ultrafiltration reference volume for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a + * request to override the ultrafiltration reference volume for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutUFReferenceVolumeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3114,26 +4271,26 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a - * request to override the ultrafiltration measured volume for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a + * request to override the ultrafiltration measured volume for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutUFMeasuredVolumeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3147,26 +4304,26 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a - * request to override the measured motor controller speed for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a + * request to override the measured motor controller speed for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3180,26 +4337,26 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a - * request to override the measured motor controller current for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a + * request to override the measured motor controller current for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3213,25 +4370,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a - * request to override the measured speed for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a + * request to override the measured speed for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3245,25 +4402,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a - * request to override the measured rotor speed for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a + * request to override the measured rotor speed for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3277,25 +4434,25 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutLoadCellWeightOverrideRequest function handles a - * request to override the measured load cell weight for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutLoadCellWeightOverrideRequest function handles a + * request to override the measured load cell weight for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutLoadCellWeightOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3309,25 +4466,50 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestHDSafetyShutdownOverrideRequest function handles a - * request to override the safety shutdown signal. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestTreatmentTimeRemainingOverrideRequest function handles a treatment + * time remaining override request message. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentTimeRemainingOverrideRequest( MESSAGE_T *message ) +{ + U32 payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(U32) ); + result = testSetTreatmentTimeRemainingOverride( payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestHDSafetyShutdownOverrideRequest function handles a + * request to override the safety shutdown signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestHDSafetyShutdownOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3341,7 +4523,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3359,7 +4541,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3373,7 +4555,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3391,7 +4573,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3405,7 +4587,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3423,7 +4605,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3437,90 +4619,12 @@ } } - // respond to request + // 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 - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetAccelCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // verify payload length - if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) - { - ACCEL_CAL_PAYLOAD_T payload; - - 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 - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetBloodFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - 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 - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetDialysateFlowCalibration( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // verify payload length - if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) - { - LINEAR_F32_CAL_PAYLOAD_T payload; - - 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 handleTestSetTreatmentParameter function handles a request to set * a specific treatment parameter value. * @details Inputs: none @@ -3532,7 +4636,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) { CRITICAL_DATAS_T payload[2]; @@ -3541,11 +4645,11 @@ result = testSetTreatmentParameter( (TREATMENT_PARAM_T)payload[0].uInt, payload[1] ); } - // respond to request + // 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 @@ -3557,7 +4661,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(U32) ) { U32 valve; @@ -3568,7 +4672,7 @@ result = TRUE; } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3586,7 +4690,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3600,7 +4704,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3627,7 +4731,7 @@ result = TRUE; } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3645,7 +4749,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3659,11 +4763,10 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The handleSetHDValvePWMOverrideRequest function handles a request to @@ -3678,7 +4781,7 @@ OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // 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) ); @@ -3692,12 +4795,11 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -#endif -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a * request to override the air trap data broadcast interval. @@ -3711,7 +4813,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3725,11 +4827,11 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to * override an air trap level sensor. @@ -3743,26 +4845,428 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + // Verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)(payload.state.u32) ); + result = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)( payload.state.u32 ) ); } else { result = testResetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index ); } } + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetFluidLeakBroadcastIntervalOverrideRequest function handles a + * request to override the fluid leak state broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakBroadcastIntervalOverrideRequest( 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 = testSetFluidLeakStatePublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStatePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetFluidLeakStateOverrideRequest function handles a request to + * override the fluid leak detector state. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakStateOverrideRequest( 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 = testSetFluidLeakStateOverride( ( FLUID_LEAK_STATES_T)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStateOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBloodLeakDataBroadcastIntervalOverrideRequest function handles a + * request to override the blood leak data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBloodLeakDataBroadcastIntervalOverrideRequest( 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 = testSetBloodLeakDataPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetBloodLeakDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBloodLeakStatusOverrideRequest function handles a request to + * override the blood leak detector status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBloodLeakStatusOverrideRequest( 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 = testSetBloodLeakStatusOverride( (BLOOD_LEAK_STATUS_T)( payload.state.u32 ) ); + } + else + { + result = testResetBloodLeakStatusOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakZeroRequest function handles a request to + * zero the blood leak detector. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodLeakZeroRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + result = TRUE; + zeroBloodLeak(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBubblesDataBroadcastIntervalOverrideRequest function handles a + * request to override the air bubble detectors data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBubblesDataBroadcastIntervalOverrideRequest( 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 = testSetBubblesDataPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetBubblesDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBubbleStatusOverrideRequest function handles a request to + * override a given air bubble detector status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBubbleStatusOverrideRequest( 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 = testSetBubbleStatusOverride( (BUBBLE_STATUS_T)payload.state.u32, (BUBBLES_T)payload.index ); + } + else + { + result = testResetBubbleStatusOverride( (BUBBLES_T)payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBubbleSelfTestRequest function handles a request to + * self-test a given air bubble detector. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBubbleSelfTestRequest( MESSAGE_T *message ) +{ + U32 payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( U32 ) ); + result = TRUE; + selfTestBubble( (BUBBLES_T)payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleSetSwitchesStatusOverrideRequest function handles a + * request to override the status of a switch in HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetSwitchesStatusOverrideRequest( 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 = testSetSwitchesStatusOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetSwitchesStatusOverride( payload.index ); + } + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleTestSwitchesPublishIntervalOverrideRequest function handles a + * request to override the the switches data publish interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSwitchesPublishIntervalOverrideRequest( 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 = testSetSwitchesDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetSwitchesDataPublishIntervalOverrid(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief + * The handleBatteryRemainingPercentOverrideRequest function handles a + * request to override battery remaining percent. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBatteryRemainingPercentOverrideRequest( 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 = testSetBatteryRemainingPercentOverride( payload.state.u32 ); + } + else + { + result = testResetSetBatteryRemainingPercentOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodPrimeVolumeOverrideRequest function handles a request to + * override the calculated blood prime volume (in mL). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodPrimeVolumeOverrideRequest( 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 = testSetBloodPrimeVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetBloodPrimeVolumeOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleRinsebackVolumeOverrideRequest function handles a request to + * override the calculated rinseback volume (in mL). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleRinsebackVolumeOverrideRequest( 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 = testSetRinsebackVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetRinsebackVolumeOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleHDSoftwareResetRequest function handles a request to reset the * HD firmware processor. * @details Inputs: none @@ -3774,30 +5278,29 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( 0 == message->hdr.payloadLen ) { - // tester must be logged in + // Tester must be logged in if ( TRUE == isTestingActivated() ) - { // s/w reset of processor - result = TRUE; // reset will prevent this from getting transmitted though + { // S/w reset of processor + result = TRUE; // Reset will prevent this from getting transmitted though #ifndef _VECTORCAST_ - systemREG1->SYSECR = (0x2) << 14; // reset processor + systemREG1->SYSECR = (0x2) << 14; // Reset processor #endif } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestBloodPumpHomeRequest function handles a request to home * the blood pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3810,17 +5313,16 @@ result = homeBloodPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDialInPumpHomeRequest function handles a request to home * the dialysate inlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3833,17 +5335,16 @@ result = homeDialInPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestDialOutPumpHomeRequest function handles a request to home * the dialysate outlet pump. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3856,17 +5357,16 @@ result = homeDialOutPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief * The handleTestSuperClearAlarmsRequest function handles a request to clear * all active alarms. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -3880,79 +5380,1924 @@ memcpy( &key, message->payload, sizeof(U32) ); result = testClearAllAlarms( key ); + } - result = TRUE; + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSetOpModeRequest function handles a request to set the + * HD operation mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetOpModeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 mode; + + memcpy( &mode, message->payload, sizeof(U32) ); + result = testSetOperationMode( (HD_OP_MODE_T)mode ); } + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetHDCalibrationRecord function handles a request to set the HD +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDCalibrationRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetHDCalibrationRecord function handles a request to get the HD +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDCalibrationRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_CALIBRATION_RECORD ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpDataBroadcastIntervalOverrideRequest function handles a + * request to override the syringe pump data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpDataBroadcastIntervalOverrideRequest( 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 = testSetSyringePumpDataPublishIntervalOverride( (U32)(payload.state.u32) ); + } + else + { + result = testResetSyringePumpDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpOperationRequest function handles a + * request to initiate a syringe pump operation. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpOperationRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ) + { + SYRINGE_PUMP_OP_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ); + result = testSyringePumpOperationRequest( payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredRateOverrideRequest function handles a + * request to override the syringe pump measured rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredRateOverrideRequest( 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 = testSetSyringePumpMeasuredRateOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredRateOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpHeprinBolusTargetRateOverrideRequest function handles a + * request to override the syringe pump heprin bolus target rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpHeprinBolusTargetRateOverrideRequest( 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 = testSetHeprinBolusTargetRateOverride( payload.state.f32 ); + } + else + { + result = testResetHeprinBolusTargetRateOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetHDSystemRecord function handles a request to set the HD +* system data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDSystemRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetHDSystemRecord function handles a request to get the HD +* system data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDSystemRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_SYSTEM_RECORD ); + } + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** * @brief - * The handleTestHDCalibrationDataRequest function handles a request for - * HD calibration data. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle + * The handleTestSyringePumpMeasuredForceOverrideRequest function handles a + * request to override the syringe pump measured force analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle * @return none *************************************************************************/ -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) +void handleTestSyringePumpMeasuredForceOverrideRequest( 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 = testSetSyringePumpMeasuredForceOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredForceOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredSyringeDetectOverrideRequest function handles a + * request to override the syringe pump syringe detected analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredSyringeDetectOverrideRequest( 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 = testSetSyringePumpMeasuredSyringeDetectOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredSyringeDetectOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleGetHDServiceRecord function handles a request to get the HD +* service data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDServiceRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length if ( 0 == message->hdr.payloadLen ) { - CALIBRATION_DATA_T cal; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_SERVICE_RECORD ); + } + } - // get calibration data - result = getCalibrationData( &cal ); - if ( TRUE == result ) + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredHomeOverrideRequest function handles a + * request to override the syringe pump measured home analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredHomeOverrideRequest( 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 ) { - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; - msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); + result = testSetSyringePumpMeasuredHomeOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredHomeOverride(); + } + } - memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_T ) ); + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} - // 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 ); +/*********************************************************************//** +* @brief +* The handleSetHDServiceRecord function handles a request to set the HD +* service data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDServiceRecord( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_SERVICE_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredPositionOverrideRequest function handles a + * request to override the syringe pump measured position. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredPositionOverrideRequest( 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 = testSetSyringePumpMeasuredPositionOverride( (S32)(payload.state.u32) ); } + else + { + result = testResetSyringePumpMeasuredPositionOverride(); + } } + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredVolumeOverrideRequest function handles a + * request to override the syringe pump measured volume delivered. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredVolumeOverrideRequest( 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 = testSetSyringePumpMeasuredVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredVolumeOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestValvesCurrentOverrideRequest function handles a + * request to override HD valves' current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestValvesCurrentOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + +#ifndef _RELEASE_ + // 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 = testSetValvesCurrentOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetValvesCurrentOverride( payload.index ); + } + } +#endif + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestMonitoredVoltagesSendIntervalOverrideRequest function + * handles a request to override the monitored HD voltages data + * publication interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestMonitoredVoltagesSendIntervalOverrideRequest( 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 = testSetVoltagesDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetVoltagesDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestValvesPositionCountOverrideRequest function handles a + * request to override HD valves' position in counts. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestValvesPositionCountOverrideRequest( 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 = testSetValvesPositionCountOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetValvesPositionCountOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestMonitoredVoltageOverrideRequest function handles a + * request to override the monitored HD voltage override. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestMonitoredVoltageOverrideRequest( 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 = testSetLineLevelOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetLineLevelOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmInfoSendIntervalOverrideRequest function handles a + * request to override the HD alarm information broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmInfoSendIntervalOverrideRequest( 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 = testSetAlarmInfoPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmInfoPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmStatusSendIntervalOverrideRequest function handles a + * request to override the HD alarm status broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmStatusSendIntervalOverrideRequest( 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 + * The handleTestTreatmentTimeDataSendIntervalOverrideRequest function handles a + * request to override the HD treatment time data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentTimeDataSendIntervalOverrideRequest( 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 = testSetTreatmentTimePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTreatmentTimePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTreatmentRangesSendIntervalOverrideRequest function handles a + * request to override the HD treatment param ranges broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentRangesSendIntervalOverrideRequest( 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 = testSetTreatmentParamRangesPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTreatmentParamRangesPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTreatmentStopDataSendIntervalOverrideRequest function handles a + * request to override the HD treatment stop sub-mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentStopDataSendIntervalOverrideRequest( 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 = testSetTreatmentStopPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTreatmentStopPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestBloodPrimeDataSendIntervalOverrideRequest function handles a + * request to override the HD blood prime sub-mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBloodPrimeDataSendIntervalOverrideRequest( 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 = testSetBloodPrimePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetBloodPrimePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestRinsebackDataSendIntervalOverrideRequest function handles a + * request to override the HD rinseback sub-mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestRinsebackDataSendIntervalOverrideRequest( 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 = testSetRinsebackPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetRinsebackPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestStandbyModeDataSendIntervalOverrideRequest function handles a + * request to override the HD standby mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestStandbyModeDataSendIntervalOverrideRequest( 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 = testSetStandbyModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetStandbyModePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestOpModeDataSendIntervalOverrideRequest function handles a + * request to override the HD operation mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestOpModeDataSendIntervalOverrideRequest( 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 = testSetOpModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetOpModePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestPreTreatmentModeDataSendIntervalOverrideRequest function handles a + * request to override the HD pre-treatment mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestPreTreatmentModeDataSendIntervalOverrideRequest( 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 = testSetPreTreatmentModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetPreTreatmentModePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTreatmentModeSendIntervalOverrideRequest function handles a + * request to override the HD treatment mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTreatmentModeSendIntervalOverrideRequest( 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 = testSetTreatmentStatePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTreatmentStatePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestPostTreatmentModeSendIntervalOverrideRequest function handles a + * request to override the HD post-treatment mode data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestPostTreatmentModeSendIntervalOverrideRequest( 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 = testSetPostTreatmentModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetPostTreatmentModePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestBlockMessagesRequest function handles a request to + * block transmission of specific message(s). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBlockMessagesRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( BLOCKED_MSGS_DATA_T ) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + memcpy( &blockedMessagesForXmit.blockedMessages[0], message->payload, sizeof( BLOCKED_MSGS_DATA_T ) ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpForceSensorCalibrateRequest function handles a + * request message to set the syringe pump DAC reference voltage. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpForceSensorCalibrateRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + F32 dacVRef; + + memcpy( &dacVRef, message->payload, sizeof( F32 ) ); // TODO - Payload no longer used. Update Dialin command and expected payload len in f/w. + result = setSyringePumpDACVref(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioVolumeOverrideRequest function handles a + * request to override the alarm audio volume level. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioVolumeOverrideRequest( 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 = testSetAlarmAudioVolumeLevelOverride( payload.state.u32 ); + } + else + { + result = testResetAlarmAudioVolumeLevelOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioCurrentHgOverrideRequest function handles a + * request to override the alarm audio (high gain) current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioCurrentHgOverrideRequest( 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 = testSetPrimaryAlarmAudioCurrentHGOverride( payload.state.f32 ); + } + else + { + result = testResetPrimaryAlarmAudioCurrentHGOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmAudioCurrentLgOverrideRequest function handles a + * request to override the alarm audio (low gain) current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmAudioCurrentLgOverrideRequest( 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 = testSetPrimaryAlarmAudioCurrentLGOverride( payload.state.f32 ); + } + else + { + result = testResetPrimaryAlarmAudioCurrentLGOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmBackupAudioCurrentOverrideRequest function handles a + * request to override the backup alarm audio current. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestAlarmBackupAudioCurrentOverrideRequest( 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 = testSetBackupAlarmAudioCurrentOverride( payload.state.f32 ); + } + else + { + result = testResetBackupAlarmAudioCurrentOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpStatusOverrideRequest function handles a + * request to override the syringe pump status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpStatusOverrideRequest( 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 = testSetSyringePumpStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpEncoderStatusOverrideRequest function handles a + * request to override the syringe pump encoder status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpEncoderStatusOverrideRequest( 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 = testSetSyringePumpEncoderStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpEncoderStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpADCandDACStatusOverrideRequest function handles a + * request to override the syringe pump ADC & DAC status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpADCandDACStatusOverrideRequest( 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 = testSetSyringePumpADCandDACStatus( payload.state.u32 ); + } + else + { + result = testResetSyringePumpADCandDACStatus(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpADCReadCtrOverrideRequest function handles a + * request to override the syringe pump ADC read counter. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpADCReadCtrOverrideRequest( 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 = testSetSyringePumpADCReadCounter( payload.state.u32 ); + } + else + { + result = testResetSyringePumpADCReadCounter(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTemperaturesValueOverrideRequest function handles a + * request to override a temperatures sensor's value. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTemperaturesValueOverrideRequest( 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 = testSetMeasuredTemperatureOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetMeasuredTemperatureOverride( payload.index ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTemperaturesBroadcastIntervalOverrideRequest function handles a + * request to override the temperatures data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestTemperaturesBroadcastIntervalOverrideRequest( 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 = testSetTemperaturesPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetTemperaturesPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestTemperaturesBroadcastIntervalOverrideRequest function handles a + * request to override the temperatures data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFansBroadcastIntervalOverrideRequest( 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 = testSetFanPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetFanPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleFansRPMOverride function handles a request to override a fans RPM value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFansRPMOverride( 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 = testSetFanRPMOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetFanRPMOverride( payload.index ); + } + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** +* @brief +* The handleStopHDRTCClock function handles a request to stop the RTC clock. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleStopHDRTCClock( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = testSetStopRTC(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestEraseHDCalibrationDataRequest function handles a request for - * HD calibration data erasure. - * @details - * Inputs : none - * Outputs : message handled + * The handleSetFansDutyCycleOverrideRequest function handles a + * request to override the fans duty cycle. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) +void handleSetFansDutyCycleOverrideRequest( MESSAGE_T *message ) { + TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { - U32 key; + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); - memcpy( &key, message->payload, sizeof(U32) ); + if ( FALSE == payload.reset ) + { + result = testSetFansDutyCycleOverride( payload.state.f32 ); + } + else + { + result = testResetFansDutyCycleOverride(); + } + } - result = testResetCalibrationData( key ); + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestCurrentTreamtmentParametersRequest function handles a + * request to retrieve the current treatment parameters. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestCurrentTreamtmentParametersRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + result = TRUE; + // ACK request + result = testSendCurrentTreatmentParameters(); } + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} +/*********************************************************************//** + * @brief + * The sendTestCurrentTreatmentParametersResponse function constructs a current + * treatment parameter response message to the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: current treatment prameters response msg constructed and queued. + * @param data response data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTestCurrentTreatmentParametersResponse(CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T current_params) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RES_CURRENT_TREATMENT_PARAMETERS; + msg.hdr.payloadLen = sizeof(CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T); + memcpy(payloadPtr, ¤t_params, sizeof(CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T)); + + return serializeMessage(msg, COMM_BUFFER_OUT_CAN_PC, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The handleTestFansRPMAlarmStartTimeOffsetRequest function handles a + * request to set the fans RPM alarm start time offset. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFansRPMAlarmStartTimeOffsetRequest( MESSAGE_T *message ) +{ + U32 rpmTimeOffset; + + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &rpmTimeOffset, message->payload, sizeof(U32) ); + + result = testSetFanRPMAlarmStartTimeOffset( rpmTimeOffset ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The sendHDSWConfigRecord function sends out the HD software configuration record. + * @details Inputs: none + * @details Outputs: HD software configuration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param swRcrdAddress: start address of the software configuration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDSWConfigRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* swRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_SW_CONFIG_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, swRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** +* @brief +* The handleGetHDSoftwareConfigRecord function handles a request to get the HD +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDSoftwareConfigRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_SW_CONFIG_RECORD ); + } + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleSetHDSoftwareConfigRecord function handles a request to set the HD +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDSoftwareConfigRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_SW_CONFIG_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleUIServiceModeRequest function handles a request to enter service +* mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleUIServiceModeRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + HD_OP_MODE_T currentMode = getCurrentOperationMode(); + REQUEST_REJECT_REASON_CODE_T reject; + + if ( 0 == message->hdr.payloadLen ) + { + if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) + { + status = TRUE; + requestNewOperationMode( MODE_SERV ); + reject = REQUEST_REJECT_REASON_NONE; + } + else + { + reject = REQUEST_REJECT_REASON_TREATMENT_IN_PROGRESS; + } + } + else + { + reject = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + sendUIServiceModeResponse( status, (U32)reject ); +} + +/*********************************************************************//** + * @brief + * The sendUIServiceModeResponse function sends out the HD response to a + * UI request to go to service mode. + * @details Inputs: none + * @details Outputs: Service mode request response msg constructed and queued + * @param accepted TRUE if request was accepted, FALSE if not + * @param rejCode Reject reason code explaining why request was rejected + * @return none + *************************************************************************/ +void sendUIServiceModeResponse( BOOL accepted, U32 rejCode ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RESPONSE_SERVICE_MODE_REQUEST; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejCode, sizeof( U32 ) ); + + // 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 ); +} + +/*********************************************************************//** +* @brief +* The handleGetHDUsageInfoRecord function handles a request to get the HD +* usage information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_USAGE_INFO_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetHDUsageInfoRecord function handles a request to set the HD +* information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDUsageInfoRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_USAGE_INFO_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The sendDGUsageInfoRecord function sends out the DG usage information record. + * @details Inputs: none + * @details Outputs: DG usage information record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param usageInfoAddress: start address of the susage information record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSendHDUsageInfoRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* usageInfoAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_USAGE_INFO_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, usageInfoAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** +* @brief +* The handleSetBloodLeak2EmbeddedMode function handles a request to set the HD +* blood leak to embedded mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetBloodLeak2EmbeddedMode( MESSAGE_T* message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + result = testSetBloodLeak2EmbeddedMode(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetBloodLeakEmbeddedModeCommand function handles a request to set +* the HD blood leak to embedded mode command. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetBloodLeakEmbeddedModeCommand( MESSAGE_T* message ) +{ + U08 command; + U16 commandPayload; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + + // verify payload length + if ( sizeof( U08 ) + sizeof( U16 ) == message->hdr.payloadLen ) + { + memcpy( &command, payloadPtr, sizeof( U08 ) ); + payloadPtr += sizeof( U08 ); + memcpy( &commandPayload, payloadPtr, sizeof( U16 ) ); + result = testSetBloodLeakEmbeddedModeCommand( command, commandPayload ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSendBloodLeakEmbeddedModeCommandResponse function sends out + * the blood leak embedded mode command response. + * @details Inputs: none + * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param responseLen: the length of the buffer + * @param response: pointer to the response buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) + responseLen; + + memcpy( payloadPtr, &responseLen, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, response, responseLen ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + /**@}*/