Skip to content
Snippets Groups Projects
Select Git revision
  • 1b536a31fc466e0883aa05bf4b201ff5bce6a70c
  • main default protected
  • test-10rc4
  • test-pytango-10rc2
  • bassa-main-patch-68330
  • fix-hfd5-close-error
  • offer-ports-constant
  • fix-timestamps-refactor-matrix-construction
  • bugfixes
  • fix-bst-dimensions
  • fix-bsts
  • L2SS-1465-add-bst-metadata
  • L2SS-1464-add-antennafield-to-filename
  • L2SS-1451-simplify-cmdline
  • L2SS-1425-dont-rewrite-whole-dict
  • testing-specify-file
  • also-record-tilebeam-tracking-enabled
  • dont-modulo-16
  • remove-parse-device-attributes
  • support-higher-gn-indices
  • L2SS-1080_get_statistics_writer_package_version
  • v0.23
  • v0.22.3 protected
  • v0.22.dev4 protected
  • v0.22.dev3 protected
  • v0.22.2 protected
  • v0.22.1 protected
  • v0.22.dev2 protected
  • v0.22
  • v0.22.dev1 protected
  • v0.22.dev0 protected
  • v0.21
  • v0.21.dev6 protected
  • v0.21.dev5 protected
  • v0.21.dev4 protected
  • v0.21.dev3 protected
  • v0.21.dev2 protected
  • v0.21.dev1 protected
  • v0.21.dev0 protected
  • v0.20
  • v0.20.dev1 protected
41 results

observation.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    observation.py 2.07 KiB
    # -*- coding: utf-8 -*-
    #
    # This file is part of the LOFAR2.0 Station Control project.
    #
    # Distributed under the terms of the APACHE license.
    # See LICENSE.txt for more info.
    
    """
    Contains class for pythonic interface with observations
    """
    
    from json import dumps
    import logging
    
    from tango import DeviceProxy
    
    logger = logging.getLogger()
    
    
    class Observation:
        """
        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",
            station="STAT",
        ):
    
            # create device proxies to station at "host"
            self._observation_control_dev = DeviceProxy(
                f"tango://{host}/{station}/ObservationControl/1"
            )
            self.host = host
            self.station = station
    
            # convert specification dict to json
            self._specification = dumps(specification)
    
            # get the ID
            self._id = int(specification["observation_id"])
    
        def observation_id(self) -> int:
            """
            Returns the observation ID of this observation
            """
            return self._id
    
        def start(self):
            """
            Starts this observation
            """
            self._observation_control_dev.start_observation(self._specification)
    
        def abort(self):
            """
            Aborts this observation
            """
            self._observation_control_dev.stop_observation(self._id)
    
        def observation_proxy(self):
            """
            Returns the DeviceProxy of this observation
            """
            # return a proxy to the correct Observation device on the station (
            # "STAT/Observation/{observation_id}")
            return DeviceProxy(f"tango://{self.host}/{self.station}/Observation/{self._id}")
    
        def is_running(self):
            """
            Returns whether this observation is currently running or not
            """
            # return whether the observation is still running (
            # ObservationControl.is_observation_running command)
            return self._observation_control_dev.is_observation_running(self._id)