Skip to content

Performing a Calibration

In order to perform some measurements, or to improve the accuracy of others, instruments need to be calibrated. This guide describes the process required to perform an OSL calibration.

At a high level, an OSL calibration flow has four steps:

  1. Configure a trace whose configuration result defines the required calibration.
  2. Read the returned OslCalibration.
  3. Configure that calibration with configureCalibration(calibration:).
  4. Run the calibration and execute each enabled step.

The main APIs involved are configureCalibration(calibration:), runCalibration(), and runCalibrationStep(stepId:).

Applications do not always need to build an OslCalibration by hand. A trace configuration result can define the required calibration for the requested trace.

Once the trace is configured, read the concrete trace configuration result and extract its calibration:

var traceConfiguration = (CaaReturnLossFrequencyTraceConfigurationResult)
testConfigurationResult.TraceConfigurationResults.First();
var calibration = (OslCalibration)traceConfiguration.Calibration;

This is the key step: the trace configuration result defines the OSL calibration required for the requested trace.

Pass the returned calibration into configureCalibration(calibration:):

var calibrationConfigurationResult = (OslCalibrationConfigurationResult)
unify.ConfigureCalibration(calibration);

Once configuration succeeds, start runCalibration() and observe the step list it emits:

await foreach (var state in unify.RunCalibration())
{
if (state is OslCalibrationState oslState)
{
foreach (var step in oslState.Steps)
{
Console.WriteLine($"{step.Name}: enabled={step.Enabled} complete={step.Complete}");
}
}
}

Each CalibrationStep includes:

  • id, which you pass to runCalibrationStep(stepId:)
  • name, which you can show in your UI
  • instruction, which may contain Markdown
  • enabled and complete, which tell you what the user can do next

When a step becomes enabled, present its instruction to the user, wait until they are ready, and then run that step:

var nextStep = oslState.Steps.FirstOrDefault(step => step.Enabled && !step.Complete);
if (nextStep is not null)
{
Console.WriteLine(nextStep.Instruction);
await foreach (var progress in unify.RunCalibrationStep(nextStep.Id))
{
if (progress < 0)
{
Console.WriteLine("Step progress: indeterminate");
}
else
{
Console.WriteLine($"Step progress: {(int)Math.Round(progress * 100)}%");
}
}
}

Applications usually present the step instruction to the user, wait for them to place the correct calibration standard, then trigger the step run. After a step completes, keep listening to runCalibration() for the updated calibration state and the next enabled step.

Repeat this process until every step reports complete == true.