getMostRelevantMeasurementErrors
Filters, sorts, and stores measurement errors by relevance so that the most significant measurement issues can be displayed in the UI.
getMostRelevantMeasurementErrors()
Purpose
Extracts, ranks, and formats the most relevant measurement errors from a measurement result.
The function is primarily used to prepare measurement quality feedback for display within the configuration. It evaluates all available measurement errors, filters out irrelevant entries, sorts the remaining errors by severity, and stores the ranked result in a format that can easily be consumed by UI pages and result screens.
This allows configurations to dynamically display the most important factors that negatively influenced a measurement and provide targeted guidance to the user.
Typical use cases include:
- Displaying measurement quality feedback
- Showing the most significant measurement issues
- Generating user improvement recommendations
- Prioritizing measurement warnings
- Driving error-specific UI elements and explanations
Location
src/app/services/genericStages/generic-stages.service.ts
Signature
getMostRelevantMeasurementErrors(
pipelineConfig: PipelineStageConfig
): OperatorFunction<StatusObject, Observable<any>>
Parameters
| Parameter | Type | Description |
|---|---|---|
pipelineConfig |
PipelineStageConfig |
Current pipeline stage configuration containing measurement results, state, and event targets. |
Returns
OperatorFunction<StatusObject, Observable<any>>
RxJS operator which extracts and ranks measurement errors before storing the formatted result in the application state.
Configuration
Optional Parameters
| Parameter | Default Value | Description |
|---|---|---|
resKey |
mostRelevantMeasurementErrors |
State key where the result will be stored |
resGroup |
temp |
State group where the result will be written |
Input Data
The function expects measurement errors to be available at:
state.temp.resultAox.measurement_errors
Example:
{
movement: {
error: 0.83
},
unevenContact: {
error: 0.42
},
pressureTooLow: {
error: 0.67
},
electricalNoise: {
error: 0
}
}
Workflow
Read measurement_errors
↓
Remove entries without errors
↓
Remove entries with error <= 0
↓
Sort by error value (descending)
↓
Generate ranked result object
↓
Store result in state
↓
Execute onSuccess
Error Ranking Logic
Each measurement error entry is converted into:
{
name: string,
error: number
}
The function then:
- Extracts the error value.
- Removes invalid entries.
- Removes entries with error values less than or equal to zero.
- Sorts all remaining entries by severity.
- Creates a ranked output object.
Example Ranking
Input
{
movement: { error: 0.83 },
pressureTooLow: { error: 0.67 },
unevenContact: { error: 0.42 }
}
Output
{
error1: "movement",
error1Value: 0.83,
error2: "pressureTooLow",
error2Value: 0.67,
error3: "unevenContact",
error3Value: 0.42
}
State Dependencies
Reads
state.temp.resultAox.measurement_errors
Writes
state[resGroup][resKey]
Default:
state.temp.mostRelevantMeasurementErrors
Success Behaviour
On successful execution:
- Relevant measurement errors are identified.
- Errors are sorted by severity.
- The ranked result object is stored in the configured state location.
- The configured
onSuccessevent target is executed.
pipelineConfig.executeStage(
pipelineConfig.stageConfig.eventTargets?.onSuccess,
'onSuccess',
pipelineConfig.stage
);
Failure Behaviour
The stage fails when:
- No measurement errors are available.
- The measurement error object is empty.
In this case:
pipelineConfig.executeStage(
pipelineConfig.stageConfig.eventTargets?.onFail,
'onFail',
pipelineConfig.stage
);
is executed.
Example Configuration
{
"resKey": "mostRelevantMeasurementErrors",
"resGroup": "temp"
}
Example Usage
The resulting object can be used to dynamically display measurement feedback:
mostRelevantMeasurementErrors.error1
Result:
movement
or
mostRelevantMeasurementErrors.error1Value
Result:
0.83
This allows configurations to show the most important measurement issue, display corresponding help pages, or generate user-specific recommendations.
Notes
- Only errors with a severity greater than zero are included.
- Errors are always sorted from highest to lowest severity.
- The function does not interpret the meaning of the errors; it only ranks them.
- The resulting structure is optimized for configuration-driven UI rendering.
- The number of returned errors depends on the available measurement data.
- This stage is commonly used before displaying measurement quality feedback and optimization tips to the user.