Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc3cf7af051c1ee070df90a9c072df16be48f478f -r9055124b17389e04131b44c00915c33c72db3ae6 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c3cf7af051c1ee070df90a9c072df16be48f478f) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9055124b17389e04131b44c00915c33c72db3ae6) @@ -467,6 +467,41 @@ 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 + * @param heparinDeliveryState current Heparin delivery state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason, U32 heparinDeliveryState ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) * 3; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &heparinDeliveryState, 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 sendTreatmentParamsRangesToUI function constructs a treatment parameter @@ -1321,6 +1356,34 @@ 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 @@ -2413,6 +2476,31 @@ /*********************************************************************//** * @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 handleSalineBolusRequest function handles a saline bolus request * message from the UI. * @details Inputs: none