Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a -r6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 6679a2cd813b21a8cb4c58b3eeb721e0eef9a10b) @@ -15,13 +15,16 @@ * ***************************************************************************/ -#include "TDInterface.h" #include "Messaging.h" +#include "MessagePayloads.h" #include "ModeInitPOST.h" +#include "ModeStandby.h" +#include "ModeGenDialysate.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "SystemCommDD.h" #include "TaskGeneral.h" +#include "TDInterface.h" #include "Timers.h" /** @@ -318,6 +321,58 @@ return tdBicarbType; } +/*********************************************************************//** + * @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 ( ( DD_MODE_STAN == ddMode ) && ( DD_MODE_GEND == ddMode ) ) + { + // 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 *************************************************************************/