diff --git a/Java/ProjectModels/Main.java b/Java/ProjectModels/Main.java index df2fa83..c021e21 100644 --- a/Java/ProjectModels/Main.java +++ b/Java/ProjectModels/Main.java @@ -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(); } } diff --git a/Java/ProjectModels/Visualizer/visualizer.java b/Java/ProjectModels/Visualizer/visualizer.java index 2947877..cf82abc 100644 --- a/Java/ProjectModels/Visualizer/visualizer.java +++ b/Java/ProjectModels/Visualizer/visualizer.java @@ -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"); } } diff --git a/Java/ProjectModels/testprocess.java b/Java/ProjectModels/testprocess.java index c46ab97..60bd91b 100644 --- a/Java/ProjectModels/testprocess.java +++ b/Java/ProjectModels/testprocess.java @@ -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,7 +16,35 @@ 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"); + + } + } diff --git a/Java/ProjectModels/testprocess1.java b/Java/ProjectModels/testprocess1.java index 926083e..382d631 100644 --- a/Java/ProjectModels/testprocess1.java +++ b/Java/ProjectModels/testprocess1.java @@ -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()) { - 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(); - vis1.updateVisualizer(m.getCurrentControls()); + 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.printModelQueue(); + m.logData(); + try { + vis1.updateVisualizer(m.getCurrentControls()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - } 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"); } } \ No newline at end of file diff --git a/Java/ProjectModels/testprocess2.java b/Java/ProjectModels/testprocess2.java index aa6e063..a74c795 100644 --- a/Java/ProjectModels/testprocess2.java +++ b/Java/ProjectModels/testprocess2.java @@ -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() { - - } }