Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r054fa08b67ed2a31f7848b179fbcd1b4da501b0f -r744b177ec4114c62303e976aed1677b820f7a281 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 054fa08b67ed2a31f7848b179fbcd1b4da501b0f) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 744b177ec4114c62303e976aed1677b820f7a281) @@ -99,14 +99,6 @@ { F32 volume_mL; UF_ADJ_T adjustType; -} UF_SETTINGS_CHANGE_REQ_PAYLOAD_T; - -typedef struct -{ - BOOL confirmed; - F32 volume_mL; - U32 treatTime_min; - F32 uFRate_mL_min; } UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T; #pragma pack(pop) @@ -415,13 +407,13 @@ { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(UF_SETTINGS_CHANGE_REQ_PAYLOAD_T) ) + if ( message->hdr.payloadLen == sizeof(U32) ) { - UF_SETTINGS_CHANGE_REQ_PAYLOAD_T payload; + U32 uFVolume; - memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_REQ_PAYLOAD_T) ); + memcpy( &uFVolume, message->payload, sizeof(U32) ); - result = verifyUFSettingsChange( payload.volume_mL, payload.adjustType ); + result = verifyUFSettingsChange( uFVolume ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } @@ -495,7 +487,7 @@ memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ); - result = verifyUFSettingsConfirmation( payload.confirmed, payload.volume_mL, payload.treatTime_min, payload.uFRate_mL_min ); + result = verifyUFSettingsConfirmation( payload.volume_mL, payload.adjustType ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); } @@ -527,6 +519,46 @@ /************************************************************************* * @brief + * The sendChangeTreatmentDurationResponse function constructs a treatment \n + * duration change response to the UI and queues the msg for transmit on the \n + * appropriate CAN channel. + * @details + * Inputs : none + * Outputs : treatment duration change settings response msg constructed and queued. + * @param accepted : alarm status record + * @param reason : reason rejected (if not accepted) + * @param time_min : alarm status record + * @param volume_mL : alarm status record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ) +{ + BOOL result; + F32 volume_L = volume_mL / (F32)ML_PER_LITER; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_L, sizeof( F32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/************************************************************************* + * @brief * The handleChangeBloodDialysateRateChangeRequest function handles a blood \n * and dialysate rate settings change message from the UI. * @details @@ -594,6 +626,50 @@ /************************************************************************* * @brief + * The sendTreatmentParamsRangesToUI function constructs a treatment parameter \n + * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : Treatment parameter ranges msg constructed and queued. + * @param minTime : Minimum treatment duration (in minutes). + * @param maxTime : Maximum treatment duration (in minutes). + * @param minUFVol : Minimum ultrafiltration volume (in mL). + * @param maxUFVol : Maximum ultrafiltration volume (in mL). + * @param minDialRate : Minimum dialysate flow rate (in mL/min). + * @param maxDialRate : Maximum dialysate flow rate (in mL/min). + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, U32 minUFVol, U32 maxUFVol, U32 minDialRate, U32 maxDialRate ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &minTime, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &minUFVol, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &maxUFVol, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); + + // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/************************************************************************* + * @brief * The sendDialysateTempTargetsToDG function constructs a dialysate temperature \n * set points message for DG and queues the msg for transmit on the appropriate CAN channel. * @details