intellij commit #1
This commit is contained in:
@@ -12,6 +12,8 @@ public class Main {
|
||||
// Encapsulation (or lack thereof) Test
|
||||
Model m = new Model();
|
||||
testprocess1 tp1 = new testprocess1(m, null);
|
||||
tp1.runProcess();
|
||||
// tp1.runProcess();
|
||||
testprocess2 tp2 = new testprocess2(m, null);
|
||||
tp2.runProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class visualizer {
|
||||
JLabel two = new JLabel();
|
||||
JLabel three = new JLabel();
|
||||
JLabel four = new JLabel();
|
||||
|
||||
Model m;
|
||||
|
||||
|
||||
@@ -30,7 +31,6 @@ public class visualizer {
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
|
||||
public void initializeDisplay() {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
@@ -126,7 +126,7 @@ public class visualizer {
|
||||
visualizer.add(rudderGrid);
|
||||
|
||||
JToolBar tool = new JToolBar("Toolbar");
|
||||
JButton b1 = new JButton("Data Log Toggle");
|
||||
JButton b1 = new JButton("Data Log Disabled");
|
||||
ActionListener press = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -134,10 +134,12 @@ public class visualizer {
|
||||
m.startLog();
|
||||
JOptionPane.showMessageDialog(frame,"Data Logging Enabled");
|
||||
tool.setBackground(Color.green);
|
||||
b1.setText("Data Log Enabled");
|
||||
} else {
|
||||
m.stopLog();
|
||||
JOptionPane.showMessageDialog(frame,"Data Logging Disabled");
|
||||
tool.setBackground(Color.white);
|
||||
b1.setText("Data Log Disabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import ModelFiles.Model;
|
||||
import ModelFiles.XPlaneConnect;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
|
||||
import ModelFiles.*;
|
||||
import Visualizer.visualizer;
|
||||
|
||||
public abstract class testprocess {
|
||||
|
||||
@@ -13,6 +16,34 @@ public abstract class testprocess {
|
||||
|
||||
|
||||
public void runProcess() {
|
||||
try (XPlaneConnect xpc = new XPlaneConnect()) {
|
||||
// Ensure connection established.
|
||||
m = new Model(xpc);
|
||||
m.activateModel();
|
||||
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||
m.printModelQueue();
|
||||
visualizer vis1 = new visualizer(m);
|
||||
vis1.initializeDisplay();
|
||||
|
||||
while (m.isActive() && !m.isEmpty()) {
|
||||
innerProcess(vis1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (SocketException ex) {
|
||||
System.out.println("Unable to set up the connection. (Error message was '" + ex.getMessage() + "'.)");
|
||||
} catch (IOException ex) {
|
||||
System.out.println(
|
||||
"Something went wrong with one of the commands. (Error message was '" + ex.getMessage() + "'.)");
|
||||
}
|
||||
System.out.println("Exiting");
|
||||
|
||||
}
|
||||
|
||||
public void innerProcess(visualizer vis1){
|
||||
System.out.println("Using default innerProcess");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,33 +12,18 @@ public class testprocess1 extends testprocess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runProcess() {
|
||||
try (XPlaneConnect xpc = new XPlaneConnect()) {
|
||||
// Ensure connection established.
|
||||
m = new Model(xpc);
|
||||
m.activateModel();
|
||||
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||
m.printModelQueue();
|
||||
visualizer vis1 = new visualizer(m);
|
||||
vis1.initializeDisplay();
|
||||
while (m.isActive() && !m.isEmpty()) {
|
||||
public void innerProcess(visualizer vis1){
|
||||
float[] array = m.next();
|
||||
if (m.getModelQueueLength() < 5) {
|
||||
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||
// m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||
// m.createAction(ActionType.MOTOR, MotorType.PITCHDOWN, 0, null);
|
||||
}
|
||||
// m.printModelQueue();
|
||||
m.logData();
|
||||
try {
|
||||
vis1.updateVisualizer(m.getCurrentControls());
|
||||
}
|
||||
} catch (SocketException ex) {
|
||||
System.out.println("Unable to set up the connection. (Error message was '" + ex.getMessage() + "'.)");
|
||||
} catch (IOException ex) {
|
||||
System.out.println(
|
||||
"Something went wrong with one of the commands. (Error message was '" + ex.getMessage() + "'.)");
|
||||
}
|
||||
System.out.println("Exiting");
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import ModelFiles.XPlaneConnect;
|
||||
import Visualizer.visualizer;
|
||||
import ModelFiles.*;
|
||||
|
||||
public class testprocess2 extends testprocess {
|
||||
@@ -7,9 +8,5 @@ public class testprocess2 extends testprocess {
|
||||
super(m, xpc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runProcess() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user