Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -r927dfd6e109af46160e5aef687f1b7c286d24703 -r08fdaaf70ab5133cbe7d019905f745074a756027 --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 927dfd6e109af46160e5aef687f1b7c286d24703) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 08fdaaf70ab5133cbe7d019905f745074a756027) @@ -43,13 +43,17 @@ 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 U32 isBalChamberSwitchingActive; ///< Flag indicating whether bc is switching. 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 +77,7 @@ ddSubMode = 0; dialysatePressure = 0.0F; isDialysateGoodtoDeliver = FALSE; + currentGenDState = 0; ddOpModeDataFreshFlag = FALSE; ddDialysatePressureFreshFlag = FALSE; @@ -120,6 +125,10 @@ dialysateDeliveryCmdSet.bicarbConvFactor = 0.0F; dialysateDeliveryCmdSet.sodium = 0; dialysateDeliveryCmdSet.bicarbonate = 0; + dialysateDeliveryCmdSet.substitutionRate = 0.0F; + + primeDataCmdSet.chamberHValveOpen = FALSE; + primeDataCmdSet.primeFluidDiscardStart = FALSE; //dialysateDeliveryCmdSet.substitutionRate = 0.0F; } @@ -267,6 +276,7 @@ if ( message->hdr.payloadLen == sizeof( GEN_DIALYSATE_MODE_DATA_T ) ) { isDialysateGoodtoDeliver = payload.isDialysateGoodtoDeliver; + currentGenDState = payload.genDialysateExecState; result = TRUE; } else @@ -280,6 +290,38 @@ /*********************************************************************//** * @brief + * The handleBalancingChamberData function sets the latest DD balancing + * chamber switching status reported by the DD. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if message is invalid. + * @details \b Inputs: none + * @details \b Outputs: isBalChamberSwitchingActive + * @param message Pointer to the DD balancing chamber data broadcast message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL handleBalancingChamberData( MESSAGE_T *message ) +{ + BOOL result = FALSE; + BAL_CHAMBER_DATA_T payload; + + if ( message->hdr.payloadLen == sizeof( BAL_CHAMBER_DATA_T ) ) + { + // parse message payload + memcpy( &payload, &message->payload[ 0 ], sizeof( BAL_CHAMBER_DATA_T ) ); + + isBalChamberSwitchingActive = payload.isBalChamberSwitchingActive; + result = TRUE; + } + else + { +#ifndef TEST_UI_ONLY + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DD_BAL_CHAMBER_DATA, (U32)message->hdr.payloadLen ); +#endif + } + return result; +} + +/*********************************************************************//** + * @brief * The getDialysatePressure function gets the latest reported dialysate * pressure. * @details \b Inputs: dialysatePressure @@ -307,6 +349,31 @@ /*********************************************************************//** * @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 getBalChamberSwitchingStatus function returns whether the DD + * balancing chamber is currently switching. + * @details \b Inputs: isBalChamberSwitchingActive + * @details \b Outputs: none + * @return TRUE if balancing chamber switching is active, FALSE if not + *************************************************************************/ +BOOL getBalChamberSwitchingStatus( void ) +{ + return isBalChamberSwitchingActive; +} + +/*********************************************************************//** + * @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 +692,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 *************************************************************************/