Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -r3d72b777cf1ceb673d118341c46e2d6d5b7b75f5 -r6c1d6a3eaf065c2b2d537d9fef793d73ea328359 --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 3d72b777cf1ceb673d118341c46e2d6d5b7b75f5) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 6c1d6a3eaf065c2b2d537d9fef793d73ea328359) @@ -8,7 +8,7 @@ * @file ModeTreatmentParams.c * * @author (last) Dara Navaei -* @date (last) 04-Jan-2022 +* @date (last) 22-Feb-2022 * * @author (original) Sean Nash * @date (original) 29-May-2020 @@ -65,7 +65,7 @@ { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=0}, {.uInt=0} }, // TREATMENT_PARAM_HEPARIN_TYPE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=60}, {.uInt=30} }, // TREATMENT_PARAM_BP_MEAS_INTERVAL { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=150}, {.uInt=75} }, // TREATMENT_PARAM_RINSEBACK_FLOW_RATE - { CRITICAL_DATA_TYPE_S32, {.sInt=-300}, {.sInt=-30}, {.sInt=-300} }, // TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT + { CRITICAL_DATA_TYPE_S32, {.sInt=-300}, {.sInt=70}, {.sInt=-300} }, // TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT { CRITICAL_DATA_TYPE_S32, {.sInt=-270}, {.sInt=100}, {.sInt=100} }, // TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=570}, {.sInt=20} }, // TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT { CRITICAL_DATA_TYPE_S32, {.sInt=50}, {.sInt=600}, {.sInt=400} }, // TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT @@ -631,6 +631,56 @@ /*********************************************************************//** * @brief + * The getS32TreatmentParamLowerRangeLimit function returns the lower range + * limit for a given signed integer treatment parameter. + * @details Inputs: none + * @details Outputs: none + * @param param ID of parameter to get lower range limit for + * @return lower range limit for given signed integer treatment parameter + *************************************************************************/ +S32 getS32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_T param ) +{ + S32 result = 0; + + if ( param < NUM_OF_TREATMENT_PARAMS ) + { + result = TREAT_PARAMS_PROPERTIES[ param ].min.sInt; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_PARAMS_INVALID_GET_S32_PARAM_MIN_LIMIT, (U32)param ) + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getS32TreatmentParamUpperRangeLimit function returns the upper range + * limit for a given signed integer treatment parameter. + * @details Inputs: none + * @details Outputs: none + * @param param ID of parameter to get upper range limit for + * @return upper range limit for given signed integer treatment parameter + *************************************************************************/ +S32 getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_T param ) +{ + S32 result = 0; + + if ( param < NUM_OF_TREATMENT_PARAMS ) + { + result = TREAT_PARAMS_PROPERTIES[ param ].max.sInt; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_TREATMENT_PARAMS_INVALID_GET_S32_PARAM_MAX_LIMIT, (U32)param ) + } + + return result; +} + +/*********************************************************************//** + * @brief * The extractTreatmentParamsFromPayload function extracts the individual * treatment parameters received from the UI into a staging array where * they will be validated and stay until user confirms them. @@ -871,6 +921,7 @@ return ( ( origTreatmentParams.uFVolume_L * ML_PER_LITER ) / origTreatmentParams.treatmentDuration_min ); } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -909,7 +960,76 @@ } } } + return result; +} +/*********************************************************************//** + * @brief + * The testUpdateCurrentTreatmentParameters function pulls the current + * treatment parameters from the critical section if data has been + * determined to be valid. Calls sendTestCurrentTreatmentParametersResponse. + * @details Inputs: none + * @details Outputs: CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T containing + * treatment parameters. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSendCurrentTreatmentParameters( void ) +{ + BOOL result = FALSE; + CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T current_treatment_params; + + if ( TRUE == isTestingActivated() ) + { + // Test one parameter for set since all parameters are set after parameter validation. + if(TRUE == isCriticalDataSet( &treatmentParameters[TREATMENT_PARAM_BLOOD_FLOW] )) + { + result = TRUE; + current_treatment_params.accepted = TRUE; + current_treatment_params.treatment_parameters.bloodFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_BLOOD_FLOW); + current_treatment_params.treatment_parameters.dialysateFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_DIALYSATE_FLOW); + current_treatment_params.treatment_parameters.treatmentDuration_min = getTreatmentParameterU32(TREATMENT_PARAM_TREATMENT_DURATION); + current_treatment_params.treatment_parameters.heparinPreStop_min = getTreatmentParameterU32(TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME); + current_treatment_params.treatment_parameters.salineBolusVolume_mL = getTreatmentParameterU32(TREATMENT_PARAM_SALINE_BOLUS_VOLUME); + current_treatment_params.treatment_parameters.acidConcentrate = getTreatmentParameterU32(TREATMENT_PARAM_ACID_CONCENTRATE); + current_treatment_params.treatment_parameters.bicarbConcentrate = getTreatmentParameterU32(TREATMENT_PARAM_BICARB_CONCENTRATE); + current_treatment_params.treatment_parameters.dialyzerType = getTreatmentParameterU32(TREATMENT_PARAM_DIALYZER_TYPE); + current_treatment_params.treatment_parameters.heparinType = getTreatmentParameterU32(TREATMENT_PARAM_HEPARIN_TYPE); + current_treatment_params.treatment_parameters.bloodPressureMeasurementInterval_min = getTreatmentParameterU32(TREATMENT_PARAM_BP_MEAS_INTERVAL); + current_treatment_params.treatment_parameters.rinsebackFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_RINSEBACK_FLOW_RATE); + current_treatment_params.treatment_parameters.arterialPressureLowLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT); + current_treatment_params.treatment_parameters.arterialPressureHighLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT); + current_treatment_params.treatment_parameters.venousPressureLowLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT); + current_treatment_params.treatment_parameters.venousPressureHighLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT); + current_treatment_params.treatment_parameters.heparinDispenseRate_mL_hr = getTreatmentParameterF32(TREATMENT_PARAM_HEPARIN_DISPENSE_RATE); + current_treatment_params.treatment_parameters.heparinBolusVolume_mL = getTreatmentParameterF32(TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME); + current_treatment_params.treatment_parameters.dialysateTemperature_degC = getTreatmentParameterF32(TREATMENT_PARAM_DIALYSATE_TEMPERATURE); + current_treatment_params.uFVolume_L = getTreatmentParameterF32(TREATMENT_PARAM_UF_VOLUME); + } + else + { + current_treatment_params.accepted = FALSE; + current_treatment_params.treatment_parameters.bloodFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.dialysateFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.treatmentDuration_min = 0; + current_treatment_params.treatment_parameters.heparinPreStop_min = 0; + current_treatment_params.treatment_parameters.salineBolusVolume_mL = 0; + current_treatment_params.treatment_parameters.acidConcentrate = 0; + current_treatment_params.treatment_parameters.bicarbConcentrate = 0; + current_treatment_params.treatment_parameters.dialyzerType = 0; + current_treatment_params.treatment_parameters.heparinType = 0; + current_treatment_params.treatment_parameters.bloodPressureMeasurementInterval_min = 0; + current_treatment_params.treatment_parameters.rinsebackFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.arterialPressureLowLimit_mmHg = 0; + current_treatment_params.treatment_parameters.arterialPressureHighLimit_mmHg = 0; + current_treatment_params.treatment_parameters.venousPressureLowLimit_mmHg = 0; + current_treatment_params.treatment_parameters.venousPressureHighLimit_mmHg = 0; + current_treatment_params.treatment_parameters.heparinDispenseRate_mL_hr = 0; + current_treatment_params.treatment_parameters.heparinBolusVolume_mL = 0; + current_treatment_params.treatment_parameters.dialysateTemperature_degC = 0; + current_treatment_params.uFVolume_L = 0; + } + sendTestCurrentTreatmentParametersResponse(current_treatment_params); + } return result; }