mega changes -- transition to Python3

This commit is contained in:
cs-powell
2025-01-24 09:33:57 -05:00
parent 3be0e2323b
commit e15c534c07
65 changed files with 273097 additions and 16 deletions

View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA" serialisationVersion="2">
<checkstyleVersion>8.23</checkstyleVersion>
<scanScope>JavaOnlyWithTests</scanScope>
<option name="thirdPartyClasspath" />
<option name="activeLocationIds">
<option value="3d842018-59d5-4006-af8c-48e9162a546a" />
</option>
<option name="locations">
<list>
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
<ConfigurationLocation id="3d842018-59d5-4006-af8c-48e9162a546a" type="HTTP_URL" scope="All" description="CIS1210">
https://gist.github.com/superfashi/b6d24924830f45fae5786cdcee02f049/raw/520f9d293217d731e47bdc4fa0a8b2a529a4e50c/config.xml
<option name="properties">
<map>
<entry key="filter" value="https://gist.github.com/superfashi/b6d24924830f45fae5786cdcee02f049/raw/520f9d293217d731e47bdc4fa0a8b2a529a4e50c/suppressions.xml" />
</map>
</option>
</ConfigurationLocation>
</list>
</option>
</component>
</project>

View File

@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/junit-4.13.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/ProjectModels.iml" filepath="$PROJECT_DIR$/ProjectModels.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,6 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"/Users/flyingtopher/Desktop/Code Citadel/flatlaf-3.5.2.jar"
]
}

View File

@@ -0,0 +1,35 @@
package CognitiveModel.ModelFiles;
public abstract class Action {
Integer priority; // Priority of the Task
Integer delay; // Potential Delay before starting the task
String targetDREF;
Integer taskTime; // How long should the task take
boolean taskComplete; // Is the task completed?
ActionType actionType;
public Action(ActionType actionType, int delay) {
this.actionType = actionType;
this.delay = delay;
this.targetDREF = null;
}
public Action(ActionType actionType, int delay, String target) {
this.actionType = actionType;
this.delay = delay;
targetDREF = target;
}
public ActionType getType() {
return actionType;
}
public Integer getDelay() {
return delay;
}
public String getTarget() {
return targetDREF;
}
}

View File

@@ -0,0 +1,7 @@
package CognitiveModel.ModelFiles;
public enum ActionType {
VISION,
MOTOR,
DELAY,
}

View File

@@ -0,0 +1,14 @@
package CognitiveModel.ModelFiles;
// package ProjectModels.CognitiveModel;
public class Delay extends Action {
public Delay() {
super(ActionType.DELAY, 1000);
}
public Delay(int delay) {
super(ActionType.DELAY, delay);
}
}

View File

@@ -0,0 +1,62 @@
package CognitiveModel.ModelFiles;
// package ProjectModels.CognitiveModel;
import java.util.LinkedList;
public class MindQueue {
/*
Recommended Changes/Improvements
See Google Doc Notes 12/11/24
*/
LinkedList<Action> q;
public MindQueue() {
q = new LinkedList<Action>();
}
public void push(Action e) {
q.add(e);
}
public Action removeEvent(Action e) {
Action temp = e;
q.remove(e);
return temp;
}
public Action pop() {
Vision v = new Vision();
if (q.isEmpty()) {
return v;
}
return q.remove();
}
public boolean isEmpty() {
return q.isEmpty();
}
public String queueToString() {
String queueTrace = "Next to Execute ==> ";
for (Action action : q) {
if (action.getType() == ActionType.VISION) {
queueTrace += "[V]";
}
if (action.getType() == ActionType.MOTOR) {
queueTrace += "[M]";
}
if (action.getType() == ActionType.DELAY) {
queueTrace += "[D]";
}
}
queueTrace += "\n";
return queueTrace;
}
public int queueLength() {
return q.size();
}
}

View File

