intellij commit #1

This commit is contained in:
cs-powell
2024-12-05 21:08:26 -05:00
parent b460a8f8b9
commit 75cb986ed1
5 changed files with 53 additions and 36 deletions

View File

@@ -12,6 +12,8 @@ public class Main {
// Encapsulation (or lack thereof) Test // Encapsulation (or lack thereof) Test
Model m = new Model(); Model m = new Model();
testprocess1 tp1 = new testprocess1(m, null); testprocess1 tp1 = new testprocess1(m, null);
tp1.runProcess(); // tp1.runProcess();
testprocess2 tp2 = new testprocess2(m, null);
tp2.runProcess();
} }
} }

View File

@@ -22,6 +22,7 @@ public class visualizer {
JLabel two = new JLabel(); JLabel two = new JLabel();
JLabel three = new JLabel(); JLabel three = new JLabel();
JLabel four = new JLabel(); JLabel four = new JLabel();
Model m; Model m;
@@ -30,7 +31,6 @@ public class visualizer {
this.m = m; this.m = m;
} }
public void initializeDisplay() { public void initializeDisplay() {
try { try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
@@ -126,7 +126,7 @@ public class visualizer {
visualizer.add(rudderGrid); visualizer.add(rudderGrid);
JToolBar tool = new JToolBar("Toolbar"); JToolBar tool = new JToolBar("Toolbar");
JButton b1 = new JButton("Data Log Toggle"); JButton b1 = new JButton("Data Log Disabled");
ActionListener press = new ActionListener() { ActionListener press = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@@ -134,10 +134,12 @@ public class visualizer {
m.startLog(); m.startLog();
JOptionPane.showMessageDialog(frame,"Data Logging Enabled"); JOptionPane.showMessageDialog(frame,"Data Logging Enabled");
tool.setBackground(Color.green); tool.setBackground(Color.green);
b1.setText("Data Log Enabled");
} else { } else {
m.stopLog(); m.stopLog();
JOptionPane.showMessageDialog(frame,"Data Logging Disabled"); JOptionPane.showMessageDialog(frame,"Data Logging Disabled");
tool.setBackground(Color.white); tool.setBackground(Color.white);
b1.setText("Data Log Disabled");
} }
} }

View File

@@ -1,5 +1,8 @@
import ModelFiles.Model; import java.io.IOException;
import ModelFiles.XPlaneConnect; import java.net.SocketException;
import ModelFiles.*;
import Visualizer.visualizer;
public abstract class testprocess { public abstract class testprocess {
@@ -13,7 +16,35 @@ public abstract class testprocess {
public void runProcess() { 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");
}
} }

View File

@@ -12,33 +12,18 @@ public class testprocess1 extends testprocess {
} }
@Override @Override
public void runProcess() { public void innerProcess(visualizer vis1){
try (XPlaneConnect xpc = new XPlaneConnect()) { float[] array = m.next();
// Ensure connection established. if (m.getModelQueueLength() < 5) {
m = new Model(xpc); m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
m.activateModel(); }
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot"); // m.printModelQueue();
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null); m.logData();
m.printModelQueue(); try {
visualizer vis1 = new visualizer(m); vis1.updateVisualizer(m.getCurrentControls());
vis1.initializeDisplay(); } catch (IOException e) {
while (m.isActive() && !m.isEmpty()) { // TODO Auto-generated catch block
float[] array = m.next(); e.printStackTrace();
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();
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");
} }
} }

View File

@@ -1,4 +1,5 @@
import ModelFiles.XPlaneConnect; import ModelFiles.XPlaneConnect;
import Visualizer.visualizer;
import ModelFiles.*; import ModelFiles.*;
public class testprocess2 extends testprocess { public class testprocess2 extends testprocess {
@@ -7,9 +8,5 @@ public class testprocess2 extends testprocess {
super(m, xpc); super(m, xpc);
} }
@Override
public void runProcess() {
}
} }