Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90 -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) @@ -7,8 +7,8 @@ * * @file ModePostTreat.c * -* @author (last) Quang Nguyen -* @date (last) 24-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 12-Nov-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -63,7 +63,8 @@ static BOOL disposableRemovalConfirmed = FALSE; ///< Flag indicates user confirms disposable removal. static BOOL isDrainStarted = FALSE; ///< Flag indicates a drain operation has been started. -static BOOL isDrainCompleted = FALSE; +static BOOL isDrainCompleted = FALSE; ///< Flag indicates drain has completed. +static BOOL rinseConcentrateLines = FALSE; ///< FLag indicates to rinse concentrate lines. static HD_POST_TREATMENT_STATE_T currentPostTreatmentState; ///< Current state of post-treatment mode state machine. static DRAIN_STATE_T currentDrainReservoirState; ///< Current drain reservoir state. @@ -75,8 +76,9 @@ // ********** private function prototypes ********** -static HD_POST_TREATMENT_STATE_T handlePostTreatmentPatientDisconnectionState( void ); static HD_POST_TREATMENT_STATE_T handlePostTreatmentDrainReservoirsState( void ); +static HD_POST_TREATMENT_STATE_T handlePostTreatmentPatientDisconnectionState( void ); +static HD_POST_TREATMENT_STATE_T handlePostTreatmentDisposableRemovalState( void ); static HD_POST_TREATMENT_STATE_T handlePostTreatmentVerifyState( void ); static void execDrainReservoirs( void ); @@ -99,7 +101,8 @@ disposableRemovalConfirmed = FALSE; isDrainStarted = FALSE; isDrainCompleted = FALSE; - currentPostTreatmentState = HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; + rinseConcentrateLines = FALSE; + currentPostTreatmentState = HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE; currentDrainReservoirState = DRAIN_FIRST_RESERVOIR_START_STATE; postTreatmentPublishTimerCounter = 0; @@ -113,9 +116,9 @@ * post-treatment mode. * @details Inputs: none * @details Outputs: none - * @return none + * @return initial state *************************************************************************/ -void transitionToPostTreatmentMode( void ) +U32 transitionToPostTreatmentMode( void ) { initPostTreatmentMode(); @@ -141,6 +144,8 @@ signalDialInPumpHardStop(); collectTreatmentLogData(); + + return currentPostTreatmentState; } /*********************************************************************//** @@ -156,12 +161,16 @@ switch ( currentPostTreatmentState ) { + case HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE: + currentPostTreatmentState = handlePostTreatmentDrainReservoirsState(); + break; + case HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE: currentPostTreatmentState = handlePostTreatmentPatientDisconnectionState(); break; - case HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE: - currentPostTreatmentState = handlePostTreatmentDrainReservoirsState(); + case HD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE: + currentPostTreatmentState = handlePostTreatmentDisposableRemovalState(); break; case HD_POST_TREATMENT_VERIFY_STATE: @@ -175,7 +184,9 @@ if ( ++postTreatmentPublishTimerCounter >= getU32OverrideValue( &postTreatmentModePublishInterval ) ) { - broadcastPostTreatmentState( currentPostTreatmentState ); + U32 state = (U32)currentPostTreatmentState; + + broadcastData( MSG_ID_HD_POST_TREATMENT_STATE, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&state, sizeof( U32 ) ); postTreatmentPublishTimerCounter = 0; } @@ -317,6 +328,28 @@ /*********************************************************************//** * @brief + * The handlePostTreatmentDrainReservoirsState function executes drain reservoirs + * operation state machine and transition to next state once completed. + * @details Inputs: currentDrainReservoirState + * @details Outputs: executed drain reservoirs operation state machine. + * @return current state (sub-mode) + *************************************************************************/ +static HD_POST_TREATMENT_STATE_T handlePostTreatmentDrainReservoirsState( void ) +{ + HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE; + + execDrainReservoirs(); + + if ( DRAIN_COMPLETE_STATE == currentDrainReservoirState ) + { + state = HD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handlePostTreatmentPatientConnectionState function waits for user * confirms patient disconnection. * @details Inputs: none @@ -338,11 +371,11 @@ if ( TRUE == patientDisconnectionConfirmed ) { patientDisconnectionConfirmed = FALSE; - state = HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE; + state = HD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; - for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) + for ( valve = VDI; valve < NUM_OF_VALVES; valve++ ) { - homeValve( valve ); + setValvePosition( valve, VALVE_POSITION_A_INSERT_EJECT ); } homeBloodPump(); @@ -365,28 +398,24 @@ /*********************************************************************//** * @brief - * The handlePostTreatmentDrainReservoirsState function executes drain reservoirs - * operation state machine and transition to next state once completed. - * @details Inputs: currentDrainReservoirState - * @details Outputs: executed drain reservoirs operation state machine. + * The handlePostTreatmentDisposableRemovalState function waits for user + * to confirm disposable removal. + * @details Inputs: disposableRemovalConfirmed + * @details Outputs: processed disposable removal confirmation * @return current state (sub-mode) *************************************************************************/ -static HD_POST_TREATMENT_STATE_T handlePostTreatmentDrainReservoirsState( void ) +static HD_POST_TREATMENT_STATE_T handlePostTreatmentDisposableRemovalState( void ) { - HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_DRAIN_RESERVOIRS_STATE; + HD_POST_TREATMENT_STATE_T state = HD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; - execDrainReservoirs(); - - if ( DRAIN_COMPLETE_STATE == currentDrainReservoirState ) - { #ifdef SKIP_UI_INTERACTION - disposableRemovalConfirmed = TRUE; + disposableRemovalConfirmed = TRUE; #endif - if ( TRUE == disposableRemovalConfirmed ) - { - disposableRemovalConfirmed = FALSE; - state = HD_POST_TREATMENT_VERIFY_STATE; - } + + if ( TRUE == disposableRemovalConfirmed ) + { + disposableRemovalConfirmed = FALSE; + state = HD_POST_TREATMENT_VERIFY_STATE; } return state; @@ -419,7 +448,7 @@ { activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); } - + // Wait for cartridge and syringe to be removed and for DG to finish any drains/fills. if ( ( TRUE == isCartridgeRemoved ) && ( FALSE == isSyringeDetected() ) ) { cmdStopDG(); @@ -491,7 +520,7 @@ } else { - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE ); + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, rinseConcentrateLines, TRUE ); } } @@ -512,8 +541,14 @@ if ( ( DG_MODE_GENE == getDGOpMode() ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == getDGSubMode() ) ) { - state = DRAIN_FIRST_RESERVOIR_STATE; - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE ); + cmdSetDGActiveReservoir( DG_RESERVOIR_2 ); + + if ( TRUE == hasDGCompletedReservoirSwitch() ) + { + state = DRAIN_FIRST_RESERVOIR_STATE; + rinseConcentrateLines = TRUE; + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, rinseConcentrateLines, TRUE ); + } } return state; @@ -571,7 +606,8 @@ if ( TRUE == hasDGCompletedReservoirSwitch() ) { state = DRAIN_SECOND_RESERVOIR_STATE; - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE ); + rinseConcentrateLines = FALSE; + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, rinseConcentrateLines, TRUE ); } return state; @@ -594,7 +630,7 @@ isDrainStarted = TRUE; } - // Drain has started and DG goes to re-circ mode flush lines state means drain completed + // Drain has started and DG goes to generation idle mode flush lines state means drain completed if ( ( TRUE == isDrainStarted ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_LINES == getDGSubMode() ) ) { isDrainCompleted = TRUE; @@ -606,6 +642,7 @@ { isDrainStarted = FALSE; isDrainCompleted = FALSE; + rinseConcentrateLines = FALSE; state = DRAIN_COMPLETE_STATE; } } Index: firmware/App/Modes/ModePostTreat.h =================================================================== diff -u -r9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90 -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac --- firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision 9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90) +++ firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) @@ -7,8 +7,8 @@ * * @file ModePostTreat.h * -* @author (last) Sean Nash -* @date (last) 13-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 12-Nov-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -80,7 +80,7 @@ // ********** public function prototypes ********** void initPostTreatmentMode( void ); // Initialize this module -void transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode +U32 transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode U32 execPostTreatmentMode( void ); // Execute the post-treatment mode state machine (call from OperationModes) void collectTreatmentLogData( void ); Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -rdb79d769d50c69861f68b4e4aec146d807a641f2 -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision db79d769d50c69861f68b4e4aec146d807a641f2) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) @@ -7,8 +7,8 @@ * * @file ModeTreatmentParams.c * -* @author (last) Sean Nash -* @date (last) 13-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 12-Nov-2021 * * @author (original) Sean Nash * @date (original) 29-May-2020 @@ -64,10 +64,10 @@ { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=4}, {.uInt=0} }, // TREATMENT_PARAM_DIALYZER_TYPE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=60}, {.uInt=30} }, // TREATMENT_PARAM_BP_MEAS_INTERVAL { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=150}, {.uInt=75} }, // TREATMENT_PARAM_RINSEBACK_FLOW_RATE - { CRITICAL_DATA_TYPE_S32, {.sInt=-300}, {.sInt=0}, {.sInt=-300} }, // TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT - { CRITICAL_DATA_TYPE_S32, {.sInt=-300}, {.sInt=0}, {.sInt=0} }, // TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT - { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=600}, {.sInt=20} }, // TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT - { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=600}, {.sInt=400} }, // TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT + { CRITICAL_DATA_TYPE_S32, {.sInt=-300}, {.sInt=-30}, {.sInt=-300} }, // TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT + { CRITICAL_DATA_TYPE_S32, {.sInt=-270}, {.sInt=100}, {.sInt=100} }, // TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT + { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=570}, {.sInt=20} }, // TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT + { CRITICAL_DATA_TYPE_S32, {.sInt=50}, {.sInt=600}, {.sInt=400} }, // TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=1.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_DISPENSE_RATE { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=2.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME { CRITICAL_DATA_TYPE_F32, {.sFlt=35.0}, {.sFlt=38.0}, {.sFlt=37.0} }, // TREATMENT_PARAM_DIALYSATE_TEMPERATURE @@ -116,9 +116,9 @@ * parameters mode. * @details Inputs: none * @details Outputs: Treatment Parameters mode reset prior to starting - * @return none + * @return initial state *************************************************************************/ -void transitionToTreatParamsMode( void ) +U32 transitionToTreatParamsMode( void ) { // Reset this mode initTreatParamsMode(); @@ -138,6 +138,8 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); + + return currentTreatmentParamsState; } /*********************************************************************//** Index: firmware/App/Modes/ModeTreatmentParams.h =================================================================== diff -u -rdb79d769d50c69861f68b4e4aec146d807a641f2 -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac --- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision db79d769d50c69861f68b4e4aec146d807a641f2) +++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) @@ -7,8 +7,8 @@ * * @file ModeTreatmentParams.h * -* @author (last) Sean Nash -* @date (last) 17-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 12-Nov-2021 * * @author (original) Sean Nash * @date (original) 29-May-2020 @@ -74,7 +74,7 @@ // ********** Public function prototypes ********** void initTreatParamsMode( void ); // Initialize this module -void transitionToTreatParamsMode( void ); // Prepares for transition to treatment parameters mode +U32 transitionToTreatParamsMode( void ); // Prepares for transition to treatment parameters mode U32 execTreatParamsMode( void ); // Execute the treatment parameters mode state machine (call from OperationModes) BOOL validateAndSetTreatmentParameters( TREATMENT_PARAMS_DATA_PAYLOAD_T params ); // User provided treatment params to be set and validated Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90 -r65d0f3fed34c836640f502d80a8aeb4e10ddf5ac --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9bb9f9bb8b96f057b2ad8dd42c5ac4f0861c1d90) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 65d0f3fed34c836640f502d80a8aeb4e10ddf5ac) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.c * -* @author (last) Sean Nash -* @date (last) 19-Aug-2021 +* @author (last) Dara Navaei +* @date (last) 12-Nov-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -49,21 +49,29 @@ // ********** 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. - #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif +#endif + +#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. +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 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 ); static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ); @@ -75,79 +83,102 @@ * 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 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. *************************************************************************/ -static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) +U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = 0; - BOOL error = FALSE; + 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 - - // 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 ) + 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 ) { - // 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 ) + // 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 ) { - msg.hdr.seqNo *= -1; + // 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 ); + // 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 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; + // 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; + // 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; - } + // 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 ) ) + #ifndef DISABLE_ACK_ERRORS + // If ACK required, add to pending ACK list + if ( TRUE == ackReq ) { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + 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 + #endif - if ( FALSE == error ) - { - // Add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } + 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; } @@ -321,6 +352,49 @@ 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 @@ -1025,7 +1099,7 @@ * @param newValue parameter change event new data value * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentLogEventData( EVENT_ID_T event, F32 oldValue, F32 newValue ) +BOOL sendTreatmentLogEventData( TX_EVENT_ID_T event, F32 oldValue, F32 newValue ) { MESSAGE_T msg; U08 *payloadPtr = msg.payload; @@ -1705,52 +1779,6 @@ 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. - * @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) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - ACCEL_DATA_PAYLOAD_T payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_ACCELEROMETER_DATA; - msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); - payload.x = x; - payload.y = y; - payload.z = z; - payload.xMax = xm; - payload.yMax = ym; - payload.zMax = zm; - payload.xTilt = xt; - payload.yTilt = yt; - payload.zTilt = zt; - - memcpy( payloadPtr, &payload, sizeof( ACCEL_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - /*********************************************************************//** * @brief * The broadcastAlarmStatus function constructs an alarm status msg to @@ -1763,15 +1791,8 @@ 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; @@ -1790,925 +1811,14 @@ payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 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 ); - - 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 broadcastAlarmInfo function constructs an alarm information msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm information msg constructed and queued. - * @param data alarm information record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmInfo( ALARM_INFO_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_ALARM_INFORMATION; - msg.hdr.payloadLen = sizeof( ALARM_INFO_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( ALARM_INFO_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; -} + result = broadcastData( MSG_ID_ALARM_STATUS, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); -/*********************************************************************//** - * @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( U32 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( U32 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each - - memcpy( payloadPtr, &alarm, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.dataType, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.data, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData2.dataType, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData2.data, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_ALARM, ACK_REQUIRED ); - return result; -} - -/*********************************************************************//** - * @brief - * 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( U32 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( U32 ); - - memcpy( payloadPtr, &alarm, 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 broadcastAlarmConditionCleared function constructs an alarm condition - * cleared msg to be broadcast and queues the msg for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm condition cleared msg constructed and queued. - * @param alarm ID of alarm that has had its condition cleared - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmConditionCleared( U32 alarm ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &alarm, 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 broadcastBloodFlowData function constructs a blood flow data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @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 broadcastSyringePumpData function constructs a syringe pump data - * msg to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: syringe pump data msg constructed and queued. - * @param data syringe pump data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSyringePumpData( SYRINGE_PUMP_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SYRINGE_PUMP_DATA; - msg.hdr.payloadLen = sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastHeparinData function constructs a Heparin data message - * to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Heparin data msg constructed and queued. - * @param data Heparin data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHeparinData( F32 volume ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_HEPARIN_DATA_BROADCAST; - msg.hdr.payloadLen = sizeof( F32 ); - - memcpy( payloadPtr, &volume, 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_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 broadcastVoltagesData function constructs a monitored voltages data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: monitored voltages data msg constructed and queued. - * @param data Latest monitored voltage values. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastVoltagesData( VOLTAGES_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VOLTAGES_DATA; - msg.hdr.payloadLen = sizeof( VOLTAGES_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( VOLTAGES_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The 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 payload Record with treatment state data - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); - - 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 broadcastPostTreatmentState function constructs a post treatment state msg - * to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: post-treatment state msg constructed and queued - * @param postTreatmentSubMode post-treatment state sub-mode - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPostTreatmentState( U32 postTreatmentSubMode ) -{ - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_POST_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &postTreatmentSubMode, sizeof( U32 ) ); - - // 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_BROADCAST, ACK_NOT_REQUIRED ); -} - -/*********************************************************************//** - * @brief - * The broadcastPreTreatmentState function constructs a pre-treatment state msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: pre-treatment state msg constructed and queued - * @param preTreatmentDataPtr pointer to pre-treatment data record to broadcast - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPreTreatmentState( PRE_TREATMENT_STATE_DATA_T *preTreatmentDataPtr ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_PRE_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( PRE_TREATMENT_STATE_DATA_T ); - - memcpy( payloadPtr, preTreatmentDataPtr, sizeof( PRE_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 - * @param subMode current HD operation sub-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; -} - -/***********************************************************************//** - * @brief - * The broadcastHDValves function constructs an HD valves msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: HD valves msg constructed and queued - * @param valveData valve data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; - msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); - - memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastSalineBolusData function constructs a saline bolus data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: saline bolus data msg constructed and queued - * @param data saline bolus data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; - msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastTreatmentStopData function constructs a treatment stop data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment stop data msg constructed and queued - * @param timeout treatment stop timeout (in sec) - * @param countdown treatment stop timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentStopData( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TREATMENT_STOP_TIMER_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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 broadcastRinsebackData function constructs a rinseback data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: rinseback data msg constructed and queued - * @param data rinseback data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_RINSEBACK_PROGRESS; - msg.hdr.payloadLen = sizeof( RINSEBACK_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( RINSEBACK_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastRecircData function constructs a treatment re-circ data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment re-circ data msg constructed and queued - * @param timeout re-circulation timeout (in sec) - * @param countdown re-circulation timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRecircData( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_RECIRC_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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 broadcastBloodPrimeData function constructs a blood prime data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: blood prime data msg constructed and queued - * @param data blood prime data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BLOOD_PRIME_PROGRESS; - msg.hdr.payloadLen = sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastAirTrapData function constructs an HD air trap data msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: air trap data msg constructed and queued - * @param lowerLevel air trap lower level data - * @param upperLevel air trap upper level data - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 lower = (U32)lowerLevel; - U32 upper = (U32)upperLevel; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &lower, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &upper, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastNoCartSelfTestTime function sends out the no cartridge self-test - * progress data. - * @details Inputs: none - * @details Outputs: no cartridge self-test time data msg constructed and queued - * @param timeout no cartridge self-test timeout (in sec) - * @param countdown no cartridge self-test timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastNoCartSelfTestTime( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_NO_CART_SELF_TEST_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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 broadcastDrySelfTestTime function sends out the dry self-test progress data. - * @details Inputs: none - * @details Outputs: dry self-test time data msg constructed and queued - * @param timeout dry self-test timeout (in sec) - * @param countdown dry self-test timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDrySelfTestTime( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_DRY_SELF_TEST_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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 broadcastFluidLeakState function constructs an HD fluid leak state msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: fluid leak state msg constructed and queued - * @param state fluid leak state - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 leakState = (U32)state; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_FLUID_LEAK_STATE; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &leakState, 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 broadcastBloodLeakData function constructs an HD blood leak data msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: blood leak data msg constructed and queued - * @param status blood leak status - * @param state blood leak state - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodLeakData( BLOOD_LEAK_STATUS_T status, U32 state ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 leakStatus = (U32)status; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BLOOD_LEAK_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &leakStatus, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &state, 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 broadcastBubblesData function constructs an HD air bubble data msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: air bubbles data msg constructed and queued - * @param status air bubbles status - * @param state air bubbles states - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBubblesData( U32 statusADA, U32 stateADA, U32 statusADV, U32 stateADV ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BUBBLES_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &statusADA, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &stateADA, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &statusADV, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &stateADV, 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 broadcastPrimeData function constructs a prime data msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: prime data msg constructed and queued - * @param primeDataPtr prime data record pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_PRIMING_STATUS_DATA; - msg.hdr.payloadLen = sizeof( PRIMING_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, primeDataPtr, sizeof( PRIMING_DATA_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The sendHDCalibrationRecord function sends out the HD calibration * record. * @details Inputs: none @@ -2825,114 +1935,6 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastDisinfectsData function sends out the disinfects data. - * @details Inputs: none - * @details Outputs: disinfects data msg constructed and queued - * @param disinfectsData which is disinfects msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDisinfectsData( DISINFECTS_DATA_T *disinfectsData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_DISINFECT_STANDBY_DATA; - msg.hdr.payloadLen = sizeof( DISINFECTS_DATA_T ); - - memcpy( payloadPtr, disinfectsData, sizeof( DISINFECTS_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 broadcastSwitchesData function sends out switches data. - * @details Inputs: none - * @details Outputs: switches data msg constructed and queued - * @param SWITCHES_DATA_T which is switches msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSwitchesData( SWITCHES_DATA_T *switchesData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SWITCHES_DATA; - msg.hdr.payloadLen = sizeof( SWITCHES_DATA_T ); - - memcpy( payloadPtr, switchesData, sizeof( SWITCHES_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 broadcastTemperaturesData function sends out the temperatures data. - * @details Inputs: none - * @details Outputs: temperatures data msg constructed and queued - * @param temperaturesData which is the temperatures msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTemperaturesData( TEMPERATURES_DATA_T *temperaturesData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TEMPERATURES_DATA; - msg.hdr.payloadLen = sizeof( TEMPERATURES_DATA_T ); - - memcpy( payloadPtr, temperaturesData, sizeof( TEMPERATURES_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 broadcastFansData function sends out the fans data. - * @details Inputs: none - * @details Outputs: fans data msg constructed and queued - * @param fansData which is the fans msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFansData( FANS_DATA_T *fansData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_FANS_DATA; - msg.hdr.payloadLen = sizeof( FANS_DATA_T ); - - memcpy( payloadPtr, fansData, sizeof( FANS_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -3266,68 +2268,28 @@ // 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 ); - } +/*********************************************************************//** + * @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 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 ); - } -} - -/*********************************************************************//** - * @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 ); - } -} - -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The handleDGReservoirData function handles a reservoir data broadcast * message from the DG. * @details Inputs: none @@ -4564,14 +3526,14 @@ /*********************************************************************//** * @brief - * The handleTestBloodFlowSignalStrengthOverrideRequest function handles a - * request to override the measured blood flow signal strength (%). + * 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 handleTestBloodFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +void handleHDBloodPumpRotorCountOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -4582,18 +3544,50 @@ memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { - result = testSetMeasuredBloodFlowSignalStrengthOverride( payload.state.f32 ); + result = testSetBloodPumpRotorCountOverride( payload.state.u32 ); } else { - result = testResetMeasuredBloodFlowSignalStrengthOverride(); + result = testResetBloodPumpRotorCountOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - + +/*********************************************************************//** + * @brief + * 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 handleHDSetArterialPressureOffsetRequest( 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 = testSetArterialPressureOffsetOverride( payload.state.f32 ); + } + else + { + result = testResetArterialPressureOffsetOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to @@ -4836,38 +3830,6 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDialInFlowSignalStrengthOverrideRequest function handles a - * request to override the measured dialysate inlet flow signal strength (%). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialInFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // Verify payload length - if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetMeasuredDialInFlowSignalStrengthOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredDialInFlowSignalStrengthOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /*********************************************************************//** * @brief * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to @@ -5126,70 +4088,6 @@ /*********************************************************************//** * @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.u32 ); - } - 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 ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // Verify payload length - if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); - if ( FALSE == payload.reset ) - { - result = testSetDialOutPumpOcclusionOverride( payload.state.u32 ); - } - else - { - result = testResetDialOutPumpOcclusionOverride(); - } - } - - // 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 @@ -6277,38 +5175,6 @@ /*********************************************************************//** * @brief - * The handleBloodPrimeSafetyVolumeOverrideRequest function handles a request to - * override the calculated safety blood prime volume (in mL). - * @details Inputs: none - * @details Outputs: message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -void handleBloodPrimeSafetyVolumeOverrideRequest( 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 = testSetBloodPrimeSafetyVolumeOverride( payload.state.f32 ); - } - else - { - result = testResetBloodPrimeSafetyVolumeOverride(); - } - } - - // 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 @@ -6341,38 +5207,6 @@ /*********************************************************************//** * @brief - * The handleRinsebackSafetyVolumeOverrideRequest function handles a request to - * override the calculated safety rinseback volume (in mL). - * @details Inputs: none - * @details Outputs: message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -void handleRinsebackSafetyVolumeOverrideRequest( 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 = testSetRinsebackSafetyVolumeOverride( payload.state.f32 ); - } - else - { - result = testResetRinsebackSafetyVolumeOverride(); - } - } - - // 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 @@ -7458,6 +6292,63 @@ /*********************************************************************//** * @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; + + result = TRUE; + memcpy( &dacVRef, message->payload, sizeof( F32 ) ); + setSyringePumpDACVref( dacVRef ); + } + } + + // 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 @@ -7839,4 +6730,26 @@ 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 ); +} + /**@}*/