Index: firmware/App/Services/TxParams.c =================================================================== diff -u -r78fe8ab743ad4c64144421662960757a29b9b0b0 -r366a9c27c968b9102ef0e88669a9ce5bc76bf17e --- firmware/App/Services/TxParams.c (.../TxParams.c) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) +++ firmware/App/Services/TxParams.c (.../TxParams.c) (revision 366a9c27c968b9102ef0e88669a9ce5bc76bf17e) @@ -559,6 +559,160 @@ return result; } -/**@}*/ +/*********************************************************************//** + * @brief + * The setTreatmentParameterU32 function sets a given unsigned integer + * treatment parameter to a given value. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given param is invalid + * @details \b Inputs: treatmentParameters[] + * @details \b Outputs: treatmentParameters[] + * @param param ID of treatment parameter to set unsigned integer value for + * @param value unsigned integer value to assign to given treatment parameter + * @return TRUE if set was successful, FALSE if not + *************************************************************************/ +BOOL setTreatmentParameterU32( TREATMENT_PARAM_T param, U32 value ) +{ + CRITICAL_DATAS_T integerData; + BOOL result = FALSE; + integerData.uInt = value; + result = isTreatmentParamInRange( param, integerData ); + // Validate parameter + if ( param <= TREATMENT_PARAM_LAST_UINT ) + { + if ( TRUE == result ) + { + CRITICAL_DATAS_T data = treatmentParameters[ param ].data; + + data.uInt = value; + result = setCriticalData( &treatmentParameters[ param ], data ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_PARAMS_INVALID_SET_U32_PARAM, (U32)param ) + } + + return result; +} + +/*********************************************************************//** + * @brief + * The setTreatmentParameterS32 function sets a given signed integer treatment + * parameter to a given value. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given param is invalid + * @details \b Inputs: treatmentParameters[] + * @details \b Outputs: treatmentParameters[] + * @param param ID of treatment parameter to set signed integer value for + * @param value signed integer value to assign to given treatment parameter + * @return TRUE if set was successful, FALSE if not + *************************************************************************/ +BOOL setTreatmentParameterS32( TREATMENT_PARAM_T param, S32 value ) +{ + CRITICAL_DATAS_T unsignedIntData; + BOOL result = FALSE; + + unsignedIntData.sInt = value; + result = isTreatmentParamInRange( param, unsignedIntData ); + + // Validate parameter + if ( ( param >= TREATMENT_PARAM_FIRST_INT ) && ( param <= TREATMENT_PARAM_LAST_INT ) ) + { + if ( TRUE == result ) + { + CRITICAL_DATAS_T data = treatmentParameters[ param ].data; + + data.sInt = value; + result = setCriticalData( &treatmentParameters[ param ], data ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_PARAMS_INVALID_SET_S32_PARAM, (U32)param ) + } + + return result; +} + +/*********************************************************************//** + * @brief + * The setTreatmentParameterF32 sets a given floating point treatment parameter + * to a given value. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given param is invalid + * @details \b Inputs: treatmentParameters[] + * @details \b Outputs: treatmentParameters[] + * @param param ID of treatment parameter to set floating point value for + * @param value floating point value to assign to given treatment parameter + * @return TRUE if set was successful, FALSE if not + *************************************************************************/ +BOOL setTreatmentParameterF32( TREATMENT_PARAM_T param, F32 value ) +{ + CRITICAL_DATAS_T floatData; + BOOL result = FALSE; + + floatData.sFlt = value; + result = isTreatmentParamInRange( param, floatData ); + + // Validate parameter + if ( ( param >= TREATMENT_PARAM_FIRST_F32 ) && ( param < NUM_OF_TREATMENT_PARAMS ) ) + { + if ( TRUE == result ) + { + CRITICAL_DATAS_T data = treatmentParameters[ param ].data; + + data.sFlt = value; + result = setCriticalData( &treatmentParameters[ param ], data ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_PARAMS_INVALID_SET_F32_PARAM, (U32)param ) + } + + return result; +} + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetTreatmentParameterOverride function overrides the value of a + * given treatment parameter. + * @details Inputs: none + * @details Outputs: treatment parameter set to given value + * @param param ID of treatment parameter to set value of + * @param value value to set for given treatment parameter + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetTreatmentParameter( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ) +{ + BOOL result = FALSE; + + if ( param < NUM_OF_TREATMENT_PARAMS ) + { + if ( TRUE == isTestingActivated() ) + { + // Set parameter per its type + if ( CRITICAL_DATA_TYPE_U32 == TREAT_PARAMS_PROPERTIES[ param ].dataType ) + { + result = setTreatmentParameterU32( param, value.uInt ); + } + else if ( CRITICAL_DATA_TYPE_S32 == TREAT_PARAMS_PROPERTIES[ param ].dataType ) + { + result = setTreatmentParameterS32( param, value.sInt ); + } + else + { + result = setTreatmentParameterF32( param, value.sFlt ); + } + } + } + + return result; +} + +/**@}*/ Index: firmware/App/Services/TxParams.h =================================================================== diff -u -r78fe8ab743ad4c64144421662960757a29b9b0b0 -r366a9c27c968b9102ef0e88669a9ce5bc76bf17e --- firmware/App/Services/TxParams.h (.../TxParams.h) (revision 78fe8ab743ad4c64144421662960757a29b9b0b0) +++ firmware/App/Services/TxParams.h (.../TxParams.h) (revision 366a9c27c968b9102ef0e88669a9ce5bc76bf17e) @@ -82,18 +82,24 @@ // ********** public function prototypes **************** -void resetTreatmentParameters( void ); // Reset all parameters to defaults -BOOL signalUserConfirmTreatmentParameters( MESSAGE_T *message ); // Process UI confirm/reject Treatment parameters +void resetTreatmentParameters( void ); // Reset all parameters to defaults +BOOL signalUserConfirmTreatmentParameters( MESSAGE_T *message ); // Process UI confirm/reject Treatment parameters -BOOL validateAndSetTreatmentParameters( MESSAGE_T *message ); // Validate Treatment Parameters received from UI -BOOL validateAndSetUFVolume( MESSAGE_T *message ); // Validate UF volume received from UI +BOOL setTreatmentParameterU32( TREATMENT_PARAM_T param, U32 value ); // Set a specified unsigned integer treatment parameter value +BOOL setTreatmentParameterS32( TREATMENT_PARAM_T param, S32 value ); // Set a specified signed integer treatment parameter value +BOOL setTreatmentParameterF32( TREATMENT_PARAM_T param, F32 value ); // Set a specified floating point treatment parameter value -BOOL getValidTreatParamsReceived( void ); // Determine whether valid Treatment Parameters exist -BOOL getTreatParamsConfirmed( void ); // Determine whether user confirmed the parameters +BOOL validateAndSetTreatmentParameters( MESSAGE_T *message ); // Validate Treatment Parameters received from UI +BOOL validateAndSetUFVolume( MESSAGE_T *message ); // Validate UF volume received from UI -U32 getDialyzerBloodVolume( DIALYZER_TYPE_T dialyzer ); // Get the blood side volume for a given dialyzer type -U32 getDialyzerDialysateVolume( DIALYZER_TYPE_T dialyzer ); // Get the dialysate side volume for a given dialyzer type +BOOL getValidTreatParamsReceived( void ); // Determine whether valid Treatment Parameters exist +BOOL getTreatParamsConfirmed( void ); // Determine whether user confirmed the parameters +U32 getDialyzerBloodVolume( DIALYZER_TYPE_T dialyzer ); // Get the blood side volume for a given dialyzer type +U32 getDialyzerDialysateVolume( DIALYZER_TYPE_T dialyzer ); // Get the dialysate side volume for a given dialyzer type + +BOOL testSetTreatmentParameter( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ); // Set a specific treatment parameter value + /**@}*/ #endif