Commit 5e37875b authored by Matias Guijarro's avatar Matias Guijarro Committed by Wout De Nolf
Browse files

remove NonScannableHasMetadataForScan

parent 4b31ca2b
......@@ -129,8 +129,6 @@ class HasMetadataForScan(ABC):
The `scan_metadata` method is called by the acquisition chain
objects `AcquisitionObject` (directly or indirectly).
Controllers not involved in the acquisition chain should use
the `NonScannableHasMetadataForScan` protocol.
"""
def scan_metadata(self) -> Union[dict, None]:
......
......@@ -30,7 +30,6 @@ from bliss.common.utils import UserNamespace
from bliss.common import constants
from bliss.scanning import scan_saving
from bliss.scanning import scan_display
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
_SESSION_IMPORTERS = set()
......@@ -751,8 +750,6 @@ class Session:
setup_ret = self._setup(env_dict)
ret = ret and setup_ret
self.register_metadata_generators(env_dict)
return ret
def setup(
......@@ -841,7 +838,6 @@ class Session:
def close(self):
setup_globals.__dict__.clear()
self.unregister_metadata_generators(self.env_dict)
for obj_name, obj in self.env_dict.items():
if obj is self or obj is self.config:
continue
......@@ -975,18 +971,6 @@ class Session:
self.setup(self.env_dict, verbose)
@staticmethod
def register_metadata_generators(env_dict):
for o in env_dict.values():
if isinstance(o, NonScannableHasMetadataForScan):
o.enable_scan_metadata()
@staticmethod
def unregister_metadata_generators(env_dict):
for o in env_dict.values():
if isinstance(o, NonScannableHasMetadataForScan):
o.disable_scan_metadata()
class DefaultSession(Session):
"""Session without config, setup scripts and data policy
......
......@@ -21,14 +21,14 @@ from bliss.controllers.counter import counter_namespace
from bliss.scanning.chain import ChainPreset, ChainIterationPreset
from bliss.common import tango
from bliss.common.protocols import HasMetadataForDataset
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
from bliss.scanning.scan_meta import HasMetadataForScan
from bliss.controllers.tango_attr_as_counter import (
TangoCounterController,
TangoAttrCounter,
)
class MachInfo(BeaconObject, NonScannableHasMetadataForScan, HasMetadataForDataset):
class MachInfo(BeaconObject, HasMetadataForScan, HasMetadataForDataset):
""" Access to accelerator information.
- SR_Current
- SR_Lifetime
......
......@@ -51,7 +51,7 @@ import time
import math
import gevent
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
from bliss.common.protocols import HasMetadataForScan
from bliss.controllers.motor import Controller
from bliss.common.axis import AxisState
from bliss.common.tango import DevState, DeviceProxy
......@@ -72,7 +72,7 @@ from bliss.shell.cli.pt_widgets import display, BlissDialog
__author__ = "Jens Meyer / Gilles Berruyer - ESRF ISDD SOFTGROUP BLISS - June 2019"
class esrf_hexapode(Controller, NonScannableHasMetadataForScan):
class esrf_hexapode(Controller, HasMetadataForScan):
""" Class to implement BLISS motor controller of esrf hexapode controlled
via tango device server
"""
......
......@@ -7,8 +7,7 @@
from bliss.controllers.motor import CalcController
from bliss.common.logtools import user_warning, log_debug
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
from bliss.common.protocols import HasMetadataForDataset
from bliss.common.protocols import HasMetadataForScan, HasMetadataForDataset
"""
example for single VERTICAL slits:
......@@ -86,7 +85,7 @@ example for single HORIZONTAL slits:
"""
class Slits(CalcController, NonScannableHasMetadataForScan, HasMetadataForDataset):
class Slits(CalcController, HasMetadataForScan, HasMetadataForDataset):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.slit_type = self.config.get("slit_type", default="both")
......
......@@ -76,7 +76,7 @@ import warnings
from tabulate import tabulate
from gevent import Timeout
from bliss.common.protocols import HasMetadataForDataset
from bliss.common.protocols import HasMetadataForScan, HasMetadataForDataset
from bliss.common.motor_group import Group
from bliss.common.axis import AxisState
from bliss.config.channels import Channel
......@@ -84,10 +84,9 @@ from bliss.common import event
from bliss.common.utils import flatten
from bliss.common.logtools import log_warning, log_error
from bliss import global_map, is_bliss_shell
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
class MultiplePositions(HasMetadataForDataset, NonScannableHasMetadataForScan):
class MultiplePositions(HasMetadataForDataset, HasMetadataForScan):
""" Handle multiple positions.
"""
......
......@@ -79,7 +79,7 @@ from bliss.common.utils import grouped
from bliss.controllers.wago.wago import WagoController, ModulesConfig, get_wago_comm
from bliss.config import channels
from bliss.common.event import dispatcher
from bliss.scanning.scan_meta import NonScannableHasMetadataForScan
from bliss.common.protocols import HasMetadataForScan
class TfWagoMapping:
......@@ -158,7 +158,7 @@ def _encode(status):
raise ValueError("Invalid position {!r}".format(status))
class Transfocator(NonScannableHasMetadataForScan):
class Transfocator(HasMetadataForScan):
"""
The lenses are controlled pneumatically via WAGO output modules.
The position is red from WAGO input modules.
......
......@@ -276,53 +276,3 @@ def fill_positioners(scan):
rd["positioners_units"] = units
return rd
class NonScannableHasMetadataForScan(HasMetadataForScan):
"""Any controller which provides metadata intended to be saved
during a scan life cycle.
This protocol needs to be used for controllers not involved
in the acquisition chain. `enable_scan_metadata` is called by
the session for all objects with this protocol.
"""
def _metadata_generator(self):
"""
Metadata generator registred with the instrument category
of user scan metadata.
"""
metadata_name = self.scan_metadata_name
if metadata_name:
return {metadata_name: self.scan_metadata()}
else:
user_warning(str(self) + "needs a name to publish scan metadata")
return dict()
def enable_scan_metadata(self):
scan_meta_obj = get_user_scan_meta()
# We do not want to keep a reference to self
# in the scan_meta_obj
prx = weakref.proxy(self)
def metadata_generator(_):
try:
return prx._metadata_generator()
except ReferenceError:
return dict()
scan_meta_obj.instrument.set(self, metadata_generator)
def disable_scan_metadata(self):
scan_meta_obj = get_user_scan_meta()
scan_meta_obj.instrument.remove(self)
@property
def scan_metadata_enabled(self):
scan_meta_obj = get_user_scan_meta()
return scan_meta_obj.is_set(self)
@property
def scan_metadata_name(self):
raise NotImplementedError
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment