We are trying to Access 4 Dalsa Nanos in one of our Projects and cannot seem to achieve to open more than 1. While we discover all open interfaces and see that the Devices are discovered, we cannot seem to achieve to open more than 1 with DeviceFactory.TryOpen.
See below Code for reference implementation for 2 Devices. First Device is opened regularly, second is opened without a stream.
More Information:
We can open the devices through the GenICamBrowser Tool and acquire Images from each at the same time, but cant seem to do it through Code.
Is there any trick to open multiple Devices or does the current Iteration ov cvb.net not support multiple Devices at the same time?
Code
class Program
{
private static string ipAddress1 = "192.168.178.10";
private static string ipAddress2 = "192.168.178.20";
private static Device device1;
private static Device device2;
static void Main(string[] args)
{
var interfaces = DiscoverInterfaces();
foreach (var iface in interfaces)
{
var devices = DiscoverDevicesOnInterface(iface);
if(devices.Any(x => x[DiscoveryProperties.DeviceIP] == ipAddress1))
{
DeviceFactory.TryOpen(devices.FirstOrDefault(x => x[DiscoveryProperties.DeviceIP] == ipAddress1), out device1);
}
if (devices.Any(x => x[DiscoveryProperties.DeviceIP] == ipAddress2))
{
DeviceFactory.TryOpen(devices.FirstOrDefault(x => x[DiscoveryProperties.DeviceIP] == ipAddress2), out device2);
}
}
Console.ReadLine();
}
private const DiscoverFlags discoverInterfaces = DiscoverFlags.UpToLevelInterface | DiscoverFlags.IgnoreGevSD;
private static DiscoveryInformation[] DiscoverInterfaces()
{
return DeviceFactory.Discover(discoverInterfaces).Where(info => IsGigEInterface(info) && IsActiveInterface(info)).ToArray();
}
private const DiscoverFlags discoverAll = DiscoverFlags.IgnoreVins | DiscoverFlags.IgnoreGevSD | DiscoverFlags.IncludeInaccessible;
private static DiscoveryInformation[] DiscoverDevicesOnInterface(DiscoveryInformation iface)
{
return DeviceFactory.Discover(iface, discoverAll).ToArray();
}
private static bool IsGigEInterface(DiscoveryInformation info)
{
return info.TryGetProperty(DiscoveryProperties.InterfaceTLType, out var type) && type?.ToUpper() == "GEV";
}
private static bool IsActiveInterface(DiscoveryInformation info)
{
return info.TryGetProperty(DiscoveryProperties.InterfaceSubNetList, out var subnets) && string.IsNullOrEmpty(subnets) == false;
}
}