Skip to content
Snippets Groups Projects
Commit adc38bac authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-244: crude first implementation of the before and after time constraint

parent 4c86b414
No related branches found
No related tags found
1 merge request!252Resolve TMSS-190
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
from datetime import datetime, timedelta from datetime import datetime, timedelta
from lofar.common.datetimeutils import parseDatetime
from lofar.sas.tmss.tmss.tmssapp import models from lofar.sas.tmss.tmss.tmssapp import models
from lofar.sas.tmss.tmss.tmssapp.conversions import create_astroplan_observer_for_station, Time, timestamps_and_stations_to_sun_rise_and_set from lofar.sas.tmss.tmss.tmssapp.conversions import create_astroplan_observer_for_station, Time, timestamps_and_stations_to_sun_rise_and_set
...@@ -87,6 +88,18 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche ...@@ -87,6 +88,18 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche
'''evaluate the time contraint(s)''' '''evaluate the time contraint(s)'''
constraints = scheduling_unit.draft.scheduling_constraints_doc constraints = scheduling_unit.draft.scheduling_constraints_doc
# TODO: TMSS-244 (and more?), evaluate the constraints in constraints['time'] # TODO: TMSS-244 (and more?), evaluate the constraints in constraints['time']
if 'before' in constraints['time']:
before = parseDatetime(constraints['time']['before'].replace('T', ' ').replace('Z', ''))
return upper_bound <= before
if 'after' in constraints['time']:
after = parseDatetime(constraints['time']['after'].replace('T', ' ').replace('Z', ''))
return lower_bound >= after
# if 'between' in constraints['time']:
# betweens = [ dateutil.parser.parse(constraints['time']['between'])
# return lower_bound >= after
return True # for now, ignore time contraints. return True # for now, ignore time contraints.
...@@ -102,6 +115,9 @@ def get_earliest_possible_start_time(scheduling_unit: models.SchedulingUnitBluep ...@@ -102,6 +115,9 @@ def get_earliest_possible_start_time(scheduling_unit: models.SchedulingUnitBluep
constraints = scheduling_unit.draft.scheduling_constraints_doc constraints = scheduling_unit.draft.scheduling_constraints_doc
try: try:
if 'after' in constraints['time']:
return parseDatetime(constraints['time']['after'].replace('T', ' ').replace('Z', ''))
if constraints['daily']['require_day'] or constraints['daily']['require_night']: if constraints['daily']['require_day'] or constraints['daily']['require_night']:
# TODO: TMSS-254 and TMSS-255 # TODO: TMSS-254 and TMSS-255
...@@ -162,5 +178,5 @@ def compute_scores(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound: ...@@ -162,5 +178,5 @@ def compute_scores(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound:
return ScoredSchedulingUnit(scheduling_unit=scheduling_unit, return ScoredSchedulingUnit(scheduling_unit=scheduling_unit,
scores=scores, scores=scores,
weighted_score=weighted_score, weighted_score=weighted_score,
start_time=lower_bound) start_time=get_earliest_possible_start_time(scheduling_unit, lower_bound))
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