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(){
|
||||
terminate();
|
||||
execTime = -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ public class UeControlExecutor implements Runnable{
|
|||
}
|
||||
|
||||
public synchronized void reset(){
|
||||
terminateNonBlock();
|
||||
currentlyActive = null;
|
||||
for(int i=0; i<behaviours.size(); i++){
|
||||
behaviours.get(i).reset();
|
||||
|
|
@ -150,7 +149,7 @@ public class UeControlExecutor implements Runnable{
|
|||
|
||||
// Run behaviour
|
||||
UeBehaviour execBehaviour = currentlyActive;
|
||||
log.info("Running behaviour: " + currentlyActive.getName());
|
||||
log.info("Running behaviour: " + execBehaviour.getName());
|
||||
execBehaviour.run(this);
|
||||
|
||||
// Before deciding on the next behaviour check if currentlyActive
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ericsson.uecontrol.core.logic;
|
||||
|
||||
import com.ericsson.uecontrol.core.UeBehaviour;
|
||||
import com.ericsson.uecontrol.core.UeControlExecutor;
|
||||
import com.ericsson.uecontrol.core.util.Configurator.Configurable;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -13,10 +14,11 @@ public class UeBehaviourStop extends UeBehaviour {
|
|||
|
||||
@Override
|
||||
protected void execute() throws Exception {
|
||||
log.debug("Terminating execution");
|
||||
super.getExecutor().setNextBehaviour(0);
|
||||
UeControlExecutor executor = super.getExecutor();
|
||||
log.debug("Terminating executor");
|
||||
executor.terminateNonBlock();
|
||||
log.debug("Resetting executor");
|
||||
super.getExecutor().reset();
|
||||
executor.reset();
|
||||
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) {
|
||||
if(executor != null)
|
||||
if(executor != null) {
|
||||
executor.terminate();
|
||||
executor.reset();
|
||||
}
|
||||
if(statusFragment != null)
|
||||
statusFragment.reset();
|
||||
if(behaviourListFragment != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue