Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -r1b83a4555c4040a45cecfbea45b6570812ab281e -ree84e20f729b0aace2b1728c16de9a89e06eee38 --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 1b83a4555c4040a45cecfbea45b6570812ab281e) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision ee84e20f729b0aace2b1728c16de9a89e06eee38) @@ -43,13 +43,16 @@ static BOOL ddStartCommandSent; ///< Flag indicates command to start DD has been sent. static BOOL ddStarted; ///< Flag indicates whether we have commanded the DD to start or stop. static BOOL isDialysateGoodtoDeliver; ///< Flag indicating whether dialysate is good to deliver. +static U32 currentGenDState; ///< Current state of DD GenD mode. static BOOL ddOpModeDataFreshFlag; ///< Flag to signal the handleDDOpMode() to process fresh dd op mode data. static BOOL ddDialysatePressureFreshFlag; ///< Flag to signal static PRE_GEN_DIALYSATE_REQ_PAYLOAD_T preGenDialysateCmdSet; ///< Set of pre-generate dialysate parameters to send to the DD static DIALYSATE_DELIVERY_REQ_PAYLOAD_T dialysateDeliveryCmdSet; ///< Set of dialysate delivery parameters to send to the DD during treatment. +static PRIME_DATA_REQ_PAYLOAD_T primeDataCmdSet; + // DD command response static DD_CMD_RESPONSE_T ddCmdResp[ NUM_OF_DD_COMMANDS ]; ///< Keep the latest DD command response for each command. @@ -73,6 +76,7 @@ ddSubMode = 0; dialysatePressure = 0.0F; isDialysateGoodtoDeliver = FALSE; + currentGenDState = 0; ddOpModeDataFreshFlag = FALSE; ddDialysatePressureFreshFlag = FALSE; @@ -121,6 +125,9 @@ dialysateDeliveryCmdSet.sodium = 0; dialysateDeliveryCmdSet.bicarbonate = 0; dialysateDeliveryCmdSet.substitutionRate = 0.0F; + + primeDataCmdSet.chamberHValveOpen = FALSE; + primeDataCmdSet.primeFluidDiscardStart = FALSE; } /**********************************************************************//** @@ -267,6 +274,7 @@ if ( message->hdr.payloadLen == sizeof( GEN_DIALYSATE_MODE_DATA_T ) ) { isDialysateGoodtoDeliver = payload.isDialysateGoodtoDeliver; + currentGenDState = payload.genDialysateExecState; result = TRUE; } else @@ -307,6 +315,18 @@ /*********************************************************************//** * @brief + * The getCurrentGenDState function gets the current state of gen dialysate. + * @details \b Inputs: currentGenDState + * @details \b Outputs: none + * @return Current state of gen dialysate + *************************************************************************/ +BOOL getCurrentGenDState( void ) +{ + return currentGenDState; +} + +/*********************************************************************//** + * @brief * The setDialysatePressure function sets the latest dialysate pressure * reported by the DD sub-system. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if message invalid. @@ -625,7 +645,58 @@ } } +/*********************************************************************//** + * @brief + * The cmdDDChamberHValveOpen function sends a prime data request to the DD + * to open or close the Chamber H vent valve (D47) during dialysate circuit + * prime depressurization. + * @details \b Message \b Sent: MSG_ID_DD_TD_PRIME_REQUEST_DATA + * @details \b Inputs: none + * @details \b Outputs: primeDataCmdSet + * @param valveOpenRequest TRUE to open the Chamber H vent valve, FALSE to close it + * @return none + *************************************************************************/ +void cmdDDChamberHValveOpen( BOOL valveOpenRequest ) +{ + if ( TRUE == dialysateDeliveryCmdSet.start ) + { + primeDataCmdSet.chamberHValveOpen = valveOpenRequest; +#ifndef TEST_UI_ONLY + sendMessage( MSG_ID_DD_TD_PRIME_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&primeDataCmdSet), sizeof( PRIME_DATA_REQ_PAYLOAD_T ) ); +#endif + } + else + { + // TODO - s/w fault? + } +} +/*********************************************************************//** + * @brief + * The cmdDDprimeFluidDiscard function sends a prime data request to the DD + * to start or stop discarding the priming fluid via the ultrafiltration + * pump (D76) during priming fluid discard and dialyzer reverse prime. + * @details \b Message \b Sent: MSG_ID_DD_TD_PRIME_REQUEST_DATA + * @details \b Inputs: none + * @details \b Outputs: primeDataCmdSet + * @param primeFluidDiscardRequest TRUE to start priming fluid discard, FALSE to stop it + * @return none + *************************************************************************/ +void cmdDDprimeFluidDiscard( BOOL primeFluidDiscardRequest ) +{ + if ( TRUE == dialysateDeliveryCmdSet.start ) + { + primeDataCmdSet.primeFluidDiscardStart = primeFluidDiscardRequest; +#ifndef TEST_UI_ONLY + sendMessage( MSG_ID_DD_TD_PRIME_REQUEST_DATA, COMM_BUFFER_OUT_CAN_TD_2_DD, (U08*)(&primeDataCmdSet), sizeof( PRIME_DATA_REQ_PAYLOAD_T ) ); +#endif + } + else + { + // TODO - s/w fault? + } +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/