Skip to content

Commit

Permalink
Bug fix for null units on axes, fix for Kotlin primitive classes in R…
Browse files Browse the repository at this point in the history
…esultTable.findColumn, and added RTask.getTotalCount to get total counts since creation of RTask.
  • Loading branch information
WuhrlWuhrd committed Feb 18, 2024
1 parent a397bf1 commit a43428b
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 68 deletions.
Binary file modified JISA.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions src/jisa/control/RTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RTask {
private boolean running = false;
private long started;
private int iteration;
private int total = 0;
private TimerTask task;

/**
Expand Down Expand Up @@ -82,6 +83,7 @@ public void run() {
}

iteration++;
total++;

}

Expand Down Expand Up @@ -142,6 +144,10 @@ public int getCount() {
return iteration;
}

public int getTotalCount() {
return total;
}

public interface Task {

void run(RTask task) throws Exception;
Expand Down
1 change: 1 addition & 0 deletions src/jisa/devices/interfaces/IVSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ static String getDescription() {
* @return voltage setting [V]
*/
double getSetVoltage() throws DeviceException, IOException;

}
14 changes: 7 additions & 7 deletions src/jisa/devices/interfaces/MCSMU.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static String getDescription() {
*
* @return List of SMU channels
*/
List<T> getSMUChannels();
List<T> getSMUs();

/**
* Returns a list of all SMU channels in this multi-channel SMU.
Expand All @@ -30,20 +30,20 @@ static String getDescription() {
* @return List of SMU channels
*/
default List<T> getChannels() {
return getSMUChannels();
return getSMUs();
}

default T getSMUChannel(int index) {
return getSMUChannels().get(index);
default T getSMU(int index) {
return getSMUs().get(index);
}

default T getChannel(int index) {
return getSMUChannel(index);
return getSMU(index);
}

@Override
default List<? extends Instrument> getSubInstruments() {
return getSMUChannels();
return getSMUs();
}

/**
Expand All @@ -67,7 +67,7 @@ default void forEachSMU(SMUAcceptor<T> forEach) throws IOException, DeviceExcept
@NotNull
@Override
default Iterator<T> iterator() {
return getSMUChannels().iterator();
return getSMUs().iterator();
}

interface SMUAcceptor<T extends SMU> {
Expand Down
8 changes: 4 additions & 4 deletions src/jisa/devices/interfaces/MSTMeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

public interface MSTMeter<T extends TMeter> extends MultiInstrument {

List<T> getTMeterChannels();
List<T> getThermometers();

default T getTMeterChannel(int n) {
return getTMeterChannels().get(n);
default T getThermometer(int n) {
return getThermometers().get(n);
}

default List<? extends Instrument> getSubInstruments() {
return getTMeterChannels();
return getThermometers();
}

/**
Expand Down
12 changes: 5 additions & 7 deletions src/jisa/devices/power/AgilentE3644A.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ public AgilentE3644A(Address address) throws IOException, DeviceException {
}

@Override
public double getSetCurrent() throws DeviceException, IOException
{
throw new DeviceException("Not implemented");
public double getSetCurrent() throws DeviceException, IOException {
return queryDouble("CURRENT?");
}

@Override
public double getSetVoltage() throws DeviceException, IOException
{
throw new DeviceException("Not implemented");
public double getSetVoltage() throws DeviceException, IOException {
return queryDouble("VOLTAGE?");
}

@Override
Expand All @@ -53,7 +51,7 @@ public void turnOff() throws IOException, DeviceException {
@Override
public boolean isOn() throws IOException, DeviceException {

switch(queryInt("OUTPUT:STATE?")) {
switch (queryInt("OUTPUT:STATE?")) {

case 0:
return false;
Expand Down
9 changes: 3 additions & 6 deletions src/jisa/devices/power/K2200.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ public K2200(Address address) throws IOException, DeviceException {
}

@Override
public double getSetCurrent() throws DeviceException, IOException
{
public double getSetCurrent() throws DeviceException, IOException {
throw new DeviceException("Not implemented");
}

@Override
public double getSetVoltage() throws DeviceException, IOException
{
public double getSetVoltage() throws DeviceException, IOException {
throw new DeviceException("Not implemented");
}

Expand Down Expand Up @@ -85,8 +83,7 @@ public double getVoltageLimit() throws IOException, DeviceException {
}

@Override
public void setCurrentLimit(double current) throws IOException, DeviceException
{
public void setCurrentLimit(double current) throws IOException, DeviceException {
throw new DeviceException("Device not available");
}

Expand Down
2 changes: 1 addition & 1 deletion src/jisa/devices/smu/DummyMCSMU.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static String getDescription() {
}

@Override
public List<DSMU> getSMUChannels() {
public List<DSMU> getSMUs() {
return channels;
}

Expand Down
6 changes: 3 additions & 3 deletions src/jisa/devices/smu/K236.java
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,9 @@ public enum Source {
CURRENT(1, jisa.enums.Source.CURRENT),
VOLTAGE(0, jisa.enums.Source.VOLTAGE);

private final int c;
private final jisa.enums.Source src;
private static final HashMap<Integer, Source> lookup = new HashMap<>();
private final int c;
private final jisa.enums.Source src;
private static final HashMap<Integer, Source> lookup = new HashMap<>();
private static final HashMap<jisa.enums.Source, Source> convert = new HashMap<>();

static Source fromInt(int i) {
Expand Down
2 changes: 1 addition & 1 deletion src/jisa/devices/smu/K26Dual.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public K26Dual(Address address, String model) throws IOException, DeviceExceptio
}

@Override
public List<KSMU<T>> getSMUChannels() {
public List<KSMU<T>> getSMUs() {
return channels;
}

Expand Down
2 changes: 1 addition & 1 deletion src/jisa/devices/smu/TestFET.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public TestFET(Address address) {
}

@Override
public List<jisa.devices.interfaces.SMU> getSMUChannels() {
public List<jisa.devices.interfaces.SMU> getSMUs() {
return channels;
}

Expand Down
7 changes: 5 additions & 2 deletions src/jisa/devices/temperature/USBTC08.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public USBTC08() throws IOException, DeviceException {
}

@Override
public List<TC08TMeter> getTMeterChannels() {
public List<TC08TMeter> getThermometers() {
return channels;
}

Expand All @@ -124,7 +124,10 @@ public Map<TC08TMeter, Double> getTemperatures(TC08TMeter... channels) throws IO
channels = this.channels.toArray(TC08TMeter[]::new);
}

updateReadings();
// If it's been long enough, update the readings buffer
if ((System.currentTimeMillis() - lastTime) > interval) {
updateReadings();
}

return Arrays.stream(channels).collect(Collectors.toMap(c -> c, c -> (double) lastValues[c.channel]));

Expand Down
47 changes: 43 additions & 4 deletions src/jisa/gui/DeviceShell.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package jisa.gui;

import com.sun.javafx.scene.control.IntegerField;
import javafx.scene.control.CheckBox;
import jisa.addresses.Address;
import jisa.visa.VISADevice;
import javafx.scene.control.Label;
Expand All @@ -12,10 +14,16 @@

public class DeviceShell extends JFXElement {

public ListView terminal;
public TextField input;
private final Address address;
private VISADevice device = null;
public ListView terminal;
public TextField input;
public IntegerField timeOut;
public TextField writeTerm;
public TextField readTerm;
public CheckBox eoi;
public IntegerField baud;
public IntegerField data;
private final Address address;
private VISADevice device = null;

public DeviceShell(Address address) {

Expand Down Expand Up @@ -151,4 +159,35 @@ public void showAndWait() {
GUI.runNow(() -> getStage().showAndWait());
}

public void updateParameters() {

if (device == null) {
addErrorLine("Error: Not Connected.");
return;
}

try {

int timeout = this.timeOut.getValue();
String writeTerm = this.writeTerm.getText();
String readTerm = this.readTerm.getText();
boolean eoi = this.eoi.isSelected();
int baud = this.baud.getValue();
int data = this.data.getValue();

device.setTimeout(timeout);
device.setWriteTerminator(writeTerm.replace("\\n", "\n").replace("\\r", "\r"));
device.setReadTerminator(readTerm.replace("\\n", "\n").replace("\\r", "\r"));
device.configGPIB(gpib -> gpib.setEOIEnabled(eoi));
device.configSerial(serial -> serial.setSerialParameters(baud, data));

addSuccessLine("Instrument settings applied");

} catch (Exception e) {
addErrorLine(String.format("Error when updating settings: [%s] %s", e.getClass().getSimpleName(), e.getMessage()));
GUI.showException(e);
}

}

}
2 changes: 1 addition & 1 deletion src/jisa/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static <T extends Instrument> T connectTo(Class<T> driver, Address addres
try {
instrument = constructor.newInstance(address);
} catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
GUI.errorAlert("Error connecting to \"" + address.toString() + "\":\n" + e.getMessage());
GUI.showException(e);
return null;
}

Expand Down
8 changes: 4 additions & 4 deletions src/jisa/gui/Plot.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public void setXAxisType(AxisType type) {
GUI.runNow(() -> {
xAxis.setLogAxis(false);
xAxis.setTimeAxis(false);
xAxis.setAutoUnitScaling(JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
xAxis.setAutoUnitScaling(xAxis.getUnit() != null && JISAAxis.KNOWN_UNITS.contains(xAxis.getUnit()));
});

break;
Expand All @@ -443,7 +443,7 @@ public void setXAxisType(AxisType type) {
GUI.runNow(() -> {
xAxis.setLogAxis(true);
xAxis.setTimeAxis(false);
xAxis.setAutoUnitScaling(JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
xAxis.setAutoUnitScaling(xAxis.getUnit() != null && JISAAxis.KNOWN_UNITS.contains(xAxis.getUnit()));
});

break;
Expand Down Expand Up @@ -472,7 +472,7 @@ public void setYAxisType(AxisType type) {
GUI.runNow(() -> {
yAxis.setLogAxis(false);
yAxis.setTimeAxis(false);
yAxis.setAutoUnitScaling(JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
yAxis.setAutoUnitScaling(yAxis.getUnit() != null && JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
});

break;
Expand All @@ -482,7 +482,7 @@ public void setYAxisType(AxisType type) {
GUI.runNow(() -> {
yAxis.setLogAxis(true);
yAxis.setTimeAxis(false);
yAxis.setAutoUnitScaling(JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
yAxis.setAutoUnitScaling(yAxis.getUnit() != null && JISAAxis.KNOWN_UNITS.contains(yAxis.getUnit()));
});

break;
Expand Down
57 changes: 37 additions & 20 deletions src/jisa/gui/fxml/DeviceShell.fxml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import com.sun.javafx.scene.control.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="666.0" prefWidth="1115.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<center>
<ListView fx:id="terminal" prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
<ListView fx:id="terminal" prefHeight="332.0" prefWidth="438.0" BorderPane.alignment="CENTER" />
</center>
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
Expand All @@ -36,18 +30,41 @@
</HBox>
</bottom>
<right>
<GridPane hgap="15.0" vgap="15.0" BorderPane.alignment="CENTER">
<GridPane hgap="15.0" prefHeight="332.0" prefWidth="292.0" vgap="15.0" BorderPane.alignment="CENTER">
<children>
<Label text="Time Out [ms]" GridPane.rowIndex="0" GridPane.columnIndex="0" />
<TextField GridPane.rowIndex="0" GridPane.columnIndex="1" />
<Label text="Write Terminator" GridPane.rowIndex="1" GridPane.columnIndex="0" />
<TextField GridPane.rowIndex="1" GridPane.columnIndex="1" />
<Label text="Read Terminator" GridPane.rowIndex="2" GridPane.columnIndex="0" />
<TextField GridPane.rowIndex="2" GridPane.columnIndex="1" />
<Label text="Time Out [ms]" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<IntegerField fx:id="timeOut" value="2000" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Label text="Write Terminator" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="writeTerm" text="\\n" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Read Terminator" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<TextField fx:id="readTerm" text="\\n" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Separator GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="3" />
<CheckBox fx:id="eoi" selected="true" text="Use EOI (GPIB)" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Separator GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="5" />
<Label text="Baud (Serial)" GridPane.columnIndex="0" GridPane.rowIndex="6" />
<IntegerField fx:id="baud" value="9600" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Label text="Data (Serial)" GridPane.columnIndex="0" GridPane.rowIndex="7" />
<IntegerField fx:id="data" value="8" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<Button fx:id="update" onAction="#updateParameters" text="Update" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
</children>

<padding>
<Insets left="15.0" />
</padding></GridPane>
</padding>
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints></GridPane>
</right>
</BorderPane>
Loading

0 comments on commit a43428b

Please sign in to comment.