From 7bd21f51f350d8c57e53f0b3444f4335aca6799f Mon Sep 17 00:00:00 2001 From: marlon Date: Wed, 18 Jun 2014 23:08:49 -0500 Subject: [PATCH] Pre-Test --- .../ConicalTankTransferFunction.java | 4 ++-- src/main/java/gui/Gui.java | 14 +++++------ src/main/java/process/FirstOrderSystem.java | 2 +- src/main/java/process/SystemSimulator.java | 23 +++++-------------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/main/java/conicaltank/ConicalTankTransferFunction.java b/src/main/java/conicaltank/ConicalTankTransferFunction.java index 48a459a..82cec1e 100644 --- a/src/main/java/conicaltank/ConicalTankTransferFunction.java +++ b/src/main/java/conicaltank/ConicalTankTransferFunction.java @@ -13,8 +13,8 @@ public class ConicalTankTransferFunction { // PROPERTIES // - private static final double HEIGHT = 10.0; - private static final double RADIUS = 5.0; + private static final double HEIGHT = 100.0; + private static final double RADIUS = 40.0; private static final double GRAVITY = 9.8; private static final double OBSTRUCTION = 1.5; diff --git a/src/main/java/gui/Gui.java b/src/main/java/gui/Gui.java index 4d2d108..c9e1eed 100644 --- a/src/main/java/gui/Gui.java +++ b/src/main/java/gui/Gui.java @@ -23,7 +23,7 @@ /** * Created by marlon on 6/16/14. */ -public class Gui extends AnchorPane implements Initializable{ +public class Gui extends AnchorPane { private static final int TRENDING_DATA_LIMIT = 50; private static final long SAMPLING_TIME = 500; @@ -51,6 +51,9 @@ public class Gui extends AnchorPane implements Initializable{ private long lastUpdate; public Gui() { + processSimulator = new SystemSimulator(); + conicalTank = new ConicalTankTransferFunction(); + try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Gui.fxml")); fxmlLoader.setRoot(this); @@ -69,11 +72,6 @@ public String toString(Number object) { }); trendings.getData().add(outputTrendingSeries); - conicalTank = new ConicalTankTransferFunction(); - } - - @Override - public void initialize(URL location, ResourceBundle resources) { registerListeners(); } @@ -96,12 +94,12 @@ private void registerListeners() { private void startSimulation(){ lastUpdate = System.currentTimeMillis(); - processSimulator = new SystemSimulator(); processSimulator.run(); } private void stopSimulation(){ processSimulator.interrupt(); + processSimulator = new SystemSimulator(); } private void updateTrending(Timestamp currentTime){ @@ -115,7 +113,7 @@ private void updateTrending(Timestamp currentTime){ } private void recalculate() { - conicalTank.setHeightOperationPoint(Double.parseDouble(heightOperationPointLabel.getText())); + conicalTank.setHeightOperationPoint(Double.parseDouble(heightSetPointTextField.getText())); processSimulator.getProcess().setGain(conicalTank.getGain()); processSimulator.getProcess().setTau(conicalTank.getTau()); } diff --git a/src/main/java/process/FirstOrderSystem.java b/src/main/java/process/FirstOrderSystem.java index a49aa73..becc401 100644 --- a/src/main/java/process/FirstOrderSystem.java +++ b/src/main/java/process/FirstOrderSystem.java @@ -27,7 +27,7 @@ public FirstOrderSystem() { output = new SimpleDoubleProperty(this, "output", 0.0); gain = new SimpleDoubleProperty(this, "gaing", 0.0); tau = new SimpleDoubleProperty(this, "tau", 0.0); - samplingTime = new SimpleLongProperty(this, "samplingTime", 100); + samplingTime = new SimpleLongProperty(this, "samplingTime", 1000); } public double getInput() { diff --git a/src/main/java/process/SystemSimulator.java b/src/main/java/process/SystemSimulator.java index 51cfaa1..decfcae 100644 --- a/src/main/java/process/SystemSimulator.java +++ b/src/main/java/process/SystemSimulator.java @@ -1,10 +1,7 @@ package process; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleObjectProperty; - -import java.sql.Time; -import java.sql.Timestamp; +import javafx.beans.property.LongProperty; +import javafx.beans.property.SimpleLongProperty; /** * Created by marlon on 6/17/14. @@ -18,14 +15,14 @@ public class SystemSimulator extends Thread{ private FirstOrderSystem process; private double[] vz; - private ObjectProperty timeStamp; + private LongProperty timeStamp; public SystemSimulator() { setName("OpenLoopSimulator"); setDaemon(true); process = new FirstOrderSystem(); vz = new double[2]; - timeStamp = new SimpleObjectProperty<>(this, "timestamp", new Timestamp(System.currentTimeMillis())); + timeStamp = new SimpleLongProperty(this, "timestamp", System.currentTimeMillis()); } @Override @@ -41,7 +38,7 @@ public void run() { } vz[1] = vz[0]; - timeStamp.set(new Timestamp(System.currentTimeMillis())); + timeStamp.set(System.currentTimeMillis()); } } @@ -52,13 +49,5 @@ public void setProcess(FirstOrderSystem process) { this.process = process; } - public Timestamp getTimeStamp() { - return timeStamp.get(); - } - public ObjectProperty timeStampProperty() { - return timeStamp; - } - public void setTimeStamp(Timestamp timeStamp) { - this.timeStamp.set(timeStamp); - } + }