Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -ra4f5ed3748870d287a4c2c6fcc003fc4d3b9233f --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a4f5ed3748870d287a4c2c6fcc003fc4d3b9233f) @@ -30,12 +30,12 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "PresOccl.h" +#include "RTC.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "SystemCommMessages.h" -#include "Utilities.h" +#include "Utilities.h" #include "WatchdogMgmt.h" -#include "RTC.h" /** * @addtogroup SystemCommMessages @@ -1129,6 +1129,33 @@ return result; } +/***********************************************************************//** + * @brief + * The broadcastHDValves function constructs an HD valves msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD valves msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; + msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); + + memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_T ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -1739,6 +1766,72 @@ { sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); } +} + +/*********************************************************************//** + * @brief + * The handleSalineBolusRequest function handles a saline bolus request + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSalineBolusRequest( MESSAGE_T *message ) +{ + if ( sizeof(BOOL) == message->hdr.payloadLen ) + { + BOOL start; + + memcpy( &start, &message->payload[0], sizeof(BOOL) ); + + if ( TRUE == start ) + { + signalStartSalineBolus(); + } + else + { + signalAbortSalineBolus(); + } + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendSalineBolusResponse function constructs a saline bolus start/abort + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameters response msg constructed and queued. + * @param accepted T/F - was saline bolus request accepted? + * @param rejReason reason why request was rejected (or zero if accepted) + * @param bolusVol volume (in mL) currently set for saline bolus + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendSalineBolusResponse( BOOL accepted, U32 rejReason, U32 bolusVol ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &bolusVol, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } /*********************************************************************//** @@ -1752,7 +1845,7 @@ *************************************************************************/ void handleDGOpMode( MESSAGE_T *message ) { - U32 payloadSize = sizeof(U32) + sizeof(U32); + U32 payloadSize = sizeof(U32) + sizeof(U32); if ( message->hdr.payloadLen == payloadSize ) {