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 {
|
||||
|
||||
@@ -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 {
|
||||
@@ -1,4 +1,5 @@
|
||||
package ProjectModels.CognitiveModel;
|
||||
package ModelFiles;
|
||||
// package ProjectModels.CognitiveModel;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package ProjectModels.CognitiveModel;
|
||||
package ModelFiles;
|
||||
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
|
||||
|
||||
float[] storedVision;
|
||||
|
||||
//Constructors
|
||||
public Model() {
|
||||
@@ -64,19 +67,22 @@ public class Model {
|
||||
return q.queueLength();
|
||||
}
|
||||
|
||||
public void createAction(int actionType,int delay,String target) {
|
||||
public void createAction(ActionType actionType,int delay,String target) {
|
||||
Action newAction = null;
|
||||
switch(actionType){
|
||||
case 1:
|
||||
switch(actionType) {
|
||||
case VISION:
|
||||
newAction = new Vision(delay,target);
|
||||
this.push(newAction);
|
||||
case 2:
|
||||
break;
|
||||
case MOTOR:
|
||||
newAction = new Motor(delay,target);
|
||||
this.push(newAction);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case DELAY:
|
||||
newAction = new Delay(delay);
|
||||
this.push(newAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,14 +118,42 @@ public class Model {
|
||||
String dref = tempV.getTarget();
|
||||
try {
|
||||
returnArray = xpc.getDREF(dref);
|
||||
storedVision = returnArray.clone();
|
||||
// System.out.println(returnArray[0]);
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMotorAction(Action temp){
|
||||
private void handleMotorAction(Action 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){
|
||||
@@ -1,10 +1,11 @@
|
||||
package ProjectModels.CognitiveModel;
|
||||
package ModelFiles;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class Motor extends Action {
|
||||
|
||||
float[] control;
|
||||
MotorType motorType;
|
||||
|
||||
public Motor() {
|
||||
super(ActionType.MOTOR,1000);
|
||||
@@ -24,6 +25,11 @@ public void createMotorControl(){ // TODO: Maybe takes in a formatted set of vis
|
||||
control = null;
|
||||
}
|
||||
|
||||
|
||||
public MotorType getMotorType(){
|
||||
return motorType;
|
||||
}
|
||||
|
||||
public void sendMotorControl(XPlaneConnect xpc) {
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ProjectModels.CognitiveModel;
|
||||
package ModelFiles;
|
||||
import org.junit.Test;
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
||||
package ModelFiles.XPCdependencies;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
@@ -1,4 +1,4 @@
|
||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
||||
package ModelFiles.XPCdependencies;
|
||||
|
||||
public interface BeaconReceivedListener {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
||||
package ModelFiles.XPCdependencies;
|
||||
|
||||
import ProjectModels.CognitiveModel.*;
|
||||
import ModelFiles.*;
|
||||
|
||||
public interface DiscoveryConnectionCallback {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
||||
// PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER
|
||||
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
||||
package ModelFiles.XPCdependencies;
|
||||
|
||||
/**
|
||||
* Represents a camera view in X-Plane
|
||||
@@ -22,7 +22,7 @@
|
||||
// HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
|
||||
// PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER
|
||||
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||
package ProjectModels.CognitiveModel.XPCdependencies;
|
||||
package ModelFiles.XPCdependencies;
|
||||
|
||||
/**
|
||||
* 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.net.DatagramPacket;
|
||||
@@ -23,11 +23,7 @@
|
||||
// PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER
|
||||
// SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.
|
||||
|
||||
package ProjectModels.CognitiveModel;
|
||||
|
||||
import ProjectModels.CognitiveModel.XPCdependencies.*;
|
||||
import src.discovery.ViewType;
|
||||
import src.discovery.WaypointOp;
|
||||
package ModelFiles;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -38,6 +34,8 @@ import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import ModelFiles.XPCdependencies.*;
|
||||
|
||||
/**
|
||||
* 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.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -13,7 +13,14 @@ import javax.swing.OverlayLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
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 {
|
||||
|
||||
@@ -28,34 +35,33 @@ public class Main {
|
||||
System.out.println(q2.pop());
|
||||
|
||||
//Using actions
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
m.createAction(0, 0, null);
|
||||
try(XPlaneConnect xpc = new XPlaneConnect()) {
|
||||
Action b = new Vision(10,"sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||
Action d = new Delay(20);
|
||||
// Ensure connection established.
|
||||
m = new Model(xpc);
|
||||
m.activateModel();
|
||||
m.push(b);
|
||||
m.push(d);
|
||||
m.createAction(ActionType.VISION, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||
m.createAction(ActionType.MOTOR, 0, null);
|
||||
// m.push(b);
|
||||
// m.push(d);
|
||||
m.printModelQueue();
|
||||
// m.deactivateModel();
|
||||
while(m.isActive() && !m.isEmpty()) {
|
||||
float[] array = m.next();
|
||||
if(array != null){
|
||||
// System.out.println(array[0]);
|
||||
if(array[0] > 80.0f){
|
||||
m.push(d);
|
||||
while(m.isActive() && !m.isEmpty()) {
|
||||
float[] array = m.next();
|
||||
if(array != null) {
|
||||
System.out.println(array[0]);
|
||||
if(array[0] > 80.0f) {
|
||||
m.push(d);
|
||||
}
|
||||
} else {
|
||||
// System.out.println("no dice");
|
||||
// System.out.println(xpc.getDREF(null)");
|
||||
}
|
||||
} else {
|
||||
// System.out.println("no dice");
|
||||
// System.out.println(xpc.getDREF(null)");
|
||||
|
||||
// m.createAction(ActionType.MOTOR, 0, null);
|
||||
m.printModelQueue();
|
||||
}
|
||||
if(m.getModelQueueLength() < 5){
|
||||
m.push(b);
|
||||
}
|
||||
m.printModelQueue();
|
||||
}
|
||||
}
|
||||
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