OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::DeviceControl

The camera as a device on a plant: what the user calls it, its network settings, and the fail-safe that holds its outputs while something is knowingly disturbed.

A handle, not an owner. Reached through Imager::Device().

Public functions

DeviceControl

DeviceControl(ClientBridge *bridge)

Wraps the imager's shared state. Constructed by the SDK; get one from Imager::Device() rather than building it yourself.

SetNetworkConfig

auto SetNetworkConfig(const DeviceNetworkConfig &config) -> NetworkConfigOutcome

Write a new network configuration to the camera.

Returns: which of the four outcomes happened. Check it, and read NetworkConfigOutcome before you decide what to do with the handle. A new stream destination or subnet mask ends this connection; a new device address or port does not -- the SDK follows the camera and returns kAppliedConnectionKept on a handle that still works, with your cached address now stale. An identical configuration writes nothing and returns kUnchanged. Over USB nothing takes effect until the camera is next on Ethernet, which is kAppliedPendingEthernet.

Exceptions

Name Description
DeviceException if the configuration was refused or the camera has no Ethernet interface. Nothing was written in that case; the message says why. The commonest refusal is a stream_destination equal to ip_address, which the SDK rejects itself before writing -- the camera is never asked.
FeatureNotSupportedException if the camera has an Ethernet interface but its control path carries no command to configure it, which is the Xi 640 ETH when it is opened over Ethernet (over USB it can be configured). Nothing was written, and unlike a DeviceException there is nothing to retry.

A refusal by the camera itself (the Xi 640 ETH checks the values and can say no) is also a DeviceException, whose message names the reason. RequestNetworkConfig() returns that refusal as a value with the reason and what the camera kept.

RequestNetworkConfig

auto RequestNetworkConfig(const DeviceNetworkConfig &config) -> NetworkConfigReply

Ask the camera to take a new network configuration, and report its answer, including a refusal, as a value.

The same write as SetNetworkConfig(), with the same checks before anything is sent and the same four outcomes when it is taken. The difference is a refusal: a camera that states why it refuses (the Xi 640 ETH over USB, firmware reporting 4200..4399) has its reason and the configuration it kept returned here instead of thrown.

Returns: the camera's verdict. Read NetworkConfigReply::accepted first, then outcome or refusal.

Exceptions

Name Description
DeviceException for everything SetNetworkConfig() throws a DeviceException for except the camera's own refusal: no Ethernet interface, a stream_destination equal to ip_address (refused by the SDK before the camera is asked), a value that is not an address, or a write the camera did not answer.
FeatureNotSupportedException as SetNetworkConfig() does.

Added in 12.0.16.

HasNetworkInterface

auto HasNetworkInterface() const -> bool

Whether this camera has an Ethernet interface to configure.

False for every USB-only model. Ask this before GetNetworkConfig(), which reports the same all-empty configuration for a camera that has no interface as it would for one whose settings could not be read -- except that it now throws for the second case, so the two are distinguishable either way.

GetNetworkConfig

auto GetNetworkConfig() const -> DeviceNetworkConfig

How the camera is addressed on the network.

All-empty for a camera with no Ethernet interface, which is not an error -- most cameras are USB and have nothing to report.

Exceptions

Name Description
DeviceException if the camera has an interface and its configuration could not be read. This used to be swallowed and returned as the same empty struct, so a broken control channel was indistinguishable from a USB camera.
FeatureNotSupportedException if the camera has an interface but its control path carries no command to read it. The Xi 640 ETH opened over Ethernet is one of these: it is an Ethernet camera, so HasNetworkInterface() answers true, and that control channel has no such command (over USB it does). Distinct from DeviceException on purpose: nothing is wrong with the camera or the link, so there is nothing to retry.

InterruptFailSafe

void InterruptFailSafe(bool active, const std::string &reason="")

Hold the fail-safe while a process is knowingly disturbed, and release it again. The reason is carried through for logging.

GetMetadata

auto GetMetadata() const -> DeviceMetadata

Everything recorded about this camera, or empty metadata if nothing has been.

SetMetadata

void SetMetadata(const DeviceMetadata &metadata)

Replace everything recorded about this camera. Writing empty metadata forgets it entirely.

Exceptions

Name Description
SdkException if a key or value is unusable, or the store cannot be written.

GetName

auto GetName() const -> std::string

What the user calls this camera, or an empty string.

SetName

void SetName(const std::string &name)

Name this camera, keeping whatever else is recorded about it. An empty name clears it. The name is not required to be unique.

Exceptions

Name Description
SdkException if the name is too long or the store cannot be written.