Get Started - go to homepage
Get Started logo

Get Started

Basics

See the Connect section for establishing a connection and obtaining a valid _sensor instance (e.g., Trimble S Series instruments).

After connecting, follow these best practices:

  1. Acquire frequently used interfaces once
  2. Register required events
  3. Create targets early (optical instruments)

This minimizes repeated initialization and reduces maintenance overhead.

Simple Interfaces

Assume _sensor is already connected.

Check whether _sensor supports ISsiPower; if so, retrieve it via GetInterface<TSsiInterface>() and subscribe to its events.

OnPowerSourceChanged fires on every reported change (e.g., 98% → 97%). Use _battery to distinguish internal vs. external supply.

protected void InitInterfacesAndSubscribeToSystemEvents()
{
    // Ensure we don't subscribe multiple times
    _sensor.ConnectionStateChanged -= OnConnectionStateChanged;
    _sensor.ConnectionStateChanged += OnConnectionStateChanged;

    if (_sensor.IsSupported<ISsiPower>())
    {
        _power = _sensor.GetInterface<ISsiPower>();
        _power.CurrentPowerSourceChanged -= OnPowerSourceChanged;
        _power.CurrentPowerSourceChanged += OnPowerSourceChanged;

        if (_power.CurrentPowerSource is IExternalPower)
            SensorProperties.Battery = 100; // Assume external power = full / not discharging
        else if (_power.CurrentPowerSource is IInternalBattery)
            _battery = _power.CurrentPowerSource as IBattery;
    }

    if (_sensor.IsSupported<ISsiSensorProperties>())
        _sensorProperties = _sensor.GetInterface<ISsiSensorProperties>();

    if (_sensor.IsSupported<ISsiCorrectionValues>())
        _correctionValues = _sensor.GetInterface<ISsiCorrectionValues>();

    if (_sensor.IsSupported<ISsiPpmCorrectionParameter>())
        _ppmParameter = _sensor.GetInterface<ISsiPpmCorrectionParameter>();
}

Other interfaces above are read-only style accessors (instrument metadata, correction values, PPM parameters).

Tip: Always unsubscribe before subscribing. This is crucial when multiple connections (or reconnections) can occur—preventing duplicate handlers and unexpected event storms.