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

SW-488: little tweaks and fixes from live testing on scu199

parent 6840eca3
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,8 @@ def stationname2hostname(station_name): ...@@ -98,7 +98,8 @@ def stationname2hostname(station_name):
def hostname2stationname(station_hostname): def hostname2stationname(station_hostname):
'''Convert a lcu hostname to a parset-like station name , like cs001c or cs001c.control.lofar to CS001''' '''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 # 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): def get_stations_rcu_mode(stations=None):
''' '''
......
...@@ -115,8 +115,7 @@ class TaskInfoCache(OTDBBusListener): ...@@ -115,8 +115,7 @@ class TaskInfoCache(OTDBBusListener):
if ti.radb_task['starttime'] <= active_at and ti.radb_task['endtime'] >= active_at] if ti.radb_task['starttime'] <= active_at and ti.radb_task['endtime'] >= active_at]
if task_type is not None: if task_type is not None:
tasks = [ti for ti in tasks tasks = [ti for ti in tasks if ti.radb_task['type'] == task_type]
if ti.radb_task['task_type'] == task_type]
return tasks return tasks
...@@ -238,4 +237,4 @@ if __name__ == '__main__': ...@@ -238,4 +237,4 @@ if __name__ == '__main__':
# start listening on all default messaging buses, # start listening on all default messaging buses,
# and let the TaskInfoCache instance log the events as they come along. # and let the TaskInfoCache instance log the events as they come along.
with TaskInfoCache() as cache: with TaskInfoCache() as cache:
waitForInterrupt() waitForInterrupt()
\ No newline at end of file
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
from StringIO import StringIO from StringIO import StringIO
from lxml import etree from lxml import etree
from datetime import datetime from datetime import datetime, timedelta
from lofar.messaging import Service, EventMessage, ToBus from lofar.messaging import Service, EventMessage, ToBus
from lofar.messaging.Service import MessageHandlerInterface from lofar.messaging.Service import MessageHandlerInterface
from lofar.common.util import waitForInterrupt 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.mom.momqueryservice.momqueryrpc import MoMQueryRPC
from lofar.specificationservices.specification_service_rpc import SpecificationRPC from lofar.specificationservices.specification_service_rpc import SpecificationRPC
...@@ -409,7 +409,8 @@ class ALERTHandler(VOEventListenerInterface): ...@@ -409,7 +409,8 @@ class ALERTHandler(VOEventListenerInterface):
logger.info('TBB is in correct operational mode: %s' % DEFAULT_TBB_ALERT_MODE) logger.info('TBB is in correct operational mode: %s' % DEFAULT_TBB_ALERT_MODE)
# Any running observations? # 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: if active_tasks:
otdb_ids = sorted([t.radb_task['otdb_id'] for t in 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) logger.info('Observation(s) %s is/are running at time %s', otdb_ids, stoptime)
...@@ -417,8 +418,8 @@ class ALERTHandler(VOEventListenerInterface): ...@@ -417,8 +418,8 @@ class ALERTHandler(VOEventListenerInterface):
logger.warning('No observations running at %s, so TBB\'s are not recording', stoptime) logger.warning('No observations running at %s, so TBB\'s are not recording', stoptime)
return False return False
active_stations = self._cache.get_stations() active_stations = set(hostname2stationname(x) for x in self._cache.get_stations())
active_tbb_stations = set(DEFAULT_TBB_STATIONS).intersection(active_stations) active_tbb_stations = set(hostname2stationname(x) for x in DEFAULT_TBB_STATIONS).intersection(active_stations)
if len(active_tbb_stations) > 0: if len(active_tbb_stations) > 0:
logger.info('Enough TBB stations available: %s', active_tbb_stations) logger.info('Enough TBB stations available: %s', active_tbb_stations)
......
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