Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rd3ae2d91603ae6d2d25b9abdb220cc144cf90692 -r054fa08b67ed2a31f7848b179fbcd1b4da501b0f --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d3ae2d91603ae6d2d25b9abdb220cc144cf90692) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 054fa08b67ed2a31f7848b179fbcd1b4da501b0f) @@ -435,14 +435,15 @@ * Inputs : none * Outputs : UF change settings response msg constructed and queued. * @param accepted : alarm status record + * @param reason : reason rejected (if not accepted) * @param volume_mL : alarm status record * @param time_min : alarm status record * @param ufRate_mL_min : alarm status record * @param timeDiff : alarm status record * @param rateDiff : alarm status record * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendChangeUFSettingsResponse( BOOL accepted, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff ) +BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff ) { BOOL result; F32 volume_L = volume_mL / (F32)ML_PER_LITER; @@ -452,10 +453,12 @@ // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof (F32 ); + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + 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_L, sizeof( F32 ) ); payloadPtr += sizeof( F32 ); memcpy( payloadPtr, &time_min, sizeof( U32 ) ); @@ -523,6 +526,105 @@ } /************************************************************************* + * @brief + * The handleChangeBloodDialysateRateChangeRequest function handles a blood \n + * and dialysate rate settings change message from the UI. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 expPayloadSize = sizeof(U32) + sizeof(U32); + + if ( expPayloadSize == message->hdr.payloadLen ) + { + U32 bloodRate; + U32 dialRate; + + memcpy( &bloodRate, &message->payload[0], sizeof(U32) ); + memcpy( &dialRate, &message->payload[sizeof(U32)], sizeof(U32) ); + + result = verifyBloodAndDialysateRateSettingsChange( bloodRate, dialRate ); + } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/************************************************************************* + * @brief + * The sendChangeBloodDialysateRateChangeResponse function constructs a change \n + * blood and dialysate rate settings response to the UI and queues the msg for \n + * transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : Blood & dialysate rate change response msg constructed and queued. + * @param accepted : alarm status record + * @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 sendDialysateTempTargetsToDG function constructs a dialysate temperature \n + * set points message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : Dialysate temperature set points msg constructed and queued. + * @param primary : temperature set point for primary heater. + * @param trimmer : temperature set point for trimmer heater. + * @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 broadcastAlarmStatus * The broadcastAlarmStatus function constructs an alarm status msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel.