diff --git a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py index 308e66981d7c9447826470626c06af570a9267b1..0a44999f5a3aabc966cadf00d8d2dcab1f6fa9c5 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py @@ -1163,6 +1163,10 @@ def unschededule_blocking_scheduled_units_if_needed_and_possible(candidate_sched if candidate_scheduling_unit.priority_queue.value == models.PriorityQueueType.Choices.B.value: overlapping_scheduled_scheduling_units = overlapping_scheduled_scheduling_units.exclude(priority_queue__value=models.PriorityQueueType.Choices.A.value) + # non-triggered dynamically scheduled units are not allowed to unschedule fixed_time scheduled units + if candidate_scheduling_unit.is_dynamically_scheduled and not candidate_scheduling_unit.interrupts_telescope: + overlapping_scheduled_scheduling_units = overlapping_scheduled_scheduling_units.exclude(scheduling_constraints_doc__scheduler='fixed_time') + if not overlapping_scheduled_scheduling_units.exists(): logger.debug('no scheduled scheduling_units are blocking candidate scheduling_unit id=%s name=%s, nothing needs to be unscheduled', candidate_scheduling_unit.id, candidate_scheduling_unit.name) return diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 1b0ba4d358ee80a4155e597808295bb2a573e092..35e6bc0ce1da56ddadc0c5ac14ef2c92fcdb19f1 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -1368,6 +1368,20 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, Schedul ''' return self.draft.scheduling_set.project + @property + def is_dynamically_scheduled(self) -> bool: + '''is this unit scheduled dynamically?''' + if self.scheduling_constraints_doc is not None: + return self.scheduling_constraints_doc.get('scheduler', '') == 'dynamic' + return False + + @property + def is_fixed_time_scheduled(self) -> bool: + '''is this unit scheduled at fixed time?''' + if self.scheduling_constraints_doc is not None: + return self.scheduling_constraints_doc.get('scheduler', '') == 'fixed_time' + return False + @property def main_observation_used_stations(self) -> list: '''return the list of used stations of the main observation task'''