Added new Reset behaviour that was removed from Stop.

[artf485115]
This commit is contained in:
Ziver Koc 2015-02-09 14:51:33 +01:00
parent f067ff3122
commit 9a25cb9dbd
4 changed files with 66 additions and 13 deletions

View file

@ -180,6 +180,17 @@ public class UeControlExecutor implements Runnable{
public void setNextBehaviour(int i) { public void setNextBehaviour(int i) {
if(0 <= i && i < behaviours.size()) if(0 <= i && i < behaviours.size())
currentlyActive = behaviours.get(i); currentlyActive = behaviours.get(i);
else
currentlyActive = null;
}
public int getBehaviourIndex(UeBehaviour b) {
return behaviours.indexOf(b);
}
public UeBehaviour getRunningBehaviour(){
return currentlyActive;
}
public List<UeBehaviour> getBehaviourList() {
return behaviours;
} }
/** /**
@ -188,6 +199,10 @@ public class UeControlExecutor implements Runnable{
public void setLogPath(String path){ public void setLogPath(String path){
csvPath = path; csvPath = path;
} }
public CSVWriter getCsvLogger() {
return csvLogger;
}
public void setThroughputListener(ThroughputListener listener){ public void setThroughputListener(ThroughputListener listener){
throughputListener = listener; throughputListener = listener;
} }
@ -198,17 +213,6 @@ public class UeControlExecutor implements Runnable{
throughputUpdateRunnable.deviceBasedThroughput = enable; throughputUpdateRunnable.deviceBasedThroughput = enable;
} }
public List<UeBehaviour> getBehaviourList() {
return behaviours;
}
public UeBehaviour getRunningBehaviour(){
return currentlyActive;
}
public CSVWriter getCsvLogger() {
return csvLogger;
}
public static interface ExecutionListener { public static interface ExecutionListener {
public void executionStarted(); public void executionStarted();

View file

@ -0,0 +1,35 @@
package com.ericsson.uecontrol.core.logic;
import com.ericsson.uecontrol.core.UeBehaviour;
import com.ericsson.uecontrol.core.UeControlExecutor;
import org.apache.log4j.Logger;
/**
* Created by ezivkoc on 2015-01-19.
*/
public class UeBehaviourReset extends UeBehaviour {
private static final Logger log = Logger.getLogger(UeBehaviourReset.class);
@Override
protected void execute() throws Exception {
UeControlExecutor executor = super.getExecutor();
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
if(!super.stopExecution()) {
executor.setNextBehaviour(0);
}
}
@Override
public String getName() {
return "Reset";
}
@Override
public String toString() {
return "Will reset execution";
}
}

View file

@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
public class UeBehaviourStop extends UeBehaviour { public class UeBehaviourStop extends UeBehaviour {
private static final Logger log = Logger.getLogger(UeBehaviourStop.class); private static final Logger log = Logger.getLogger(UeBehaviourStop.class);
private transient boolean stopped = false;
@Override @Override
protected void execute() throws Exception { protected void execute() throws Exception {
@ -18,12 +19,24 @@ public class UeBehaviourStop extends UeBehaviour {
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
if(!super.stopExecution()) { if(!super.stopExecution()) {
if(!stopped) {
executor.terminateNonBlock(); executor.terminateNonBlock();
executor.setNextBehaviour(0); stopped = true;
//executor.setNextBehaviour( // Skipp this behaviour when execution starts
// executor.getBehaviourIndex(this)+1 );
}
else
stopped = false;
} }
} }
@Override
public void reset() {
stopped = false;
super.reset();
}
@Override @Override
public String getName() { public String getName() {
return "Stop"; return "Stop";

View file

@ -12,6 +12,7 @@
<item>com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming</item> <item>com.ericsson.uecontrol.core.behaviour.UeBehaviourVideoStreaming</item>
<item>com.ericsson.uecontrol.core.logic.UeBehaviourIterator</item> <item>com.ericsson.uecontrol.core.logic.UeBehaviourIterator</item>
<item>com.ericsson.uecontrol.core.logic.UeBehaviourReset</item>
<item>com.ericsson.uecontrol.core.logic.UeBehaviourStop</item> <item>com.ericsson.uecontrol.core.logic.UeBehaviourStop</item>
<item>com.ericsson.uecontrol.core.logic.UeBehaviourSynchronize</item> <item>com.ericsson.uecontrol.core.logic.UeBehaviourSynchronize</item>
</string-array> </string-array>