Advanced
In this section the previous sample is continued.
Its still assumed there is a connect _sensor
instance in place.
Creating a target
To perform a measurement its required to create an instance of ISsiTargets
.
Therefore the InitInterfacesAndSubscribeToSystemEvents
function gets extended by the _target
part.
if (_sensor.IsSupported<ISsiTargets>())
{
_target = _sensor.GetInterface<ISsiTargets>();
_target.TargetChanged -= OnTargetChanged;
_target.TargetChanged += OnTargetChanged;
}
Later on we can use the _target
interface to create specific targets like a generic prism, a DR target or a Trimble Multitrack Target
ITrimbleMultiTrackTarget multiTrackTarget;
if (_target != null)
{
try
{
if (_target.IsSupported(TargetType.TrimbleMultiTrack))
{
multiTrackTarget = _target.CreateTarget(TargetType.TrimbleMultiTrack) as ITrimbleMultiTrackTarget;
multiTrackTarget.TargetId = targetId;
multiTrackTarget.WorkingMode = WorkingMode.Autolock;
return multiTrackTarget;
}
}
catch (Exception e)
{
throw;
}
}
In this example a Trimble Multitrack target gets created.
Measure a target
We can use this ITrimbleMultiTrackTarget
target instance to perform measurements with the configuration as shown above (meaning a valid target ID and working mode Autolock).
To do so we first need to set the target, then use the _measurement
interface to perform a measurement.
_target.SetTarget(multiTrackTarget); //sets the configured target
if (_measurement != null && _compensator != null) //check for ISsiMeasurement and ISsiTiltCompensator
{
try
{
if (!_compensator.IsCompensatorEnabled)
_compensator.EnableCompensator(); //turns on the compensator if not already enabled
var parameters = new List<IMeasurementParameter>();
if (_measurement.IsSupported(MeasurementType.AnglesAndDistance, MeasurementParameterType.DistancePrecision))
{
var precisionSettings = _measurement.CreateMeasurementParameter(MeasurementParameterType.DistancePrecision) as IMeasurementParameterDirectionalPrecision;
precisionSettings.StandardDeviation = 0.003;
parameters.Add(precisionSettings);
}
MeasurementSettings settings = new MeasurementSettings(MeasurementType.AnglesAndDistance, parameters);
Task.Run(() => _measurement.Measure(settings));
}
catch (Exception e)
{
exceptionCallback(e);
}
}
Walking a bit further we also define the standard deviation of the measurement to be at least 0.003m.
To do so we first create a parameter list of type List<IMeasurementParameter>()
. This will be the container of all settings that get configured for the measurement.
Next a specific setting - a IMeasurementParameterDirectionalPrecision
- gets checked and created - and an appropriate values gets set.
In the end all settings get added to the list; gets connected to the final MeasurementSettings
object. This object will be used for the actual measurement in _measurement.Measure(settings)
.