Improved method name

This commit is contained in:
Ziver Koc 2017-08-22 17:54:49 +02:00
parent 0357d12739
commit 7915a13a83
14 changed files with 18 additions and 19 deletions

View file

@ -75,7 +75,7 @@ public abstract class UeBehaviour implements Serializable{
/**
* @return if currently running behaviour should be terminated
*/
protected boolean stopExecution(){
protected boolean isExecutionStopped(){
return !isRunning();
}

View file

@ -38,7 +38,7 @@ public class UeBehaviourFileDownload extends UeBehaviour {
long progress = 0;
long read = 0;
while((read = in.read(data)) != -1 && !stopExecution()){
while((read = in.read(data)) != -1 && !isExecutionStopped()){
progress += read;
super.setProgress((float)progress/estimatedDataLength);
}

View file

@ -38,7 +38,7 @@ public class UeBehaviourFtpDownload extends UeBehaviourFtp {
long progress = 0;
long read = 0;
byte[] data = new byte[BUFFER_SIZE];
while((read = in.read(data)) != -1 && !stopExecution()){
while((read = in.read(data)) != -1 && !isExecutionStopped()){
progress += read;
super.setProgress((float)progress/estimatedDataLength);
}

View file

@ -60,7 +60,7 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
log.debug("Uploading random data with size "+size);
long total = 0;
byte[] data = new byte[BUFFER_SIZE];
while (total < size && !stopExecution()) {
while (total < size && !isExecutionStopped()) {
int writeLength = (int)(total + data.length < size ? data.length : size - total);
out.write(data, 0, writeLength);
@ -77,7 +77,7 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
int writeLength = 0;
int total = 0;
byte[] data = new byte[BUFFER_SIZE];
while ((writeLength = in.read(data)) > 0 && !stopExecution()) {
while ((writeLength = in.read(data)) > 0 && !isExecutionStopped()) {
out.write(data, 0, writeLength);
total += writeLength;

View file

@ -28,7 +28,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
// Wait to receive Call
log.debug("Waiting for call...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_RINGING ){
if(super.stopExecution())
if(super.isExecutionStopped())
return;
super.setProgress(0.2f);
Thread.sleep(SLEEP_PERIOD);
@ -40,7 +40,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
// Wait for call to end
log.debug("Waiting for call to end...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
if(super.isExecutionStopped())
return;
super.setProgress(0.6f);
Thread.sleep(SLEEP_PERIOD);

View file

@ -75,7 +75,7 @@ public class UeBehaviourSendSMS extends UeBehaviour{
status != MessageStatus.MESSAGE_CANCELED){
if(status == MessageStatus.MESSAGE_SENT)
this.setProgress(2/3f);
if(stopExecution())
if(isExecutionStopped())
break;
Thread.sleep(SLEEP_PERIOD);
}

View file

@ -27,7 +27,7 @@ public class UeBehaviourSleep extends UeBehaviour{
protected void execute() throws InterruptedException {
log.debug("Will sleep for "+time+" milliseconds");
int elapsedTime = 0;
while(elapsedTime < time && !super.stopExecution()){
while(elapsedTime < time && !super.isExecutionStopped()){
super.setProgress((float)elapsedTime/time);
int sleep = (elapsedTime+SLEEP_PERIOD < time ? SLEEP_PERIOD : time-elapsedTime);
Thread.sleep(sleep);

View file

@ -46,7 +46,7 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
// Wait for call to start
log.debug("Waiting call to start");
while(tm.getCallState() == TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
if(super.isExecutionStopped())
return;
super.setProgress(0.2f);
Thread.sleep(SLEEP_PERIOD);
@ -57,7 +57,7 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
int elapsedTime = 0;
int lengthMillisec = length*1000;
while(elapsedTime < lengthMillisec){
if(super.stopExecution())
if(super.isExecutionStopped())
return;
if(tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
log.debug("Call ended prematurely");
@ -73,7 +73,7 @@ public class UeBehaviourSpeechCall extends UeBehaviour{
CallUtil.endCall();
log.debug("Waiting call to end");
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
if(super.isExecutionStopped())
return;
super.setProgress(0.95f);
Thread.sleep(SLEEP_PERIOD);

View file

@ -91,7 +91,7 @@ public class UeBehaviourSurfing extends UeBehaviour {
StringBuilder content = new StringBuilder();
while ((read = in.read(data)) != -1) {
if (stopExecution())
if (isExecutionStopped())
return;
totalRead += read;
super.setProgress((float) totalRead / estimatedDataLength);

View file

@ -64,7 +64,7 @@ public class UeBehaviourVideoStreaming extends UeBehaviour implements MediaPlaye
while (mp.isPlaying() && playbackException == null) {
super.setProgress((float) mp.getCurrentPosition() / mp.getDuration());
if (super.stopExecution()) break;
if (super.isExecutionStopped()) break;
Thread.sleep(UeBehaviourSleep.SLEEP_PERIOD);
}
}catch(Exception e){

View file

@ -20,7 +20,7 @@ public class UeBehaviourIterator extends UeBehaviour {
@Override
protected void execute() throws Exception {
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
if(!super.stopExecution()) {
if(!super.isExecutionStopped()) {
iterationCount++;
if (iterationCount < iterations) {
log.debug("Iteration: " + iterationCount);

View file

@ -16,7 +16,7 @@ public class UeBehaviourReset extends UeBehaviour {
UeControlExecutor executor = super.getExecutor();
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
if(!super.stopExecution()) {
if(!super.isExecutionStopped()) {
executor.setNextBehaviour(0);
}
}

View file

@ -2,7 +2,6 @@ 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;
/**
@ -18,7 +17,7 @@ public class UeBehaviourStop extends UeBehaviour {
UeControlExecutor executor = super.getExecutor();
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
if(!super.stopExecution()) {
if(!super.isExecutionStopped()) {
if(!stopped) {
executor.terminateNonBlock();
stopped = true;

View file

@ -70,7 +70,7 @@ public class UeBehaviourSynchronize extends UeBehaviour implements BluetoothClie
try {
// Wait for sync message
while (!super.stopExecution()) {
while (!super.isExecutionStopped()) {
Thread.sleep(SLEEP_PERIOD);
long syncDiff = System.currentTimeMillis() - syncTimestamp;