Skip to content

Commit

Permalink
Pre-Test
Browse files Browse the repository at this point in the history
  • Loading branch information
marl0rd committed Jun 19, 2014
1 parent 377f697 commit 7bd21f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/main/java/conicaltank/ConicalTankTransferFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
14 changes: 6 additions & 8 deletions src/main/java/gui/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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();
}

Expand All @@ -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){
Expand All @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/process/FirstOrderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
23 changes: 6 additions & 17 deletions src/main/java/process/SystemSimulator.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,14 +15,14 @@ public class SystemSimulator extends Thread{

private FirstOrderSystem process;
private double[] vz;
private ObjectProperty<Timestamp> 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
Expand All @@ -41,7 +38,7 @@ public void run() {
}

vz[1] = vz[0];
timeStamp.set(new Timestamp(System.currentTimeMillis()));
timeStamp.set(System.currentTimeMillis());
}
}

Expand All @@ -52,13 +49,5 @@ public void setProcess(FirstOrderSystem process) {
this.process = process;
}

public Timestamp getTimeStamp() {
return timeStamp.get();
}
public ObjectProperty<Timestamp> timeStampProperty() {
return timeStamp;
}
public void setTimeStamp(Timestamp timeStamp) {
this.timeStamp.set(timeStamp);
}

}

0 comments on commit 7bd21f5

Please sign in to comment.