Commit 8d85eeb6 authored by Xiaoying Pu's avatar Xiaoying Pu

Hmmm

parent 7d702331
......@@ -16,9 +16,16 @@
<group>
<file>file:/Users/pxy/dm_task/test/tracker/DecisionTest.java</file>
<file>file:/Users/pxy/dm_task/src/tracker/Decision.java</file>
<file>file:/Users/pxy/dm_task/src/util/Trial.java</file>
<file>file:/Users/pxy/dm_task/src/util/WLState.java</file>
<file>file:/Users/pxy/dm_task/src/util/DecisionType.java</file>
<file>file:/Users/pxy/dm_task/src/tracker/PrimaryTaskController.java</file>
<file>file:/Users/pxy/dm_task/src/main/TestUDPController.java</file>
<file>file:/Users/pxy/dm_task/src/tracker/MouseTrackerFacade.java</file>
<file>file:/Users/pxy/dm_task/src/util/ActionType.java</file>
</group>
</open-files>
</project-private>
......@@ -2,8 +2,6 @@ package tracker;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import util.EventListener;
import util.EventType;
import util.WLState;
......@@ -24,7 +22,7 @@ public class MouseTrackerFacade {
this.theModel = new PrimaryTaskModel();
this.theController = new PrimaryTaskController(theModel);
this.eventList = new ArrayList<>();
this.theController.addListener(new ControllerEndDecisionListener());
// this.theController.addListener(new ControllerEndDecisionListener());
}
public void theFirstContact() {
......@@ -46,14 +44,16 @@ public class MouseTrackerFacade {
}
/**
* TODO: Either user make a decision, or time is up
* Now this class decides when a chunk of decision-making should end. In the
* meanwhile, the MouseTracker is told to display break screen.
*/
public void endDecision() {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
Logger.getLogger(MouseTrackerFacade.class.getName()).log(Level.SEVERE, null, ex);
}
// try {
// Thread.sleep(2000);
// } catch (InterruptedException ex) {
// Logger.getLogger(MouseTrackerFacade.class.getName()).log(Level.SEVERE, null, ex);
// }
this.theController.endDecision();
System.out.println("Let's say the decision is done");
handleEvent(EventType.DECISION_FINISHED);
......@@ -69,11 +69,11 @@ public class MouseTrackerFacade {
});
}
class ControllerEndDecisionListener extends EventListener {
@Override
public void run(EventType type) {
}
}
// class ControllerEndDecisionListener extends EventListener {
//
// @Override
// public void run(EventType type) {
//
// }
// }
}
......@@ -6,7 +6,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import util.DecisionType;
import util.EventListener;
import util.EventType;
import util.WLState;
/**
......@@ -18,6 +17,10 @@ public class PrimaryTaskController {
private final boolean turnUDPOn = true; // TODO what an ugly flag
private final PrimaryTaskModel theModel;
private UDPController udpHandle;
/**
* Don't need AtomicBoolean, too bad
*/
private boolean timeIsUp;
/**
* Event Listener list
......@@ -34,8 +37,9 @@ public class PrimaryTaskController {
this.eventListenerList = new ArrayList<>();
if (turnUDPOn) {
this.udpHandle = new UDPController();// should set up the UDP connection
this.udpHandle.addListener(new UDPListener());
// this.udpHandle.addListener(new UDPListener());
}
}
public void addListener(EventListener l) {
......@@ -56,11 +60,22 @@ public class PrimaryTaskController {
}
public void startDecision(WLState state) {
//TODO need to fix this
String msg = this.theModel.getDecision(DecisionType.GETMIXATYPICAL, state.toString());
this.udpHandle.sendTrialAndRecvResponse(msg);
System.out.println("Decision started, waiting for response.. ");
while (!this.timeIsUp) {
String msg = this.theModel.getDecision(DecisionType.GETMIXATYPICAL, state.toString());
this.udpHandle.sendTrialAndRecvResponse(msg);
System.out.println("Decision started, waiting for response.. ");
}
//after some time, the facade interrupts and MouseTracker displays a break screen
// while the user recalls digits
// TODO: break also needs to wait for response message??????
String breakMsg = this.theModel.getDecision(DecisionType.GETBREAK, state.toString());
this.udpHandle.sendTrialAndRecvResponse(breakMsg);
}
public void endDecision() {
this.timeIsUp = false;
}
public void connect() {
......@@ -68,7 +83,7 @@ public class PrimaryTaskController {
}
/**
* Ha this method is not called anywhere
* Ha this method is not called anywhere only for testing
*/
public void run() {
......@@ -83,19 +98,19 @@ public class PrimaryTaskController {
}
}).start();
}
class UDPListener extends EventListener {
@Override
public void run(EventType type) {
eventListenerList.stream().forEach((listener) -> {
System.out.println("hey UDPListner is working\n");
// TODO or type, right?
// should have multiple MT trials run
// before telling the MouseTrackerFacade that it's done
// like a counter here
listener.run(EventType.END_MULTI_DECISION);
});
}
}
// logic changed... now UDP does not report back
// class UDPListener extends EventListener {
//
// @Override
// public void run(EventType type) {
// eventListenerList.stream().forEach((listener) -> {
// System.out.println("hey UDPListner is working\n");
// // TODO or type, right?
// // should have multiple MT trials run
// // before telling the MouseTrackerFacade that it's done
// // like a counter here
// listener.run(EventType.END_MULTI_DECISION);
// })
// }
// }
}
......@@ -75,6 +75,9 @@ public class PrimaryTaskModel {
case GETMIXATYPICAL:
result = this.decision.getMixAtypical(condition);
break;
case GETBREAK:
result = this.decision.getBreak();
break;
default:
result = "??????";
System.out.println("ACHTUNG");
......
......@@ -16,6 +16,7 @@ public class Configurator {
private static int tPTask;
private static int tSTask;
private static int tPause;
private static int tDecisions;
/**
* @throws java.io.IOException
......@@ -44,11 +45,13 @@ public class Configurator {
String strNTrials = prop.getProperty("tPTask");
String strNHighWorkLoad = prop.getProperty("tSTask");
String strTPause = prop.getProperty("tPause");
String strTDecisions = prop.getProperty("tDecisions");
try {
tPTask = Integer.parseInt(strNTrials);
tSTask = Integer.parseInt(strNHighWorkLoad);
tPause = Integer.parseInt(strTPause);
tDecisions = Integer.parseInt(strTDecisions);
} catch (NumberFormatException e) {
e.printStackTrace();
}
......
......@@ -9,5 +9,6 @@ public enum DecisionType {
GETCATAGORY1,
GETCATAGORY2,
GETMIXTYPICAL,
GETMIXATYPICAL;
GETMIXATYPICAL,
GETBREAK;
}
......@@ -75,6 +75,8 @@ public class Trial extends Thread {
@Override
public void run(EventType type) {
switch (type) {
// Now the Trial should decide when the decision is done
// more of an action than response to listen to ...
case DECISION_FINISHED:
sFacade.startRecallingDigit();
break;
......
......@@ -9,4 +9,4 @@ tSTask = 1000
tPause = 4000
tDecisions = 30000
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment