FrontPanel SDK Examples

These pages include a number of resources to help make you more productive with our products. Please refer to the following resources if you need a hand.

Open two devices

You may open and communicate with two devices in the same program. Each requires its own instance of okCFrontPanel. The code below opens the first available device to instance “dev1” and the second available device to “dev2”. Recall that once a device is opened, it is unavailable to other processes. This is why both devices may be opened without specifying a serial number.

While it is possible to open both devices without specifying a serial number, there may be complications if there are relevant differences between the devices. For this reason, it is a good idea to implement a check to make sure you know which device corresponds to each okCFrontPanel object. This can be done by verifying device model, version, serial number, or other identifying information using the okTDeviceInfo struct, or you can open each device using its serial number.

// Instantiate okCFrontPanel for each device
okCFrontPanel dev1;
okCFrontPanel dev2;
 
// Open each device separately
dev1.OpenBySerial();
dev2.OpenBySerial();
 
// It's a good idea to retrieve identifying information for each device
okTDeviceInfo infoDev1;
okTDeviceInfo infoDev2;
 
// Retrieve serial number for verification
dev1.GetDeviceInfo(infoDev1);
dev2.GetDeviceInfo(infoDev2);
std::cout << "Device 1 serial number: " << infoDev1.serialNumber << "n";
std::cout << "Device 2 serial number: " << infoDev2.serialNumber << "n";
// Instantiate okCFrontPanel for each device
okCFrontPanel dev1 = new okCFrontPanel();
okCFrontPanel dev2 = new okCFrontPanel();
 
// Open each device separately
dev1.OpenBySerial("");
dev2.OpenBySerial("");
 
// It's a good idea to retrieve identifying information for each device
okTDeviceInfo infoDev1 = new okTDeviceInfo();
okTDeviceInfo infoDev2 = new okTDeviceInfo();
 
// Retrieve serial number for verification
dev1.GetDeviceInfo(infoDev1);
dev2.GetDeviceInfo(infoDev2);
Console.WriteLine("Device 1 serial number: {0}", infoDev1.serialNumber);
Console.WriteLine("Device 2 serial number: {0}", infoDev2.serialNumber);
# Instantiate okCFrontPanel for each device
dev1 = ok.okCFrontPanel()
dev2 = ok.okCFrontPanel()
 
# Open each device separately
dev1.OpenBySerial("")
dev2.OpenBySerial("") 
 
# It's a good idea to retrieve identifying information for each device
infoDev1 = ok.okTDeviceInfo();
infoDev2 = ok.okTDeviceInfo();
 
# Retrieve serial number for verification
dev1.GetDeviceInfo(infoDev1);
dev2.GetDeviceInfo(infoDev2);
print infoDev1.serialNumber;
print infoDev2.serialNumber;
public class example{
     // Instantiate okCFrontPanel for each device
     okCFrontPanel dev1;
     okCFrontPanel dev2;
     // It's a good idea to retrieve identifying information for each device
     okTDeviceInfo infoDev1;
     okTDeviceInfo infoDev2;
 
     public void Open(){
          dev1 = new okCFrontPanel();
          dev2 = new okCFrontPanel();
 
          // Open each device separately
          dev1.OpenBySerial("");
          dev2.OpenBySerial("");
 
          // Retrieve serial number for verification
          dev1.GetDeviceInfo(infoDev1);
          dev2.GetDeviceInfo(infoDev2);
          System.out.println("Device 1 serial number: " + infoDev1.serialNumber);
          System.out.println("Device 2 serial number: " + infoDev2.serialNumber);
     }
}