Add experiment run time/expected experiment runtime (of already queued experiments) and the time of the already finished experiments to the status bar in the gui.

This commit is contained in:
Joachim Beerwerth 2018-04-05 17:25:35 +02:00
parent 3dc98f0970
commit 63cb9e7d05
2 changed files with 44 additions and 0 deletions

View File

@ -541,6 +541,33 @@ class DamarisGUI:
r = self.si.data.get( "__recentresult", -1 ) + 1
b = self.si.data.get( "__resultsinadvance", -1 ) + 1
e = self.si.data.get( "__recentexperiment", -1 ) + 1
experimentstarttime = self.si.data.get( "__experimentstarted", 0 )
expectedexperimentruntime = self.si.data.get( "__totalexperimentlength", 0 )
experimentsfinishedtime = 0.0
for i in range(0, b):
experimentsfinishedtime += self.si.data.get("__experimentlengths", {}).get(i, 0.0)
experimentruntime = time.time() - experimentstarttime
experimenttimetext = ""
if experimentstarttime > 0 and expectedexperimentruntime > 0:
runtimemin, runtimesec = divmod(math.floor(experimentruntime), 60)
runtimehours, runtimemin = divmod(runtimemin, 60)
experimenttimetext += " ({:02d}:{:02d}:{:02d} / ".format(runtimehours, runtimemin, runtimesec)
expectedmin, expectedsec = divmod(math.ceil(expectedexperimentruntime), 60)
expectedhours, expectedmin = divmod(expectedmin, 60)
experimenttimetext += "{:02d}:{:02d}:{:02d})".format(expectedhours, expectedmin, expectedsec)
backendtimetext = ""
if experimentsfinishedtime > 0:
finexperimmin, finexperimsec = divmod(round(experimentsfinishedtime), 60)
finexperimhours, finexperimmin = divmod(finexperimmin, 60)
backendtimetext = " ({:02d}:{:02d}:{:02d})".format(finexperimhours, finexperimmin, finexperimsec)
e_text = None
r_text = None
b_text = None
@ -559,6 +586,7 @@ class DamarisGUI:
self.si.exp_handling = None
else:
e_text = "Experiment Script Running (%d)" % e
e_text += experimenttimetext
if self.si.res_handling is not None:
if not self.si.res_handling.isAlive( ):

View File

@ -66,6 +66,7 @@ class ExperimentHandling(threading.Thread):
self.traceback=traceback_file.getvalue()
traceback_file=None
return
while exp_iterator is not None and not self.quit_flag.isSet():
# get next experiment from script
try:
@ -86,6 +87,21 @@ class ExperimentHandling(threading.Thread):
if isinstance(job, Experiment):
if self.data is not None:
self.data["__recentexperiment"]=job.job_id+0
# track time when experiment is started. This is placed after executing the script
# and getting the iterator so that time for initializing devices etc. is not included
if "__experimentstarted" not in self.data:
self.data["__experimentstarted"] = time.time()
# track time of experiments in queue, the total time and for each experiment:
if "__totalexperimentlength" not in self.data:
self.data["__totalexperimentlength"] = 0.0
if "__experimentlengths" not in self.data:
self.data["__experimentlengths"] = {}
experimentlength = job.get_length()
self.data["__experimentlengths"][job.job_id+0] = experimentlength
self.data["__totalexperimentlength"] += experimentlength
# relax for a short time
if "__resultsinadvance" in self.data and self.data["__resultsinadvance"]+100<job.job_id:
self.quit_flag.wait(0.05)