Refactored Executor reset function
This commit is contained in:
parent
4ecca44cc1
commit
9b6ba3d086
4 changed files with 9 additions and 7 deletions
|
|
@ -53,7 +53,6 @@ public abstract class UeBehaviour implements Serializable{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
terminate();
|
|
||||||
execTime = -1;
|
execTime = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,6 @@ public class UeControlExecutor implements Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reset(){
|
public synchronized void reset(){
|
||||||
terminateNonBlock();
|
|
||||||
currentlyActive = null;
|
currentlyActive = null;
|
||||||
for(int i=0; i<behaviours.size(); i++){
|
for(int i=0; i<behaviours.size(); i++){
|
||||||
behaviours.get(i).reset();
|
behaviours.get(i).reset();
|
||||||
|
|
@ -150,7 +149,7 @@ public class UeControlExecutor implements Runnable{
|
||||||
|
|
||||||
// Run behaviour
|
// Run behaviour
|
||||||
UeBehaviour execBehaviour = currentlyActive;
|
UeBehaviour execBehaviour = currentlyActive;
|
||||||
log.info("Running behaviour: " + currentlyActive.getName());
|
log.info("Running behaviour: " + execBehaviour.getName());
|
||||||
execBehaviour.run(this);
|
execBehaviour.run(this);
|
||||||
|
|
||||||
// Before deciding on the next behaviour check if currentlyActive
|
// Before deciding on the next behaviour check if currentlyActive
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ericsson.uecontrol.core.logic;
|
package com.ericsson.uecontrol.core.logic;
|
||||||
|
|
||||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||||
|
import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||||
import com.ericsson.uecontrol.core.util.Configurator.Configurable;
|
import com.ericsson.uecontrol.core.util.Configurator.Configurable;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -13,10 +14,11 @@ public class UeBehaviourStop extends UeBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute() throws Exception {
|
protected void execute() throws Exception {
|
||||||
log.debug("Terminating execution");
|
UeControlExecutor executor = super.getExecutor();
|
||||||
super.getExecutor().setNextBehaviour(0);
|
log.debug("Terminating executor");
|
||||||
|
executor.terminateNonBlock();
|
||||||
log.debug("Resetting executor");
|
log.debug("Resetting executor");
|
||||||
super.getExecutor().reset();
|
executor.reset();
|
||||||
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,8 +191,10 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == R.id.action_reset) {
|
else if (id == R.id.action_reset) {
|
||||||
if(executor != null)
|
if(executor != null) {
|
||||||
|
executor.terminate();
|
||||||
executor.reset();
|
executor.reset();
|
||||||
|
}
|
||||||
if(statusFragment != null)
|
if(statusFragment != null)
|
||||||
statusFragment.reset();
|
statusFragment.reset();
|
||||||
if(behaviourListFragment != null)
|
if(behaviourListFragment != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue