Skip to content
Snippets Groups Projects
Commit 1ca3c5c8 authored by Taya Snijder's avatar Taya Snijder
Browse files

moved observationWrapper class to lsc

parent 068c3080
No related branches found
No related tags found
1 merge request!457Resolve L2SS-825 "Start an observation"
......@@ -5,7 +5,7 @@
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
from json import loads, dumps
from json import loads
import jsonschema
from jsonschema import Draft7Validator, FormatChecker
import logging
......@@ -28,37 +28,6 @@ logger = logging.getLogger()
__all__ = ["ObservationControl", "main"]
class ObservationWrapper(object):
""" This class provides a pythonic interface to the ObservationControl and Observation devices on a station. """
def __init__(self, specification: dict, host: str = "databaseds.tangonet:10000"):
# create device proxies to station at "host"
self._observation_control_dev = DeviceProxy(f"tango://{host}/STAT/ObservationControl/1")
# convert specification dict to json
self._specification = dumps(specification)
# get the ID
self._id = int(specification['observation_id'])
def observation_id(self) -> int:
return self._id
def start(self):
self._observation_control_dev.start_observation(self._specification)
def abort(self):
self._observation_control_dev.stop_observation(self._id)
def observation_proxy(self):
# return a proxy to the correct Observation device on the station ("STAT/Observation/{observation_id}")
return DeviceProxy(f"STAT/Observation/{self._id}")
def is_running(self):
# return whether the observation is still running (ObservationControl.is_observation_running command)
return self._observation_control_dev.is_observation_running(self._id)
@device_logging_to_python()
class ObservationControl(lofar_device):
""" Observation Control Device Server for LOFAR2.0
......
......@@ -11,7 +11,7 @@ from tangostationcontrol.test.devices.test_observation_base import TestObservati
from tangostationcontrol.integration_test import base
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
from tangostationcontrol.devices.observation.observation_control import ObservationWrapper
from lofar_station_client.observation.observation import Observation
from os import environ
from json import loads
......@@ -32,7 +32,7 @@ class TestObservation(base.IntegrationTestCase):
specification_dict = loads(TestObservationBase.VALID_JSON)
# create an observation class using the dict and as host just get it using a util function
observation = ObservationWrapper(specification=specification_dict, host=environ["TANGO_HOST"])
observation = Observation(specification=specification_dict, host=environ["TANGO_HOST"])
# Assert the observation is running after starting it
observation.start()
......
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