Changes so that UI displays execution time in milliseconds also.

[artf485006]
This commit is contained in:
Ziver Koc 2015-02-09 13:47:32 +01:00
parent 8379e3f3e7
commit ec14c949fa
3 changed files with 12 additions and 7 deletions

View file

@ -153,6 +153,7 @@ public class UeControlExecutor implements Runnable{
UeBehaviour execBehaviour = currentlyActive; UeBehaviour execBehaviour = currentlyActive;
log.info("Running behaviour: " + execBehaviour.getName()); log.info("Running behaviour: " + execBehaviour.getName());
execBehaviour.run(this); execBehaviour.run(this);
log.info("Behaviour done, execution time: "+execBehaviour.getExecTime()+"ms");
// Before deciding on the next behaviour check if currentlyActive // Before deciding on the next behaviour check if currentlyActive
// has been changed by the previous behaviour // has been changed by the previous behaviour

View file

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

View file

@ -1,5 +1,7 @@
package com.ericsson.uecontrol.core.util; package com.ericsson.uecontrol.core.util;
import java.text.DecimalFormat;
/** /**
* Created by ezivkoc on 2015-01-16. * Created by ezivkoc on 2015-01-16.
*/ */
@ -30,12 +32,14 @@ public class StringUtil {
int timeSec = (int)(time / 1000); int timeSec = (int)(time / 1000);
int hours = timeSec / (60*60); int hours = timeSec / (60*60);
int minutes = (timeSec-(hours*60*60)) / 60; int minutes = (timeSec-(hours*60*60)) / 60;
int seconds = timeSec-(hours*60*60)-(minutes*60); double seconds = (time-((hours*60*60)-(minutes*60))*1000)/1000.0;
String ret = ""; String ret = "";
DecimalFormat df = new DecimalFormat("#0.##"); // Round to 2 decimals of seconds
if(hours > 0) ret += hours+"h "; if(hours > 0) ret += hours+"h ";
if(minutes > 0) ret += minutes+"m "; if(minutes > 0) ret += minutes+"m ";
if(seconds > 0) ret += seconds+"s "; if(seconds > 0) ret += df.format(seconds)+"s ";
return ret; return ret;
} }
} }