Index: firmware/App/Services/TDInterface.c =================================================================== diff -u -rbd522c8ffdf75130571e5b6a79d1b1d6acd78b1c -r1a15aa462c0db129606243a4761fa2978ce01730 --- firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision bd522c8ffdf75130571e5b6a79d1b1d6acd78b1c) +++ firmware/App/Services/TDInterface.c (.../TDInterface.c) (revision 1a15aa462c0db129606243a4761fa2978ce01730) @@ -93,7 +93,7 @@ // 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 BOOL tdDialyzerBypass; ///< TD dialyzer bypass +static U32 tdRequestedGenDState; ///< TD-requested gen dialysate sub-state (DD_GEND_MODE_STATE_T). static BOOL tdOpModeDataFreshFlag = FALSE; ///< Flag to signal/process fresh TD op mode data static OVERRIDE_F32_T tdDialysateFlowrate; ///< TD Dialysate flow rate @@ -108,6 +108,7 @@ // ********** private function prototypes ********** static void checkTDDataFreshness( ALARM_ID_T alarmID, BOOL *tdFreshDataFlag ); +static BOOL isValidTDGenDStateRequest( U32 genDialysateState ); /*********************************************************************//** * @brief @@ -119,10 +120,10 @@ void initTDInterface( void ) { // Initialize unit state variables - tdCurrentOpMode = MODE_INIT; - tdSubMode = 0U; - tdDialyzerBypass = FALSE; - tdOpModeDataFreshFlag = FALSE; + tdCurrentOpMode = MODE_INIT; + tdSubMode = 0U; + tdRequestedGenDState = DD_GEND_DIALYSATE_BYPASS_STATE; + tdOpModeDataFreshFlag = FALSE; // Initialize treatment parameters from TD tdDialysateFlowrate.data = 0.0F; @@ -201,6 +202,31 @@ /*********************************************************************//** * @brief + * The isValidTDGenDStateRequest function validates a TD gen dialysate + * sub-state request. + * @details \b Inputs: genDialysateState + * @details \b Outputs: none + * @param genDialysateState Requested DD gen dialysate sub-state. + * @return TRUE if the request is a TD-commandable treatment sub-state + * (bypass, delivery, or isolated UF). Internal DD states such as spent/ + * bicarb chamber fill and delivery pause are not TD-requestable. + *************************************************************************/ +static BOOL isValidTDGenDStateRequest( U32 genDialysateState ) +{ + BOOL result = FALSE; + + if ( ( DD_GEND_DIALYSATE_BYPASS_STATE == genDialysateState ) || + ( DD_GEND_DIALYSATE_DELIVERY_STATE == genDialysateState ) || + ( DD_GEND_ISOLATED_UF_STATE == genDialysateState ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The execTDInterfaceMonitor function executes the TD Interface monitoring * function. Ensures TD is sending fresh data in a timely manner. * @details \b Inputs: none @@ -306,16 +332,25 @@ /*********************************************************************//** * @brief - * The setTDDialyzerBypass function sets the latest TD dialyzer bypass - * enable. + * The setTDRequestedGenDState function sets the latest TD-requested gen + * dialysate sub-state. + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if requested state is not + * a TD-commandable gen dialysate sub-state. * @details \b Inputs: none - * @details \b Outputs: tdDialyzerBypass - * @param Dialyzer Bypass enable. + * @details \b Outputs: tdRequestedGenDState + * @param genDialysateState Requested DD gen dialysate sub-state. * @return none. *************************************************************************/ -void setTDDialyzerBypass( BOOL dialBypass ) +void setTDRequestedGenDState( U32 genDialysateState ) { - tdDialyzerBypass = dialBypass; + if ( TRUE == isValidTDGenDStateRequest( genDialysateState ) ) + { + tdRequestedGenDState = genDialysateState; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TD_GEND_STATE_REQUEST, genDialysateState ); + } } /*********************************************************************//** @@ -389,15 +424,15 @@ } /*********************************************************************//** * @brief - * The getTDDialyzerBypass function gets the latest TD dailyzer bypass valve - * enable flag. - * @details \b Inputs: tdDialyzerBypass + * The getTDRequestedGenDState function gets the latest TD-requested gen + * dialysate sub-state. + * @details \b Inputs: tdRequestedGenDState * @details \b Outputs: none - * @return Latest dialyzer bypass valve enable. + * @return Latest requested gen dialysate sub-state. *************************************************************************/ -BOOL getTDDialyzerBypass( void ) +U32 getTDRequestedGenDState( void ) { - return tdDialyzerBypass; + return tdRequestedGenDState; } /****************************************************************************** @@ -558,12 +593,10 @@ setTDUFRate( startTxRequest.ufRate ); setTDTargetDialysateTemperature( startTxRequest.dialTemp ); - // Set concentrate types, Bypass dialyzer and substitution rate + // Set concentrate types and requested gen dialysate sub-state setTDAcidAndBicarbType( startTxRequest.acidConvFactor, startTxRequest.bicarbConvFactor, startTxRequest.sodium, startTxRequest.bicarbonate ); - setTDDialyzerBypass( startTxRequest.bypassDialyzer ); - tdSubstitutionFlowRate.data = startTxRequest.substitutionRate; - setSubstitutionPumpTargetRate( D92_PUMP, getTDSubstitutionFlowRate() ); + setTDRequestedGenDState( startTxRequest.genDialysateState ); // start dialysate generation result = requestDDGenDialStart(); @@ -589,12 +622,10 @@ setTDUFRate( startTxRequest.ufRate ); setTDTargetDialysateTemperature( startTxRequest.dialTemp ); - // Set concentrate types, Bypass dialyzer and substitution rate + // Set concentrate types and requested gen dialysate sub-state setTDAcidAndBicarbType( startTxRequest.acidConvFactor, startTxRequest.bicarbConvFactor, startTxRequest.sodium, startTxRequest.bicarbonate ); - setTDDialyzerBypass( startTxRequest.bypassDialyzer ); - tdSubstitutionFlowRate.data = startTxRequest.substitutionRate; - setSubstitutionPumpTargetRate( D92_PUMP, getTDSubstitutionFlowRate() ); + setTDRequestedGenDState( startTxRequest.genDialysateState ); // Signal to update treatement parameters setTreatmentParamUpdate();