fixed package mismatch
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
|
||||||
|
|
||||||
public enum ActionType{
|
|
||||||
VISION,
|
|
||||||
MOTOR,
|
|
||||||
DELAY
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Action {
|
public abstract class Action {
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package ModelFiles;
|
||||||
|
|
||||||
|
|
||||||
|
public enum ActionType{
|
||||||
|
VISION,
|
||||||
|
MOTOR,
|
||||||
|
DELAY,
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
|
// package ProjectModels.CognitiveModel;
|
||||||
|
|
||||||
|
|
||||||
public class Delay extends Action {
|
public class Delay extends Action {
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
|
// package ProjectModels.CognitiveModel;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import ModelFiles.ActionType;
|
||||||
|
import ModelFiles.MotorType;
|
||||||
|
|
||||||
public class Model {
|
public class Model {
|
||||||
|
|
||||||
private MindQueue q; //Queue for actions
|
private MindQueue q; //Queue for actions
|
||||||
boolean modelActive; // On/Off Switch for the model execution
|
boolean modelActive; // On/Off Switch for the model execution
|
||||||
XPlaneConnect xpc; //Allows connection to the simulator
|
XPlaneConnect xpc; //Allows connection to the simulator
|
||||||
|
float[] storedVision;
|
||||||
|
|
||||||
//Constructors
|
//Constructors
|
||||||
public Model() {
|
public Model() {
|
||||||
@@ -64,19 +67,22 @@ public class Model {
|
|||||||
return q.queueLength();
|
return q.queueLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAction(int actionType,int delay,String target) {
|
public void createAction(ActionType actionType,int delay,String target) {
|
||||||
Action newAction = null;
|
Action newAction = null;
|
||||||
switch(actionType){
|
switch(actionType) {
|
||||||
case 1:
|
case VISION:
|
||||||
newAction = new Vision(delay,target);
|
newAction = new Vision(delay,target);
|
||||||
this.push(newAction);
|
this.push(newAction);
|
||||||
case 2:
|
break;
|
||||||
|
case MOTOR:
|
||||||
newAction = new Motor(delay,target);
|
newAction = new Motor(delay,target);
|
||||||
this.push(newAction);
|
this.push(newAction);
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case DELAY:
|
||||||
newAction = new Delay(delay);
|
newAction = new Delay(delay);
|
||||||
this.push(newAction);
|
this.push(newAction);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,14 +118,42 @@ public class Model {
|
|||||||
String dref = tempV.getTarget();
|
String dref = tempV.getTarget();
|
||||||
try {
|
try {
|
||||||
returnArray = xpc.getDREF(dref);
|
returnArray = xpc.getDREF(dref);
|
||||||
|
storedVision = returnArray.clone();
|
||||||
|
// System.out.println(returnArray[0]);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMotorAction(Action temp){
|
private void handleMotorAction(Action temp) {
|
||||||
Motor tempM = (Motor) temp;
|
Motor tempM = (Motor) temp;
|
||||||
tempM.getDelay();
|
MotorType motorType = tempM.getMotorType();
|
||||||
|
float[] currentControls = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
switch(motorType){
|
||||||
|
case PITCHUP:
|
||||||
|
float[] pitchUp = {currentControls[0] + 0.01f};
|
||||||
|
if(storedVision[0] > 90) {
|
||||||
|
if(currentControls[0] < 0.1f) {
|
||||||
|
xpc.sendCTRL(pitchUp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Pitching Up");
|
||||||
|
case PITCHDOWN:
|
||||||
|
float[] pitchDown = {currentControls[0] - 0.01f};
|
||||||
|
if(storedVision[0] < 50) {
|
||||||
|
if(currentControls[0] > 0.1f) {
|
||||||
|
xpc.sendCTRL(pitchDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Pitching Down");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDelayAction(Action temp){
|
private void handleDelayAction(Action temp){
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
public class Motor extends Action {
|
public class Motor extends Action {
|
||||||
|
|
||||||
float[] control;
|
float[] control;
|
||||||
|
MotorType motorType;
|
||||||
|
|
||||||
public Motor() {
|
public Motor() {
|
||||||
super(ActionType.MOTOR,1000);
|
super(ActionType.MOTOR,1000);
|
||||||
@@ -24,6 +25,11 @@ public void createMotorControl(){ // TODO: Maybe takes in a formatted set of vis
|
|||||||
control = null;
|
control = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public MotorType getMotorType(){
|
||||||
|
return motorType;
|
||||||
|
}
|
||||||
|
|
||||||
public void sendMotorControl(XPlaneConnect xpc) {
|
public void sendMotorControl(XPlaneConnect xpc) {
|
||||||
|
|
||||||
if(control != null) {
|
if(control != null) {
|
||||||
@@ -36,4 +42,5 @@ public void sendMotorControl(XPlaneConnect xpc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package ModelFiles;
|
||||||
|
|
||||||
|
public enum MotorType{
|
||||||
|
PITCHUP,
|
||||||
|
PITCHDOWN
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
public class Process {
|
public class Process {
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
22
Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java
Normal file
22
Java/ProjectModels/CognitiveModel/ModelFiles/Vision.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
public interface BeaconReceivedListener {
|
public interface BeaconReceivedListener {
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
import ProjectModels.CognitiveModel.*;
|
import ModelFiles.*;
|
||||||
|
|
||||||
public interface DiscoveryConnectionCallback {
|
public interface DiscoveryConnectionCallback {
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
// HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
// 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
|
// 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.
|
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a camera view in X-Plane
|
* Represents a camera view in X-Plane
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
// HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
// 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
|
// 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.
|
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents operations that can be performed by the WYPT command.
|
* Represents operations that can be performed by the WYPT command.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
package ModelFiles.XPCdependencies;
|
||||||
|
|
||||||
import ProjectModels.CognitiveModel.*;
|
import ModelFiles.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
@@ -23,11 +23,7 @@
|
|||||||
// PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER
|
// 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.
|
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||||
|
|
||||||
package ProjectModels.CognitiveModel;
|
package ModelFiles;
|
||||||
|
|
||||||
import ProjectModels.CognitiveModel.XPCdependencies.*;
|
|
||||||
import src.discovery.ViewType;
|
|
||||||
import src.discovery.WaypointOp;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -38,6 +34,8 @@ import java.nio.ByteOrder;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import ModelFiles.XPCdependencies.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a client that can connect to and interact with the X-Plane Connect plugin.
|
* Represents a client that can connect to and interact with the X-Plane Connect plugin.
|
||||||
*
|
*
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package ProjectModels.CognitiveModel;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ProjectModels.src;
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@@ -13,7 +13,14 @@ import javax.swing.OverlayLayout;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
|
|
||||||
import ProjectModels.CognitiveModel.*;
|
import ModelFiles.*;
|
||||||
|
import ModelFiles.Action;
|
||||||
|
import ModelFiles.ActionType;
|
||||||
|
import ModelFiles.Delay;
|
||||||
|
import ModelFiles.MindQueue;
|
||||||
|
import ModelFiles.Model;
|
||||||
|
import ModelFiles.Vision;
|
||||||
|
import ModelFiles.XPlaneConnect;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
@@ -28,34 +35,33 @@ public class Main {
|
|||||||
System.out.println(q2.pop());
|
System.out.println(q2.pop());
|
||||||
|
|
||||||
//Using actions
|
//Using actions
|
||||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
try(XPlaneConnect xpc = new XPlaneConnect()) {
|
||||||
{
|
|
||||||
m.createAction(0, 0, null);
|
|
||||||
Action b = new Vision(10,"sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
Action b = new Vision(10,"sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
Action d = new Delay(20);
|
Action d = new Delay(20);
|
||||||
// Ensure connection established.
|
// Ensure connection established.
|
||||||
m = new Model(xpc);
|
m = new Model(xpc);
|
||||||
m.activateModel();
|
m.activateModel();
|
||||||
m.push(b);
|
m.createAction(ActionType.VISION, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
m.push(d);
|
m.createAction(ActionType.MOTOR, 0, null);
|
||||||
|
// m.push(b);
|
||||||
|
// m.push(d);
|
||||||
m.printModelQueue();
|
m.printModelQueue();
|
||||||
// m.deactivateModel();
|
// m.deactivateModel();
|
||||||
while(m.isActive() && !m.isEmpty()) {
|
while(m.isActive() && !m.isEmpty()) {
|
||||||
float[] array = m.next();
|
float[] array = m.next();
|
||||||
if(array != null){
|
if(array != null) {
|
||||||
// System.out.println(array[0]);
|
System.out.println(array[0]);
|
||||||
if(array[0] > 80.0f){
|
if(array[0] > 80.0f) {
|
||||||
m.push(d);
|
m.push(d);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// System.out.println("no dice");
|
||||||
|
// System.out.println(xpc.getDREF(null)");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// System.out.println("no dice");
|
// m.createAction(ActionType.MOTOR, 0, null);
|
||||||
// System.out.println(xpc.getDREF(null)");
|
m.printModelQueue();
|
||||||
}
|
}
|
||||||
if(m.getModelQueueLength() < 5){
|
|
||||||
m.push(b);
|
|
||||||
}
|
|
||||||
m.printModelQueue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
BIN
Java/ProjectModels/lib/hamcrest-core-1.3.jar
Normal file
BIN
Java/ProjectModels/lib/hamcrest-core-1.3.jar
Normal file
Binary file not shown.
BIN
Java/ProjectModels/lib/junit-4.13.2.jar
Normal file
BIN
Java/ProjectModels/lib/junit-4.13.2.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user