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.

Device Sensors API

The Device Sensors API provides a way to monitor your device by populating a class with sensor data that includes voltage, temperature, and current for certain elements. The following example demonstrates how to populate the Device Sensors class and draw from it.

The okDeviceSensors class includes an array of okTDeviceSensor structs and is populated by calling GetDeviceSensors() on the device. Once you have populated the device sensors class, you can read from it by using indices to reference individual structs within the class. Retrieve individual parameters for each sensor by referencing it by name (i.e. sensor.name).

Note: In C++, the okDeviceSensors class is called okCDeviceSensors.

okCFrontPanel dev;
okTDeviceSensor sensor;
okCDeviceSensors sensors;
int i;

error = dev.OpenBySerial();

// Populate DeviceSensors
dev.GetDeviceSensors(sensors);

// Retrieve individual sensors using an index value and the GetSensor method
for (i = 0; i < sensors.GetSensorCount(); i++){
	sensor = sensors.GetSensor(i);
	std::cout << sensor.name << "\n";
	std::cout << sensor.value << "\n";
}
okCFrontPanel dev = new okCFrontPanel();
okDeviceSensors sensors = new okDeviceSensors();
okTDeviceSensor sensor = new okTDeviceSensor();
int count;
int i;

dev.OpenBySerial("");

// Populate okDeviceSensors
sensors = dev.GetDeviceSensors();

// Retrieve individual sensors using index values
count = sensors.Count();
for (i = 0; i < count; i++)
{
 	sensor = sensors[i];
 	Console.WriteLine(sensor.name);
 	Console.WriteLine(sensor.value);
}
dev = ok.okCFrontPanel()
dev.OpenBySerial("")

# Populate okDeviceSensors
sensors = dev.GetDeviceSensors()

# Retrieve individual sensors using index values
length = len(sensors)
for i in range(length):
        s = sensors[i]

        print s.name
        print s.value
public class devSensors{
        okCFrontPanel device;

        public void Sensors(){
                device = new okFrontPanel();
                device.OpenBySerial("");
                okDeviceSensors sensors = new okDeviceSensors();
                okTDeviceSensor sensor = new okTDeviceSensor();
                int count;
                int i;

                // Populate okDeviceSensors
                sensors = device.GetDeviceSensors();

                // Retrieve individual sensors using get() and index values
                for(i = 0; i < sensors.size(); i++){
                        sensor = sensors.get(i);
                        System.out.println(sensor.getName());
                        System.out.println(sensor.getValue());
                }
        }
}