Skip to content
Snippets Groups Projects
Commit bea88ec3 authored by Mario Raciti's avatar Mario Raciti
Browse files

TMSS-610: Update observed_duration

parent 5dbcdf69
No related branches found
No related tags found
3 merge requests!634WIP: COBALT commissioning delta,!492Resolve TMSS-610,!481Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
...@@ -592,8 +592,18 @@ class SchedulingUnitBlueprint(RefreshFromDbInvalidatesCachedPropertiesMixin, Tem ...@@ -592,8 +592,18 @@ class SchedulingUnitBlueprint(RefreshFromDbInvalidatesCachedPropertiesMixin, Tem
""" """
return the overall observed duration of all (observation) tasks of this scheduling unit return the overall observed duration of all (observation) tasks of this scheduling unit
""" """
# TODO: Trigger an exception if a task overlaps with another. Just assume that they run subsequently for now.
if self.observed_start_time and self.observed_end_time: if self.observed_start_time and self.observed_end_time:
observed_tasks = []
for task in self.task_blueprints.all():
if task.specifications_template.type.value == TaskType.Choices.OBSERVATION.value and \
(task.status == "observed" or task.status == "finished"):
observed_tasks.append(task)
# TODO: For now we just assume that tasks run subsequently. Handle overlapping in future.
# Check if there are any overlapping obs task
for i, t1 in enumerate(observed_tasks):
for t2 in observed_tasks[i + 1:]:
if t1.start_time < t2.start_time < t1.stop_time: # Trigger an exception if any overlaps.
raise Exception('There are at least two tasks overlapping: observed_duration is not reliable.')
return self.observed_end_time - self.observed_start_time return self.observed_end_time - self.observed_start_time
else: else:
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment