compartmentalization of main method into testprocess files
This commit is contained in:
@@ -27,52 +27,54 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Encapsulation (or lack thereof) Test
|
// Encapsulation (or lack thereof) Test
|
||||||
Model m = new Model();
|
Model m = new Model();
|
||||||
MindQueue q = m.getQueue();
|
testprocess1 tp1 = new testprocess1(m, null);
|
||||||
Action a = new Vision();
|
tp1.runProcess();
|
||||||
System.out.println(q.pop());
|
|
||||||
q.push(a);
|
|
||||||
MindQueue q2 = m.getQueue();
|
|
||||||
System.out.println(q2.pop());
|
|
||||||
|
|
||||||
// Using actions
|
// MindQueue q = m.getQueue();
|
||||||
try (XPlaneConnect xpc = new XPlaneConnect()) {
|
// Action a = new Vision();
|
||||||
Action b = new Vision(10, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
// System.out.println(q.pop());
|
||||||
Action d = new Delay(20);
|
// q.push(a);
|
||||||
// Ensure connection established.
|
// MindQueue q2 = m.getQueue();
|
||||||
m = new Model(xpc);
|
// System.out.println(q2.pop());
|
||||||
m.activateModel();
|
|
||||||
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
|
||||||
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 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);
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
// System.out.println("no dice");
|
|
||||||
// System.out.println(xpc.getDREF(null)");
|
|
||||||
}
|
|
||||||
if (m.getModelQueueLength() < 5) {
|
|
||||||
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
|
||||||
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
|
||||||
m.createAction(ActionType.MOTOR, MotorType.PITCHDOWN, 0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// m.printModelQueue();
|
// // Using actions
|
||||||
}
|
// try (XPlaneConnect xpc = new XPlaneConnect()) {
|
||||||
} catch (SocketException ex) {
|
// Action b = new Vision(10, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
System.out.println("Unable to set up the connection. (Error message was '" + ex.getMessage() + "'.)");
|
// Action d = new Delay(20);
|
||||||
} catch (IOException ex) {
|
// // Ensure connection established.
|
||||||
System.out.println(
|
// m = new Model(xpc);
|
||||||
"Something went wrong with one of the commands. (Error message was '" + ex.getMessage() + "'.)");
|
// m.activateModel();
|
||||||
}
|
// m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
System.out.println("Exiting");
|
// m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 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);
|
||||||
|
// // }
|
||||||
|
// } else {
|
||||||
|
// // System.out.println("no dice");
|
||||||
|
// // System.out.println(xpc.getDREF(null)");
|
||||||
|
// }
|
||||||
|
// if (m.getModelQueueLength() < 5) {
|
||||||
|
// m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
|
// m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||||
|
// m.createAction(ActionType.MOTOR, MotorType.PITCHDOWN, 0, null);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // m.printModelQueue();
|
||||||
|
// }
|
||||||
|
// } 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
66
Java/ProjectModels/testprocess1.java
Normal file
66
Java/ProjectModels/testprocess1.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import ModelFiles.Model;
|
||||||
|
import ModelFiles.XPlaneConnect;
|
||||||
|
|
||||||
|
|
||||||
|
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 testprocess1 {
|
||||||
|
|
||||||
|
Model m = new Model();
|
||||||
|
|
||||||
|
public testprocess1(Model inputM, XPlaneConnect xpc) {
|
||||||
|
m = inputM;
|
||||||
|
m.establishConnection(xpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runProcess() {
|
||||||
|
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.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
|
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 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);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
// System.out.println("no dice");
|
||||||
|
// System.out.println(xpc.getDREF(null)");
|
||||||
|
}
|
||||||
|
if (m.getModelQueueLength() < 5) {
|
||||||
|
m.createAction(ActionType.VISION, null, 0, "sim/cockpit2/gauges/indicators/airspeed_kts_pilot");
|
||||||
|
m.createAction(ActionType.MOTOR, MotorType.PITCHUP, 0, null);
|
||||||
|
m.createAction(ActionType.MOTOR, MotorType.PITCHDOWN, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// m.printModelQueue();
|
||||||
|
}
|
||||||
|
} 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user