OptrisOptrisDocumentation

Documentation/OTC SDK/Optris.Sdk — C# API referencev12.0

DeviceInfo

public sealed class DeviceInfo

One camera, as found by Sdk.EnumerateDevices.

A snapshot taken during enumeration, not a live view. Pass it to ThermalCamera.Open(…) to open that specific camera.

Example

foreach (DeviceInfo device in Sdk.EnumerateDevices())
{
    Console.WriteLine($"{device.Model} ({device.Serial}) " +
                      $"{device.Width}x{device.Height} over {device.Connection}");
}

DeviceInfo: properties

public string? Address { get; }

Where the camera is when DeviceInfo.Connection is ConnectionType.Network: the address it answered discovery from. null for a camera that has no address of its own, which is every camera on USB.

null, never "" or "0.0.0.0". A camera on USB is addressed by the operating system and has no address to report; a placeholder would be indistinguishable from a real one in the reachability and duplicate-address checks this exists for.

Filled in by Sdk.EnumerateDevices without opening the camera, which is the case it is for: showing the address on a tile, checking that nothing else already uses it, and recording it in a layout so the same camera is recognised later. DeviceInfo.ControlPath is the platform control node and is empty for a network camera, so it is not a substitute.

This is also what makes the camera openable. Passing the whole DeviceInfo to ThermalCamera.Open(…) carries the address across; keeping only DeviceInfo.Serial throws it away, and a camera on another subnet cannot be found again without it.

public DeviceCapabilities Capabilities { get; }

What this camera can do.

public string? ClaimedBy { get; }

Which process holds it, for example optris-relay (pid 4711), or null when that cannot be found out.

Both platforms can name a holder, by different means, and the "Linux only" that used to be written here has been untrue since the SDK began writing an owner file beside the lock. On Linux the name comes from the kernel's lock table; on Windows, where a sharing violation names nobody, it comes from that file. A claim taken by an older version of the SDK, or by another program, leaves no owner file, so this can still be null for a camera that is definitely claimed, on either platform. It is null everywhere for a camera nobody holds.

A diagnostic, to put in a message an operator can act on. Never test it to decide whether a camera is free; that is DeviceInfo.IsClaimed, and only DeviceInfo.IsClaimed. And never parse it to decide whether the holder is you; that is DeviceInfo.IsClaimedByThisProcess.

public ConnectionType Connection { get; }

How the camera is attached.

public string ControlPath { get; }

The platform-specific control node, or an empty string if the camera has none.

public int Height { get; }

Sensor height in pixels.

public bool IsClaimed { get; }

Some process has this camera open, as far as enumeration could tell, including this one.

This used to be documented as "another process", which was wrong. The wording changed, not the value. A claim is exclusive against every client, this application included: opening a camera your program already has open is refused exactly as another program's open would be. So "claimed" is the right answer to "can this be opened", which is what this property is for, and reporting a camera you hold as free would make it a lie in the one place it is read. Use DeviceInfo.IsClaimedByThisProcess to tell the two apart.

A hint, not a guarantee. Nothing is reserved to answer this and nothing keeps it true. A camera can be claimed between the enumeration that set it and the ThermalCamera.Open(…) that follows, so false here does not promise the open will succeed: the open can still throw ThermalDeviceException, and code that treats this as a guarantee will be wrong on a busy machine. Show it; do not branch your error handling on it.

What it is good for is exactly the thing that is otherwise impossible: showing a camera as in use without opening it. Before this existed a user interface had to attempt ThermalCamera.Open(…) on every camera it listed and read the failure message, which is not a side-effect-free probe.

Refreshed by every Sdk.EnumerateDevices. To be told when it changes without re-enumerating, watch for DeviceChangeKind.Claimed and DeviceChangeKind.Released with Sdk.WatchDevicesAsync(…).

Example

foreach (DeviceInfo device in Sdk.EnumerateDevices())
{
    string state = device.IsClaimed ? "in use": "available";
    Console.WriteLine($"{device.Model}: {state}"
                      + (device.ClaimedBy is null
                           ? "": $" ({device.ClaimedBy})"));
}
public bool IsClaimedByThisProcess { get; }

The process holding this camera is your own.

Only meaningful when DeviceInfo.IsClaimed is true. It separates "in use by me" from "in use by someone else", which is what a camera list needs in order to grey out the cameras it cannot have and leave its own tiles alone.

Before this existed the only way to ask was to parse DeviceInfo.ClaimedBy for your own process id, which the documentation on that property forbids, and which applications did anyway for want of an alternative. Nothing needs to parse anything now.

It rides on the claim events too, so a watcher can tell its own program's open from a stranger's: see DeviceChangeKind.Claimed and DeviceChangeKind.Released.

false for a camera nobody holds, and false on one path even for a camera your own program is using: an Ethernet camera's claim state starts from the camera's own busy flag, which says that someone is streaming and cannot say who. A sweep that reads that flag while you are streaming, and reaches the claim file after you have let it go, reports a claim with this false. Read it as "known to be mine" rather than as "not mine".

Example

foreach (DeviceInfo device in Sdk.EnumerateDevices())
{
    string state = !device.IsClaimed ? "available"
: device.IsClaimedByThisProcess ? "open here"
: "in use elsewhere";
    Console.WriteLine($"{device.Model}: {state}");
}
public string Model { get; }

The camera's model name, for display.

public string Name { get; }

What the user calls this camera, or an empty string if nobody has named it.

Read from this machine during enumeration, keyed by DeviceInfo.Serial, without opening the camera. It is what tells two identical cameras apart in a device list.

This is a snapshot. Change the name with DeviceMetadata.SetName(…), and read anything else recorded about the camera with DeviceMetadata.GetAll(…).

public ushort Port { get; }

The UDP port the camera streams to when DeviceInfo.Connection is ConnectionType.Network, or zero when it has none.

Zero on USB, and zero is not a usable port; test DeviceInfo.Address for null rather than this to decide whether a camera is on the network.

public int ProductId { get; }

USB product identifier, or zero if not on USB.

public string Serial { get; }

The camera's serial number.

public DeviceType Type { get; }

The camera's model.

public int VendorId { get; }

USB vendor identifier, or zero if not on USB.

public string VideoPath { get; }

The platform-specific video node, or an empty string if the camera has none.

public int Width { get; }

Sensor width in pixels.