Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rb6d20d9e5c704a9f7ebceea9bb12731dac61fc2a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision b6d20d9e5c704a9f7ebceea9bb12731dac61fc2a) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -18,21 +18,23 @@ #include // for memcpy() #include "reg_system.h" - +#include "BalancingChamber.h" #include "Conductivity.h" #include "Compatible.h" #include "ConcentratePumps.h" #include "DialysatePumps.h" #include "Heaters.h" #include "Level.h" #include "Messaging.h" +#include "MessagePayloads.h" #include "ModeStandby.h" #include "ModeGenDialysate.h" #include "OperationModes.h" #include "PAL.h" #include "Pressure.h" #include "SystemCommDD.h" #include "Temperature.h" +#include "TDInterface.h" #include "Utilities.h" #include "Valves.h" @@ -128,6 +130,7 @@ MSG_ID_DD_CONCENTRATE_PUMPS_START_STOP_OVERRIDE_REQUEST, MSG_ID_DD_HEATERS_START_STOP_OVERRIDE_REQUEST, MSG_ID_DD_VALVES_OPEN_CLOSE_STATE_OVERRIDE_REQUEST, + MSG_ID_DD_GEN_DIALYSATE_REQUEST_DATA, }; /// Message handling function table @@ -180,6 +183,7 @@ &testConcentratePumpStartStopOverride, &testHeaterStartStopOverride, &testValveOpenCloseStateOverride, + &handleDialysateDeliveryRequestMsg, }; #define NUM_OF_FUNCTION_HANDLERS (sizeof(MSG_FUNCTION_HANDLERS) / sizeof(MsgFuncPtr)) @@ -412,10 +416,10 @@ /*********************************************************************//** * @brief - * The sendEvent function constructs an DG event message to the UI and + * The sendEvent function constructs an DD event message to the UI and * queues the msg for transmit on the appropriate CAN channel. * @details \b Inputs: none - * @details \b Outputs: DG event msg constructed and queued. + * @details \b Outputs: DD 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 @@ -483,7 +487,7 @@ payloadPtr += sizeof( U32 ); data = almData2.data.uInt.data; memcpy( payloadPtr, &data, sizeof( U32 ) ); - // Pad with space for 3 U32s - set to zero - unused for DG + // Pad with space for 3 U32s - set to zero - unused for DD payloadPtr += ( sizeof( U32) * 3 ); memset( payloadPtr, 0, sizeof( U32) * 3 ); @@ -585,6 +589,57 @@ return status; } +/*********************************************************************//** + * @brief + * The handleDialysateDeliveryRequestMsg function handles a dailysate + * delivery request from TD and updates dialysate flowrate, UF rate, + * dialysate temperature, dialyzer bypass and concentrate types ( acid + * and bicarb types). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return TRUE if message is sucessfully parsed, FALSE if not. + *************************************************************************/ +BOOL handleDialysateDeliveryRequestMsg( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ) + { + DIALYSATE_DELIVERY_REQ_PAYLOAD_T startTxRequest; + DD_OP_MODE_T ddMode = getCurrentOperationMode(); + + memcpy( &startTxRequest, message->payload, sizeof( DIALYSATE_DELIVERY_REQ_PAYLOAD_T ) ); + + if ( ( DD_MODE_STAN == ddMode ) && ( TRUE == startTxRequest.start ) ) + { + result = requestDDStart(); + } + else if ( ( DD_MODE_GEND == ddMode ) && ( FALSE == startTxRequest.start ) ) + { + result = requestDDStop(); + } + + if ( ddMode >= DD_MODE_STAN ) + { + // Set dialysate flow rate, UF rate and dialysate temperature + setTDDialysateFlowrate( startTxRequest.dialRate ); + setTDUFRate( startTxRequest.ufRate ); + setTDTargetDialysateTemperature( startTxRequest.dialTemp ); + + // Set concentrate types, Bypass dialyzer + setTDAcidAndBicarbType( startTxRequest.acidType, startTxRequest.bicarbType ); + setTDDialyzerBypass( startTxRequest.bypassDialyzer ); + + result |= TRUE; + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DD_2_TD, result ); + + return result; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/