-
Notifications
You must be signed in to change notification settings - Fork 9
Tables
One of the most obvious ways to display data is in the form of a table. JISA
provides the means of doing this in a GUI in the form of the Table
GUI element.
To create a Table
element you need simply instantiate a Table
object:
Java
Table table = new Table("Title");
Kotlin
val table = Table("Title")
Python
table = Table("Title")
If you were to show this table element now:
table.show();
you will see a blank box:
this is because the table has no contents
The Table
element is designed to display the contents of a ResultTable
object. Thus, after creating a table you can make it show this data by use of:
ResultTable results = new ResultList("Voltage", "Current");
table.watchList(results);
or by specifying the ResultTable
upon instantiation like so:
Java
ResultTable results = new ResultList("Voltage", "Current");
Table table = new Table("Title", results);
Kotlin
val results = ResultList("Voltage", "Current")
val table = Table("Title", results)
Python
results = ResultList("Voltage", "Current")
table = Table("Title", results)
this will result in the table's columns now being visible:
Now the Table
will show the live contents of the ResultTable
object, automatically updating every time new data is added.
For example:
Java
ResultTable tData = new ResultList("X", "Y");
Table table = new Table("Example", tData);
table.show();
for (double x : Range.linear(0, 10)) {
tData.addData(x, 10.0*x);
}
Kotlin
val tData = ResultList("X", "Y")
val table = Table("Example", tData)
table.show()
for (x in Range.linear(0, 10)) {
tData.addData(x, 10.0*x)
}
Python
tData = ResultList("X", "Y")
table = Table("Example", tData)
table.show()
for x in Range.linear(0, 10):
tData.addData(x, 10.0*x)
will result in:
Java
import jisa.gui.GUI;
import jisa.gui.Table;
import jisa.experiment.ResultList;
import jisa.addresses.USBAddress;
import jisa.devices.K2450;
import jisa.maths.Range;
import jisa.Util;
public class Main {
public static void main(String[] args) {
ResultList results = new ResultList(
new Col("Voltage", "V"),
new Col("Current", "A"),
new Col("Power", "W"),
new Col("Resistance", "Ohm")
);
Table table = new Table("Results", results);
table.setExitOnClose(true);
table.show();
try {
K2450 smu = new K2450(new USBAddress(0x05E6, 0x2450, "57463"));
smu.turnOn();
for (double v : Range.linear(0, 60)) {
smu.setVoltage(v);
Util.sleep(500);
results.addData(
smu.getVoltage(),
smu.getCurrent(),
smu.getVoltage() * smu.getCurrent(),
smu.getVoltage() / smu.getCurrent()
);
}
smu.turnOff();
} catch (Exception e) {
GUI.errorAlert(e.getMessage());
System.exit(0);
}
}
}
Kotlin
import jisa.gui.GUI
import jisa.gui.Table
import jisa.experiment.ResultList
import jisa.addresses.USBAddress
import jisa.devices.K2450
import jisa.maths.Range
import jisa.Util
import kotlin.system.exitProcess
fun main() {
val results = ResultList(
Col("Voltage", "V"),
Col("Current", "A"),
Col("Power", "W"),
Col("Resistance", "Ohm")
)
val table = Table("Results", results)
table.setExitOnClose(true)
table.show()
try {
val smu = K2450(USBAddress(0x05E6, 0x2450, "57463"));
smu.turnOn();
for (v in Range.linear(0, 60)) {
smu.voltage = v
Util.sleep(500)
results.addData(
smu.voltage,
smu.current,
smu.voltage * smu.current,
smu.voltage / smu.current
);
}
smu.turnOff();
} catch (e: Exception) {
GUI.errorAlert(e.message)
exitProcess(0)
}
}
Python
import pyjisa
pyjisa.load()
from jisa.gui import GUI, Table
from jisa.experiment import ResultList, Col
from jisa.addresses import USBAddress
from jisa.devices import K2450
from jisa.maths import Range
from jisa import Util
from java.lang import Exception
def main():
results = ResultList(
Col("Voltage", "V"),
Col("Current", "A"),
Col("Power", "W"),
Col("Resistance", "Ohm")
)
table = Table("Results", results)
table.setExitOnClose(True)
table.show()
try:
smu = K2450(USBAddress(0x05E6, 0x2450, "57463"))
smu.turnOn()
for v in Range.linear(0, 60):
smu.setVoltage(v)
Util.sleep(500)
results.addData(
smu.getVoltage(),
smu.getCurrent(),
smu.getVoltage() * smu.getCurrent(),
smu.getVoltage() / smu.getCurrent()
)
smu.turnOff()
except Exception as e:
GUI.errorAlert(e.getMessage())
quit()
main()
GUI.waitForExit()
Which results in the following:
- Getting Started
- Object Orientation
- Choosing a Language
- Using JISA in Java
- Using JISA in Python
- Using JISA in Kotlin
- Exceptions
- Functions as Objects
- Instrument Basics
- SMUs
- Thermometers (and old TCs)
- PID and Temperature Controllers
- Lock-Ins
- Power Supplies
- Pre-Amplifiers
- Writing New Drivers