final update commit (backlog 1)
This commit is contained in:
@@ -67,7 +67,7 @@ public class Model {
|
|||||||
return q.queueLength();
|
return q.queueLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAction(ActionType actionType,int delay,String target) {
|
public void createAction(ActionType actionType, MotorType motorType, int delay,String target) {
|
||||||
Action newAction = null;
|
Action newAction = null;
|
||||||
switch(actionType) {
|
switch(actionType) {
|
||||||
case VISION:
|
case VISION:
|
||||||
@@ -75,7 +75,7 @@ public class Model {
|
|||||||
this.push(newAction);
|
this.push(newAction);
|
||||||
break;
|
break;
|
||||||
case MOTOR:
|
case MOTOR:
|
||||||
newAction = new Motor(delay,target);
|
newAction = new Motor(motorType,delay,target);
|
||||||
this.push(newAction);
|
this.push(newAction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -129,25 +129,36 @@ public class Model {
|
|||||||
Motor tempM = (Motor) temp;
|
Motor tempM = (Motor) temp;
|
||||||
MotorType motorType = tempM.getMotorType();
|
MotorType motorType = tempM.getMotorType();
|
||||||
float[] currentControls = null;
|
float[] currentControls = null;
|
||||||
|
try {
|
||||||
|
currentControls = xpc.getCTRL(0);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
switch(motorType){
|
switch(motorType){
|
||||||
case PITCHUP:
|
case PITCHUP:
|
||||||
float[] pitchUp = {currentControls[0] + 0.01f};
|
float[] pitchUp = {currentControls[0] + 0.01f};
|
||||||
if(storedVision[0] > 90) {
|
if(storedVision[0] > 80) {
|
||||||
if(currentControls[0] < 0.1f) {
|
if(currentControls[0] < 0.2f) {
|
||||||
|
System.out.println("Pitching Up");
|
||||||
xpc.sendCTRL(pitchUp);
|
xpc.sendCTRL(pitchUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Pitching Up");
|
|
||||||
|
break;
|
||||||
case PITCHDOWN:
|
case PITCHDOWN:
|
||||||
float[] pitchDown = {currentControls[0] - 0.01f};
|
float[] pitchDown = {currentControls[0] - 0.01f};
|
||||||
if(storedVision[0] < 50) {
|
if(storedVision[0] < 80) {
|
||||||
if(currentControls[0] > 0.1f) {
|
if(currentControls[0] > -0.2f) {
|
||||||
|
// System.out.println("Sending Pitch Down");
|
||||||
|
System.out.println("Pitching Down");
|
||||||
xpc.sendCTRL(pitchDown);
|
xpc.sendCTRL(pitchDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Pitching Down");
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -7,17 +7,19 @@ public class Motor extends Action {
|
|||||||
float[] control;
|
float[] control;
|
||||||
MotorType motorType;
|
MotorType motorType;
|
||||||
|
|
||||||
public Motor() {
|
public Motor(MotorType motorType) {
|
||||||
super(ActionType.MOTOR,1000);
|
super(ActionType.MOTOR,1000);
|
||||||
|
this.motorType = motorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Motor(int delay) {
|
// public Motor(int delay) {
|
||||||
super(ActionType.MOTOR,delay);
|
// super(ActionType.MOTOR,delay);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public Motor(int delay, String target) {
|
public Motor(MotorType motorType,int delay, String target) {
|
||||||
super(ActionType.MOTOR,delay,target);
|
super(ActionType.MOTOR,delay,target);
|
||||||
|
this.motorType = motorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public class Main {
|
|||||||
// Ensure connection established.
|
// Ensure connection established.
|
||||||
m = new Model(xpc);
|
m = new Model(xpc);
|
||||||
m.activateModel();
|
m.activateModel();
|
||||||
m.createAction(ActionType.VISION, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
m.createAction(ActionType.MOTOR, 0, null);
|
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||||
// m.push(b);
|
// m.push(b);
|
||||||
// m.push(d);
|
// m.push(d);
|
||||||
m.printModelQueue();
|
m.printModelQueue();
|
||||||
@@ -50,17 +50,21 @@ public class Main {
|
|||||||
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 {
|
} else {
|
||||||
// System.out.println("no dice");
|
// System.out.println("no dice");
|
||||||
// System.out.println(xpc.getDREF(null)");
|
// System.out.println(xpc.getDREF(null)");
|
||||||
}
|
}
|
||||||
|
if(m.getModelQueueLength() < 5){
|
||||||
// m.createAction(ActionType.MOTOR, 0, null);
|
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
m.printModelQueue();
|
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||||
|
m.createAction(ActionType.MOTOR, MotorType.PITCHDOWN, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// m.printModelQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user