Device enumeration#

One of the key functionalities of the system is to enumerate and provide usable devices to the client code. Opto Engineering devices are controlled via the IDevice interface.

Warning

The maximum number of enumerated devices is 255. The maximum number of simultaneously created devices is 50.

Enumerate all available devices#

The quickest way to be up and running is to make the system look for devices across all network interfaces available. The result of the enumeration performed by the system enable the user to retrive those data and store them as DeviceInfo containing useful information about available devices. To start using a specific device, the client code must pick the proper DeviceInfo and provide it to the system so that it can create the device instance.

Warning

The client code is responsible for device instances lifetime. The client code must destroy the device instances when they are no longer required.

//Look for connected devices across all network interfaces on the host.
//Stop the enumeration after an elapsed time of 700 milliseconds.
List<DeviceInfo> deviceInfos = system.EnumerateDevices(700);
DeviceInfo firstDeviceInfo = deviceInfos[0];

Console.WriteLine("First device found is: " + firstDeviceInfo.SerialNumber );

IDevice device = system.CreateDevice(firstDeviceInfo);

//Use the device

device.Dispose();

Enumerate devices under specific network interfaces#

A more precise enumeration can be performed by specifing a target network interface. The proper InterfaceInfo data must be passed to the system to specify under which interface the device enumeration must be performed. To obtain the InterfaceInfo object, an interface enumeration must be accomplished, via ISystem.EnumerateInterfaces.

//Look for available network interfaces on the host.
List<InterfaceInfo> interfaceInfos = system.EnumerateInterfaces();
InterfaceInfo firstInterfaceInfo = interfaceInfos[0];

Console.WriteLine( "First interface found is " + firstInterfaceInfo.DisplayName);

//Looks for connected devices under the specified interface.
//Stops the enumeration after an elapsed time of 700 milliseconds.
List<DeviceInfo> deviceInfos = system.EnumerateDevices(firstInterfaceInfo, 700);
DeviceInfo firstDeviceInfo = deviceInfos[0];

Console.WriteLine( "First device found under " + firstInterfaceInfo.DisplayName + " is: " + firstDeviceInfo.SerialNumber);

IDevice device = system.CreateDevice(firstDeviceInfo);

//Use the device

device.Dispose();