From 2297854c2830f2b31438ce7f35b9bd7ed465d39a Mon Sep 17 00:00:00 2001 From: cs-powell <142438185+cs-powell@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:48:34 -0500 Subject: [PATCH] Refactor package names for intellij --- Java/ProjectModels/.idea/checkstyle-idea.xml | 1 + .../CognitiveModel/ModelFiles/Action.java | 2 +- .../CognitiveModel/ModelFiles/ActionType.java | 2 +- .../CognitiveModel/ModelFiles/Delay.java | 2 +- .../CognitiveModel/ModelFiles/MindQueue.java | 2 +- .../CognitiveModel/ModelFiles/Model.java | 2 +- .../CognitiveModel/ModelFiles/Motor.java | 2 +- .../CognitiveModel/ModelFiles/MotorType.java | 2 +- .../CognitiveModel/ModelFiles/Process.java | 2 +- .../CognitiveModel/ModelFiles/Tests.java | 2 +- .../CognitiveModel/ModelFiles/Vision.java | 2 +- .../ModelFiles/XPCdependencies/Beacon.java | 2 +- .../XPCdependencies/BeaconParser.java | 2 +- .../BeaconReceivedListener.java | 2 +- .../DiscoveryConnectionCallback.java | 4 +- .../ModelFiles/XPCdependencies/ViewType.java | 2 +- .../XPCdependencies/WaypointOp.java | 2 +- .../XPlaneConnectDiscovery.java | 4 +- .../ModelFiles/XPlaneConnect.java | 4 +- Java/ProjectModels/Main.java | 23 +- Java/ProjectModels/Model-1/src/Main.java | 632 ------------------ Java/ProjectModels/Model-1/src/Main1.java | 632 ++++++++++++++++++ Java/ProjectModels/ProjectModels.iml | 1 + Java/ProjectModels/Visualizer/axis.java | 2 - .../Visualizer/rudderPosition.java | 2 - Java/ProjectModels/Visualizer/visualizer.java | 2 +- .../Visualizer/yokePosition.java | 2 - Java/ProjectModels/testprocess.java | 4 +- Java/ProjectModels/testprocess1.java | 2 +- Java/ProjectModels/testprocess2.java | 4 +- 30 files changed, 676 insertions(+), 673 deletions(-) delete mode 100644 Java/ProjectModels/Model-1/src/Main.java create mode 100644 Java/ProjectModels/Model-1/src/Main1.java diff --git a/Java/ProjectModels/.idea/checkstyle-idea.xml b/Java/ProjectModels/.idea/checkstyle-idea.xml index ff8860d..36ab091 100644 --- a/Java/ProjectModels/.idea/checkstyle-idea.xml +++ b/Java/ProjectModels/.idea/checkstyle-idea.xml @@ -3,6 +3,7 @@ 8.23 JavaOnlyWithTests + diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Action.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Action.java index 94ecb79..c203790 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Action.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Action.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; public abstract class Action { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/ActionType.java b/Java/ProjectModels/CognitiveModel/ModelFiles/ActionType.java index 24bb9c3..1dbd30e 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/ActionType.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/ActionType.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; public enum ActionType { VISION, diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Delay.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Delay.java index f0cf276..b6685b5 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Delay.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Delay.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; // package ProjectModels.CognitiveModel; public class Delay extends Action { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/MindQueue.java b/Java/ProjectModels/CognitiveModel/ModelFiles/MindQueue.java index 7e45543..9a7ba07 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/MindQueue.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/MindQueue.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; // package ProjectModels.CognitiveModel; import java.util.LinkedList; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Model.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Model.java index 4216d07..a8b67a7 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Model.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Model.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; import java.io.BufferedWriter; import java.io.File; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Motor.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Motor.java index f2cb776..56bd756 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Motor.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Motor.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; import java.io.IOException; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/MotorType.java b/Java/ProjectModels/CognitiveModel/ModelFiles/MotorType.java index 7d90a2c..75f8b97 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/MotorType.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/MotorType.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; public enum MotorType { PITCHUP, diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Process.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Process.java index 502f0ba..eb6ad66 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Process.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Process.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; public class Process { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Tests.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Tests.java index 16de4e3..d85d872 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Tests.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Tests.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; import org.junit.Test; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java b/Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java index 48971da..027f409 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java @@ -1,4 +1,4 @@ -package ModelFiles; +package CognitiveModel.ModelFiles; public class Vision extends Action { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/Beacon.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/Beacon.java index 291e5f1..c998ea8 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/Beacon.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/Beacon.java @@ -1,4 +1,4 @@ -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; import java.net.InetAddress; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconParser.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconParser.java index 402d736..d14344d 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconParser.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconParser.java @@ -1,4 +1,4 @@ -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; import java.io.IOException; import java.net.DatagramPacket; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconReceivedListener.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconReceivedListener.java index 09c7940..b66338a 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconReceivedListener.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/BeaconReceivedListener.java @@ -1,4 +1,4 @@ -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; public interface BeaconReceivedListener { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/DiscoveryConnectionCallback.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/DiscoveryConnectionCallback.java index eaa6a06..88cffb5 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/DiscoveryConnectionCallback.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/DiscoveryConnectionCallback.java @@ -1,6 +1,6 @@ -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; public interface DiscoveryConnectionCallback { diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/ViewType.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/ViewType.java index f990adc..60ea6ba 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/ViewType.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/ViewType.java @@ -22,7 +22,7 @@ // HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY // PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER // SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; /** * Represents a camera view in X-Plane diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/WaypointOp.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/WaypointOp.java index 29e3bbb..5f31615 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/WaypointOp.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/WaypointOp.java @@ -22,7 +22,7 @@ // HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY // PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER // SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; /** * Represents operations that can be performed by the WYPT command. diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/XPlaneConnectDiscovery.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/XPlaneConnectDiscovery.java index 2cc8256..8672dd1 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/XPlaneConnectDiscovery.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPCdependencies/XPlaneConnectDiscovery.java @@ -1,6 +1,6 @@ -package ModelFiles.XPCdependencies; +package CognitiveModel.ModelFiles.XPCdependencies; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; import java.io.IOException; import java.net.DatagramPacket; diff --git a/Java/ProjectModels/CognitiveModel/ModelFiles/XPlaneConnect.java b/Java/ProjectModels/CognitiveModel/ModelFiles/XPlaneConnect.java index 7e202ef..a422e4a 100644 --- a/Java/ProjectModels/CognitiveModel/ModelFiles/XPlaneConnect.java +++ b/Java/ProjectModels/CognitiveModel/ModelFiles/XPlaneConnect.java @@ -23,7 +23,7 @@ // PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER // SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. -package ModelFiles; +package CognitiveModel.ModelFiles; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -34,7 +34,7 @@ import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import ModelFiles.XPCdependencies.*; +import CognitiveModel.ModelFiles.XPCdependencies.*; /** * Represents a client that can connect to and interact with the X-Plane Connect diff --git a/Java/ProjectModels/Main.java b/Java/ProjectModels/Main.java index c021e21..80e1ac4 100644 --- a/Java/ProjectModels/Main.java +++ b/Java/ProjectModels/Main.java @@ -1,19 +1,26 @@ import javax.swing.UIManager; -import com.formdev.flatlaf.FlatLightLaf; - -import ModelFiles.Model; +//import CognitiveModel.ModelFiles.*; public class Main { public static void main(String[] args) { - // FlatLightLaf.setup(); // Encapsulation (or lack thereof) Test - Model m = new Model(); - testprocess1 tp1 = new testprocess1(m, null); +// Model m = new Model(); +// testprocess1 tp1 = new testprocess1(m, null); // tp1.runProcess(); - testprocess2 tp2 = new testprocess2(m, null); - tp2.runProcess(); +// testprocess2 tp2 = new testprocess2(m, null); +// tp2.runProcess(); + + for (int i = 1; i<10; i++) { + if (i%2 == 0) { + int t = 0; + } else if(i == 9) { + System.out.println("Breaking now"); + break; + } + } + } } diff --git a/Java/ProjectModels/Model-1/src/Main.java b/Java/ProjectModels/Model-1/src/Main.java deleted file mode 100644 index 5eab706..0000000 --- a/Java/ProjectModels/Model-1/src/Main.java +++ /dev/null @@ -1,632 +0,0 @@ - - -import ModelFiles.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.net.SocketException; -import java.util.Arrays; -import javax.swing.*; -import javax.swing.border.Border; -import javax.imageio.ImageIO; -import java.awt.Graphics; -import java.awt.image.BufferedImage; - -import java.awt.*; - -/** - * An example program demonstrating the basic features of the X-Plane Connect toolbox. - * - * @author Jason Watkins - * @version 1.0 - * @since 2015-04-06 - */ -public class Main -{ - public static void main(String[] args) { - System.out.println("X-Plane Connect example program"); - System.out.println("Setting up simulation..."); - JFrame frame = new JFrame(); - - try(XPlaneConnect xpc = new XPlaneConnect()) - { - // Ensure connection established. - xpc.getDREF("sim/test/test_float"); - - // System.out.println("Setting player aircraft position"); - // double[] posi = new double[] {37.524, -122.06899, 2500, 0, 0, 0, 1}; - // xpc.sendPOSI(posi); - - // System.out.println("Setting another aircraft position"); - // posi[0] = 37.52465; - // posi[4] = 20; - // xpc.sendPOSI(posi, 1); - - System.out.println("Setting rates"); - float[][] data = new float[3][9]; - for(float[] row : data) - { - Arrays.fill(row, -998); - } - data[0][0] = 0; //Alpha - data[0][1] = 0; - data[0][3] = 0; - - data[1][0] = 0; //Velocity - data[1][1] = 0; - data[1][2] = 0; - data[1][3] = 0; - data[1][4] = 0; - - data[2][0] = 0; //PQR - data[2][1] = 0; - data[2][2] = 0; - data[2][3] = 0; - - xpc.sendDATA(data); - - System.out.println("Trying something new!!"); - - - frame.setPreferredSize(new Dimension(1700,270)); - frame.setLayout(new GridLayout(1,2)); - frame.setVisible(true); - - JPanel display = new JPanel(); - display.setPreferredSize(new Dimension(100,100)); - display.setLayout(new GridLayout(2,4)); - - Font fontTitles = new Font("Impact", 1,40); - Font fontData = new Font("Monospaced", 1,30); - JLabel titleOne = new JLabel("Elevator"); - titleOne.setFont(fontTitles); - titleOne.setHorizontalAlignment(SwingConstants.CENTER); - titleOne.setVerticalAlignment(SwingConstants.BOTTOM); - JLabel titleTwo = new JLabel("Roll"); - titleTwo.setFont(fontTitles); - titleTwo.setHorizontalAlignment(SwingConstants.CENTER); - titleTwo.setVerticalAlignment(SwingConstants.BOTTOM); - JLabel titleThree = new JLabel("Yaw"); - titleThree.setFont(fontTitles); - titleThree.setHorizontalAlignment(SwingConstants.CENTER); - titleThree.setVerticalAlignment(SwingConstants.BOTTOM); - JLabel titleFour = new JLabel("Throttle"); - titleFour.setFont(fontTitles); - titleFour.setHorizontalAlignment(SwingConstants.CENTER); - titleFour.setVerticalAlignment(SwingConstants.BOTTOM); - JLabel one = new JLabel(); - one.setFont(fontData); - one.setHorizontalAlignment(SwingConstants.CENTER); - one.setVerticalAlignment(SwingConstants.TOP); - JLabel two = new JLabel(); - two.setFont(fontData); - two.setHorizontalAlignment(SwingConstants.CENTER); - two.setVerticalAlignment(SwingConstants.TOP); - JLabel three = new JLabel(); - three.setFont(fontData); - three.setHorizontalAlignment(SwingConstants.CENTER); - three.setVerticalAlignment(SwingConstants.TOP); - JLabel four = new JLabel(); - four.setFont(fontData); - four.setHorizontalAlignment(SwingConstants.CENTER); - four.setVerticalAlignment(SwingConstants.TOP); - - one.setText("Test"); - two.setText("Test"); - three.setText("Test"); - four.setText("Test"); - display.add(titleOne); - display.add(titleTwo); - display.add(titleThree); - display.add(titleFour); - display.add(one); - display.add(two); - display.add(three); - display.add(four); - - JPanel visualizer = new JPanel(); - visualizer.setLayout(new GridLayout(2,1)); - - - //Col 1 of Visualizer - JPanel yokeGrid = new JPanel(); - yokeGrid.setMinimumSize(new Dimension(100,100)); - //grid.setOpaque(true); - // grid.setLayout(null); - yokeGrid.setBackground(Color.black); - yokeGrid.setVisible(true); - Integer layer1 = 0; - Integer layer2 = 1; - // grid.setLayout(new GridLayout(1,1)); - yokeGrid.setLayout(new OverlayLayout(yokeGrid)); - - yokePosition yoke = new yokePosition(yokeGrid.getWidth(), yokeGrid.getHeight()); - // yaw yaw = new yaw(grid.getWidth(), grid.getHeight()); - axis axis = new axis(yokeGrid.getWidth(), yokeGrid.getHeight()); - - // grid.setLayer(axis, layer1); - yokeGrid.add(axis); - yokeGrid.add(yoke); - // grid.add(yaw); - // grid.setLayer(yoke, layer2); - - Border greenLine = BorderFactory.createLineBorder(Color.green); - yokeGrid.setBorder(greenLine); - - visualizer.add(yokeGrid); - - - //Row 2 of Visualizer - //Rudder Vizualizer - rudderPosition rudderGrid = new rudderPosition(yokeGrid.getWidth(), 0); - visualizer.add(rudderGrid); - - - - - frame.add(display); // Left Side - frame.add(visualizer); // Right Side - frame.pack(); - - // JLabel text = new JLabel("Hello"); - // JLabel text2 = new JLabel("Hello"); - // JPanel display = new JPanel(); - // display.setLayout(new GridLayout()); - // display.setPreferredSize(size); - // display.add(text); - // display.add(text2); - - // container.add(display); - // container.pack(); - - - - - int aircraft = 0; - boolean takeoff = true; - boolean climb = false; - boolean cruise = false; - boolean throttleFull = false; - boolean brakeOff = false; - boolean switchTrack = false; - String dref = "sim/cockpit2/gauges/indicators/airspeed_kts_pilot"; - String dref2 = "sim/flightmodel/position/true_phi"; - String drefHDG = "sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot"; - String drefHDGBug = "sim/cockpit/autopilot/heading_mag"; - String drefAltitude = "sim/cockpit2/gauges/indicators/altitude_ft_pilot"; - - File file = new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/src/output"); - if (!file.exists()) { - file.createNewFile(); - } - FileWriter fw = new FileWriter(file, true); - BufferedWriter bw = new BufferedWriter(fw); - - while(true) { - //THE GETTERS - double[] posi1 = xpc.getPOSI(aircraft); // FIXME: change this to 64-bit double - float[] ctrl1 = xpc.getCTRL(aircraft); - float[] value = xpc.getDREF(dref); - float[] value2 = xpc.getDREF(dref2); - float[] valueHDG = xpc.getDREF(drefHDG); - float[] valueHDGBug = xpc.getDREF(drefHDGBug); - float[] valueAltitude = xpc.getDREF(drefAltitude); - float bugged = 50; - float rwyHDG = valueHDGBug[0]; - /* - * Outputs - */ - // System.out.format("\r[Elevator: %2f] [Roll: %2f] [Yaw: %2f] ---- [Throttle:%2f] ---- [Flaps: %2f] -- [Data Ref: %2f] -- [T/O: %b ][Cruise: %b ]", - // ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5], valueAltitude[0], takeoff, cruise); - String log = String.format("[Elevator: %2f] [Roll: %2f] [Yaw: %2f] [Throttle:%2f] [Flaps: %2f] [Data Ref: %2f] [T/O: %b ][Cruise: %b ]", - ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5], valueAltitude[0], takeoff, cruise); - - one.setText(String.valueOf(ctrl1[0])); - if(ctrl1[0] >= 0 ) { - one.setForeground(Color.green); - } else { - one.setForeground(Color.red); - } - two.setText(String.valueOf(ctrl1[1])); - if(ctrl1[1] >= 0 ) { - two.setForeground(Color.green); - } else { - two.setForeground(Color.red); - } - three.setText(String.valueOf(ctrl1[2])); - if(ctrl1[2] >= 0 ) { - three.setForeground(Color.green); - } else { - three.setForeground(Color.red); - } - four.setText(String.valueOf(ctrl1[3])); - if(ctrl1[3] >= 0 ) { - four.setForeground(Color.green); - } else { - four.setForeground(Color.red); - } - - yoke.setXBound(yokeGrid.getWidth()); - yoke.setYBound(yokeGrid.getHeight()); - yoke.setX(ctrl1[1]); - yoke.setY(ctrl1[0]); - yoke.repaint(); - - rudderGrid.setXBound(yokeGrid.getWidth()); - rudderGrid.setYBound(yokeGrid.getHeight()); - rudderGrid.setX(ctrl1[2]); - rudderGrid.repaint(); - - - - // yaw.setYBound(grid.getHeight()); - // yaw.setYBound(grid.getHeight()); - // yaw.setX(ctrl1[2]); - // yaw.repaint(); - - axis.setXBound(yokeGrid.getWidth()); - axis.setYBound(yokeGrid.getHeight()); - axis.repaint(); - - //Writing Data to a File - try { - bw.write(log + "\n"); - bw.flush(); - } catch (IOException e) { - System.out.println("Log Data Failed"); - } - /* - * Flight Controls - */ - // //Basic Autopilot For Roll (based on yoke position) - // float[] rollRight = {-998.0f, ctrl1[1]-(ctrl1[1]/2)}; - // float[] rollLeft = {-998.0f, ctrl1[1]-(ctrl1[1]/2)}; - // if(ctrl1[1] < 0) { - // xpc.sendCTRL(rollRight); - // } else if(ctrl1[1] > 0) { - // xpc.sendCTRL(rollLeft); - // } - - //Basic Autopilot For Pitch (based on VSI) - // float[] pitchUp = {ctrl1[0] + 0.01f}; - // float[] pitchDown = {ctrl1[0]- 0.01f}; - // if(value[0] < 0) { - // xpc.sendCTRL(pitchUp); - // } else if(value[0] > 0) { - // xpc.sendCTRL(pitchDown); - // } - - - - if(valueAltitude[0] > 1000f && !switchTrack && takeoff == true) { - System.out.println("In switch"); - takeoff = false; - cruise = true; - switchTrack = true; - } else if (valueAltitude[0] < 1000f && switchTrack && takeoff == true) { - takeoff = true; - cruise = false; - switchTrack = false; - } - - - //Control Profiles - if(takeoff) { - float[] fullThrottle = {-998.0f, -998.0f, -998.0f, 1f}; - if(!throttleFull) { - xpc.sendCTRL(fullThrottle); - throttleFull = true; - } - - if(throttleFull && !brakeOff) { - String parkingBrake = "sim/cockpit2/controls/parking_brake_ratio"; - xpc.sendDREF(parkingBrake, 0f); - brakeOff = true; - } - - //Takeoff Pitch Control - float[] pitchUp = {ctrl1[0] + 0.01f}; - if(value[0] > bugged) { - if(ctrl1[0] < 0.1f){ - xpc.sendCTRL(pitchUp); - } - } - - //Takeoff Roll Control - float[] rollRight = {-998.0f, ctrl1[1] + 0.01f}; - float[] rollLeft = {-998.0f, ctrl1[1] - 0.01f}; - if(value2[0] < 0 && value[0] > bugged) { - if(ctrl1[1] < 0.15f) { - xpc.sendCTRL(rollRight); - } - - } else if(value2[0] > 0 && value[0] > bugged) { - if(ctrl1[1] > -0.15f) { - xpc.sendCTRL(rollLeft); - } - } - - //Takeoff Rudder ControlĀ  - float[] yawRight = {-998.0f, -998.0f, ctrl1[2] + 0.03f}; - float[] yawLeft = {-998.0f, -998.0f, ctrl1[2] - 0.03f}; - if(valueHDG[0] < rwyHDG && value[0] > 0) { - - if(ctrl1[2] < 0.5f) { - xpc.sendCTRL(yawRight); // YAW RIGHT - } - - } else if(valueHDG[0] > rwyHDG && value[0] > 0) { - if(ctrl1[2] > -0.5f){ - xpc.sendCTRL(yawLeft); // YAW LEFT - } - } - } - - - if(cruise) { - //Basic Autopilot For Roll (based on bank angle) - float[] rollRight = {-998.0f, ctrl1[1] + 0.01f}; - float[] rollLeft = {-998.0f, ctrl1[1] - 0.01f}; - if(value2[0] < 0) { - - if(ctrl1[1] < 0.15f) { - xpc.sendCTRL(rollRight); - } - - } else if(value2[0] > 0) { - if(ctrl1[1] > -0.15f) { - xpc.sendCTRL(rollLeft); - } - } - - //Basic Autopilot For Pitch (based on speed) - float[] pitchUp = {ctrl1[0] + 0.01f}; - float[] pitchDown = {ctrl1[0]- 0.01f}; - - if(value[0] > bugged+25) { - if(ctrl1[0] < 0.2f) { - xpc.sendCTRL(pitchUp); - } - } else if(value[0] < bugged+25) { - if(ctrl1[0] > -0.2f) { - xpc.sendCTRL(pitchDown); - } - } - - } - - try { - Thread.sleep(0); - } - catch (InterruptedException ex) {} - - if (System.in.available() > 0) { - break; - } - } - - // System.out.println("Setting controls"); - // float[] ctrl = new float[4]; - // ctrl[3] = 0.8F; - // xpc.sendCTRL(ctrl); - - // System.out.println("Pausing sim"); - // xpc.pauseSim(true); - // try { Thread.sleep(5000); } catch (InterruptedException ex) {} - // System.out.println("Un-pausing"); - // xpc.pauseSim(false); - - System.out.println("Example complete"); - - } - 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() + "'.)"); - frame.dispose(); - - } - System.out.println("Exiting"); - } - - - //Helper Methods - // public static void logData (BufferedWriter bw, String log) { - // bw.write(log); - // } -} - -class axis extends JComponent { - - int xBound = 0; - int yBound = 0; - - axis(int currentX, int currentY) { - xBound = currentX; - yBound = currentY; - } - - public void paint(Graphics g) - { - Graphics2D g2 = (Graphics2D) g; - g2.setColor(Color.green); - g2.drawLine(xBound/2, 0, xBound/2, yBound); - g2.drawLine(0, yBound/2, xBound, yBound/2); - } - - public void setXBound(int newX){ - this.xBound = newX; - } - - public void setYBound(int newY){ - this.yBound = newY; - } -} - - - -// class yaw extends JComponent { - -// int xBound; -// int yBound; -// float x = 0; - - -// int currX = (int)(x*xBound) + xBound/2; - -// yaw(int currentX, int currentY) { -// xBound = currentX; -// yBound = currentY; -// } - -// public void paint(Graphics g) -// { -// Graphics2D g2 = (Graphics2D) g; -// g2.setColor(Color.blue); -// g2.drawLine(currX, 0, currX, yBound); -// g2.fillOval(currX, yBound/2, 20, 20); -// } - -// public void setXBound(int newX){ -// this.xBound = newX; -// } - -// public void setYBound(int newY){ -// this.yBound = newY; -// } - -// public void setX(float newX){ -// this.x = newX; -// } -// } - - - - - - - - - - -class yokePosition extends JComponent { - float x = 0; - int xBound = 0; - float y = 0; - int yBound = 0; - - int width = 50; - int height = 50; - - yokePosition(int currentX, int currentY) { - xBound = currentX; - yBound = currentY; - } - - yokePosition() { - - } - - public void paint(Graphics g) - { - Graphics2D g2 = (Graphics2D) g; - - try { - final BufferedImage image = ImageIO.read(new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/content/Yoke Symbol.png")); - Image scaledImage = image.getScaledInstance(xBound, yBound, Image.SCALE_DEFAULT); - - g.drawImage(scaledImage, 0, 0, getFocusCycleRootAncestor()); - } catch (IOException e){ - System.out.print("Rudder Image Failed"); - } - - g2.setColor(Color.red); - int currX = (int)(x*xBound) + xBound/2 - width/2; - int currY = (int)(y*yBound) + yBound/2 - height/2; - System.out.println("CurrX, CurrY: " + currX +", " + currY); - // g2.drawOval(currX, currY, width, height); - - g2.fillOval(currX, currY, width, height); - g.setColor(Color.green); - int height = g.getFontMetrics().getHeight(); - g.drawString("Nose Down", (xBound/2) + 5, height); - g.drawString("Nose Up", (xBound/2) + 5, yBound - height/2); - g.drawString("Roll Left",0, yBound/2); - int width = g.getFontMetrics().stringWidth("Roll Right"); - g.drawString("Roll Right", xBound - width, yBound/2); - - - - - } - - public void setX(float newX){ - this.x = newX; - } - - public void setXBound(int newX){ - this.xBound = newX; - } - - public void setY(float newY){ - this.y = newY; - } - public void setYBound(int newY){ - this.yBound = newY; - } -} - - -class rudderPosition extends JComponent { - - int xBound = 0; - int yBound = 0; - - float rudderTravel = 0; - - rudderPosition(int currentXBound, int currentYBound) { - xBound = currentXBound; - yBound = currentYBound; - } - - public void paint(Graphics g) { - Graphics2D g2 = (Graphics2D) g; - int spacer = 10; - g.setColor(Color.gray); - g2.fillRect(0, spacer, xBound, yBound - spacer); - - g2.setColor(Color.red); - int width = (int) (xBound/2 * rudderTravel); - //g2.drawRect(xBound/2, 0 +spacer, width, yBound); - g2.fillRect(xBound/2, 0 + spacer, width, yBound); - - g.drawString("Yaw Left",0, yBound/2); - int textWidth = g.getFontMetrics().stringWidth("Roll Right"); - g.drawString("Yaw Right", xBound - textWidth, yBound/2); - try { - final BufferedImage image = ImageIO.read(new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/content/Rudder Pedals.png")); - Image scaledImage = image.getScaledInstance(xBound, yBound, Image.SCALE_DEFAULT); - g.drawImage(scaledImage, 0, 0, getFocusCycleRootAncestor()); - } catch (IOException e) { - System.out.print("Rudder Image Failed"); - } - } - - public void setX(float newX) { - this.rudderTravel = newX; - } - - public void setXBound(int newX) { - this.xBound = newX; - } - - public void setYBound(int newY) { - this.yBound = newY; - } - -} \ No newline at end of file diff --git a/Java/ProjectModels/Model-1/src/Main1.java b/Java/ProjectModels/Model-1/src/Main1.java new file mode 100644 index 0000000..4808f3b --- /dev/null +++ b/Java/ProjectModels/Model-1/src/Main1.java @@ -0,0 +1,632 @@ + +// +//import ModelFiles.*; +// +//import java.io.BufferedWriter; +//import java.io.File; +//import java.io.FileWriter; +//import java.io.IOException; +//import java.net.SocketException; +//import java.util.Arrays; +//import javax.swing.*; +//import javax.swing.border.Border; +//import javax.imageio.ImageIO; +//import java.awt.Graphics; +//import java.awt.image.BufferedImage; +// +//import java.awt.*; +// +///** +// * An example program demonstrating the basic features of the X-Plane Connect toolbox. +// * +// * @author Jason Watkins +// * @version 1.0 +// * @since 2015-04-06 +// */ +//public class Main +//{ +// public static void main(String[] args) { +// System.out.println("X-Plane Connect example program"); +// System.out.println("Setting up simulation..."); +// JFrame frame = new JFrame(); +// +// try(XPlaneConnect xpc = new XPlaneConnect()) +// { +// // Ensure connection established. +// xpc.getDREF("sim/test/test_float"); +// +// // System.out.println("Setting player aircraft position"); +// // double[] posi = new double[] {37.524, -122.06899, 2500, 0, 0, 0, 1}; +// // xpc.sendPOSI(posi); +// +// // System.out.println("Setting another aircraft position"); +// // posi[0] = 37.52465; +// // posi[4] = 20; +// // xpc.sendPOSI(posi, 1); +// +// System.out.println("Setting rates"); +// float[][] data = new float[3][9]; +// for(float[] row : data) +// { +// Arrays.fill(row, -998); +// } +// data[0][0] = 0; //Alpha +// data[0][1] = 0; +// data[0][3] = 0; +// +// data[1][0] = 0; //Velocity +// data[1][1] = 0; +// data[1][2] = 0; +// data[1][3] = 0; +// data[1][4] = 0; +// +// data[2][0] = 0; //PQR +// data[2][1] = 0; +// data[2][2] = 0; +// data[2][3] = 0; +// +// xpc.sendDATA(data); +// +// System.out.println("Trying something new!!"); +// +// +// frame.setPreferredSize(new Dimension(1700,270)); +// frame.setLayout(new GridLayout(1,2)); +// frame.setVisible(true); +// +// JPanel display = new JPanel(); +// display.setPreferredSize(new Dimension(100,100)); +// display.setLayout(new GridLayout(2,4)); +// +// Font fontTitles = new Font("Impact", 1,40); +// Font fontData = new Font("Monospaced", 1,30); +// JLabel titleOne = new JLabel("Elevator"); +// titleOne.setFont(fontTitles); +// titleOne.setHorizontalAlignment(SwingConstants.CENTER); +// titleOne.setVerticalAlignment(SwingConstants.BOTTOM); +// JLabel titleTwo = new JLabel("Roll"); +// titleTwo.setFont(fontTitles); +// titleTwo.setHorizontalAlignment(SwingConstants.CENTER); +// titleTwo.setVerticalAlignment(SwingConstants.BOTTOM); +// JLabel titleThree = new JLabel("Yaw"); +// titleThree.setFont(fontTitles); +// titleThree.setHorizontalAlignment(SwingConstants.CENTER); +// titleThree.setVerticalAlignment(SwingConstants.BOTTOM); +// JLabel titleFour = new JLabel("Throttle"); +// titleFour.setFont(fontTitles); +// titleFour.setHorizontalAlignment(SwingConstants.CENTER); +// titleFour.setVerticalAlignment(SwingConstants.BOTTOM); +// JLabel one = new JLabel(); +// one.setFont(fontData); +// one.setHorizontalAlignment(SwingConstants.CENTER); +// one.setVerticalAlignment(SwingConstants.TOP); +// JLabel two = new JLabel(); +// two.setFont(fontData); +// two.setHorizontalAlignment(SwingConstants.CENTER); +// two.setVerticalAlignment(SwingConstants.TOP); +// JLabel three = new JLabel(); +// three.setFont(fontData); +// three.setHorizontalAlignment(SwingConstants.CENTER); +// three.setVerticalAlignment(SwingConstants.TOP); +// JLabel four = new JLabel(); +// four.setFont(fontData); +// four.setHorizontalAlignment(SwingConstants.CENTER); +// four.setVerticalAlignment(SwingConstants.TOP); +// +// one.setText("Test"); +// two.setText("Test"); +// three.setText("Test"); +// four.setText("Test"); +// display.add(titleOne); +// display.add(titleTwo); +// display.add(titleThree); +// display.add(titleFour); +// display.add(one); +// display.add(two); +// display.add(three); +// display.add(four); +// +// JPanel visualizer = new JPanel(); +// visualizer.setLayout(new GridLayout(2,1)); +// +// +// //Col 1 of Visualizer +// JPanel yokeGrid = new JPanel(); +// yokeGrid.setMinimumSize(new Dimension(100,100)); +// //grid.setOpaque(true); +// // grid.setLayout(null); +// yokeGrid.setBackground(Color.black); +// yokeGrid.setVisible(true); +// Integer layer1 = 0; +// Integer layer2 = 1; +// // grid.setLayout(new GridLayout(1,1)); +// yokeGrid.setLayout(new OverlayLayout(yokeGrid)); +// +// yokePosition yoke = new yokePosition(yokeGrid.getWidth(), yokeGrid.getHeight()); +// // yaw yaw = new yaw(grid.getWidth(), grid.getHeight()); +// axis axis = new axis(yokeGrid.getWidth(), yokeGrid.getHeight()); +// +// // grid.setLayer(axis, layer1); +// yokeGrid.add(axis); +// yokeGrid.add(yoke); +// // grid.add(yaw); +// // grid.setLayer(yoke, layer2); +// +// Border greenLine = BorderFactory.createLineBorder(Color.green); +// yokeGrid.setBorder(greenLine); +// +// visualizer.add(yokeGrid); +// +// +// //Row 2 of Visualizer +// //Rudder Vizualizer +// rudderPosition rudderGrid = new rudderPosition(yokeGrid.getWidth(), 0); +// visualizer.add(rudderGrid); +// +// +// +// +// frame.add(display); // Left Side +// frame.add(visualizer); // Right Side +// frame.pack(); +// +// // JLabel text = new JLabel("Hello"); +// // JLabel text2 = new JLabel("Hello"); +// // JPanel display = new JPanel(); +// // display.setLayout(new GridLayout()); +// // display.setPreferredSize(size); +// // display.add(text); +// // display.add(text2); +// +// // container.add(display); +// // container.pack(); +// +// +// +// +// int aircraft = 0; +// boolean takeoff = true; +// boolean climb = false; +// boolean cruise = false; +// boolean throttleFull = false; +// boolean brakeOff = false; +// boolean switchTrack = false; +// String dref = "sim/cockpit2/gauges/indicators/airspeed_kts_pilot"; +// String dref2 = "sim/flightmodel/position/true_phi"; +// String drefHDG = "sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot"; +// String drefHDGBug = "sim/cockpit/autopilot/heading_mag"; +// String drefAltitude = "sim/cockpit2/gauges/indicators/altitude_ft_pilot"; +// +// File file = new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/src/output"); +// if (!file.exists()) { +// file.createNewFile(); +// } +// FileWriter fw = new FileWriter(file, true); +// BufferedWriter bw = new BufferedWriter(fw); +// +// while(true) { +// //THE GETTERS +// double[] posi1 = xpc.getPOSI(aircraft); // FIXME: change this to 64-bit double +// float[] ctrl1 = xpc.getCTRL(aircraft); +// float[] value = xpc.getDREF(dref); +// float[] value2 = xpc.getDREF(dref2); +// float[] valueHDG = xpc.getDREF(drefHDG); +// float[] valueHDGBug = xpc.getDREF(drefHDGBug); +// float[] valueAltitude = xpc.getDREF(drefAltitude); +// float bugged = 50; +// float rwyHDG = valueHDGBug[0]; +// /* +// * Outputs +// */ +// // System.out.format("\r[Elevator: %2f] [Roll: %2f] [Yaw: %2f] ---- [Throttle:%2f] ---- [Flaps: %2f] -- [Data Ref: %2f] -- [T/O: %b ][Cruise: %b ]", +// // ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5], valueAltitude[0], takeoff, cruise); +// String log = String.format("[Elevator: %2f] [Roll: %2f] [Yaw: %2f] [Throttle:%2f] [Flaps: %2f] [Data Ref: %2f] [T/O: %b ][Cruise: %b ]", +// ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5], valueAltitude[0], takeoff, cruise); +// +// one.setText(String.valueOf(ctrl1[0])); +// if(ctrl1[0] >= 0 ) { +// one.setForeground(Color.green); +// } else { +// one.setForeground(Color.red); +// } +// two.setText(String.valueOf(ctrl1[1])); +// if(ctrl1[1] >= 0 ) { +// two.setForeground(Color.green); +// } else { +// two.setForeground(Color.red); +// } +// three.setText(String.valueOf(ctrl1[2])); +// if(ctrl1[2] >= 0 ) { +// three.setForeground(Color.green); +// } else { +// three.setForeground(Color.red); +// } +// four.setText(String.valueOf(ctrl1[3])); +// if(ctrl1[3] >= 0 ) { +// four.setForeground(Color.green); +// } else { +// four.setForeground(Color.red); +// } +// +// yoke.setXBound(yokeGrid.getWidth()); +// yoke.setYBound(yokeGrid.getHeight()); +// yoke.setX(ctrl1[1]); +// yoke.setY(ctrl1[0]); +// yoke.repaint(); +// +// rudderGrid.setXBound(yokeGrid.getWidth()); +// rudderGrid.setYBound(yokeGrid.getHeight()); +// rudderGrid.setX(ctrl1[2]); +// rudderGrid.repaint(); +// +// +// +// // yaw.setYBound(grid.getHeight()); +// // yaw.setYBound(grid.getHeight()); +// // yaw.setX(ctrl1[2]); +// // yaw.repaint(); +// +// axis.setXBound(yokeGrid.getWidth()); +// axis.setYBound(yokeGrid.getHeight()); +// axis.repaint(); +// +// //Writing Data to a File +// try { +// bw.write(log + "\n"); +// bw.flush(); +// } catch (IOException e) { +// System.out.println("Log Data Failed"); +// } +// /* +// * Flight Controls +// */ +// // //Basic Autopilot For Roll (based on yoke position) +// // float[] rollRight = {-998.0f, ctrl1[1]-(ctrl1[1]/2)}; +// // float[] rollLeft = {-998.0f, ctrl1[1]-(ctrl1[1]/2)}; +// // if(ctrl1[1] < 0) { +// // xpc.sendCTRL(rollRight); +// // } else if(ctrl1[1] > 0) { +// // xpc.sendCTRL(rollLeft); +// // } +// +// //Basic Autopilot For Pitch (based on VSI) +// // float[] pitchUp = {ctrl1[0] + 0.01f}; +// // float[] pitchDown = {ctrl1[0]- 0.01f}; +// // if(value[0] < 0) { +// // xpc.sendCTRL(pitchUp); +// // } else if(value[0] > 0) { +// // xpc.sendCTRL(pitchDown); +// // } +// +// +// +// if(valueAltitude[0] > 1000f && !switchTrack && takeoff == true) { +// System.out.println("In switch"); +// takeoff = false; +// cruise = true; +// switchTrack = true; +// } else if (valueAltitude[0] < 1000f && switchTrack && takeoff == true) { +// takeoff = true; +// cruise = false; +// switchTrack = false; +// } +// +// +// //Control Profiles +// if(takeoff) { +// float[] fullThrottle = {-998.0f, -998.0f, -998.0f, 1f}; +// if(!throttleFull) { +// xpc.sendCTRL(fullThrottle); +// throttleFull = true; +// } +// +// if(throttleFull && !brakeOff) { +// String parkingBrake = "sim/cockpit2/controls/parking_brake_ratio"; +// xpc.sendDREF(parkingBrake, 0f); +// brakeOff = true; +// } +// +// //Takeoff Pitch Control +// float[] pitchUp = {ctrl1[0] + 0.01f}; +// if(value[0] > bugged) { +// if(ctrl1[0] < 0.1f){ +// xpc.sendCTRL(pitchUp); +// } +// } +// +// //Takeoff Roll Control +// float[] rollRight = {-998.0f, ctrl1[1] + 0.01f}; +// float[] rollLeft = {-998.0f, ctrl1[1] - 0.01f}; +// if(value2[0] < 0 && value[0] > bugged) { +// if(ctrl1[1] < 0.15f) { +// xpc.sendCTRL(rollRight); +// } +// +// } else if(value2[0] > 0 && value[0] > bugged) { +// if(ctrl1[1] > -0.15f) { +// xpc.sendCTRL(rollLeft); +// } +// } +// +// //Takeoff Rudder ControlĀ  +// float[] yawRight = {-998.0f, -998.0f, ctrl1[2] + 0.03f}; +// float[] yawLeft = {-998.0f, -998.0f, ctrl1[2] - 0.03f}; +// if(valueHDG[0] < rwyHDG && value[0] > 0) { +// +// if(ctrl1[2] < 0.5f) { +// xpc.sendCTRL(yawRight); // YAW RIGHT +// } +// +// } else if(valueHDG[0] > rwyHDG && value[0] > 0) { +// if(ctrl1[2] > -0.5f){ +// xpc.sendCTRL(yawLeft); // YAW LEFT +// } +// } +// } +// +// +// if(cruise) { +// //Basic Autopilot For Roll (based on bank angle) +// float[] rollRight = {-998.0f, ctrl1[1] + 0.01f}; +// float[] rollLeft = {-998.0f, ctrl1[1] - 0.01f}; +// if(value2[0] < 0) { +// +// if(ctrl1[1] < 0.15f) { +// xpc.sendCTRL(rollRight); +// } +// +// } else if(value2[0] > 0) { +// if(ctrl1[1] > -0.15f) { +// xpc.sendCTRL(rollLeft); +// } +// } +// +// //Basic Autopilot For Pitch (based on speed) +// float[] pitchUp = {ctrl1[0] + 0.01f}; +// float[] pitchDown = {ctrl1[0]- 0.01f}; +// +// if(value[0] > bugged+25) { +// if(ctrl1[0] < 0.2f) { +// xpc.sendCTRL(pitchUp); +// } +// } else if(value[0] < bugged+25) { +// if(ctrl1[0] > -0.2f) { +// xpc.sendCTRL(pitchDown); +// } +// } +// +// } +// +// try { +// Thread.sleep(0); +// } +// catch (InterruptedException ex) {} +// +// if (System.in.available() > 0) { +// break; +// } +// } +// +// // System.out.println("Setting controls"); +// // float[] ctrl = new float[4]; +// // ctrl[3] = 0.8F; +// // xpc.sendCTRL(ctrl); +// +// // System.out.println("Pausing sim"); +// // xpc.pauseSim(true); +// // try { Thread.sleep(5000); } catch (InterruptedException ex) {} +// // System.out.println("Un-pausing"); +// // xpc.pauseSim(false); +// +// System.out.println("Example complete"); +// +// } +// 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() + "'.)"); +// frame.dispose(); +// +// } +// System.out.println("Exiting"); +// } +// +// +// //Helper Methods +// // public static void logData (BufferedWriter bw, String log) { +// // bw.write(log); +// // } +//} +// +//class axis extends JComponent { +// +// int xBound = 0; +// int yBound = 0; +// +// axis(int currentX, int currentY) { +// xBound = currentX; +// yBound = currentY; +// } +// +// public void paint(Graphics g) +// { +// Graphics2D g2 = (Graphics2D) g; +// g2.setColor(Color.green); +// g2.drawLine(xBound/2, 0, xBound/2, yBound); +// g2.drawLine(0, yBound/2, xBound, yBound/2); +// } +// +// public void setXBound(int newX){ +// this.xBound = newX; +// } +// +// public void setYBound(int newY){ +// this.yBound = newY; +// } +//} +// +// +// +//// class yaw extends JComponent { +// +//// int xBound; +//// int yBound; +//// float x = 0; +// +// +//// int currX = (int)(x*xBound) + xBound/2; +// +//// yaw(int currentX, int currentY) { +//// xBound = currentX; +//// yBound = currentY; +//// } +// +//// public void paint(Graphics g) +//// { +//// Graphics2D g2 = (Graphics2D) g; +//// g2.setColor(Color.blue); +//// g2.drawLine(currX, 0, currX, yBound); +//// g2.fillOval(currX, yBound/2, 20, 20); +//// } +// +//// public void setXBound(int newX){ +//// this.xBound = newX; +//// } +// +//// public void setYBound(int newY){ +//// this.yBound = newY; +//// } +// +//// public void setX(float newX){ +//// this.x = newX; +//// } +//// } +// +// +// +// +// +// +// +// +// +// +//class yokePosition extends JComponent { +// float x = 0; +// int xBound = 0; +// float y = 0; +// int yBound = 0; +// +// int width = 50; +// int height = 50; +// +// yokePosition(int currentX, int currentY) { +// xBound = currentX; +// yBound = currentY; +// } +// +// yokePosition() { +// +// } +// +// public void paint(Graphics g) +// { +// Graphics2D g2 = (Graphics2D) g; +// +// try { +// final BufferedImage image = ImageIO.read(new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/content/Yoke Symbol.png")); +// Image scaledImage = image.getScaledInstance(xBound, yBound, Image.SCALE_DEFAULT); +// +// g.drawImage(scaledImage, 0, 0, getFocusCycleRootAncestor()); +// } catch (IOException e){ +// System.out.print("Rudder Image Failed"); +// } +// +// g2.setColor(Color.red); +// int currX = (int)(x*xBound) + xBound/2 - width/2; +// int currY = (int)(y*yBound) + yBound/2 - height/2; +// System.out.println("CurrX, CurrY: " + currX +", " + currY); +// // g2.drawOval(currX, currY, width, height); +// +// g2.fillOval(currX, currY, width, height); +// g.setColor(Color.green); +// int height = g.getFontMetrics().getHeight(); +// g.drawString("Nose Down", (xBound/2) + 5, height); +// g.drawString("Nose Up", (xBound/2) + 5, yBound - height/2); +// g.drawString("Roll Left",0, yBound/2); +// int width = g.getFontMetrics().stringWidth("Roll Right"); +// g.drawString("Roll Right", xBound - width, yBound/2); +// +// +// +// +// } +// +// public void setX(float newX){ +// this.x = newX; +// } +// +// public void setXBound(int newX){ +// this.xBound = newX; +// } +// +// public void setY(float newY){ +// this.y = newY; +// } +// public void setYBound(int newY){ +// this.yBound = newY; +// } +//} +// +// +//class rudderPosition extends JComponent { +// +// int xBound = 0; +// int yBound = 0; +// +// float rudderTravel = 0; +// +// rudderPosition(int currentXBound, int currentYBound) { +// xBound = currentXBound; +// yBound = currentYBound; +// } +// +// public void paint(Graphics g) { +// Graphics2D g2 = (Graphics2D) g; +// int spacer = 10; +// g.setColor(Color.gray); +// g2.fillRect(0, spacer, xBound, yBound - spacer); +// +// g2.setColor(Color.red); +// int width = (int) (xBound/2 * rudderTravel); +// //g2.drawRect(xBound/2, 0 +spacer, width, yBound); +// g2.fillRect(xBound/2, 0 + spacer, width, yBound); +// +// g.drawString("Yaw Left",0, yBound/2); +// int textWidth = g.getFontMetrics().stringWidth("Roll Right"); +// g.drawString("Yaw Right", xBound - textWidth, yBound/2); +// try { +// final BufferedImage image = ImageIO.read(new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/Project_Models/Model-1/content/Rudder Pedals.png")); +// Image scaledImage = image.getScaledInstance(xBound, yBound, Image.SCALE_DEFAULT); +// g.drawImage(scaledImage, 0, 0, getFocusCycleRootAncestor()); +// } catch (IOException e) { +// System.out.print("Rudder Image Failed"); +// } +// } +// +// public void setX(float newX) { +// this.rudderTravel = newX; +// } +// +// public void setXBound(int newX) { +// this.xBound = newX; +// } +// +// public void setYBound(int newY) { +// this.yBound = newY; +// } +// +//} \ No newline at end of file diff --git a/Java/ProjectModels/ProjectModels.iml b/Java/ProjectModels/ProjectModels.iml index fde019f..10cb84f 100644 --- a/Java/ProjectModels/ProjectModels.iml +++ b/Java/ProjectModels/ProjectModels.iml @@ -7,6 +7,7 @@ + diff --git a/Java/ProjectModels/Visualizer/axis.java b/Java/ProjectModels/Visualizer/axis.java index 9d185ff..b7df85f 100644 --- a/Java/ProjectModels/Visualizer/axis.java +++ b/Java/ProjectModels/Visualizer/axis.java @@ -2,8 +2,6 @@ package Visualizer; import javax.swing.JComponent; - - import java.awt.Graphics; import java.awt.*; diff --git a/Java/ProjectModels/Visualizer/rudderPosition.java b/Java/ProjectModels/Visualizer/rudderPosition.java index e08f536..ca1a5e1 100644 --- a/Java/ProjectModels/Visualizer/rudderPosition.java +++ b/Java/ProjectModels/Visualizer/rudderPosition.java @@ -1,8 +1,6 @@ package Visualizer; import javax.swing.JComponent; - - import java.awt.Graphics; import java.awt.*; diff --git a/Java/ProjectModels/Visualizer/visualizer.java b/Java/ProjectModels/Visualizer/visualizer.java index cf82abc..fda0d3a 100644 --- a/Java/ProjectModels/Visualizer/visualizer.java +++ b/Java/ProjectModels/Visualizer/visualizer.java @@ -6,7 +6,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; public class visualizer { diff --git a/Java/ProjectModels/Visualizer/yokePosition.java b/Java/ProjectModels/Visualizer/yokePosition.java index d889f41..69e8da8 100644 --- a/Java/ProjectModels/Visualizer/yokePosition.java +++ b/Java/ProjectModels/Visualizer/yokePosition.java @@ -1,8 +1,6 @@ package Visualizer; import javax.swing.JComponent; - - import java.awt.Graphics; import java.awt.*; diff --git a/Java/ProjectModels/testprocess.java b/Java/ProjectModels/testprocess.java index 60bd91b..3a8f409 100644 --- a/Java/ProjectModels/testprocess.java +++ b/Java/ProjectModels/testprocess.java @@ -1,12 +1,12 @@ import java.io.IOException; import java.net.SocketException; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; + import Visualizer.visualizer; public abstract class testprocess { - Model m = new Model(); public testprocess(Model inputM, XPlaneConnect xpc) { diff --git a/Java/ProjectModels/testprocess1.java b/Java/ProjectModels/testprocess1.java index 382d631..a2a9234 100644 --- a/Java/ProjectModels/testprocess1.java +++ b/Java/ProjectModels/testprocess1.java @@ -1,7 +1,7 @@ import java.io.IOException; import java.net.SocketException; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; import Visualizer.visualizer; public class testprocess1 extends testprocess { diff --git a/Java/ProjectModels/testprocess2.java b/Java/ProjectModels/testprocess2.java index a74c795..ac39c2f 100644 --- a/Java/ProjectModels/testprocess2.java +++ b/Java/ProjectModels/testprocess2.java @@ -1,6 +1,6 @@ -import ModelFiles.XPlaneConnect; +import CognitiveModel.ModelFiles.XPlaneConnect; import Visualizer.visualizer; -import ModelFiles.*; +import CognitiveModel.ModelFiles.*; public class testprocess2 extends testprocess {