diff --git a/LCS/PyCommon/lcu_utils.py b/LCS/PyCommon/lcu_utils.py index 3d78d29916ec5bbc4f5ef326f24d60e413eda255..3becb6ab161f1bbc5c91053eaaa204aef9de08f7 100644 --- a/LCS/PyCommon/lcu_utils.py +++ b/LCS/PyCommon/lcu_utils.py @@ -98,7 +98,8 @@ def stationname2hostname(station_name): def hostname2stationname(station_hostname): '''Convert a lcu hostname to a parset-like station name , like cs001c or cs001c.control.lofar to CS001''' # assume a hostname is encoded as stationname in lowercase with a c appended, like cs001c for CS001 - return station_hostname.split('.')[0].strip()[:-1].upper() + stationname = station_hostname.split('.')[0].strip().upper() + return stationname[:-1] if stationname.endswith('C') else stationname def get_stations_rcu_mode(stations=None): ''' diff --git a/SAS/TriggerServices/lib/task_info_cache.py b/SAS/TriggerServices/lib/task_info_cache.py index 1d2cfadaaf990a6d2ab525aad03d057ea4800788..66e46bf0ce40713b23c2022359a9fcc82752b7ec 100644 --- a/SAS/TriggerServices/lib/task_info_cache.py +++ b/SAS/TriggerServices/lib/task_info_cache.py @@ -115,8 +115,7 @@ class TaskInfoCache(OTDBBusListener): if ti.radb_task['starttime'] <= active_at and ti.radb_task['endtime'] >= active_at] if task_type is not None: - tasks = [ti for ti in tasks - if ti.radb_task['task_type'] == task_type] + tasks = [ti for ti in tasks if ti.radb_task['type'] == task_type] return tasks @@ -238,4 +237,4 @@ if __name__ == '__main__': # start listening on all default messaging buses, # and let the TaskInfoCache instance log the events as they come along. with TaskInfoCache() as cache: - waitForInterrupt() \ No newline at end of file + waitForInterrupt() diff --git a/SAS/TriggerServices/lib/trigger_service.py b/SAS/TriggerServices/lib/trigger_service.py index 3a58efcc8894c748bfea0a3ea930b5c45ce5270c..722592f87421f6979fd8e59439e18a030e8d183d 100644 --- a/SAS/TriggerServices/lib/trigger_service.py +++ b/SAS/TriggerServices/lib/trigger_service.py @@ -23,12 +23,12 @@ from StringIO import StringIO from lxml import etree -from datetime import datetime +from datetime import datetime, timedelta from lofar.messaging import Service, EventMessage, ToBus from lofar.messaging.Service import MessageHandlerInterface from lofar.common.util import waitForInterrupt -from lofar.common.lcu_utils import stationname2hostname +from lofar.common.lcu_utils import stationname2hostname, hostname2stationname from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC from lofar.specificationservices.specification_service_rpc import SpecificationRPC @@ -409,7 +409,8 @@ class ALERTHandler(VOEventListenerInterface): logger.info('TBB is in correct operational mode: %s' % DEFAULT_TBB_ALERT_MODE) # Any running observations? - active_tasks = self._cache.get_active_tasks(stoptime, 'observation') + #TODO: make stoptime a datetime instance eveywhere + active_tasks = self._cache.get_active_tasks(datetime(1970, 1, 1) + timedelta(seconds=stoptime), 'observation') if active_tasks: otdb_ids = sorted([t.radb_task['otdb_id'] for t in active_tasks]) logger.info('Observation(s) %s is/are running at time %s', otdb_ids, stoptime) @@ -417,8 +418,8 @@ class ALERTHandler(VOEventListenerInterface): logger.warning('No observations running at %s, so TBB\'s are not recording', stoptime) return False - active_stations = self._cache.get_stations() - active_tbb_stations = set(DEFAULT_TBB_STATIONS).intersection(active_stations) + active_stations = set(hostname2stationname(x) for x in self._cache.get_stations()) + active_tbb_stations = set(hostname2stationname(x) for x in DEFAULT_TBB_STATIONS).intersection(active_stations) if len(active_tbb_stations) > 0: logger.info('Enough TBB stations available: %s', active_tbb_stations)