Wiki.js

getMostRelevantMeasurementErrors

Filters, sorts, and stores measurement errors by relevance so that the most significant measurement issues can be displayed in the UI.

AI Generated

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:


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:

  1. Extracts the error value.
  2. Removes invalid entries.
  3. Removes entries with error values less than or equal to zero.
  4. Sorts all remaining entries by severity.
  5. 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:

  1. Relevant measurement errors are identified.
  2. Errors are sorted by severity.
  3. The ranked result object is stored in the configured state location.
  4. The configured onSuccess event target is executed.
pipelineConfig.executeStage(
  pipelineConfig.stageConfig.eventTargets?.onSuccess,
  'onSuccess',
  pipelineConfig.stage
);

Failure Behaviour

The stage fails when:

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