@@ -0,0 +1,282 @@
package CognitiveModel.ModelFiles;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
// import ModelFiles.ActionType;
// import ModelFiles.MotorType;
public class Model {
private MindQueue q; // Queue for actions
boolean modelActive; // On/Off Switch for the model execution
XPlaneConnect xpc; // Allows connection to the simulator
String storedVisionTarget;
float[] storedVisionResult;
boolean logCreated;
boolean logAllowed;
File dataLogFile = null;
// Constructors
public Model() {
q = new MindQueue();
modelActive = false;
logCreated = false;
}
public Model(XPlaneConnect xpc) {
q = new MindQueue();
modelActive = false;
this.xpc = xpc;
logCreated = false;
}
/* Getters */
public MindQueue getQueue() {
return q;
}
/* Setters */
/*
* Setup Methods
* Printing, Empty check, Activation/Deactivation of Model, etc.
*/
public void activateModel() {
modelActive = true;
}
public void establishConnection(XPlaneConnect newXPC) {
this.xpc = newXPC;
}
public void deactivateModel() {
modelActive = false;
}
public boolean isEmpty() {
return q.isEmpty();
}
public void push(Action a) {
q.push(a);
}
public boolean isActive() {
return modelActive;
}
public void printModelQueue() {
System.out.println(q.queueToString());
}
public int getModelQueueLength() {
return q.queueLength();
}
public void createAction(ActionType actionType, MotorType motorType, int delay, String target) {
Action newAction = null;
switch (actionType) {
case VISION:
newAction = new Vision(delay, target);
this.push(newAction);
break;
case MOTOR:
newAction = new Motor(motorType, delay, target);
this.push(newAction);
break;
case DELAY:
newAction = new Delay(delay);
this.push(newAction);
break;
}
}
/*
* Processing Methods
*
*/
/*
* Process the next event in the model queue
*/
public float[] next() {
float[] returnArray = null;
Action temp = q.pop();
// System.out.println("Type of Action: " + temp.getType());
if (temp.getType() == ActionType.VISION) { // Vision Action (Get Data)
handelVisionAction(temp, returnArray);
} else if (temp.getType() == ActionType.MOTOR) { // Motor Action (Act Upon Data)
handleMotorAction(temp);
} else if (temp.getType() == ActionType.DELAY) {// Pure Delays (Do nothing)
handleDelayAction(temp);
}
// q.push(temp);
return returnArray;
}
/* Next Helpers */
private void handelVisionAction(Action temp, float[] returnArray) {
Vision tempV = (Vision) temp;
initiateDelay(tempV.getDelay());
String dref = tempV.getTarget();
try {
returnArray = xpc.getDREF(dref);
storedVisionTarget = dref;
storedVisionResult = returnArray.clone();
// System.out.println(returnArray[0]);
} catch (IOException e) {
}
}
private void handleMotorAction(Action temp) {
/*
TODO: GoogleDoc Notes 12/11/24
*/
Motor tempM = (Motor) temp;
MotorType motorType = tempM.getMotorType();
float[] currentControls = null;
try {
currentControls = xpc.getCTRL(0);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
switch (motorType) {
case PITCHUP:
float[] pitchUp = { currentControls[0] + 0.01f };
if (storedVisionResult[0] > 80) {
if (currentControls[0] < 0.2f) {
System.out.println("Pitching Up");
xpc.sendCTRL(pitchUp);
}
}
break;
case PITCHDOWN:
float[] pitchDown = { currentControls[0] - 0.01f };
if (storedVisionResult[0] < 80) {
if (currentControls[0] > -0.2f) {
// System.out.println("Sending Pitch Down");
System.out.println("Pitching Down");
xpc.sendCTRL(pitchDown);
}
}
break;
case THROTTLEUP:
break;
case THROTTLEDOWN:
break;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void handleDelayAction(Action temp) {
Delay tempD = (Delay) temp;
initiateDelay(tempD.getDelay());
storedVisionTarget = "INTERRUPTION: DELAY";
}
public static void initiateDelay(int delay) {
try {
Thread.sleep(delay); // Using the action's Built in Delay
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public float[] getCurrentControls() throws IOException{
float [] returnArray = null;
try {
returnArray = xpc.getCTRL(0);
} catch (IOException e) {
// TODO Auto-generated catch block
while(returnArray == null) {
System.out.println("Waiting for reconnect");
returnArray = xpc.getCTRL(0);
}
}
return returnArray;
}
public void startLog() {
logAllowed = true;
}
public void stopLog() {
logAllowed = false;
logCreated = false;
}
public boolean logPermission() {
return logAllowed;
}
public void logData() {
if(logAllowed) {
logProcess();
}
}
private void logProcess(){
if(!logCreated) {
dataLogFile = new File("./dataLog/" + java.time.LocalDateTime.now() + ".csv");
logCreated = true;
try {
float[] ctrl1 = this.getCurrentControls();
String setup = "Elevator, Roll, Yaw, Throttle, Flaps\n";
FileWriter fw = new FileWriter(dataLogFile, true);
BufferedWriter br = new BufferedWriter(fw);
br.write(setup);
br.flush();
} catch (IOException e) {
}
}
String log = null;
try {
float[] ctrl1 = this.getCurrentControls();
//Labled Format
log = String.format("[Elevator: %2f] [Roll: %2f] [Yaw: %2f] [Throttle:%2f] [Flaps: %2f] \n",
ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5]);
//CSV Format
log = String.format("%2f, %2f, %2f, %2f, %2f\n",
ctrl1[0], ctrl1[1], ctrl1[2], ctrl1[3], ctrl1[5]);
FileWriter fw = new FileWriter(dataLogFile, true);
BufferedWriter br = new BufferedWriter(fw);
br.write(log);
br.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("No data to log");
}
}
public float[] getStoredVisionResult() {
return storedVisionResult;
}
public String getStoredVisionTarget() {
return storedVisionTarget;
}
}

View File

@@ -0,0 +1,44 @@
package CognitiveModel.ModelFiles;
import java.io.IOException;
public class Motor extends Action {
float[] control;
MotorType motorType;
public Motor(MotorType motorType) {
super(ActionType.MOTOR, 1000);
this.motorType = motorType;
}
// public Motor(int delay) {
// super(ActionType.MOTOR,delay);
// }
public Motor(MotorType motorType, int delay, String target) {
super(ActionType.MOTOR, delay, target);
this.motorType = motorType;
}
public void createMotorControl() { // TODO: Maybe takes in a formatted set of vision inputs?
control = null;
}
public MotorType getMotorType() {
return motorType;
}
public void sendMotorControl(XPlaneConnect xpc) {
if (control != null) {
try {
xpc.sendCTRL(control);
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Control failed to send");
}
}
}
}

View File

@@ -0,0 +1,8 @@
package CognitiveModel.ModelFiles;
public enum MotorType {
PITCHUP,
PITCHDOWN,
THROTTLEUP,
THROTTLEDOWN
}

View File

@@ -0,0 +1,9 @@
package CognitiveModel.ModelFiles;
public class Process {
public Process() {
}
}

View File

@@ -0,0 +1,19 @@
package CognitiveModel.ModelFiles;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class Tests {
MindQueue m = new MindQueue();
@Test
public void test1() {
Integer i = 1;
Action a = new Vision();
m.push(a);
assertEquals(i, m.pop());
}
}

View File

@@ -0,0 +1,21 @@
package CognitiveModel.ModelFiles;
public class Vision extends Action {
public Vision() {
super(ActionType.VISION, 1000);
}
public Vision(int delay) {
super(ActionType.VISION, delay);
}
public Vision(String dref) {
super(ActionType.VISION, 1000, dref);
}
public Vision(int delay, String dref) {
super(ActionType.VISION, delay, dref);
}
}

View File

@@ -0,0 +1,45 @@
package CognitiveModel.ModelFiles.XPCdependencies;
import java.net.InetAddress;
public class Beacon {
private InetAddress xplaneAddress;
private int pluginPort;
private String pluginVersion;
private int xPlaneVersion;
public Beacon(InetAddress xplaneAddress, int pluginPort, String pluginVersion, int xPlaneVersion) {
this.xplaneAddress = xplaneAddress;
this.pluginPort = pluginPort;
this.pluginVersion = pluginVersion;
this.xPlaneVersion = xPlaneVersion;
}
public String getHost() {
return xplaneAddress.getHostAddress();
}
public String getPluginVersion() {
return pluginVersion;
}
public String getXplaneVersion() {
return String.format("%.2f", xPlaneVersion / 100.0);
}
public int getPluginPort() {
return pluginPort;
}
public InetAddress getXplaneAddress() {
return xplaneAddress;
}
@Override
public String toString() {
return "host: " + getHost() + ":" + getPluginPort() +" version: " + getPluginVersion() + " X-Plane Version: " + getXplaneVersion();
}
}

View File

@@ -0,0 +1,54 @@
package CognitiveModel.ModelFiles.XPCdependencies;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Parser class that parses the UDP discovery BECN packet. The format of the packet is
* - 4 bytes: BECN
* - 1 byte: 0
* - 2 bytes: XPlaneConnect server port e.g. '49009'
* - 4 bytes: X-Plane version e.g. '11260'
* - null terminated string: XPlaneConnect plugin version e.g. '1.3-rc.1'
*/
public class BeaconParser {
private static String BECN = "BECN";
private static int XPC_PORT_OFFSET = BECN.length() + 1;
private static int XPC_PORT_LEN = 2;
private static int XPC_VERSION_OFFSET = XPC_PORT_OFFSET + XPC_PORT_LEN;
private static int XPC_VERSION_LEN = 4;
private static int XPC_PLUGIN_VERSION_OFFSET = XPC_VERSION_OFFSET + XPC_VERSION_LEN;
public Beacon readBCN(DatagramPacket packet) throws IOException {
if (packet.getLength() < BECN.length()) {
throw new IOException("BECN response too short");
}
byte[] data = packet.getData();
String command = new String(data, 0, BECN.length());
if (!command.equals(BECN)) {
throw new IOException("Expected " + BECN + " got '" + command + "'");
}
InetAddress address = packet.getAddress();
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
// 2 bytes: port as short + converted to an int
int port = bb.getShort(XPC_PORT_OFFSET) & 0xffff;
// 4 bytes: x plane version as int
int version = bb.getInt(XPC_VERSION_OFFSET);
// plugin version
String pluginVersion = new String(data, XPC_PLUGIN_VERSION_OFFSET, packet.getLength() - XPC_PLUGIN_VERSION_OFFSET);
return new Beacon(address, port, pluginVersion.trim(), version);
}
}

View File

@@ -0,0 +1,10 @@
package CognitiveModel.ModelFiles.XPCdependencies;
public interface BeaconReceivedListener {
/**
* Called every time a BECN packet is received
* @param beacon The parsed beacon
*/
void onBeaconReceived(Beacon beacon);
}

View File

@@ -0,0 +1,14 @@
package CognitiveModel.ModelFiles.XPCdependencies;
import CognitiveModel.ModelFiles.*;
public interface DiscoveryConnectionCallback {
/**
* Helper callback called when a 1st XPlanePlugin is discovered. When the 1st packet is received, an XPlaneConnect
* instance is created and the discovery is stopped.
*
* @param xpc The XPlaneConnect instance configured with the discovered
*/
void onConnectionEstablished(XPlaneConnect xpc);
}

View File

@@ -0,0 +1,60 @@
//NOTICES:
// Copyright (c) 2013-2018 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
// No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND,
// EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE
// SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT
// SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
// THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY
// GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
// SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
// FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY
// SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
//
// Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES
// GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF
// RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
// EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR
// RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD
// 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 CognitiveModel.ModelFiles.XPCdependencies;
/**
* Represents a camera view in X-Plane
*
* @author Jason Watkins
* @version 1.1
* @since 2015-05-08
*/
public enum ViewType
{
Forwards(73),
Down(74),
Left(75),
Right(76),
Back(77),
Tower(78),
Runway(79),
Chase(80),
Follow(81),
FollowWithPanel(82),
Spot(83),
FullscreenWithHud(84),
FullscreenNoHud(85);
private final int value;
private ViewType(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
}

View File

@@ -0,0 +1,50 @@
//NOTICES:
// Copyright (c) 2013-2018 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
// No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND,
// EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE
// SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT
// SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
// THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY
// GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
// SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
// FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY
// SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
//
// Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES
// GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF
// RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
// EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR
// RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD
// 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 CognitiveModel.ModelFiles.XPCdependencies;
/**
* Represents operations that can be performed by the WYPT command.
*
* @author Jason Watkins
* @version 1.0
* @since 2015-04-09
*/
public enum WaypointOp
{
Add(1),
Del(2),
Clr(3);
private final int value;
private WaypointOp(int value)
{
this.value = value;
}
public int getValue()
{
return value;
}
}

View File

@@ -0,0 +1,94 @@
package CognitiveModel.ModelFiles.XPCdependencies;
import CognitiveModel.ModelFiles.*;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
/**
* The XPlaneConnectDiscovery joins a UDP multi cast group and listens for BECN packets published by
* XPlaneConnect server plugin. It allows to clients to discover XPlane instances and be sure that the XPlanePlugin is
* installed.
*/
public class XPlaneConnectDiscovery implements AutoCloseable {
private static int DEFAULT_PORT = 49710;
private static String DEFAULT_ADDRESS = "239.255.1.1";
private BeaconReceivedListener mListener;
private MulticastSocket socket = null;
private byte[] buf = new byte[256];
private int mPort;
private String mAddress;
private BeaconParser parser = new BeaconParser();
private XPlaneConnectDiscovery(int port, String address) {
mPort = port;
mAddress = address;
}
public XPlaneConnectDiscovery() {
this(DEFAULT_PORT, DEFAULT_ADDRESS);
}
public void start(DiscoveryConnectionCallback callback) throws IOException {
onBeaconReceived(beacon -> {
this.close();
try {
XPlaneConnect xpc = new XPlaneConnect(beacon);
callback.onConnectionEstablished(xpc);
} catch (SocketException e) {
System.err.println("Could not connect to a discovered XplaneConnect " +beacon+ ": " + e.getMessage());
}
});
start();
}
@SuppressWarnings("deprecation") // Added custom
public void start() throws IOException {
System.out.println("Starting XPlane Connect discovery");
socket = new MulticastSocket(mPort);
InetAddress group = InetAddress.getByName(mAddress);
socket.joinGroup(group);
while (socket != null) {
DatagramPacket packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
if (mListener == null) {
continue;
}
try {
Beacon beacon = parser.readBCN(packet);
mListener.onBeaconReceived(beacon);
} catch (IOException ex) {
System.err.println("Received packet on discovery group but could not parse it: " + ex);
}
}
close();
System.out.println("XPlane Connect discovery ended");
}
public void onBeaconReceived(BeaconReceivedListener mListener) {
this.mListener = mListener;
}
@Override
public void close() {
if (socket != null) {
socket.close();
socket = null;
}
}
public void stop() {
close();
}
}

View File

@@ -0,0 +1,919 @@
//NOTICES:
// Copyright (c) 2013-2018 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
// No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND,
// EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE
// SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT
// SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
// THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY
// GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
// SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
// FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY
// SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
//
// Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES
// GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF
// RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
// EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR
// RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD
// 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 CognitiveModel.ModelFiles;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.AutoCloseable;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import CognitiveModel.ModelFiles.XPCdependencies.*;
/**
* Represents a client that can connect to and interact with the X-Plane Connect
* plugin.
*
* @author Jason Watkins
* @version 0.1
* @since 2015-03-31
*/
public class XPlaneConnect implements AutoCloseable {
// private static int clientNum;
private DatagramSocket socket;
private InetAddress xplaneAddr;
private int xplanePort;
/**
* Gets the port on which the client receives data from the plugin.
*
* @return The incoming port number.
*/
public int getRecvPort() {
return socket.getLocalPort();
}
/**
* Gets the port on which the client sends data to X-Plane.
*
* @return The outgoing port number.
*/
public int getXPlanePort() {
return xplanePort;
}
/**
* Sets the port on which the client sends data to X-Plane
*
* @param port The new outgoing port number.
* @throws IllegalArgumentException If {@code port} is not a valid port number.
*/
public void setXPlanePort(int port) {
if (port < 0 || port >= 0xFFFF) {
throw new IllegalArgumentException("Invalid port (must be non-negative and less than 65536).");
}
xplanePort = port;
}
/**
* Gets the hostname of the X-Plane host.
*
* @return The hostname of the X-Plane host.
*/
public String getXPlaneAddr() {
return xplaneAddr.getHostAddress();
}
/**
* Sets the hostname of the X-Plane host.
*
* @param host The new hostname of the X-Plane host machine.
* @throws UnknownHostException {@code host} is not valid.
*/
public void setXplaneAddr(String host) throws UnknownHostException {
xplaneAddr = InetAddress.getByName(host);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using default
* ports and assuming X-Plane is running on the
* local machine.
*
* @throws SocketException If this instance is unable to bind to the default
* receive port.
*/
public XPlaneConnect() throws SocketException {
this(100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class with the
* specified timeout using default ports and
* assuming X-Plane is running on the local machine.
*
* @param timeout The time, in milliseconds, after which read attempts will
* timeout.
* @throws SocketException If this instance is unable to bind to the default
* receive port.
*/
public XPlaneConnect(int timeout) throws SocketException {
this.socket = new DatagramSocket(0);
this.xplaneAddr = InetAddress.getLoopbackAddress();
this.xplanePort = 49009;
this.socket.setSoTimeout(timeout);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using the
* specified ports and X-Plane host.
*
* @param xpHost The network host on which X-Plane is running.
* @param xpPort The port on which the X-Plane Connect plugin is listening.
* @param port The local port to use when sending and receiving data from XPC.
* @throws java.net.SocketException If this instance is unable to bind to
* the specified port.
* @throws java.net.UnknownHostException If the specified hostname can not be
* resolved.
*/
public XPlaneConnect(String xpHost, int xpPort, int port)
throws java.net.SocketException, java.net.UnknownHostException {
this(xpHost, xpPort, port, 100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class from a received
* discovery Beacon
*
* @param beacon The beacon received from {@code XPlaneConnectDiscovery}
* @throws SocketException If this instance is unable to bind to the specified
* port.
*/
public XPlaneConnect(Beacon beacon) throws SocketException {
this.socket = new DatagramSocket(0);
this.xplaneAddr = beacon.getXplaneAddress();
this.xplanePort = beacon.getPluginPort();
this.socket.setSoTimeout(100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using the
* specified ports, hostname, and timeout.
*
* @param xpHost The network host on which X-Plane is running.
* @param xpPort The port on which the X-Plane Connect plugin is listening.
* @param port The port on which the X-Plane Connect plugin is sending data.
* @param timeout The time, in milliseconds, after which read attempts will
* timeout.
* @throws java.net.SocketException If this instance is unable to bind to
* the specified port.
* @throws java.net.UnknownHostException If the specified hostname can not be
* resolved.
*/
public XPlaneConnect(String xpHost, int xpPort, int port, int timeout)
throws java.net.SocketException, java.net.UnknownHostException {
this.socket = new DatagramSocket(port);
this.xplaneAddr = InetAddress.getByName(xpHost);
this.xplanePort = xpPort;
this.socket.setSoTimeout(timeout);
}
/**
* Closes the underlying socket.
*/
public void close() {
if (socket != null) {
socket.close();
socket = null;
}
}
/**
* Read data from the X-Plane plugin. This method will read whatever data is
* available and return it.
*
* @return The data send from X-Plane.
* @throws IOException If the read operation fails
*/
private byte[] readUDP() throws IOException {
byte[] buffer = new byte[65536];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
try {
socket.receive(packet);
return Arrays.copyOf(buffer, packet.getLength());
} catch (SocketTimeoutException ex) {
return new byte[0];
}
}
/**
* Send the given data to the X-Plane plugin.
*
* @param buffer The data to send.
* @throws IOException If the send operation fails.
*/
private void sendUDP(byte[] buffer) throws IOException {
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, xplaneAddr, xplanePort);
socket.send(packet);
}
/**
* Pauses or unpauses X-Plane.
*
* @param pause {@code true} to pause the simulator; {@code false} to un-pause.
* @throws IOException If the command cannot be sent.
*/
public void pauseSim(boolean pause) throws IOException {
// S I M U LEN VAL
byte[] msg = { 0x53, 0x49, 0x4D, 0x55, 0x00, 0x00 };
msg[5] = (byte) (pause ? 0x01 : 0x00);
sendUDP(msg);
}
/**
* Pauses, unpauses, or switches the pause state of X-Plane.
*
* @param pause {@code 1} to pause the simulator, {@code 0} to unpause, or
* {@code 2} to switch.
* @throws IllegalArgumentException If the values of {@code pause} is not a
* valid command.
* @throws IOException If the command cannot be sent.
*/
public void pauseSim(int pause) throws IOException {
if (pause < 0 || (pause > 2 && pause < 100) || (pause > 119 && pause < 200) || pause > 219) {
throw new IllegalArgumentException("pause must be a value in the range [0, 2], [100, 119], or [200, 219].");
}
// S I M U LEN VAL
byte[] msg = { 0x53, 0x49, 0x4D, 0x55, 0x00, 0x00 };
msg[5] = (byte) pause;
sendUDP(msg);
}
/**
* Requests a single dref value from X-Plane.
*
* @param dref The name of the dref requested.
* @return A byte array representing data dependent on the dref requested.
* @throws IOException If either the request or the response fails.
*/
public float[] getDREF(String dref) throws IOException {
return getDREFs(new String[] { dref })[0];
}
/**
* Requests several dref values from X-Plane.
*
* @param drefs An array of dref names to request.
* @return A multidimensional array representing the data for each requested
* dref.
* @throws IOException If either the request or the response fails.
*/
public float[][] getDREFs(String[] drefs) throws IOException {
// Preconditions
if (drefs == null || drefs.length == 0) {
throw new IllegalArgumentException("drefs must be a valid array with at least one dref.");
}
if (drefs.length > 255) {
throw new IllegalArgumentException("Can not request more than 255 DREFs at once.");
}
// Convert drefs to bytes.
byte[][] drefBytes = new byte[drefs.length][];
for (int i = 0; i < drefs.length; ++i) {
drefBytes[i] = drefs[i].getBytes(StandardCharsets.UTF_8);
if (drefBytes[i].length == 0) {
throw new IllegalArgumentException("DREF " + i + " is an empty string!");
}
if (drefBytes[i].length > 255) {
throw new IllegalArgumentException("DREF " + i
+ " is too long (must be less than 255 bytes in UTF-8). Are you sure this is a valid DREF?");
}
}
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETD".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(drefs.length);
for (byte[] dref : drefBytes) {
os.write(dref.length);
os.write(dref, 0, dref.length);
}
sendUDP(os.toByteArray());
// Read response
byte[] data = readUDP();
if (data.length == 0) {
throw new IOException("No response received.");
}
if (data.length < 6) {
throw new IOException("Response too short");
}
float[][] result = new float[drefs.length][];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
int cur = 6;
for (int j = 0; j < result.length; ++j) {
result[j] = new float[data[cur++]];
for (int k = 0; k < result[j].length; ++k) // TODO: There must be a better way to do this
{
result[j][k] = bb.getFloat(cur);
cur += 4;
}
}
return result;
}
public void sendDREF(String dref, float value) throws IOException {
sendDREF(dref, new float[] { value });
}
/**
* Sends a command to X-Plane that sets the given DREF.
*
* @param dref The name of the X-Plane dataref to set.
* @param value An array of floating point values whose structure depends on the
* dref specified.
* @throws IOException If the command cannot be sent.
*/
public void sendDREF(String dref, float[] value) throws IOException {
sendDREFs(new String[] { dref }, new float[][] { value });
}
/**
* Sends a command to X-Plane that sets the given DREF.
*
* @param drefs The names of the X-Plane datarefs to set.
* @param values A sequence of arrays of floating point values whose structure
* depends on the drefs specified.
* @throws IOException If the command cannot be sent.
*/
public void sendDREFs(String[] drefs, float[][] values) throws IOException {
// Preconditions
if (drefs == null || drefs.length == 0) {
throw new IllegalArgumentException(("drefs must be non-empty."));
}
if (values == null || values.length != drefs.length) {
throw new IllegalArgumentException("values must be of the same size as drefs.");
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DREF".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
for (int i = 0; i < drefs.length; ++i) {
String dref = drefs[i];
float[] value = values[i];
if (dref == null) {
throw new IllegalArgumentException("dref must be a valid string.");
}
if (value == null || value.length == 0) {
throw new IllegalArgumentException("value must be non-null and should contain at least one value.");
}
// Convert drefs to bytes.
byte[] drefBytes = dref.getBytes(StandardCharsets.UTF_8);
if (drefBytes.length == 0) {
throw new IllegalArgumentException("DREF is an empty string!");
}
if (drefBytes.length > 255) {
throw new IllegalArgumentException(
"dref must be less than 255 bytes in UTF-8. Are you sure this is a valid dref?");
}
ByteBuffer bb = ByteBuffer.allocate(4 * value.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (int j = 0; j < value.length; ++j) {
bb.putFloat(j * 4, value[j]);
}
// Build and send message
os.write(drefBytes.length);
os.write(drefBytes, 0, drefBytes.length);
os.write(value.length);
os.write(bb.array());
}
sendUDP(os.toByteArray());
}
/**
* Gets the control surface information for the specified airplane.
*
* @param ac The aircraft to get control surface information for.
* @return An array containing control surface data in the same format as
* {@code sendCTRL}.
* @throws IOException If the command cannot be sent or a response cannot be
* read.
*/
public float[] getCTRL(int ac) throws IOException {
// Send request
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETC".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(ac);
sendUDP(os.toByteArray());
// Read response
byte[] data = readUDP();
if (data.length == 0) {
throw new IOException("No response received.");
}
if (data.length < 31) {
throw new IOException("Response too short");
}
// Parse response
float[] result = new float[7];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
result[0] = bb.getFloat(5);
result[1] = bb.getFloat(9);
result[2] = bb.getFloat(13);
result[3] = bb.getFloat(17);
result[4] = bb.get(21);
result[5] = bb.getFloat(22);
result[6] = bb.getFloat(27);
return result;
}
/**
* Sends command to X-Plane setting control surfaces on the player ac.
*
* @param values
* <p>
* An array containing zero to six values representing control
* surface data as follows:
* </p>
* <ol>
* <li>Latitudinal Stick [-1,1]</li>
* <li>Longitudinal Stick [-1,1]</li>
* <li>Rudder Pedals [-1, 1]</li>
* <li>Throttle [-1, 1]</li>
* <li>Gear (0=up, 1=down)</li>
* <li>Flaps [0, 1]</li>
* <li>Speedbrakes [-0.5, 1.5]</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing
* elements will not be changed. To
* change values in the middle of the array without affecting the
* preceding values, set the
* preceding values to -998.
* </p>
* @throws IOException If the command cannot be sent.
*/
public void sendCTRL(float[] values) throws IOException {
sendCTRL(values, 0);
}
/**
* Sends command to X-Plane setting control surfaces on the specified ac.
*
* @param values
* <p>
* An array containing zero to six values representing control
* surface data as follows:
* </p>
* <ol>
* <li>Latitudinal Stick [-1,1]</li>
* <li>Longitudinal Stick [-1,1]</li>
* <li>Rudder Pedals [-1, 1]</li>
* <li>Throttle [-1, 1]</li>
* <li>Gear (0=up, 1=down)</li>
* <li>Flaps [0, 1]</li>
* <li>Speedbrakes [-0.5, 1.5]</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing
* elements will not be changed. To
* change values in the middle of the array without affecting the
* preceding values, set the
* preceding values to -998.
* </p>
* @param ac The ac to set. 0 for the player's ac.
* @throws IOException If the command cannot be sent.
*/
public void sendCTRL(float[] values, int ac) throws IOException {
// Preconditions
if (values == null) {
throw new IllegalArgumentException("ctrl must no be null.");
}
if (values.length > 7) {
throw new IllegalArgumentException("ctrl must have 7 or fewer elements.");
}
if (ac < 0 || ac > 9) {
throw new IllegalArgumentException("ac must be non-negative and less than 9.");
}
// Pad command values and convert to bytes
int i;
int cur = 0;
ByteBuffer bb = ByteBuffer.allocate(26);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (i = 0; i < 6; ++i) {
if (i == 4) {
if (i >= values.length) {
bb.put(cur, (byte) -1);
} else {
bb.put(cur, (byte) values[i]);
}
cur += 1;
} else if (i >= values.length) {
bb.putFloat(cur, -998);
cur += 4;
} else {
bb.putFloat(cur, values[i]);
cur += 4;
}
}
bb.put(cur++, (byte) ac);
bb.putFloat(cur, values.length == 7 ? values[6] : -998);
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("CTRL".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Gets position information for the specified airplane.
*
* @param ac The aircraft to get position information for.
* @return An array containing control surface data in the same format as
* {@code sendPOSI}.
* @throws IOException If the command cannot be sent or a response cannot be
* read.
*/
public double[] getPOSI(int ac) throws IOException {
// Send request
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETP".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(ac);
sendUDP(os.toByteArray());
// Read response
byte[] data = readUDP();
if (data.length == 0) {
throw new IOException("No response received.");
}
if (data.length < 34) {
throw new IOException("Response too short");
}
// Parse response
double[] result = new double[7];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < 7; ++i) {
result[i] = bb.getFloat(6 + 4 * i);
}
return result;
}
/**
* Sets the position of the player ac.
*
* @param values
* <p>
* An array containing position elements as follows:
* </p>
* <ol>
* <li>Latitude (deg)</li>
* <li>Longitude (deg)</li>
* <li>Altitude (m above MSL)</li>
* <li>Roll (deg)</li>
* <li>Pitch (deg)</li>
* <li>True Heading (deg)</li>
* <li>Gear (0=up, 1=down)</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing
* elements will not be changed. To
* change values in the middle of the array without affecting the
* preceding values, set the
* preceding values to -998.
* </p>
* @throws IOException If the command can not be sent.
*/
public void sendPOSI(double[] values) throws IOException {
sendPOSI(values, 0);
}
/**
* Sets the position of the specified ac with double precision coordinates.
*
* @param values
* <p>
* An array containing position elements as follows:
* </p>
* <ol>
* <li>Latitude (deg)</li>
* <li>Longitude (deg)</li>
* <li>Altitude (m above MSL)</li>
* <li>Roll (deg)</li>
* <li>Pitch (deg)</li>
* <li>True Heading (deg)</li>
* <li>Gear (0=up, 1=down)</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing
* elements will not be changed. To
* change values in the middle of the array without affecting the
* preceding values, set the
* preceding values to -998.
* </p>
* @param ac The ac to set. 0 for the player ac.
* @throws IOException If the command can not be sent.
*/
public void sendPOSI(double[] values, int ac) throws IOException {
// Preconditions
if (values == null) {
throw new IllegalArgumentException("posi must no be null.");
}
if (values.length > 7) {
throw new IllegalArgumentException("posi must have 7 or fewer elements.");
}
if (ac < 0 || ac > 255) {
throw new IllegalArgumentException("ac must be between 0 and 255.");
}
// Pad command values and convert to bytes
int i;
ByteBuffer bb = ByteBuffer.allocate(40);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (i = 0; i < values.length; ++i) {
if (i < 3) /* lat/lon/height as double */
{
bb.putDouble(values[i]);
} else {
bb.putFloat((float) values[i]);
}
}
for (; i < 7; ++i) {
bb.putFloat(-998);
}
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("POSI".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(ac);
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Reads X-Plane data
*
* @return The data read.
* @throws IOException If the read operation fails.
*/
public float[][] readData() throws IOException {
byte[] buffer = readUDP();
ByteBuffer bb = ByteBuffer.wrap(buffer);
int cur = 5;
int len = bb.get(cur++);
float[][] result = new float[bb.get(len)][9];
for (int i = 0; i < len; ++i) {
for (int j = 0; j < 9; ++j) {
result[i][j] = bb.getFloat(cur);
cur += 4;
}
}
return result;
}
/**
* Sends data to X-Plane
*
* @param data The data to send.
* @throws IOException If the command cannot be sent.
*/
public void sendDATA(float[][] data) throws IOException {
// Preconditions
if (data == null || data.length == 0) {
throw new IllegalArgumentException("data must be a non-null, non-empty array.");
}
// Convert data to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * 9 * data.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < data.length; ++i) {
int rowStart = 9 * 4 * i;
float[] row = data[i];
if (row.length != 9) {
throw new IllegalArgumentException("Rows must contain exactly 9 items. (Row " + i + ")");
}
bb.putInt(rowStart, (int) row[0]);
for (int j = 1; j < row.length; ++j) {
bb.putFloat(rowStart + 4 * j, row[j]);
}
}
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DATA".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Selects what data X-Plane will export over UDP.
*
* @param rows The row numbers to select.
* @throws IOException If the command cannot be sent.
*/
public void selectDATA(int[] rows) throws IOException {
// Preconditions
if (rows == null || rows.length == 0) {
throw new IllegalArgumentException("rows must be a non-null, non-empty array.");
}
// Convert data to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * rows.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < rows.length; ++i) {
bb.putInt(i * 4, rows[i]);
}
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DSEL".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Sets a message to be displayed on the screen in X-Plane at the default screen
* location.
*
* @param msg The message to display. Should not contain any newline characters.
* @throws IOException If the command cannot be sent.
*/
public void sendTEXT(String msg) throws IOException {
sendTEXT(msg, -1, -1);
}
/**
* Sets a message to be displayed on the screen in X-Plane at the specified
* coordinates.
*
* @param msg The message to display. Should not contain any newline characters.
* @param x The number of pixels from the right edge of the screen to display
* the text.
* @param y The number of pixels from the bottom edge of the screen to display
* the text.
* @throws IOException If the command cannot be sent.
*/
public void sendTEXT(String msg, int x, int y) throws IOException {
// Preconditions
if (msg == null) {
msg = "";
}
// Convert drefs to bytes.
byte[] msgBytes = msg.getBytes(StandardCharsets.UTF_8);
if (msgBytes.length > 255) {
throw new IllegalArgumentException("msg must be less than 255 bytes in UTF-8.");
}
ByteBuffer bb = ByteBuffer.allocate(8);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(0, x);
bb.putInt(4, y);
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("TEXT".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(bb.array());
os.write(msgBytes.length);
os.write(msgBytes);
sendUDP(os.toByteArray());
}
/**
* Sets the camera view in X-Plane.
*
* @param view The view to use.
* @throws IOException If the command cannot be sent.
*/
public void sendVIEW(ViewType view) throws IOException {
ByteBuffer bb = ByteBuffer.allocate(4);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(view.getValue());
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("VIEW".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Adds, removes, or clears a set of waypoints. If the command is clear, the
* points are ignored
* and all points are removed.
*
* @param op The operation to perform.
* @param points An array of values representing points. Each triplet in the
* array will be
* interpreted as a (Lat, Lon, Alt) point.
* @throws IOException If the command cannot be sent.
*/
public void sendWYPT(WaypointOp op, float[] points) throws IOException {
// Preconditions
if (points.length % 3 != 0) {
throw new IllegalArgumentException("points.length should be divisible by 3.");
}
if (points.length / 3 > 255) {
throw new IllegalArgumentException("Too many points. Must be less than 256.");
}
// Convert points to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * points.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (float f : points) {
bb.putFloat(f);
}
// Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("WYPT".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write(op.getValue());
os.write(points.length / 3);
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Send a command to X-Plane.
*
* @param comm The name of the X-Plane command to send.
* @throws IOException If the command cannot be sent.
*/
public void sendCOMM(String comm) throws IOException {
// Preconditions
if (comm == null || comm.length() == 0) {
throw new IllegalArgumentException(("comm must be non-empty."));
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("COMM".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
// Convert comm to bytes.
byte[] commBytes = comm.getBytes(StandardCharsets.UTF_8);
if (commBytes.length == 0) {
throw new IllegalArgumentException("COMM is an empty string!");
}
if (commBytes.length > 255) {
throw new IllegalArgumentException(
"comm must be less than 255 bytes in UTF-8. Are you sure this is a valid comm?");
}
// Build and send message
os.write(commBytes.length);
os.write(commBytes);
sendUDP(os.toByteArray());
}
/**
* Sets the port on which the client will receive data from X-Plane.
*
* @param port The new incoming port number.
* @throws IOException If the command cannot be sent.
*/
public void setCONN(int port) throws IOException {
if (port < 0 || port >= 0xFFFF) {
throw new IllegalArgumentException("Invalid port (must be non-negative and less than 65536).");
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("CONN".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); // Placeholder for message length
os.write((byte) port);
os.write((byte) (port >> 8));
sendUDP(os.toByteArray());
int soTimeout = socket.getSoTimeout();
socket.close();
socket = new DatagramSocket(port);
socket.setSoTimeout(soTimeout);
readUDP(); // Try to read response
}
}

View File

@@ -0,0 +1,57 @@
import javax.swing.*;
import CognitiveModel.ModelFiles.*;
import Visualizer.Screen;
import Visualizer.ScreenFrame;
import Visualizer.ScreenManager;
import java.awt.*;
public class Main {
public static void main(String[] args) {
// Encapsulation (or lack thereof) Test
// Model m = new Model();
// testprocess1 tp1 = new testprocess1(m, null);
// tp1.runProcess();
//Toolkit.getDefaultToolkit().setDynamicLayout(true);
JLabel t1 = new JLabel("t1");
JLabel t2 = new JLabel("t2");
JLabel t3 = new JLabel("t3");
JLabel t4 = new JLabel("t4");
Screen s1 = new Screen(new GridLayout(1,2));
s1.add(t1);
s1.add(t2);
Screen s2 = new Screen(new GridLayout(1,2));
s2.add(t3);
s2.add(t4);
ScreenManager m = new ScreenManager(s1,s2);
Dimension d = new Dimension(500,500);
ScreenFrame f = new ScreenFrame(m,d);
f.initialize();
while (true) {
f.repaint();
}
// 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;
// }
// }
}
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="Java">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../out/artifacts/XPlaneConnect_jar/XPlaneConnect.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/BasicOperation.iml" filepath="$PROJECT_DIR$/BasicOperation.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="gov.nasa.xpc.ex" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="Java" level="project" />
</component>
</module>

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -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;
// }
//
//}

View File

@@ -0,0 +1,954 @@
//NOTICES:
// Copyright (c) 2013-2018 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
// No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND,
// EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE
// SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT
// SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO
// THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY
// GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
// SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
// FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY
// SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."
//
// Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES
// GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF
// RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
// EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR
// RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD
// 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 gov.nasa.xpc;
import gov.nasa.xpc.discovery.Beacon;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.AutoCloseable;
import java.net.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
/**
* Represents a client that can connect to and interact with the X-Plane Connect plugin.
*
* @author Jason Watkins
* @version 0.1
* @since 2015-03-31
*/
public class XPlaneConnect implements AutoCloseable
{
private static int clientNum;
private DatagramSocket socket;
private InetAddress xplaneAddr;
private int xplanePort;
/**
* Gets the port on which the client receives data from the plugin.
*
* @return The incoming port number.
*/
public int getRecvPort() { return socket.getLocalPort(); }
/**
* Gets the port on which the client sends data to X-Plane.
*
* @return The outgoing port number.
*/
public int getXPlanePort() { return xplanePort; }
/**
* Sets the port on which the client sends data to X-Plane
*
* @param port The new outgoing port number.
* @throws IllegalArgumentException If {@code port} is not a valid port number.
*/
public void setXPlanePort(int port)
{
if(port < 0 || port >= 0xFFFF)
{
throw new IllegalArgumentException("Invalid port (must be non-negative and less than 65536).");
}
xplanePort = port;
}
/**
* Gets the hostname of the X-Plane host.
*
* @return The hostname of the X-Plane host.
*/
public String getXPlaneAddr() { return xplaneAddr.getHostAddress(); }
/**
* Sets the hostname of the X-Plane host.
*
* @param host The new hostname of the X-Plane host machine.
* @throws UnknownHostException {@code host} is not valid.
*/
public void setXplaneAddr(String host) throws UnknownHostException
{
xplaneAddr = InetAddress.getByName(host);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using default ports and assuming X-Plane is running on the
* local machine.
*
* @throws SocketException If this instance is unable to bind to the default receive port.
*/
public XPlaneConnect() throws SocketException
{
this(100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class with the specified timeout using default ports and
* assuming X-Plane is running on the local machine.
*
* @param timeout The time, in milliseconds, after which read attempts will timeout.
* @throws SocketException If this instance is unable to bind to the default receive port.
*/
public XPlaneConnect(int timeout) throws SocketException
{
this.socket = new DatagramSocket(0);
this.xplaneAddr = InetAddress.getLoopbackAddress();
this.xplanePort = 49009;
this.socket.setSoTimeout(timeout);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using the specified ports and X-Plane host.
*
* @param xpHost The network host on which X-Plane is running.
* @param xpPort The port on which the X-Plane Connect plugin is listening.
* @param port The local port to use when sending and receiving data from XPC.
* @throws java.net.SocketException If this instance is unable to bind to the specified port.
* @throws java.net.UnknownHostException If the specified hostname can not be resolved.
*/
public XPlaneConnect(String xpHost, int xpPort, int port)
throws java.net.SocketException, java.net.UnknownHostException
{
this(xpHost, xpPort, port, 100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class from a received discovery Beacon
* @param beacon The beacon received from {@code XPlaneConnectDiscovery}
* @throws SocketException If this instance is unable to bind to the specified port.
*/
public XPlaneConnect(Beacon beacon) throws SocketException {
this.socket = new DatagramSocket(0);
this.xplaneAddr = beacon.getXplaneAddress();
this.xplanePort = beacon.getPluginPort();
this.socket.setSoTimeout(100);
}
/**
* Initializes a new instance of the {@code XPlaneConnect} class using the specified ports, hostname, and timeout.
*
* @param xpHost The network host on which X-Plane is running.
* @param xpPort The port on which the X-Plane Connect plugin is listening.
* @param port The port on which the X-Plane Connect plugin is sending data.
* @param timeout The time, in milliseconds, after which read attempts will timeout.
* @throws java.net.SocketException If this instance is unable to bind to the specified port.
* @throws java.net.UnknownHostException If the specified hostname can not be resolved.
*/
public XPlaneConnect(String xpHost, int xpPort, int port, int timeout)
throws java.net.SocketException, java.net.UnknownHostException
{
this.socket = new DatagramSocket(port);
this.xplaneAddr = InetAddress.getByName(xpHost);
this.xplanePort = xpPort;
this.socket.setSoTimeout(timeout);
}
/**
* Closes the underlying socket.
*/
public void close()
{
if(socket != null)
{
socket.close();
socket = null;
}
}
/**
* Read data from the X-Plane plugin. This method will read whatever data is available and return it.
*
* @return The data send from X-Plane.
* @throws IOException If the read operation fails
*/
private byte[] readUDP() throws IOException
{
byte[] buffer = new byte[65536];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
try
{
socket.receive(packet);
return Arrays.copyOf(buffer, packet.getLength());
}
catch (SocketTimeoutException ex)
{
return new byte[0];
}
}
/**
* Send the given data to the X-Plane plugin.
*
* @param buffer The data to send.
* @throws IOException If the send operation fails.
*/
private void sendUDP(byte[] buffer) throws IOException
{
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, xplaneAddr, xplanePort);
socket.send(packet);
}
/**
* Pauses or unpauses X-Plane.
*
* @param pause {@code true} to pause the simulator; {@code false} to un-pause.
* @throws IOException If the command cannot be sent.
*/
public void pauseSim(boolean pause) throws IOException
{
// S I M U LEN VAL
byte[] msg = {0x53, 0x49, 0x4D, 0x55, 0x00, 0x00};
msg[5] = (byte)(pause ? 0x01 : 0x00);
sendUDP(msg);
}
/**
* Pauses, unpauses, or switches the pause state of X-Plane.
*
* @param pause {@code 1} to pause the simulator, {@code 0} to unpause, or {@code 2} to switch.
* @throws IllegalArgumentException If the values of {@code pause} is not a valid command.
* @throws IOException If the command cannot be sent.
*/
public void pauseSim(int pause) throws IOException
{
if(pause < 0 || (pause > 2 && pause < 100) || (pause > 119 && pause < 200) || pause > 219)
{
throw new IllegalArgumentException("pause must be a value in the range [0, 2], [100, 119], or [200, 219].");
}
// S I M U LEN VAL
byte[] msg = {0x53, 0x49, 0x4D, 0x55, 0x00, 0x00};
msg[5] = (byte)pause;
sendUDP(msg);
}
/**
* Requests a single dref value from X-Plane.
*
* @param dref The name of the dref requested.
* @return A byte array representing data dependent on the dref requested.
* @throws IOException If either the request or the response fails.
*/
public float[] getDREF(String dref) throws IOException
{
return getDREFs(new String[] {dref})[0];
}
/**
* Requests several dref values from X-Plane.
*
* @param drefs An array of dref names to request.
* @return A multidimensional array representing the data for each requested dref.
* @throws IOException If either the request or the response fails.
*/
public float[][] getDREFs(String[] drefs) throws IOException
{
//Preconditions
if(drefs == null || drefs.length == 0)
{
throw new IllegalArgumentException("drefs must be a valid array with at least one dref.");
}
if(drefs.length > 255)
{
throw new IllegalArgumentException("Can not request more than 255 DREFs at once.");
}
//Convert drefs to bytes.
byte[][] drefBytes = new byte[drefs.length][];
for(int i = 0; i < drefs.length; ++i)
{
drefBytes[i] = drefs[i].getBytes(StandardCharsets.UTF_8);
if(drefBytes[i].length == 0)
{
throw new IllegalArgumentException("DREF " + i + " is an empty string!");
}
if(drefBytes[i].length > 255)
{
throw new IllegalArgumentException("DREF " + i + " is too long (must be less than 255 bytes in UTF-8). Are you sure this is a valid DREF?");
}
}
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETD".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(drefs.length);
for(byte[] dref : drefBytes)
{
os.write(dref.length);
os.write(dref, 0, dref.length);
}
sendUDP(os.toByteArray());
//Read response
byte[] data = readUDP();
if(data.length == 0)
{
throw new IOException("No response received.");
}
if(data.length < 6)
{
throw new IOException("Response too short");
}
float[][] result = new float[drefs.length][];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
int cur = 6;
for(int j = 0; j < result.length; ++j)
{
result[j] = new float[data[cur++]];
for(int k = 0; k < result[j].length; ++k) //TODO: There must be a better way to do this
{
result[j][k] = bb.getFloat(cur);
cur += 4;
}
}
return result;
}
public void sendDREF(String dref, float value) throws IOException
{
sendDREF(dref, new float[] {value});
}
/**
* Sends a command to X-Plane that sets the given DREF.
*
* @param dref The name of the X-Plane dataref to set.
* @param value An array of floating point values whose structure depends on the dref specified.
* @throws IOException If the command cannot be sent.
*/
public void sendDREF(String dref, float[] value) throws IOException
{
sendDREFs(new String[] {dref}, new float[][] {value});
}
/**
* Sends a command to X-Plane that sets the given DREF.
*
* @param drefs The names of the X-Plane datarefs to set.
* @param values A sequence of arrays of floating point values whose structure depends on the drefs specified.
* @throws IOException If the command cannot be sent.
*/
public void sendDREFs(String[] drefs, float[][] values) throws IOException
{
//Preconditions
if(drefs == null || drefs.length == 0)
{
throw new IllegalArgumentException(("drefs must be non-empty."));
}
if(values == null || values.length != drefs.length)
{
throw new IllegalArgumentException("values must be of the same size as drefs.");
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DREF".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
for(int i = 0; i < drefs.length; ++i)
{
String dref = drefs[i];
float[] value = values[i];
if (dref == null)
{
throw new IllegalArgumentException("dref must be a valid string.");
}
if (value == null || value.length == 0)
{
throw new IllegalArgumentException("value must be non-null and should contain at least one value.");
}
//Convert drefs to bytes.
byte[] drefBytes = dref.getBytes(StandardCharsets.UTF_8);
if (drefBytes.length == 0)
{
throw new IllegalArgumentException("DREF is an empty string!");
}
if (drefBytes.length > 255)
{
throw new IllegalArgumentException("dref must be less than 255 bytes in UTF-8. Are you sure this is a valid dref?");
}
ByteBuffer bb = ByteBuffer.allocate(4 * value.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for (int j = 0; j < value.length; ++j)
{
bb.putFloat(j * 4, value[j]);
}
//Build and send message
os.write(drefBytes.length);
os.write(drefBytes, 0, drefBytes.length);
os.write(value.length);
os.write(bb.array());
}
sendUDP(os.toByteArray());
}
/**
* Gets the control surface information for the specified airplane.
*
* @param ac The aircraft to get control surface information for.
* @return An array containing control surface data in the same format as {@code sendCTRL}.
* @throws IOException If the command cannot be sent or a response cannot be read.
*/
public float[] getCTRL(int ac) throws IOException
{
// Send request
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETC".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(ac);
sendUDP(os.toByteArray());
// Read response
byte[] data = readUDP();
if(data.length == 0)
{
throw new IOException("No response received.");
}
if(data.length < 31)
{
throw new IOException("Response too short");
}
// Parse response
float[] result = new float[7];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
result[0] = bb.getFloat(5);
result[1] = bb.getFloat(9);
result[2] = bb.getFloat(13);
result[3] = bb.getFloat(17);
result[4] = bb.get(21);
result[5] = bb.getFloat(22);
result[6] = bb.getFloat(27);
return result;
}
/**
* Sends command to X-Plane setting control surfaces on the player ac.
*
* @param values <p>An array containing zero to six values representing control surface data as follows:</p>
* <ol>
* <li>Latitudinal Stick [-1,1]</li>
* <li>Longitudinal Stick [-1,1]</li>
* <li>Rudder Pedals [-1, 1]</li>
* <li>Throttle [-1, 1]</li>
* <li>Gear (0=up, 1=down)</li>
* <li>Flaps [0, 1]</li>
* <li>Speedbrakes [-0.5, 1.5]</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing elements will not be changed. To
* change values in the middle of the array without affecting the preceding values, set the
* preceding values to -998.
* </p>
* @throws IOException If the command cannot be sent.
*/
public void sendCTRL(float[] values) throws IOException
{
sendCTRL(values, 0);
}
/**
* Sends command to X-Plane setting control surfaces on the specified ac.
*
* @param values <p>An array containing zero to six values representing control surface data as follows:</p>
* <ol>
* <li>Latitudinal Stick [-1,1]</li>
* <li>Longitudinal Stick [-1,1]</li>
* <li>Rudder Pedals [-1, 1]</li>
* <li>Throttle [-1, 1]</li>
* <li>Gear (0=up, 1=down)</li>
* <li>Flaps [0, 1]</li>
* <li>Speedbrakes [-0.5, 1.5]</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing elements will not be changed. To
* change values in the middle of the array without affecting the preceding values, set the
* preceding values to -998.
* </p>
* @param ac The ac to set. 0 for the player's ac.
* @throws IOException If the command cannot be sent.
*/
public void sendCTRL(float[] values, int ac) throws IOException
{
//Preconditions
if(values == null)
{
throw new IllegalArgumentException("ctrl must no be null.");
}
if(values.length > 7)
{
throw new IllegalArgumentException("ctrl must have 7 or fewer elements.");
}
if(ac < 0 || ac > 9)
{
throw new IllegalArgumentException("ac must be non-negative and less than 9.");
}
//Pad command values and convert to bytes
int i;
int cur = 0;
ByteBuffer bb = ByteBuffer.allocate(26);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(i = 0; i < 6; ++i)
{
if(i == 4)
{
if(i >= values.length)
{
bb.put(cur, (byte)-1);
}
else
{
bb.put(cur, (byte)values[i]);
}
cur += 1;
}
else if (i >= values.length)
{
bb.putFloat(cur, -998);
cur+= 4;
}
else
{
bb.putFloat(cur, values[i]);
cur += 4;
}
}
bb.put(cur++, (byte) ac);
bb.putFloat(cur, values.length == 7 ? values[6] : -998);
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("CTRL".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Gets position information for the specified airplane.
*
* @param ac The aircraft to get position information for.
* @return An array containing control surface data in the same format as {@code sendPOSI}.
* @throws IOException If the command cannot be sent or a response cannot be read.
*/
public double[] getPOSI(int ac) throws IOException
{
// Send request
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("GETP".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(ac);
sendUDP(os.toByteArray());
// Read response
byte[] data = readUDP();
if(data.length == 0)
{
throw new IOException("No response received.");
}
if(data.length < 34)
{
throw new IOException("Response too short");
}
// Parse response
double[] result = new double[7];
ByteBuffer bb = ByteBuffer.wrap(data);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(int i = 0; i < 7; ++i)
{
result[i] = bb.getFloat(6 + 4 * i);
}
return result;
}
/**
* Sets the position of the player ac.
*
* @param values <p>An array containing position elements as follows:</p>
* <ol>
* <li>Latitude (deg)</li>
* <li>Longitude (deg)</li>
* <li>Altitude (m above MSL)</li>
* <li>Roll (deg)</li>
* <li>Pitch (deg)</li>
* <li>True Heading (deg)</li>
* <li>Gear (0=up, 1=down)</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing elements will not be changed. To
* change values in the middle of the array without affecting the preceding values, set the
* preceding values to -998.
* </p>
* @throws IOException If the command can not be sent.
*/
public void sendPOSI(double[] values) throws IOException
{
sendPOSI(values, 0);
}
/**
* Sets the position of the specified ac with double precision coordinates.
*
* @param values <p>An array containing position elements as follows:</p>
* <ol>
* <li>Latitude (deg)</li>
* <li>Longitude (deg)</li>
* <li>Altitude (m above MSL)</li>
* <li>Roll (deg)</li>
* <li>Pitch (deg)</li>
* <li>True Heading (deg)</li>
* <li>Gear (0=up, 1=down)</li>
* </ol>
* <p>
* If @{code ctrl} is less than 6 elements long, The missing elements will not be changed. To
* change values in the middle of the array without affecting the preceding values, set the
* preceding values to -998.
* </p>
* @param ac The ac to set. 0 for the player ac.
* @throws IOException If the command can not be sent.
*/
public void sendPOSI(double[] values, int ac) throws IOException
{
//Preconditions
if(values == null)
{
throw new IllegalArgumentException("posi must no be null.");
}
if(values.length > 7)
{
throw new IllegalArgumentException("posi must have 7 or fewer elements.");
}
if(ac < 0 || ac > 255)
{
throw new IllegalArgumentException("ac must be between 0 and 255.");
}
//Pad command values and convert to bytes
int i;
ByteBuffer bb = ByteBuffer.allocate(40);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(i = 0; i < values.length; ++i)
{
if(i<3) /* lat/lon/height as double */
{
bb.putDouble(values[i]);
}
else
{
bb.putFloat((float)values[i]);
}
}
for(; i < 7; ++i)
{
bb.putFloat(-998);
}
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("POSI".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(ac);
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Reads X-Plane data
*
* @return The data read.
* @throws IOException If the read operation fails.
*/
public float[][] readData() throws IOException
{
byte[] buffer = readUDP();
ByteBuffer bb = ByteBuffer.wrap(buffer);
int cur = 5;
int len = bb.get(cur++);
float[][] result = new float[bb.get(len)][9];
for(int i = 0; i < len; ++i)
{
for(int j = 0; j < 9; ++j)
{
result[i][j] = bb.getFloat(cur);
cur += 4;
}
}
return result;
}
/**
* Sends data to X-Plane
*
* @param data The data to send.
* @throws IOException If the command cannot be sent.
*/
public void sendDATA(float[][] data) throws IOException
{
//Preconditions
if(data == null || data.length == 0)
{
throw new IllegalArgumentException("data must be a non-null, non-empty array.");
}
//Convert data to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * 9 * data.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(int i = 0; i < data.length; ++i)
{
int rowStart = 9 * 4 * i;
float[] row = data[i];
if(row.length != 9)
{
throw new IllegalArgumentException("Rows must contain exactly 9 items. (Row " + i + ")");
}
bb.putInt(rowStart, (int) row[0]);
for(int j = 1; j < row.length; ++j)
{
bb.putFloat(rowStart + 4 * j, row[j]);
}
}
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DATA".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Selects what data X-Plane will export over UDP.
*
* @param rows The row numbers to select.
* @throws IOException If the command cannot be sent.
*/
public void selectDATA(int[] rows) throws IOException
{
//Preconditions
if(rows == null || rows.length == 0)
{
throw new IllegalArgumentException("rows must be a non-null, non-empty array.");
}
//Convert data to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * rows.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(int i = 0; i < rows.length; ++i)
{
bb.putInt(i * 4, rows[i]);
}
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("DSEL".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Sets a message to be displayed on the screen in X-Plane at the default screen location.
*
* @param msg The message to display. Should not contain any newline characters.
* @throws IOException If the command cannot be sent.
*/
public void sendTEXT(String msg) throws IOException
{
sendTEXT(msg, -1, -1);
}
/**
* Sets a message to be displayed on the screen in X-Plane at the specified coordinates.
*
* @param msg The message to display. Should not contain any newline characters.
* @param x The number of pixels from the right edge of the screen to display the text.
* @param y The number of pixels from the bottom edge of the screen to display the text.
* @throws IOException If the command cannot be sent.
*/
public void sendTEXT(String msg, int x, int y) throws IOException
{
//Preconditions
if(msg == null)
{
msg = "";
}
//Convert drefs to bytes.
byte[] msgBytes = msg.getBytes(StandardCharsets.UTF_8);
if(msgBytes.length > 255)
{
throw new IllegalArgumentException("msg must be less than 255 bytes in UTF-8.");
}
ByteBuffer bb = ByteBuffer.allocate(8);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(0, x);
bb.putInt(4, y);
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("TEXT".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(bb.array());
os.write(msgBytes.length);
os.write(msgBytes);
sendUDP(os.toByteArray());
}
/**
* Sets the camera view in X-Plane.
*
* @param view The view to use.
* @throws IOException If the command cannot be sent.
*/
public void sendVIEW(ViewType view) throws IOException
{
ByteBuffer bb = ByteBuffer.allocate(4);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(view.getValue());
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("VIEW".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Adds, removes, or clears a set of waypoints. If the command is clear, the points are ignored
* and all points are removed.
*
* @param op The operation to perform.
* @param points An array of values representing points. Each triplet in the array will be
* interpreted as a (Lat, Lon, Alt) point.
* @throws IOException If the command cannot be sent.
*/
public void sendWYPT(WaypointOp op, float[] points) throws IOException
{
//Preconditions
if(points.length % 3 != 0)
{
throw new IllegalArgumentException("points.length should be divisible by 3.");
}
if(points.length / 3 > 255)
{
throw new IllegalArgumentException("Too many points. Must be less than 256.");
}
//Convert points to bytes
ByteBuffer bb = ByteBuffer.allocate(4 * points.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
for(float f : points)
{
bb.putFloat(f);
}
//Build and send message
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("WYPT".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write(op.getValue());
os.write(points.length / 3);
os.write(bb.array());
sendUDP(os.toByteArray());
}
/**
* Send a command to X-Plane.
*
* @param comm The name of the X-Plane command to send.
* @throws IOException If the command cannot be sent.
*/
public void sendCOMM(String comm) throws IOException
{
//Preconditions
if(comm == null || comm.length() == 0)
{
throw new IllegalArgumentException(("comm must be non-empty."));
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("COMM".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
//Convert comm to bytes.
byte[] commBytes = comm.getBytes(StandardCharsets.UTF_8);
if (commBytes.length == 0)
{
throw new IllegalArgumentException("COMM is an empty string!");
}
if (commBytes.length > 255)
{
throw new IllegalArgumentException("comm must be less than 255 bytes in UTF-8. Are you sure this is a valid comm?");
}
//Build and send message
os.write(commBytes.length);
os.write(commBytes);
sendUDP(os.toByteArray());
}
/**
* Sets the port on which the client will receive data from X-Plane.
*
* @param port The new incoming port number.
* @throws IOException If the command cannot be sent.
*/
public void setCONN(int port) throws IOException
{
if(port < 0 || port >= 0xFFFF)
{
throw new IllegalArgumentException("Invalid port (must be non-negative and less than 65536).");
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write("CONN".getBytes(StandardCharsets.UTF_8));
os.write(0xFF); //Placeholder for message length
os.write((byte) port);
os.write((byte) (port >> 8));
sendUDP(os.toByteArray());
int soTimeout = socket.getSoTimeout();
socket.close();
socket = new DatagramSocket(port);
socket.setSoTimeout(soTimeout);
readUDP(); // Try to read response
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="CheckStyle-IDEA-Module" serialisationVersion="2">
<option name="activeLocationsIds" />
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/Model-1" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>

View File

@@ -0,0 +1,13 @@
package Visualizer;
import javax.swing.*;
import java.awt.*;
public class Screen extends JPanel {
public Screen(LayoutManager l) {
this.setLayout(l);
this.setVisible(true);
}
}

View File

@@ -0,0 +1,22 @@
package Visualizer;
import javax.script.ScriptEngine;
import javax.swing.*;
import java.awt.*;
public class ScreenFrame extends JFrame {
ScreenManager sm;
public ScreenFrame(ScreenManager sm, Dimension d) {
this.sm = sm;
this.setPreferredSize(d);
}
public void initialize() {
this.setVisible(true);
this.setFocusable(true);
this.add(sm);
this.pack();
}
}

View File

@@ -0,0 +1,64 @@
package Visualizer;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class ScreenManager extends JPanel {
JPanel display = new JPanel(new BorderLayout());
Screen[] screens = new Screen[2];
ScreenType currentScreen;
JButton toggle = new JButton();
public ScreenManager(Screen start, Screen data) {
super(new BorderLayout());
this.setVisible(true);
screens[0] = start;
screens[1] = data;
toggle.setVisible(true);
toggle.addActionListener(e -> {
if (currentScreen == ScreenType.START) {
switchScreens(ScreenType.DATA);
} else {
switchScreens(ScreenType.START);
}
});
this.add(toggle, BorderLayout.WEST);
currentScreen = ScreenType.START;
display.add(screens[0]);
this.add(display, BorderLayout.CENTER);
display.setBackground(Color.black);
}
public void switchScreens(ScreenType st) {
display.removeAll();
switch(st) {
case START:
System.out.println("Switch to start");
display.add(screens[0],BorderLayout.CENTER);
currentScreen = ScreenType.START;
display.repaint();
revalidate();
break;
case DATA:
System.out.println("Switch to data");
display.add(screens[1],BorderLayout.CENTER);
currentScreen = ScreenType.DATA;
display.repaint();
revalidate();
break;
}
}
}

View File

@@ -0,0 +1,6 @@
package Visualizer;
public enum ScreenType {
START,
DATA
}

View File

@@ -0,0 +1,15 @@
package Visualizer;
import javax.swing.*;
public class StartScreen extends JPanel {
public StartScreen() {
JLabel l = new JLabel();
l.setText("Hello");
l.setVisible(true);
this.add(l);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -0,0 +1,33 @@
package Visualizer;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.*;
public 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;
}
}

View File

@@ -0,0 +1,54 @@
package Visualizer;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.*;
public 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/ProjectModels/Visualizer/assets/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;
}
}

View File

@@ -0,0 +1,277 @@
package Visualizer;
import javax.swing.border.Border;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import CognitiveModel.ModelFiles.*;
public class visualizer {
JFrame frame = new JFrame();
JPanel frameBottom = new JPanel();
JPanel controlDisplay = new JPanel();
JPanel modelDisplay = new JPanel();
JTextArea modelQueue = new JTextArea();
JTextArea modelVision = new JTextArea();
JPanel mainDisplay = new JPanel();
JPanel visualizer = new JPanel();
JPanel yokeGrid = new JPanel();
axis axis = new axis(0,0);
rudderPosition rudderGrid = new rudderPosition(yokeGrid.getWidth(), 0);
yokePosition yoke = new yokePosition(yokeGrid.getWidth(), yokeGrid.getHeight());
JLabel one = new JLabel();
JLabel two = new JLabel();
JLabel three = new JLabel();
JLabel four = new JLabel();
Model m;
public visualizer(Model m){
this.m = m;
}
public void initializeDisplay() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch(Exception ignored){}
frame.setPreferredSize(new Dimension(1700,270));
frame.setLayout(new BorderLayout());
frameBottom.setLayout(new GridLayout(1,2));
frame.setVisible(true);
controlDisplay.setPreferredSize(new Dimension(100,100));
controlDisplay.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);
one = new JLabel();
one.setFont(fontData);
one.setHorizontalAlignment(SwingConstants.CENTER);
one.setVerticalAlignment(SwingConstants.TOP);
two = new JLabel();
two.setFont(fontData);
two.setHorizontalAlignment(SwingConstants.CENTER);
two.setVerticalAlignment(SwingConstants.TOP);
three = new JLabel();
three.setFont(fontData);
three.setHorizontalAlignment(SwingConstants.CENTER);
three.setVerticalAlignment(SwingConstants.TOP);
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");
controlDisplay.add(titleOne);
controlDisplay.add(titleTwo);
controlDisplay.add(titleThree);
controlDisplay.add(titleFour);
controlDisplay.add(one);
controlDisplay.add(two);
controlDisplay.add(three);
controlDisplay.add(four);
visualizer.setLayout(new GridLayout(2,1));
//Col 1 of Visualizer
yokeGrid.setMinimumSize(new Dimension(100,100));
//grid.setOpaque(true);
// grid.setLayout(null);
yokeGrid.setBackground(Color.black);
yokeGrid.setVisible(true);
// grid.setLayout(new GridLayout(1,1));
yokeGrid.setLayout(new OverlayLayout(yokeGrid));
yoke = new yokePosition(yokeGrid.getWidth(), yokeGrid.getHeight());
// yaw yaw = new yaw(grid.getWidth(), grid.getHeight());
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
rudderGrid = new rudderPosition(yokeGrid.getWidth(), 0);
visualizer.add(rudderGrid);
JToolBar tool = new JToolBar("Toolbar");
JButton b1 = new JButton("Data Log Disabled");
ActionListener press = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(m.logPermission() == false){
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");
}
}
};
b1.addActionListener(press);
JButton b2 = new JButton("button 2");
tool.setBackground(Color.red);
tool.setOrientation(1);
tool.add(b1);
tool.add(b2);
frame.add(tool,BorderLayout.WEST);
JPanel buttonBar = new JPanel();
buttonBar.setLayout(new GridLayout(2,1));
JToolBar tool2 = new JToolBar("Toolbar");
JButton b3 = new JButton("button 2");
JButton b4 = new JButton("button 2");
tool2.add(b3);
tool2.add(b4);
JToolBar tool3 = new JToolBar("Toolbar");
JButton b5 = new JButton("button 3");
JButton b6 = new JButton("button 3");
tool3.add(b5);
tool3.add(b6);
buttonBar.add(tool2);
buttonBar.add(tool3);
modelQueue.setRows(3);
modelQueue.setPreferredSize(new Dimension(250, mainDisplay.getWidth()));
modelVision.setRows(1);
Font font = new Font("Verdana", Font.BOLD, 12);
modelVision.setFont(font);
modelVision.setBackground(Color.PINK);
modelVision.setPreferredSize(new Dimension(250, mainDisplay.getWidth()));
modelDisplay.setLayout(new GridLayout(2,1));
modelDisplay.add(modelQueue);
modelDisplay.add(modelVision);
mainDisplay.setLayout(new BorderLayout());
mainDisplay.add(controlDisplay,BorderLayout.CENTER);
mainDisplay.add(modelDisplay,BorderLayout.SOUTH);
frameBottom.add(mainDisplay); // Left Side
frameBottom.add(visualizer); // Right Side
frame.add(frameBottom,BorderLayout.CENTER);
frame.add(buttonBar, BorderLayout.SOUTH);
frame.pack();
}
public void updateVisualizer(Model m) throws IOException {
float[] ctrl1 = m.getCurrentControls();
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();
modelQueue.setText(m.getQueue().queueToString());
modelQueue.setPreferredSize(new Dimension(mainDisplay.getWidth(),100));
modelVision.setPreferredSize(new Dimension(mainDisplay.getWidth(),100));
modelVision.setText("We just looked at: " + m.getStoredVisionTarget() +"\n" +
"Result: " + m.getStoredVisionResult()[0]);
// yaw.setYBound(grid.getHeight());
// yaw.setYBound(grid.getHeight());
// yaw.setX(ctrl1[2]);
// yaw.repaint();
axis.setXBound(yokeGrid.getWidth());
axis.setYBound(yokeGrid.getHeight());
axis.repaint();
JButton j = new JButton();
}
}

View File

@@ -0,0 +1,73 @@
package Visualizer;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.*;
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/ProjectModels/Visualizer/assets/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;
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="gov.nasa.xpc" />
</content>
<content url="file://$MODULE_DIR$/../TestScripts/Java Tests">
<sourceFolder url="file://$MODULE_DIR$/../TestScripts/Java Tests" isTestSource="true" packagePrefix="gov.nasa.xpc.test" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$MODULE_DIR$/lib/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@@ -0,0 +1,142 @@
Elevator, Roll, Yaw, Throttle, Flaps
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.025160, 0.615686, 0.121569, 1.000000, 0.000000
-0.018032, 0.615686, 0.121569, 1.000000, 0.000000
-0.008946, 0.558105, 0.110294, 1.000000, 0.000000
0.016080, 0.046859, 0.010190, 1.000000, 0.000000
0.041168, -0.465645, -0.090160, 1.000000, 0.000000
0.072984, -0.714807, -0.141151, 1.000000, 0.000000
0.105265, -0.940778, -0.187779, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.111637, -1.000000, -0.200000, 1.000000, 0.000000
0.107753, -1.000000, -0.200000, 1.000000, 0.000000
0.090097, -0.804658, -0.160537, 1.000000, 0.000000
0.059241, -0.422819, -0.083398, 1.000000, 0.000000
0.033948, -0.164720, -0.032111, 1.000000, 0.000000
0.015275, -0.045211, -0.009702, 1.000000, 0.000000
0.003922, 0.032740, 0.005244, 1.000000, 0.000000
0.003922, 0.046948, 0.008796, 1.000000, 0.000000
0.003922, 0.061786, 0.012259, 1.000000, 0.000000
0.003922, 0.083051, 0.015803, 1.000000, 0.000000
0.003922, 0.104358, 0.019354, 1.000000, 0.000000
0.003922, 0.125915, 0.022947, 1.000000, 0.000000
0.003922, 0.148159, 0.026654, 1.000000, 0.000000
0.003922, 0.158683, 0.030322, 1.000000, 0.000000
0.003922, 0.166116, 0.034039, 1.000000, 0.000000
0.003922, 0.283275, 0.057725, 1.000000, 0.000000
0.003922, 0.457834, 0.091878, 1.000000, 0.000000
0.003922, 0.546335, 0.110113, 1.000000, 0.000000
0.003922, 0.574907, 0.117256, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.004623, 0.578134, 0.118764, 1.000000, 0.000000
0.011669, 0.437213, 0.090580, 1.000000, 0.000000
0.019799, 0.276776, 0.058441, 1.000000, 0.000000
0.030902, 0.180551, 0.036236, 1.000000, 0.000000
0.041750, 0.086531, 0.014539, 1.000000, 0.000000
0.046236, 0.055917, 0.008666, 1.000000, 0.000000
0.049697, 0.035152, 0.005205, 1.000000, 0.000000
0.050980, 0.007684, -0.000032, 1.000000, 0.000000
0.050980, -0.031292, -0.007827, 1.000000, 0.000000
0.047747, -0.076850, -0.016615, 1.000000, 0.000000
0.040527, -0.134607, -0.027445, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.030835, -0.156406, -0.030835, 1.000000, 0.000000
0.023403, -0.122963, -0.023403, 1.000000, 0.000000
0.019608, -0.087175, -0.015866, 1.000000, 0.000000
0.019608, -0.048247, -0.008081, 1.000000, 0.000000
0.019608, -0.025737, -0.003922, 1.000000, 0.000000
0.019608, -0.022039, -0.003922, 1.000000, 0.000000
0.019608, -0.006105, -0.001466, 1.000000, 0.000000
0.019608, 0.033829, 0.005794, 1.000000, 0.000000
0.019608, 0.075119, 0.013715, 1.000000, 0.000000
0.019608, 0.116461, 0.023256, 1.000000, 0.000000
0.019608, 0.153501, 0.031803, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.016330, 0.198129, 0.041850, 1.000000, 0.000000
0.013181, 0.226473, 0.048149, 1.000000, 0.000000
0.011765, 0.269528, 0.056492, 1.000000, 0.000000
0.011765, 0.308989, 0.063667, 1.000000, 0.000000
0.011765, 0.330794, 0.066667, 1.000000, 0.000000
0.011765, 0.340486, 0.066667, 1.000000, 0.000000
0.011765, 0.350149, 0.067232, 1.000000, 0.000000
0.011765, 0.357444, 0.070879, 1.000000, 0.000000
0.011765, 0.365362, 0.074611, 1.000000, 0.000000
0.011765, 0.406242, 0.080900, 1.000000, 0.000000
0.011765, 0.442962, 0.086549, 1.000000, 0.000000
0.011765, 0.469278, 0.091502, 1.000000, 0.000000
0.011765, 0.476131, 0.094928, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.460970, 0.093927, 1.000000, 0.000000
0.011765, 0.377419, 0.077860, 1.000000, 0.000000
0.011765, 0.290506, 0.061146, 1.000000, 0.000000
0.017800, 0.030978, 0.007522, 1.000000, 0.000000
0.024597, -0.247670, -0.050246, 1.000000, 0.000000
0.027451, -0.376429, -0.075975, 1.000000, 0.000000
0.027451, -0.398298, -0.078709, 1.000000, 0.000000
0.027451, -0.421658, -0.081629, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.034393, -0.253911, -0.047645, 1.000000, 0.000000
0.048982, 0.110811, 0.025300, 1.000000, 0.000000
0.059845, 0.368099, 0.076553, 1.000000, 0.000000
0.063351, 0.406663, 0.083564, 1.000000, 0.000000
0.066667, 0.443677, 0.090196, 1.000000, 0.000000
0.066667, 0.454719, 0.090196, 1.000000, 0.000000
0.066667, 0.465692, 0.090196, 1.000000, 0.000000
0.066667, 0.469954, 0.093483, 1.000000, 0.000000
0.066667, 0.473556, 0.097085, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
1 Elevator Roll Yaw Throttle Flaps
2 -0.027451 0.615686 0.121569 1.000000 0.000000
3 -0.027451 0.615686 0.121569 1.000000 0.000000
4 -0.027451 0.615686 0.121569 1.000000 0.000000
5 -0.025160 0.615686 0.121569 1.000000 0.000000
6 -0.018032 0.615686 0.121569 1.000000 0.000000
7 -0.008946 0.558105 0.110294 1.000000 0.000000
8 0.016080 0.046859 0.010190 1.000000 0.000000
9 0.041168 -0.465645 -0.090160 1.000000 0.000000
10 0.072984 -0.714807 -0.141151 1.000000 0.000000
11 0.105265 -0.940778 -0.187779 1.000000 0.000000
12 0.113726 -1.000000 -0.200000 1.000000 0.000000
13 0.113726 -1.000000 -0.200000 1.000000 0.000000
14 0.113726 -1.000000 -0.200000 1.000000 0.000000
15 0.113726 -1.000000 -0.200000 1.000000 0.000000
16 0.111637 -1.000000 -0.200000 1.000000 0.000000
17 0.107753 -1.000000 -0.200000 1.000000 0.000000
18 0.090097 -0.804658 -0.160537 1.000000 0.000000
19 0.059241 -0.422819 -0.083398 1.000000 0.000000
20 0.033948 -0.164720 -0.032111 1.000000 0.000000
21 0.015275 -0.045211 -0.009702 1.000000 0.000000
22 0.003922 0.032740 0.005244 1.000000 0.000000
23 0.003922 0.046948 0.008796 1.000000 0.000000
24 0.003922 0.061786 0.012259 1.000000 0.000000
25 0.003922 0.083051 0.015803 1.000000 0.000000
26 0.003922 0.104358 0.019354 1.000000 0.000000
27 0.003922 0.125915 0.022947 1.000000 0.000000
28 0.003922 0.148159 0.026654 1.000000 0.000000
29 0.003922 0.158683 0.030322 1.000000 0.000000
30 0.003922 0.166116 0.034039 1.000000 0.000000
31 0.003922 0.283275 0.057725 1.000000 0.000000
32 0.003922 0.457834 0.091878 1.000000 0.000000
33 0.003922 0.546335 0.110113 1.000000 0.000000
34 0.003922 0.574907 0.117256 1.000000 0.000000
35 0.003922 0.592157 0.121569 1.000000 0.000000
36 0.003922 0.592157 0.121569 1.000000 0.000000
37 0.003922 0.592157 0.121569 1.000000 0.000000
38 0.003922 0.592157 0.121569 1.000000 0.000000
39 0.003922 0.592157 0.121569 1.000000 0.000000
40 0.003922 0.592157 0.121569 1.000000 0.000000
41 0.003922 0.592157 0.121569 1.000000 0.000000
42 0.003922 0.592157 0.121569 1.000000 0.000000
43 0.003922 0.592157 0.121569 1.000000 0.000000
44 0.003922 0.592157 0.121569 1.000000 0.000000
45 0.003922 0.592157 0.121569 1.000000 0.000000
46 0.003922 0.592157 0.121569 1.000000 0.000000
47 0.003922 0.592157 0.121569 1.000000 0.000000
48 0.003922 0.592157 0.121569 1.000000 0.000000
49 0.003922 0.592157 0.121569 1.000000 0.000000
50 0.003922 0.592157 0.121569 1.000000 0.000000
51 0.003922 0.592157 0.121569 1.000000 0.000000
52 0.003922 0.592157 0.121569 1.000000 0.000000
53 0.004623 0.578134 0.118764 1.000000 0.000000
54 0.011669 0.437213 0.090580 1.000000 0.000000
55 0.019799 0.276776 0.058441 1.000000 0.000000
56 0.030902 0.180551 0.036236 1.000000 0.000000
57 0.041750 0.086531 0.014539 1.000000 0.000000
58 0.046236 0.055917 0.008666 1.000000 0.000000
59 0.049697 0.035152 0.005205 1.000000 0.000000
60 0.050980 0.007684 -0.000032 1.000000 0.000000
61 0.050980 -0.031292 -0.007827 1.000000 0.000000
62 0.047747 -0.076850 -0.016615 1.000000 0.000000
63 0.040527 -0.134607 -0.027445 1.000000 0.000000
64 0.035294 -0.176471 -0.035294 1.000000 0.000000
65 0.035294 -0.176471 -0.035294 1.000000 0.000000
66 0.035294 -0.176471 -0.035294 1.000000 0.000000
67 0.030835 -0.156406 -0.030835 1.000000 0.000000
68 0.023403 -0.122963 -0.023403 1.000000 0.000000
69 0.019608 -0.087175 -0.015866 1.000000 0.000000
70 0.019608 -0.048247 -0.008081 1.000000 0.000000
71 0.019608 -0.025737 -0.003922 1.000000 0.000000
72 0.019608 -0.022039 -0.003922 1.000000 0.000000
73 0.019608 -0.006105 -0.001466 1.000000 0.000000
74 0.019608 0.033829 0.005794 1.000000 0.000000
75 0.019608 0.075119 0.013715 1.000000 0.000000
76 0.019608 0.116461 0.023256 1.000000 0.000000
77 0.019608 0.153501 0.031803 1.000000 0.000000
78 0.019608 0.168628 0.035294 1.000000 0.000000
79 0.019608 0.168628 0.035294 1.000000 0.000000
80 0.019608 0.168628 0.035294 1.000000 0.000000
81 0.019608 0.168628 0.035294 1.000000 0.000000
82 0.019608 0.168628 0.035294 1.000000 0.000000
83 0.019608 0.168628 0.035294 1.000000 0.000000
84 0.019608 0.168628 0.035294 1.000000 0.000000
85 0.019608 0.168628 0.035294 1.000000 0.000000
86 0.019608 0.168628 0.035294 1.000000 0.000000
87 0.016330 0.198129 0.041850 1.000000 0.000000
88 0.013181 0.226473 0.048149 1.000000 0.000000
89 0.011765 0.269528 0.056492 1.000000 0.000000
90 0.011765 0.308989 0.063667 1.000000 0.000000
91 0.011765 0.330794 0.066667 1.000000 0.000000
92 0.011765 0.340486 0.066667 1.000000 0.000000
93 0.011765 0.350149 0.067232 1.000000 0.000000
94 0.011765 0.357444 0.070879 1.000000 0.000000
95 0.011765 0.365362 0.074611 1.000000 0.000000
96 0.011765 0.406242 0.080900 1.000000 0.000000
97 0.011765 0.442962 0.086549 1.000000 0.000000
98 0.011765 0.469278 0.091502 1.000000 0.000000
99 0.011765 0.476131 0.094928 1.000000 0.000000
100 0.011765 0.482353 0.098039 1.000000 0.000000
101 0.011765 0.482353 0.098039 1.000000 0.000000
102 0.011765 0.482353 0.098039 1.000000 0.000000
103 0.011765 0.482353 0.098039 1.000000 0.000000
104 0.011765 0.482353 0.098039 1.000000 0.000000
105 0.011765 0.482353 0.098039 1.000000 0.000000
106 0.011765 0.482353 0.098039 1.000000 0.000000
107 0.011765 0.460970 0.093927 1.000000 0.000000
108 0.011765 0.377419 0.077860 1.000000 0.000000
109 0.011765 0.290506 0.061146 1.000000 0.000000
110 0.017800 0.030978 0.007522 1.000000 0.000000
111 0.024597 -0.247670 -0.050246 1.000000 0.000000
112 0.027451 -0.376429 -0.075975 1.000000 0.000000
113 0.027451 -0.398298 -0.078709 1.000000 0.000000
114 0.027451 -0.421658 -0.081629 1.000000 0.000000
115 0.027451 -0.427451 -0.082353 1.000000 0.000000
116 0.027451 -0.427451 -0.082353 1.000000 0.000000
117 0.027451 -0.427451 -0.082353 1.000000 0.000000
118 0.027451 -0.427451 -0.082353 1.000000 0.000000
119 0.034393 -0.253911 -0.047645 1.000000 0.000000
120 0.048982 0.110811 0.025300 1.000000 0.000000
121 0.059845 0.368099 0.076553 1.000000 0.000000
122 0.063351 0.406663 0.083564 1.000000 0.000000
123 0.066667 0.443677 0.090196 1.000000 0.000000
124 0.066667 0.454719 0.090196 1.000000 0.000000
125 0.066667 0.465692 0.090196 1.000000 0.000000
126 0.066667 0.469954 0.093483 1.000000 0.000000
127 0.066667 0.473556 0.097085 1.000000 0.000000
128 0.066667 0.474510 0.098039 1.000000 0.000000
129 0.066667 0.474510 0.098039 1.000000 0.000000
130 0.066667 0.474510 0.098039 1.000000 0.000000
131 0.066667 0.474510 0.098039 1.000000 0.000000
132 0.066667 0.474510 0.098039 1.000000 0.000000
133 0.066667 0.474510 0.098039 1.000000 0.000000
134 0.066667 0.474510 0.098039 1.000000 0.000000
135 0.066667 0.474510 0.098039 1.000000 0.000000
136 0.066667 0.474510 0.098039 1.000000 0.000000
137 0.066667 0.474510 0.098039 1.000000 0.000000
138 0.066667 0.474510 0.098039 1.000000 0.000000
139 0.066667 0.474510 0.098039 1.000000 0.000000
140 0.066667 0.474510 0.098039 1.000000 0.000000
141 0.066667 0.474510 0.098039 1.000000 0.000000
142 0.066667 0.474510 0.098039 1.000000 0.000000

View File

@@ -0,0 +1,176 @@
Elevator, Roll, Yaw, Throttle, Flaps
0.003922, -0.145098, -0.027451, 1.000000, 0.000000
0.003922, -0.145098, -0.027451, 1.000000, 0.000000
0.001758, -0.106149, -0.020959, 1.000000, 0.000000
-0.001903, -0.040256, -0.009977, 1.000000, 0.000000
-0.003922, -0.002225, -0.002225, 1.000000, 0.000000
-0.003922, 0.001639, 0.001639, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.004704, 0.003922, 1.000000, 0.000000
-0.003922, 0.008182, 0.003922, 1.000000, 0.000000
-0.003922, 0.012505, 0.003922, 1.000000, 0.000000
-0.003922, 0.022975, 0.003922, 1.000000, 0.000000
-0.003922, 0.033004, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.000840, 0.035294, 0.003922, 1.000000, 0.000000
0.003379, 0.035294, 0.003922, 1.000000, 0.000000
0.051002, 0.031673, 0.003922, 1.000000, 0.000000
0.105875, 0.027452, 0.003922, 1.000000, 0.000000
0.109934, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.104427, 0.027451, 0.003922, 1.000000, 0.000000
0.077874, 0.027451, 0.003922, 1.000000, 0.000000
0.050050, 0.027451, 0.003922, 1.000000, 0.000000
0.017162, 0.027451, 0.003922, 1.000000, 0.000000
-0.016851, 0.027451, 0.003922, 1.000000, 0.000000
-0.023007, 0.027451, 0.003922, 1.000000, 0.000000
-0.026621, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.028397, 0.027451, 0.003922, 1.000000, 0.000000
-0.031739, 0.027451, 0.003922, 1.000000, 0.000000
-0.034961, 0.027451, 0.003922, 1.000000, 0.000000
-0.038293, 0.027451, 0.003922, 1.000000, 0.000000
-0.042012, 0.027451, 0.003922, 1.000000, 0.000000
-0.043137, 0.027451, 0.003922, 1.000000, 0.000000
-0.043137, 0.027451, 0.003922, 1.000000, 0.000000
-0.044327, 0.027451, 0.003922, 1.000000, 0.000000
-0.047871, 0.027451, 0.003922, 1.000000, 0.000000
-0.051675, 0.027451, 0.003922, 1.000000, 0.000000
-0.055168, 0.027451, 0.003922, 1.000000, 0.000000
-0.058754, 0.027451, 0.003922, 1.000000, 0.000000
-0.065101, 0.027451, 0.003922, 1.000000, 0.000000
-0.072274, 0.027451, 0.003922, 1.000000, 0.000000
-0.082223, 0.027451, 0.003922, 1.000000, 0.000000
-0.092332, 0.027451, 0.003922, 1.000000, 0.000000
-0.103807, 0.027451, 0.003922, 1.000000, 0.000000
-0.119170, 0.027451, 0.003922, 1.000000, 0.000000
-0.135084, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.127643, 0.024247, 0.003922, 1.000000, 0.000000
-0.116964, 0.020687, 0.003922, 1.000000, 0.000000
-0.101080, 0.019608, 0.003922, 1.000000, 0.000000
-0.084524, 0.019608, 0.003922, 1.000000, 0.000000
-0.073260, 0.019608, 0.003922, 1.000000, 0.000000
-0.069383, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.006472, 0.001732, 1.000000, 0.000000
-0.066667, -0.016772, -0.002142, 1.000000, 0.000000
-0.072984, -0.048510, -0.008133, 1.000000, 0.000000
-0.084076, -0.085483, -0.015528, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
1 Elevator Roll Yaw Throttle Flaps
2 0.003922 -0.145098 -0.027451 1.000000 0.000000
3 0.003922 -0.145098 -0.027451 1.000000 0.000000
4 0.001758 -0.106149 -0.020959 1.000000 0.000000
5 -0.001903 -0.040256 -0.009977 1.000000 0.000000
6 -0.003922 -0.002225 -0.002225 1.000000 0.000000
7 -0.003922 0.001639 0.001639 1.000000 0.000000
8 -0.003922 0.003922 0.003922 1.000000 0.000000
9 -0.003922 0.003922 0.003922 1.000000 0.000000
10 -0.003922 0.003922 0.003922 1.000000 0.000000
11 -0.003922 0.003922 0.003922 1.000000 0.000000
12 -0.003922 0.004704 0.003922 1.000000 0.000000
13 -0.003922 0.008182 0.003922 1.000000 0.000000
14 -0.003922 0.012505 0.003922 1.000000 0.000000
15 -0.003922 0.022975 0.003922 1.000000 0.000000
16 -0.003922 0.033004 0.003922 1.000000 0.000000
17 -0.003922 0.035294 0.003922 1.000000 0.000000
18 -0.003922 0.035294 0.003922 1.000000 0.000000
19 -0.003922 0.035294 0.003922 1.000000 0.000000
20 -0.003922 0.035294 0.003922 1.000000 0.000000
21 -0.003922 0.035294 0.003922 1.000000 0.000000
22 -0.003922 0.035294 0.003922 1.000000 0.000000
23 -0.003922 0.035294 0.003922 1.000000 0.000000
24 -0.003922 0.035294 0.003922 1.000000 0.000000
25 -0.003922 0.035294 0.003922 1.000000 0.000000
26 -0.003922 0.035294 0.003922 1.000000 0.000000
27 -0.003922 0.035294 0.003922 1.000000 0.000000
28 -0.003922 0.035294 0.003922 1.000000 0.000000
29 -0.003922 0.035294 0.003922 1.000000 0.000000
30 -0.003922 0.035294 0.003922 1.000000 0.000000
31 -0.003922 0.035294 0.003922 1.000000 0.000000
32 -0.003922 0.035294 0.003922 1.000000 0.000000
33 -0.003922 0.035294 0.003922 1.000000 0.000000
34 -0.003922 0.035294 0.003922 1.000000 0.000000
35 -0.000840 0.035294 0.003922 1.000000 0.000000
36 0.003379 0.035294 0.003922 1.000000 0.000000
37 0.051002 0.031673 0.003922 1.000000 0.000000
38 0.105875 0.027452 0.003922 1.000000 0.000000
39 0.109934 0.027451 0.003922 1.000000 0.000000
40 0.113726 0.027451 0.003922 1.000000 0.000000
41 0.113726 0.027451 0.003922 1.000000 0.000000
42 0.113726 0.027451 0.003922 1.000000 0.000000
43 0.113726 0.027451 0.003922 1.000000 0.000000
44 0.113726 0.027451 0.003922 1.000000 0.000000
45 0.113726 0.027451 0.003922 1.000000 0.000000
46 0.113726 0.027451 0.003922 1.000000 0.000000
47 0.113726 0.027451 0.003922 1.000000 0.000000
48 0.113726 0.027451 0.003922 1.000000 0.000000
49 0.113726 0.027451 0.003922 1.000000 0.000000
50 0.113726 0.027451 0.003922 1.000000 0.000000
51 0.113726 0.027451 0.003922 1.000000 0.000000
52 0.113726 0.027451 0.003922 1.000000 0.000000
53 0.113726 0.027451 0.003922 1.000000 0.000000
54 0.113726 0.027451 0.003922 1.000000 0.000000
55 0.113726 0.027451 0.003922 1.000000 0.000000
56 0.113726 0.027451 0.003922 1.000000 0.000000
57 0.113726 0.027451 0.003922 1.000000 0.000000
58 0.113726 0.027451 0.003922 1.000000 0.000000
59 0.113726 0.027451 0.003922 1.000000 0.000000
60 0.113726 0.027451 0.003922 1.000000 0.000000
61 0.113726 0.027451 0.003922 1.000000 0.000000
62 0.113726 0.027451 0.003922 1.000000 0.000000
63 0.113726 0.027451 0.003922 1.000000 0.000000
64 0.113726 0.027451 0.003922 1.000000 0.000000
65 0.113726 0.027451 0.003922 1.000000 0.000000
66 0.113726 0.027451 0.003922 1.000000 0.000000
67 0.113726 0.027451 0.003922 1.000000 0.000000
68 0.113726 0.027451 0.003922 1.000000 0.000000
69 0.113726 0.027451 0.003922 1.000000 0.000000
70 0.113726 0.027451 0.003922 1.000000 0.000000
71 0.113726 0.027451 0.003922 1.000000 0.000000
72 0.113726 0.027451 0.003922 1.000000 0.000000
73 0.113726 0.027451 0.003922 1.000000 0.000000
74 0.113726 0.027451 0.003922 1.000000 0.000000
75 0.113726 0.027451 0.003922 1.000000 0.000000
76 0.113726 0.027451 0.003922 1.000000 0.000000
77 0.113726 0.027451 0.003922 1.000000 0.000000
78 0.113726 0.027451 0.003922 1.000000 0.000000
79 0.113726 0.027451 0.003922 1.000000 0.000000
80 0.113726 0.027451 0.003922 1.000000 0.000000
81 0.113726 0.027451 0.003922 1.000000 0.000000
82 0.113726 0.027451 0.003922 1.000000 0.000000
83 0.104427 0.027451 0.003922 1.000000 0.000000
84 0.077874 0.027451 0.003922 1.000000 0.000000
85 0.050050 0.027451 0.003922 1.000000 0.000000
86 0.017162 0.027451 0.003922 1.000000 0.000000
87 -0.016851 0.027451 0.003922 1.000000 0.000000
88 -0.023007 0.027451 0.003922 1.000000 0.000000
89 -0.026621 0.027451 0.003922 1.000000 0.000000
90 -0.027451 0.027451 0.003922 1.000000 0.000000
91 -0.027451 0.027451 0.003922 1.000000 0.000000
92 -0.027451 0.027451 0.003922 1.000000 0.000000
93 -0.027451 0.027451 0.003922 1.000000 0.000000
94 -0.027451 0.027451 0.003922 1.000000 0.000000
95 -0.027451 0.027451 0.003922 1.000000 0.000000
96 -0.027451 0.027451 0.003922 1.000000 0.000000
97 -0.027451 0.027451 0.003922 1.000000 0.000000
98 -0.027451 0.027451 0.003922 1.000000 0.000000
99 -0.028397 0.027451 0.003922 1.000000 0.000000
100 -0.031739 0.027451 0.003922 1.000000 0.000000
101 -0.034961 0.027451 0.003922 1.000000 0.000000
102 -0.038293 0.027451 0.003922 1.000000 0.000000
103 -0.042012 0.027451 0.003922 1.000000 0.000000
104 -0.043137 0.027451 0.003922 1.000000 0.000000
105 -0.043137 0.027451 0.003922 1.000000 0.000000
106 -0.044327 0.027451 0.003922 1.000000 0.000000
107 -0.047871 0.027451 0.003922 1.000000 0.000000
108 -0.051675 0.027451 0.003922 1.000000 0.000000
109 -0.055168 0.027451 0.003922 1.000000 0.000000
110 -0.058754 0.027451 0.003922 1.000000 0.000000
111 -0.065101 0.027451 0.003922 1.000000 0.000000
112 -0.072274 0.027451 0.003922 1.000000 0.000000
113 -0.082223 0.027451 0.003922 1.000000 0.000000
114 -0.092332 0.027451 0.003922 1.000000 0.000000
115 -0.103807 0.027451 0.003922 1.000000 0.000000
116 -0.119170 0.027451 0.003922 1.000000 0.000000
117 -0.135084 0.027451 0.003922 1.000000 0.000000
118 -0.137255 0.027451 0.003922 1.000000 0.000000
119 -0.137255 0.027451 0.003922 1.000000 0.000000
120 -0.137255 0.027451 0.003922 1.000000 0.000000
121 -0.137255 0.027451 0.003922 1.000000 0.000000
122 -0.137255 0.027451 0.003922 1.000000 0.000000
123 -0.137255 0.027451 0.003922 1.000000 0.000000
124 -0.137255 0.027451 0.003922 1.000000 0.000000
125 -0.137255 0.027451 0.003922 1.000000 0.000000
126 -0.137255 0.027451 0.003922 1.000000 0.000000
127 -0.137255 0.027451 0.003922 1.000000 0.000000
128 -0.137255 0.027451 0.003922 1.000000 0.000000
129 -0.137255 0.027451 0.003922 1.000000 0.000000
130 -0.137255 0.027451 0.003922 1.000000 0.000000
131 -0.137255 0.027451 0.003922 1.000000 0.000000
132 -0.127643 0.024247 0.003922 1.000000 0.000000
133 -0.116964 0.020687 0.003922 1.000000 0.000000
134 -0.101080 0.019608 0.003922 1.000000 0.000000
135 -0.084524 0.019608 0.003922 1.000000 0.000000
136 -0.073260 0.019608 0.003922 1.000000 0.000000
137 -0.069383 0.019608 0.003922 1.000000 0.000000
138 -0.066667 0.019608 0.003922 1.000000 0.000000
139 -0.066667 0.019608 0.003922 1.000000 0.000000
140 -0.066667 0.019608 0.003922 1.000000 0.000000
141 -0.066667 0.019608 0.003922 1.000000 0.000000
142 -0.066667 0.019608 0.003922 1.000000 0.000000
143 -0.066667 0.019608 0.003922 1.000000 0.000000
144 -0.066667 0.019608 0.003922 1.000000 0.000000
145 -0.066667 0.006472 0.001732 1.000000 0.000000
146 -0.066667 -0.016772 -0.002142 1.000000 0.000000
147 -0.072984 -0.048510 -0.008133 1.000000 0.000000
148 -0.084076 -0.085483 -0.015528 1.000000 0.000000
149 -0.090196 -0.105882 -0.019608 1.000000 0.000000
150 -0.090196 -0.105882 -0.019608 1.000000 0.000000
151 -0.090196 -0.105882 -0.019608 1.000000 0.000000
152 -0.090196 -0.105882 -0.019608 1.000000 0.000000
153 -0.090196 -0.105882 -0.019608 1.000000 0.000000
154 -0.090196 -0.105882 -0.019608 1.000000 0.000000
155 -0.090196 -0.105882 -0.019608 1.000000 0.000000
156 -0.090196 -0.105882 -0.019608 1.000000 0.000000
157 -0.090196 -0.105882 -0.019608 1.000000 0.000000
158 -0.090196 -0.105882 -0.019608 1.000000 0.000000
159 -0.090196 -0.105882 -0.019608 1.000000 0.000000
160 -0.090196 -0.105882 -0.019608 1.000000 0.000000
161 -0.090196 -0.105882 -0.019608 1.000000 0.000000
162 -0.090196 -0.105882 -0.019608 1.000000 0.000000
163 -0.090196 -0.105882 -0.019608 1.000000 0.000000
164 -0.090196 -0.105882 -0.019608 1.000000 0.000000
165 -0.090196 -0.105882 -0.019608 1.000000 0.000000
166 -0.090196 -0.105882 -0.019608 1.000000 0.000000
167 -0.090196 -0.105882 -0.019608 1.000000 0.000000
168 -0.090196 -0.105882 -0.019608 1.000000 0.000000
169 -0.090196 -0.105882 -0.019608 1.000000 0.000000
170 -0.090196 -0.105882 -0.019608 1.000000 0.000000
171 -0.090196 -0.105882 -0.019608 1.000000 0.000000
172 -0.090196 -0.105882 -0.019608 1.000000 0.000000
173 -0.090196 -0.105882 -0.019608 1.000000 0.000000
174 -0.090196 -0.105882 -0.019608 1.000000 0.000000
175 -0.090196 -0.105882 -0.019608 1.000000 0.000000
176 -0.090196 -0.105882 -0.019608 1.000000 0.000000

View File

@@ -0,0 +1,50 @@
import java.io.IOException;
import java.net.SocketException;
import CognitiveModel.ModelFiles.*;
import Visualizer.visualizer;
public abstract class testprocess {
Model m = new Model();
public testprocess(Model inputM, XPlaneConnect xpc) {
m = inputM;
m.establishConnection(xpc);
}
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

@@ -0,0 +1,36 @@
import java.io.IOException;
import java.net.SocketException;
import CognitiveModel.ModelFiles.*;
import Visualizer.visualizer;
public class testprocess1 extends testprocess {
public testprocess1(Model inputM, XPlaneConnect xpc) {
super(inputM, xpc);
}
@Override
public void innerProcess(visualizer vis1) {
float[] array = m.next();
double r = Math.random();
if (m.getModelQueueLength() < 5) {
if (r > 0.5) {
// m.createAction(ActionType.DELAY, null, 200, null);
// m.createAction(ActionType.DELAY, null, 200, null);
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
} else {
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
}
}
// m.printModelQueue();
m.logData();
try {
vis1.updateVisualizer(m);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,12 @@
import CognitiveModel.ModelFiles.XPlaneConnect;
import Visualizer.visualizer;
import CognitiveModel.ModelFiles.*;
public class testprocess2 extends testprocess {
public testprocess2(Model m, XPlaneConnect xpc){
super(m, xpc);
}
}

View File

@@ -20,11 +20,6 @@ public class Main {
// s2.add(t3);
// s2.add(t4);
// testprocess2 tp2 = new testprocess2(m, null);
// tp2.runProcess();

View File

@@ -1,7 +1,14 @@
Project Log:
TODO: Backfill from Google doc project log; create automated prompt.
2024-12-17: {
}
{ title: "Title Test"
date: "Date Test"
entry:"Well Well Well, Loooky what we have here. I need some lorem
Ipsum
Up
In
Here
BOOYAHHHHHHHHH"
},
{ title: "dasd"
date: "asdasd"
entry:"Anotha one"
},

View File

@@ -0,0 +1,9 @@
{ title: "Title Test",
date: "Date Test",
entry:"Well Well Well, Loooky what we have here. I need some lorem
Ipsum
Up
In
Here
BOOYAHHHHHHHHH",
},

View File

@@ -5,6 +5,8 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import CognitiveModel.ModelFiles.*;
@@ -28,6 +30,10 @@ public class visualizer extends Screen {
JLabel four = new JLabel();
Timer t = new Timer(1, null);
Model m;
FileWriter fw;
BufferedWriter bw;
public visualizer(Model m) {
super(new BorderLayout());
this.m = m;
@@ -164,11 +170,15 @@ public class visualizer extends Screen {
b1.setText("Data Log Disabled");
}
}
};
b1.addActionListener(press);
JButton b2 = new JButton("button 2");
JButton b2 = new JButton("Make Note");
b2.addActionListener(e-> {
makeNote();
});
tool.setBackground(Color.red);
tool.setOrientation(1);
tool.add(b1);
@@ -287,6 +297,59 @@ public class visualizer extends Screen {
public Timer exportTimer() {
return t;
}
public void makeNote() {
JFrame noteFrame = new JFrame();
JPanel noteScreen = new JPanel();
noteScreen.setLayout(new GridLayout(4,1));
JTextField title = new JTextField();
JTextField date = new JTextField();
JTextArea entry = new JTextArea();
JButton saveNote = new JButton();
try {
fw = new FileWriter("README.txt", true);
bw = new BufferedWriter(fw);
noteFrame.setPreferredSize(new Dimension(500,500));
noteScreen.add(title);
noteScreen.add(date);
noteScreen.add(entry);
noteScreen.add(saveNote);
noteFrame.add(noteScreen);
noteFrame.pack();
noteFrame.setVisible(true);
saveNote.addActionListener(e -> {
try {
String newEntry = String.format("\n{ title: \"%s\"\ndate: \"%s\"\n entry:\"%s\"\n},",title.getText(),date.getText(),entry.getText());
bw.write(newEntry);
bw.flush();
bw.close();
} catch (IOException e1) {
JOptionPane error = new JOptionPane("Error saving");
}
});
} catch(IOException e) {
e.printStackTrace();
}
noteFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}

View File

@@ -0,0 +1,142 @@
Elevator, Roll, Yaw, Throttle, Flaps
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.027451, 0.615686, 0.121569, 1.000000, 0.000000
-0.025160, 0.615686, 0.121569, 1.000000, 0.000000
-0.018032, 0.615686, 0.121569, 1.000000, 0.000000
-0.008946, 0.558105, 0.110294, 1.000000, 0.000000
0.016080, 0.046859, 0.010190, 1.000000, 0.000000
0.041168, -0.465645, -0.090160, 1.000000, 0.000000
0.072984, -0.714807, -0.141151, 1.000000, 0.000000
0.105265, -0.940778, -0.187779, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.113726, -1.000000, -0.200000, 1.000000, 0.000000
0.111637, -1.000000, -0.200000, 1.000000, 0.000000
0.107753, -1.000000, -0.200000, 1.000000, 0.000000
0.090097, -0.804658, -0.160537, 1.000000, 0.000000
0.059241, -0.422819, -0.083398, 1.000000, 0.000000
0.033948, -0.164720, -0.032111, 1.000000, 0.000000
0.015275, -0.045211, -0.009702, 1.000000, 0.000000
0.003922, 0.032740, 0.005244, 1.000000, 0.000000
0.003922, 0.046948, 0.008796, 1.000000, 0.000000
0.003922, 0.061786, 0.012259, 1.000000, 0.000000
0.003922, 0.083051, 0.015803, 1.000000, 0.000000
0.003922, 0.104358, 0.019354, 1.000000, 0.000000
0.003922, 0.125915, 0.022947, 1.000000, 0.000000
0.003922, 0.148159, 0.026654, 1.000000, 0.000000
0.003922, 0.158683, 0.030322, 1.000000, 0.000000
0.003922, 0.166116, 0.034039, 1.000000, 0.000000
0.003922, 0.283275, 0.057725, 1.000000, 0.000000
0.003922, 0.457834, 0.091878, 1.000000, 0.000000
0.003922, 0.546335, 0.110113, 1.000000, 0.000000
0.003922, 0.574907, 0.117256, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.003922, 0.592157, 0.121569, 1.000000, 0.000000
0.004623, 0.578134, 0.118764, 1.000000, 0.000000
0.011669, 0.437213, 0.090580, 1.000000, 0.000000
0.019799, 0.276776, 0.058441, 1.000000, 0.000000
0.030902, 0.180551, 0.036236, 1.000000, 0.000000
0.041750, 0.086531, 0.014539, 1.000000, 0.000000
0.046236, 0.055917, 0.008666, 1.000000, 0.000000
0.049697, 0.035152, 0.005205, 1.000000, 0.000000
0.050980, 0.007684, -0.000032, 1.000000, 0.000000
0.050980, -0.031292, -0.007827, 1.000000, 0.000000
0.047747, -0.076850, -0.016615, 1.000000, 0.000000
0.040527, -0.134607, -0.027445, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.035294, -0.176471, -0.035294, 1.000000, 0.000000
0.030835, -0.156406, -0.030835, 1.000000, 0.000000
0.023403, -0.122963, -0.023403, 1.000000, 0.000000
0.019608, -0.087175, -0.015866, 1.000000, 0.000000
0.019608, -0.048247, -0.008081, 1.000000, 0.000000
0.019608, -0.025737, -0.003922, 1.000000, 0.000000
0.019608, -0.022039, -0.003922, 1.000000, 0.000000
0.019608, -0.006105, -0.001466, 1.000000, 0.000000
0.019608, 0.033829, 0.005794, 1.000000, 0.000000
0.019608, 0.075119, 0.013715, 1.000000, 0.000000
0.019608, 0.116461, 0.023256, 1.000000, 0.000000
0.019608, 0.153501, 0.031803, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.019608, 0.168628, 0.035294, 1.000000, 0.000000
0.016330, 0.198129, 0.041850, 1.000000, 0.000000
0.013181, 0.226473, 0.048149, 1.000000, 0.000000
0.011765, 0.269528, 0.056492, 1.000000, 0.000000
0.011765, 0.308989, 0.063667, 1.000000, 0.000000
0.011765, 0.330794, 0.066667, 1.000000, 0.000000
0.011765, 0.340486, 0.066667, 1.000000, 0.000000
0.011765, 0.350149, 0.067232, 1.000000, 0.000000
0.011765, 0.357444, 0.070879, 1.000000, 0.000000
0.011765, 0.365362, 0.074611, 1.000000, 0.000000
0.011765, 0.406242, 0.080900, 1.000000, 0.000000
0.011765, 0.442962, 0.086549, 1.000000, 0.000000
0.011765, 0.469278, 0.091502, 1.000000, 0.000000
0.011765, 0.476131, 0.094928, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.482353, 0.098039, 1.000000, 0.000000
0.011765, 0.460970, 0.093927, 1.000000, 0.000000
0.011765, 0.377419, 0.077860, 1.000000, 0.000000
0.011765, 0.290506, 0.061146, 1.000000, 0.000000
0.017800, 0.030978, 0.007522, 1.000000, 0.000000
0.024597, -0.247670, -0.050246, 1.000000, 0.000000
0.027451, -0.376429, -0.075975, 1.000000, 0.000000
0.027451, -0.398298, -0.078709, 1.000000, 0.000000
0.027451, -0.421658, -0.081629, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.027451, -0.427451, -0.082353, 1.000000, 0.000000
0.034393, -0.253911, -0.047645, 1.000000, 0.000000
0.048982, 0.110811, 0.025300, 1.000000, 0.000000
0.059845, 0.368099, 0.076553, 1.000000, 0.000000
0.063351, 0.406663, 0.083564, 1.000000, 0.000000
0.066667, 0.443677, 0.090196, 1.000000, 0.000000
0.066667, 0.454719, 0.090196, 1.000000, 0.000000
0.066667, 0.465692, 0.090196, 1.000000, 0.000000
0.066667, 0.469954, 0.093483, 1.000000, 0.000000
0.066667, 0.473556, 0.097085, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
0.066667, 0.474510, 0.098039, 1.000000, 0.000000
1 Elevator Roll Yaw Throttle Flaps
2 -0.027451 0.615686 0.121569 1.000000 0.000000
3 -0.027451 0.615686 0.121569 1.000000 0.000000
4 -0.027451 0.615686 0.121569 1.000000 0.000000
5 -0.025160 0.615686 0.121569 1.000000 0.000000
6 -0.018032 0.615686 0.121569 1.000000 0.000000
7 -0.008946 0.558105 0.110294 1.000000 0.000000
8 0.016080 0.046859 0.010190 1.000000 0.000000
9 0.041168 -0.465645 -0.090160 1.000000 0.000000
10 0.072984 -0.714807 -0.141151 1.000000 0.000000
11 0.105265 -0.940778 -0.187779 1.000000 0.000000
12 0.113726 -1.000000 -0.200000 1.000000 0.000000
13 0.113726 -1.000000 -0.200000 1.000000 0.000000
14 0.113726 -1.000000 -0.200000 1.000000 0.000000
15 0.113726 -1.000000 -0.200000 1.000000 0.000000
16 0.111637 -1.000000 -0.200000 1.000000 0.000000
17 0.107753 -1.000000 -0.200000 1.000000 0.000000
18 0.090097 -0.804658 -0.160537 1.000000 0.000000
19 0.059241 -0.422819 -0.083398 1.000000 0.000000
20 0.033948 -0.164720 -0.032111 1.000000 0.000000
21 0.015275 -0.045211 -0.009702 1.000000 0.000000
22 0.003922 0.032740 0.005244 1.000000 0.000000
23 0.003922 0.046948 0.008796 1.000000 0.000000
24 0.003922 0.061786 0.012259 1.000000 0.000000
25 0.003922 0.083051 0.015803 1.000000 0.000000
26 0.003922 0.104358 0.019354 1.000000 0.000000
27 0.003922 0.125915 0.022947 1.000000 0.000000
28 0.003922 0.148159 0.026654 1.000000 0.000000
29 0.003922 0.158683 0.030322 1.000000 0.000000
30 0.003922 0.166116 0.034039 1.000000 0.000000
31 0.003922 0.283275 0.057725 1.000000 0.000000
32 0.003922 0.457834 0.091878 1.000000 0.000000
33 0.003922 0.546335 0.110113 1.000000 0.000000
34 0.003922 0.574907 0.117256 1.000000 0.000000
35 0.003922 0.592157 0.121569 1.000000 0.000000
36 0.003922 0.592157 0.121569 1.000000 0.000000
37 0.003922 0.592157 0.121569 1.000000 0.000000
38 0.003922 0.592157 0.121569 1.000000 0.000000
39 0.003922 0.592157 0.121569 1.000000 0.000000
40 0.003922 0.592157 0.121569 1.000000 0.000000
41 0.003922 0.592157 0.121569 1.000000 0.000000
42 0.003922 0.592157 0.121569 1.000000 0.000000
43 0.003922 0.592157 0.121569 1.000000 0.000000
44 0.003922 0.592157 0.121569 1.000000 0.000000
45 0.003922 0.592157 0.121569 1.000000 0.000000
46 0.003922 0.592157 0.121569 1.000000 0.000000
47 0.003922 0.592157 0.121569 1.000000 0.000000
48 0.003922 0.592157 0.121569 1.000000 0.000000
49 0.003922 0.592157 0.121569 1.000000 0.000000
50 0.003922 0.592157 0.121569 1.000000 0.000000
51 0.003922 0.592157 0.121569 1.000000 0.000000
52 0.003922 0.592157 0.121569 1.000000 0.000000
53 0.004623 0.578134 0.118764 1.000000 0.000000
54 0.011669 0.437213 0.090580 1.000000 0.000000
55 0.019799 0.276776 0.058441 1.000000 0.000000
56 0.030902 0.180551 0.036236 1.000000 0.000000
57 0.041750 0.086531 0.014539 1.000000 0.000000
58 0.046236 0.055917 0.008666 1.000000 0.000000
59 0.049697 0.035152 0.005205 1.000000 0.000000
60 0.050980 0.007684 -0.000032 1.000000 0.000000
61 0.050980 -0.031292 -0.007827 1.000000 0.000000
62 0.047747 -0.076850 -0.016615 1.000000 0.000000
63 0.040527 -0.134607 -0.027445 1.000000 0.000000
64 0.035294 -0.176471 -0.035294 1.000000 0.000000
65 0.035294 -0.176471 -0.035294 1.000000 0.000000
66 0.035294 -0.176471 -0.035294 1.000000 0.000000
67 0.030835 -0.156406 -0.030835 1.000000 0.000000
68 0.023403 -0.122963 -0.023403 1.000000 0.000000
69 0.019608 -0.087175 -0.015866 1.000000 0.000000
70 0.019608 -0.048247 -0.008081 1.000000 0.000000
71 0.019608 -0.025737 -0.003922 1.000000 0.000000
72 0.019608 -0.022039 -0.003922 1.000000 0.000000
73 0.019608 -0.006105 -0.001466 1.000000 0.000000
74 0.019608 0.033829 0.005794 1.000000 0.000000
75 0.019608 0.075119 0.013715 1.000000 0.000000
76 0.019608 0.116461 0.023256 1.000000 0.000000
77 0.019608 0.153501 0.031803 1.000000 0.000000
78 0.019608 0.168628 0.035294 1.000000 0.000000
79 0.019608 0.168628 0.035294 1.000000 0.000000
80 0.019608 0.168628 0.035294 1.000000 0.000000
81 0.019608 0.168628 0.035294 1.000000 0.000000
82 0.019608 0.168628 0.035294 1.000000 0.000000
83 0.019608 0.168628 0.035294 1.000000 0.000000
84 0.019608 0.168628 0.035294 1.000000 0.000000
85 0.019608 0.168628 0.035294 1.000000 0.000000
86 0.019608 0.168628 0.035294 1.000000 0.000000
87 0.016330 0.198129 0.041850 1.000000 0.000000
88 0.013181 0.226473 0.048149 1.000000 0.000000
89 0.011765 0.269528 0.056492 1.000000 0.000000
90 0.011765 0.308989 0.063667 1.000000 0.000000
91 0.011765 0.330794 0.066667 1.000000 0.000000
92 0.011765 0.340486 0.066667 1.000000 0.000000
93 0.011765 0.350149 0.067232 1.000000 0.000000
94 0.011765 0.357444 0.070879 1.000000 0.000000
95 0.011765 0.365362 0.074611 1.000000 0.000000
96 0.011765 0.406242 0.080900 1.000000 0.000000
97 0.011765 0.442962 0.086549 1.000000 0.000000
98 0.011765 0.469278 0.091502 1.000000 0.000000
99 0.011765 0.476131 0.094928 1.000000 0.000000
100 0.011765 0.482353 0.098039 1.000000 0.000000
101 0.011765 0.482353 0.098039 1.000000 0.000000
102 0.011765 0.482353 0.098039 1.000000 0.000000
103 0.011765 0.482353 0.098039 1.000000 0.000000
104 0.011765 0.482353 0.098039 1.000000 0.000000
105 0.011765 0.482353 0.098039 1.000000 0.000000
106 0.011765 0.482353 0.098039 1.000000 0.000000
107 0.011765 0.460970 0.093927 1.000000 0.000000
108 0.011765 0.377419 0.077860 1.000000 0.000000
109 0.011765 0.290506 0.061146 1.000000 0.000000
110 0.017800 0.030978 0.007522 1.000000 0.000000
111 0.024597 -0.247670 -0.050246 1.000000 0.000000
112 0.027451 -0.376429 -0.075975 1.000000 0.000000
113 0.027451 -0.398298 -0.078709 1.000000 0.000000
114 0.027451 -0.421658 -0.081629 1.000000 0.000000
115 0.027451 -0.427451 -0.082353 1.000000 0.000000
116 0.027451 -0.427451 -0.082353 1.000000 0.000000
117 0.027451 -0.427451 -0.082353 1.000000 0.000000
118 0.027451 -0.427451 -0.082353 1.000000 0.000000
119 0.034393 -0.253911 -0.047645 1.000000 0.000000
120 0.048982 0.110811 0.025300 1.000000 0.000000
121 0.059845 0.368099 0.076553 1.000000 0.000000
122 0.063351 0.406663 0.083564 1.000000 0.000000
123 0.066667 0.443677 0.090196 1.000000 0.000000
124 0.066667 0.454719 0.090196 1.000000 0.000000
125 0.066667 0.465692 0.090196 1.000000 0.000000
126 0.066667 0.469954 0.093483 1.000000 0.000000
127 0.066667 0.473556 0.097085 1.000000 0.000000
128 0.066667 0.474510 0.098039 1.000000 0.000000
129 0.066667 0.474510 0.098039 1.000000 0.000000
130 0.066667 0.474510 0.098039 1.000000 0.000000
131 0.066667 0.474510 0.098039 1.000000 0.000000
132 0.066667 0.474510 0.098039 1.000000 0.000000
133 0.066667 0.474510 0.098039 1.000000 0.000000
134 0.066667 0.474510 0.098039 1.000000 0.000000
135 0.066667 0.474510 0.098039 1.000000 0.000000
136 0.066667 0.474510 0.098039 1.000000 0.000000
137 0.066667 0.474510 0.098039 1.000000 0.000000
138 0.066667 0.474510 0.098039 1.000000 0.000000
139 0.066667 0.474510 0.098039 1.000000 0.000000
140 0.066667 0.474510 0.098039 1.000000 0.000000
141 0.066667 0.474510 0.098039 1.000000 0.000000
142 0.066667 0.474510 0.098039 1.000000 0.000000

View File

@@ -0,0 +1,176 @@
Elevator, Roll, Yaw, Throttle, Flaps
0.003922, -0.145098, -0.027451, 1.000000, 0.000000
0.003922, -0.145098, -0.027451, 1.000000, 0.000000
0.001758, -0.106149, -0.020959, 1.000000, 0.000000
-0.001903, -0.040256, -0.009977, 1.000000, 0.000000
-0.003922, -0.002225, -0.002225, 1.000000, 0.000000
-0.003922, 0.001639, 0.001639, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.003922, 0.003922, 1.000000, 0.000000
-0.003922, 0.004704, 0.003922, 1.000000, 0.000000
-0.003922, 0.008182, 0.003922, 1.000000, 0.000000
-0.003922, 0.012505, 0.003922, 1.000000, 0.000000
-0.003922, 0.022975, 0.003922, 1.000000, 0.000000
-0.003922, 0.033004, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.003922, 0.035294, 0.003922, 1.000000, 0.000000
-0.000840, 0.035294, 0.003922, 1.000000, 0.000000
0.003379, 0.035294, 0.003922, 1.000000, 0.000000
0.051002, 0.031673, 0.003922, 1.000000, 0.000000
0.105875, 0.027452, 0.003922, 1.000000, 0.000000
0.109934, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.113726, 0.027451, 0.003922, 1.000000, 0.000000
0.104427, 0.027451, 0.003922, 1.000000, 0.000000
0.077874, 0.027451, 0.003922, 1.000000, 0.000000
0.050050, 0.027451, 0.003922, 1.000000, 0.000000
0.017162, 0.027451, 0.003922, 1.000000, 0.000000
-0.016851, 0.027451, 0.003922, 1.000000, 0.000000
-0.023007, 0.027451, 0.003922, 1.000000, 0.000000
-0.026621, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.027451, 0.027451, 0.003922, 1.000000, 0.000000
-0.028397, 0.027451, 0.003922, 1.000000, 0.000000
-0.031739, 0.027451, 0.003922, 1.000000, 0.000000
-0.034961, 0.027451, 0.003922, 1.000000, 0.000000
-0.038293, 0.027451, 0.003922, 1.000000, 0.000000
-0.042012, 0.027451, 0.003922, 1.000000, 0.000000
-0.043137, 0.027451, 0.003922, 1.000000, 0.000000
-0.043137, 0.027451, 0.003922, 1.000000, 0.000000
-0.044327, 0.027451, 0.003922, 1.000000, 0.000000
-0.047871, 0.027451, 0.003922, 1.000000, 0.000000
-0.051675, 0.027451, 0.003922, 1.000000, 0.000000
-0.055168, 0.027451, 0.003922, 1.000000, 0.000000
-0.058754, 0.027451, 0.003922, 1.000000, 0.000000
-0.065101, 0.027451, 0.003922, 1.000000, 0.000000
-0.072274, 0.027451, 0.003922, 1.000000, 0.000000
-0.082223, 0.027451, 0.003922, 1.000000, 0.000000
-0.092332, 0.027451, 0.003922, 1.000000, 0.000000
-0.103807, 0.027451, 0.003922, 1.000000, 0.000000
-0.119170, 0.027451, 0.003922, 1.000000, 0.000000
-0.135084, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.137255, 0.027451, 0.003922, 1.000000, 0.000000
-0.127643, 0.024247, 0.003922, 1.000000, 0.000000
-0.116964, 0.020687, 0.003922, 1.000000, 0.000000
-0.101080, 0.019608, 0.003922, 1.000000, 0.000000
-0.084524, 0.019608, 0.003922, 1.000000, 0.000000
-0.073260, 0.019608, 0.003922, 1.000000, 0.000000
-0.069383, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.019608, 0.003922, 1.000000, 0.000000
-0.066667, 0.006472, 0.001732, 1.000000, 0.000000
-0.066667, -0.016772, -0.002142, 1.000000, 0.000000
-0.072984, -0.048510, -0.008133, 1.000000, 0.000000
-0.084076, -0.085483, -0.015528, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
-0.090196, -0.105882, -0.019608, 1.000000, 0.000000
1 Elevator Roll Yaw Throttle Flaps
2 0.003922 -0.145098 -0.027451 1.000000 0.000000
3 0.003922 -0.145098 -0.027451 1.000000 0.000000
4 0.001758 -0.106149 -0.020959 1.000000 0.000000
5 -0.001903 -0.040256 -0.009977 1.000000 0.000000
6 -0.003922 -0.002225 -0.002225 1.000000 0.000000
7 -0.003922 0.001639 0.001639 1.000000 0.000000
8 -0.003922 0.003922 0.003922 1.000000 0.000000
9 -0.003922 0.003922 0.003922 1.000000 0.000000
10 -0.003922 0.003922 0.003922 1.000000 0.000000
11 -0.003922 0.003922 0.003922 1.000000 0.000000
12 -0.003922 0.004704 0.003922 1.000000 0.000000
13 -0.003922 0.008182 0.003922 1.000000 0.000000
14 -0.003922 0.012505 0.003922 1.000000 0.000000
15 -0.003922 0.022975 0.003922 1.000000 0.000000
16 -0.003922 0.033004 0.003922 1.000000 0.000000
17 -0.003922 0.035294 0.003922 1.000000 0.000000
18 -0.003922 0.035294 0.003922 1.000000 0.000000
19 -0.003922 0.035294 0.003922 1.000000 0.000000
20 -0.003922 0.035294 0.003922 1.000000 0.000000
21 -0.003922 0.035294 0.003922 1.000000 0.000000
22 -0.003922 0.035294 0.003922 1.000000 0.000000
23 -0.003922 0.035294 0.003922 1.000000 0.000000
24 -0.003922 0.035294 0.003922 1.000000 0.000000
25 -0.003922 0.035294 0.003922 1.000000 0.000000
26 -0.003922 0.035294 0.003922 1.000000 0.000000
27 -0.003922 0.035294 0.003922 1.000000 0.000000
28 -0.003922 0.035294 0.003922 1.000000 0.000000
29 -0.003922 0.035294 0.003922 1.000000 0.000000
30 -0.003922 0.035294 0.003922 1.000000 0.000000
31 -0.003922 0.035294 0.003922 1.000000 0.000000
32 -0.003922 0.035294 0.003922 1.000000 0.000000
33 -0.003922 0.035294 0.003922 1.000000 0.000000
34 -0.003922 0.035294 0.003922 1.000000 0.000000
35 -0.000840 0.035294 0.003922 1.000000 0.000000
36 0.003379 0.035294 0.003922 1.000000 0.000000
37 0.051002 0.031673 0.003922 1.000000 0.000000
38 0.105875 0.027452 0.003922 1.000000 0.000000
39 0.109934 0.027451 0.003922 1.000000 0.000000
40 0.113726 0.027451 0.003922 1.000000 0.000000
41 0.113726 0.027451 0.003922 1.000000 0.000000
42 0.113726 0.027451 0.003922 1.000000 0.000000
43 0.113726 0.027451 0.003922 1.000000 0.000000
44 0.113726 0.027451 0.003922 1.000000 0.000000
45 0.113726 0.027451 0.003922 1.000000 0.000000
46 0.113726 0.027451 0.003922 1.000000 0.000000
47 0.113726 0.027451 0.003922 1.000000 0.000000
48 0.113726 0.027451 0.003922 1.000000 0.000000
49 0.113726 0.027451 0.003922 1.000000 0.000000
50 0.113726 0.027451 0.003922 1.000000 0.000000
51 0.113726 0.027451 0.003922 1.000000 0.000000
52 0.113726 0.027451 0.003922 1.000000 0.000000
53 0.113726 0.027451 0.003922 1.000000 0.000000
54 0.113726 0.027451 0.003922 1.000000 0.000000
55 0.113726 0.027451 0.003922 1.000000 0.000000
56 0.113726 0.027451 0.003922 1.000000 0.000000
57 0.113726 0.027451 0.003922 1.000000 0.000000
58 0.113726 0.027451 0.003922 1.000000 0.000000
59 0.113726 0.027451 0.003922 1.000000 0.000000
60 0.113726 0.027451 0.003922 1.000000 0.000000
61 0.113726 0.027451 0.003922 1.000000 0.000000
62 0.113726 0.027451 0.003922 1.000000 0.000000
63 0.113726 0.027451 0.003922 1.000000 0.000000
64 0.113726 0.027451 0.003922 1.000000 0.000000
65 0.113726 0.027451 0.003922 1.000000 0.000000
66 0.113726 0.027451 0.003922 1.000000 0.000000
67 0.113726 0.027451 0.003922 1.000000 0.000000
68 0.113726 0.027451 0.003922 1.000000 0.000000
69 0.113726 0.027451 0.003922 1.000000 0.000000
70 0.113726 0.027451 0.003922 1.000000 0.000000
71 0.113726 0.027451 0.003922 1.000000 0.000000
72 0.113726 0.027451 0.003922 1.000000 0.000000
73 0.113726 0.027451 0.003922 1.000000 0.000000
74 0.113726 0.027451 0.003922 1.000000 0.000000
75 0.113726 0.027451 0.003922 1.000000 0.000000
76 0.113726 0.027451 0.003922 1.000000 0.000000
77 0.113726 0.027451 0.003922 1.000000 0.000000
78 0.113726 0.027451 0.003922 1.000000 0.000000
79 0.113726 0.027451 0.003922 1.000000 0.000000
80 0.113726 0.027451 0.003922 1.000000 0.000000
81 0.113726 0.027451 0.003922 1.000000 0.000000
82 0.113726 0.027451 0.003922 1.000000 0.000000
83 0.104427 0.027451 0.003922 1.000000 0.000000
84 0.077874 0.027451 0.003922 1.000000 0.000000
85 0.050050 0.027451 0.003922 1.000000 0.000000
86 0.017162 0.027451 0.003922 1.000000 0.000000
87 -0.016851 0.027451 0.003922 1.000000 0.000000
88 -0.023007 0.027451 0.003922 1.000000 0.000000
89 -0.026621 0.027451 0.003922 1.000000 0.000000
90 -0.027451 0.027451 0.003922 1.000000 0.000000
91 -0.027451 0.027451 0.003922 1.000000 0.000000
92 -0.027451 0.027451 0.003922 1.000000 0.000000
93 -0.027451 0.027451 0.003922 1.000000 0.000000
94 -0.027451 0.027451 0.003922 1.000000 0.000000
95 -0.027451 0.027451 0.003922 1.000000 0.000000
96 -0.027451 0.027451 0.003922 1.000000 0.000000
97 -0.027451 0.027451 0.003922 1.000000 0.000000
98 -0.027451 0.027451 0.003922 1.000000 0.000000
99 -0.028397 0.027451 0.003922 1.000000 0.000000
100 -0.031739 0.027451 0.003922 1.000000 0.000000
101 -0.034961 0.027451 0.003922 1.000000 0.000000
102 -0.038293 0.027451 0.003922 1.000000 0.000000
103 -0.042012 0.027451 0.003922 1.000000 0.000000
104 -0.043137 0.027451 0.003922 1.000000 0.000000
105 -0.043137 0.027451 0.003922 1.000000 0.000000
106 -0.044327 0.027451 0.003922 1.000000 0.000000
107 -0.047871 0.027451 0.003922 1.000000 0.000000
108 -0.051675 0.027451 0.003922 1.000000 0.000000
109 -0.055168 0.027451 0.003922 1.000000 0.000000
110 -0.058754 0.027451 0.003922 1.000000 0.000000
111 -0.065101 0.027451 0.003922 1.000000 0.000000
112 -0.072274 0.027451 0.003922 1.000000 0.000000
113 -0.082223 0.027451 0.003922 1.000000 0.000000
114 -0.092332 0.027451 0.003922 1.000000 0.000000
115 -0.103807 0.027451 0.003922 1.000000 0.000000
116 -0.119170 0.027451 0.003922 1.000000 0.000000
117 -0.135084 0.027451 0.003922 1.000000 0.000000
118 -0.137255 0.027451 0.003922 1.000000 0.000000
119 -0.137255 0.027451 0.003922 1.000000 0.000000
120 -0.137255 0.027451 0.003922 1.000000 0.000000
121 -0.137255 0.027451 0.003922 1.000000 0.000000
122 -0.137255 0.027451 0.003922 1.000000 0.000000
123 -0.137255 0.027451 0.003922 1.000000 0.000000
124 -0.137255 0.027451 0.003922 1.000000 0.000000
125 -0.137255 0.027451 0.003922 1.000000 0.000000
126 -0.137255 0.027451 0.003922 1.000000 0.000000
127 -0.137255 0.027451 0.003922 1.000000 0.000000
128 -0.137255 0.027451 0.003922 1.000000 0.000000
129 -0.137255 0.027451 0.003922 1.000000 0.000000
130 -0.137255 0.027451 0.003922 1.000000 0.000000
131 -0.137255 0.027451 0.003922 1.000000 0.000000
132 -0.127643 0.024247 0.003922 1.000000 0.000000
133 -0.116964 0.020687 0.003922 1.000000 0.000000
134 -0.101080 0.019608 0.003922 1.000000 0.000000
135 -0.084524 0.019608 0.003922 1.000000 0.000000
136 -0.073260 0.019608 0.003922 1.000000 0.000000
137 -0.069383 0.019608 0.003922 1.000000 0.000000
138 -0.066667 0.019608 0.003922 1.000000 0.000000
139 -0.066667 0.019608 0.003922 1.000000 0.000000
140 -0.066667 0.019608 0.003922 1.000000 0.000000
141 -0.066667 0.019608 0.003922 1.000000 0.000000
142 -0.066667 0.019608 0.003922 1.000000 0.000000
143 -0.066667 0.019608 0.003922 1.000000 0.000000
144 -0.066667 0.019608 0.003922 1.000000 0.000000
145 -0.066667 0.006472 0.001732 1.000000 0.000000
146 -0.066667 -0.016772 -0.002142 1.000000 0.000000
147 -0.072984 -0.048510 -0.008133 1.000000 0.000000
148 -0.084076 -0.085483 -0.015528 1.000000 0.000000
149 -0.090196 -0.105882 -0.019608 1.000000 0.000000
150 -0.090196 -0.105882 -0.019608 1.000000 0.000000
151 -0.090196 -0.105882 -0.019608 1.000000 0.000000
152 -0.090196 -0.105882 -0.019608 1.000000 0.000000
153 -0.090196 -0.105882 -0.019608 1.000000 0.000000
154 -0.090196 -0.105882 -0.019608 1.000000 0.000000
155 -0.090196 -0.105882 -0.019608 1.000000 0.000000
156 -0.090196 -0.105882 -0.019608 1.000000 0.000000
157 -0.090196 -0.105882 -0.019608 1.000000 0.000000
158 -0.090196 -0.105882 -0.019608 1.000000 0.000000
159 -0.090196 -0.105882 -0.019608 1.000000 0.000000
160 -0.090196 -0.105882 -0.019608 1.000000 0.000000
161 -0.090196 -0.105882 -0.019608 1.000000 0.000000
162 -0.090196 -0.105882 -0.019608 1.000000 0.000000
163 -0.090196 -0.105882 -0.019608 1.000000 0.000000
164 -0.090196 -0.105882 -0.019608 1.000000 0.000000
165 -0.090196 -0.105882 -0.019608 1.000000 0.000000
166 -0.090196 -0.105882 -0.019608 1.000000 0.000000
167 -0.090196 -0.105882 -0.019608 1.000000 0.000000
168 -0.090196 -0.105882 -0.019608 1.000000 0.000000
169 -0.090196 -0.105882 -0.019608 1.000000 0.000000
170 -0.090196 -0.105882 -0.019608 1.000000 0.000000
171 -0.090196 -0.105882 -0.019608 1.000000 0.000000
172 -0.090196 -0.105882 -0.019608 1.000000 0.000000
173 -0.090196 -0.105882 -0.019608 1.000000 0.000000
174 -0.090196 -0.105882 -0.019608 1.000000 0.000000
175 -0.090196 -0.105882 -0.019608 1.000000 0.000000
176 -0.090196 -0.105882 -0.019608 1.000000 0.000000