Index: firmware/App/Modes/BalancingChamber.c =================================================================== diff -u -rb6d20d9e5c704a9f7ebceea9bb12731dac61fc2a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision b6d20d9e5c704a9f7ebceea9bb12731dac61fc2a) +++ firmware/App/Modes/BalancingChamber.c (.../BalancingChamber.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -32,6 +32,7 @@ */ // ********** private definitions ********** + #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. #define FRESH_DIAL_PRESSURE_MIN_PSIG 23.0F ///< Minimum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. #define FRESH_DIAL_PRESSURE_MAX_PSIG 25.0F ///< Maximum fresh dialysate pressure (PDf) limit for balancing chamber fill operations. @@ -665,7 +666,7 @@ data.balChamberExecState = (U32)balChamberExecState; data.balChamberSWState = (U32)balChamberSWState; data.balChamberSWFreq = getBalChamberSwitchingFreq(); - data.isDialDelInProgress = getDialDeliveryProgressStatus(); + data.isDialDelInProgress = (BOOL)getDialDeliveryProgressStatus(); data.balChamberSwPeriod = balChamberSwitchingPeriod; data.isBalChamberFillInProgress = isBalChamberFillInProgress; data.currentBalChamberSwitchingCounter = currentBalChamberSwitchingCounter; Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r48ca7fd644c67920acc29a80b7af379d0a134d1a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 48ca7fd644c67920acc29a80b7af379d0a134d1a) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -260,6 +260,22 @@ /*********************************************************************//** * @brief + * The requestDDStop function handles an TD request to stop (return to standby mode). + * @details \b Inputs: none + * @details \b Outputs: DD standby mode requested + * @return TRUE if request accepted. + *************************************************************************/ +BOOL requestDDStop( void ) +{ + BOOL result = TRUE; + + requestNewOperationMode( DD_MODE_STAN ); + + return result; +} + +/*********************************************************************//** + * @brief * The startDDFlush function starts DD flush mode. * @details \b Inputs: standbyState * @details \b Outputs: none Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r48ca7fd644c67920acc29a80b7af379d0a134d1a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 48ca7fd644c67920acc29a80b7af379d0a134d1a) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -45,7 +45,8 @@ U32 execStandbyMode( void ); // execute the standby mode state machine (call from OperationModes) BOOL areInletWaterConditionsAlarmsActive( void ); // checks water inlet pressure, temperature and conductivity alarms. -BOOL requestDDStart( void ); // TD requests DD start (go to generation idle mode) +BOOL requestDDStart( void ); // TD requests DD start (go to generation dialysate mode) +BOOL requestDDStop( void ); // TD request to stop the dialysate generation. BOOL startDDFlush( void ); // TD start flush mode BOOL startDDHeatDisinfect( void ); // TD start heat disinfect mode 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 *************************************************************************/ Index: firmware/App/Services/Messaging.h =================================================================== diff -u -rf7c714a1a09b10d85a8b013712532d37b4d7b97a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision f7c714a1a09b10d85a8b013712532d37b4d7b97a) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -66,6 +66,7 @@ // handler functions **************************************** BOOL handleSetTDOperationMode( MESSAGE_T *message ); +BOOL handleDialysateDeliveryRequestMsg( MESSAGE_T *message ); // Test Support Messaging Functions ************************** Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -rb6d20d9e5c704a9f7ebceea9bb12731dac61fc2a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision b6d20d9e5c704a9f7ebceea9bb12731dac61fc2a) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -39,12 +39,12 @@ // TD status static TD_OP_MODE_T tdCurrentOpMode; ///< Current TD operation mode. static U32 tdSubMode; ///< Current state (sub-mode) of current TD operation mode. -static F32 tdDialysisFlowrate; ///< TD dialysis flow rate +static F32 tdDialysateFlowrate; ///< TD dialysate flow rate static F32 tdUFRate; ///< TD ultrafilteration rate static F32 tdTargetDialysateTemp; ///< TD target dialysate temperature static BOOL tdDialyzerBypass; ///< TD dialyzer bypass -static U32 tdAcidType; ///< TD Acid type -static U32 tdBiCarbType; ///< TD Bicarb type +static DD_ACID_TYPES_T tdAcidType; ///< TD Acid type. +static DD_BICARB_TYPES_T tdBicarbType; ///< TD Bicarb type. static BOOL tdOpModeDataFreshFlag = FALSE; ///< Flag to signal/process fresh TD op mode data @@ -54,22 +54,22 @@ /*********************************************************************//** * @brief - * The initTDInterface function initializes the TDInterface unit. + * The initTDInterface function initializes the TD Interface unit. * @details \b Inputs: none - * @details \b Outputs: TDInterface unit initialized. + * @details \b Outputs: TD Interface unit initialized. * @return none *************************************************************************/ void initTDInterface( void ) { // Initialize unit variables tdCurrentOpMode = MODE_INIT; tdSubMode = 0; - tdDialysisFlowrate = TD_MAX_DIALYSIS_FLOW_RATE; // Will update later based on the TD value + tdDialysateFlowrate = TD_MAX_DIALYSIS_FLOW_RATE; // Will update later based on the TD value tdUFRate = 0.0F; tdTargetDialysateTemp = 0.0F; tdDialyzerBypass = FALSE; - tdAcidType = 0; - tdBiCarbType = 0; + tdAcidType = ACID_08_1251_1; + tdBicarbType = BICARB_08_677753_0; } /**********************************************************************//** @@ -171,15 +171,86 @@ /*********************************************************************//** * @brief - * The getTDDialysateFlowrate function gets the latest TD dialysis flow + * The setTDDialysateFlowrate function sets the latest TD dialysate flow * rate. - * @details \b Inputs: tdDialysisFlowrate + * @details \b Inputs: none + * @details \b Outputs: tdDialysateFlowrate + * @param dialysate flow rate. + * @return none. + *************************************************************************/ +void setTDDialysateFlowrate( F32 dialFlowrate ) +{ + tdDialysateFlowrate = dialFlowrate; +} + +/*********************************************************************//** + * @brief + * The setTDUFRate function sets the latest TD UF rate. + * @details \b Inputs: none + * @details \b Outputs: tdUFRate + * @param ultrafilteration flow rate. + * @return none. + *************************************************************************/ +void setTDUFRate( F32 ufRate ) +{ + tdUFRate = ufRate; +} + +/*********************************************************************//** + * @brief + * The setTDTargetDialysateTemperature function sets the latest TD dialysate + * temperature. + * @details \b Inputs: none + * @details \b Outputs: tdTargetDialysateTemp + * @param Target dialysate temperature. + * @return none. + *************************************************************************/ +void setTDTargetDialysateTemperature( F32 dialTemperature ) +{ + tdTargetDialysateTemp = dialTemperature; +} + +/*********************************************************************//** + * @brief + * The setTDDialyzerBypass function sets the latest TD dialyzer bypass + * enable. + * @details \b Inputs: none + * @details \b Outputs: tdDialyzerBypass + * @param Dialyzer Bypass enable. + * @return none. + *************************************************************************/ +void setTDDialyzerBypass( F32 dialBypass ) +{ + tdDialyzerBypass = dialBypass; +} + +/*********************************************************************//** + * @brief + * The setTDAcidAndBicarbType function sets the acid and bicarb types to be + * used in dialysate generation. + * @details \b Inputs: none + * @details \b Outputs: tdAcidType,tdBicarbType + * @param acid which is the type of acid + * @param bicarb which is the type of bicarb + * @return none + *************************************************************************/ +void setTDAcidAndBicarbType( U32 acid, U32 bicarb ) +{ + tdAcidType = (DD_ACID_TYPES_T)acid; + tdBicarbType = (DD_BICARB_TYPES_T)bicarb; +} + +/*********************************************************************//** + * @brief + * The getTDDialysateFlowrate function gets the latest TD dialysate flow + * rate. + * @details \b Inputs: tdDialysateFlowrate * @details \b Outputs: none - * @return Latest TD dialysis flow rate. + * @return Latest TD dialysate flow rate. *************************************************************************/ F32 getTDDialysateFlowrate( void ) { - return tdDialysisFlowrate; + return tdDialysateFlowrate; } /*********************************************************************//** @@ -210,8 +281,8 @@ /*********************************************************************//** * @brief - * The getTDDialyzerBypass function gets the latest TD - * dailyzer bypass valve enable flag. + * The getTDDialyzerBypass function gets the latest TD dailyzer bypass valve + * enable flag. * @details \b Inputs: tdDialyzerBypass * @details \b Outputs: none * @return Latest dialyzer bypass valve enable. @@ -221,6 +292,32 @@ return tdDialyzerBypass; } +/*********************************************************************//** + * @brief + * The getTDAcidConcentrateType function gets the latest Acid concentrate + * type. + * @details \b Inputs: tdAcidType + * @details \b Outputs: none + * @return Latest acid concentrate type. + *************************************************************************/ +DD_ACID_TYPES_T getTDAcidConcentrateType( void ) +{ + return tdAcidType; +} + +/*********************************************************************//** + * @brief + * The getTDBicarbConcentrateType function gets the latest Bicarb concentrate + * type. + * @details \b Inputs: tdBicarbType + * @details \b Outputs: none + * @return Latest bicarb concentrate type. + *************************************************************************/ +DD_BICARB_TYPES_T getTDBicarbConcentrateType( void ) +{ + return tdBicarbType; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/TDInterface.h =================================================================== diff -u -rb6d20d9e5c704a9f7ebceea9bb12731dac61fc2a -rbbd8ef64eb4b178ca76a9721908fee7347a71c6a --- firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision b6d20d9e5c704a9f7ebceea9bb12731dac61fc2a) +++ firmware/App/Services/TDInterface.h (.../TDInterface.h) (revision bbd8ef64eb4b178ca76a9721908fee7347a71c6a) @@ -20,6 +20,7 @@ #include "DDCommon.h" #include "TDDefs.h" +#include "DDDefs.h" /** * @defgroup TDInterface TDInterface @@ -43,12 +44,24 @@ TD_OP_MODE_T getTDOpMode( void ); U32 getTDSubMode( void ); void setTDOpMode( U32 opMode, U32 subMode ); + F32 getTDDialysateFlowrate( void ); +void setTDDialysateFlowrate( F32 dialFlowrate ); + F32 getTDUFRate( void ); +void setTDUFRate( F32 ufRate ); + F32 getTDTargetDialysateTemperature( void ); +void setTDTargetDialysateTemperature( F32 dialTemperature ); + BOOL getTDDialyzerBypass( void ); +void setTDDialyzerBypass( F32 dialBypass ); +DD_BICARB_TYPES_T getTDBicarbConcentrateType( void ); +DD_ACID_TYPES_T getTDAcidConcentrateType( void ); +void setTDAcidAndBicarbType( U32 acid, U32 bicarb ); + /**@}*/ #endif