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

more complete HasMetadataForScan with disable_scan_metadata,...

more complete HasMetadataForScan with disable_scan_metadata, scan_metadata_enabled, enable_scan_metadata, scan_metadata_name, strict_scan_metadata

The strict_scan_metadata property tells if the metadata is useful to be
reported for any scan (returns False, for example: machine info) or
only when the controller is present in the scan
(returns True, for example: Lima or MCA). Default is False.
parent 5e37875b
......@@ -131,9 +131,40 @@ class HasMetadataForScan(ABC):
objects `AcquisitionObject` (directly or indirectly).
"""
def disable_scan_metadata(self):
self.__disabled_scan_metadata = True
@property
def scan_metadata_enabled(self):
try:
return not self.__disabled_scan_metadata
except AttributeError:
return True
def enable_scan_metadata(self):
self.__disabled_scan_metadata = False
def scan_metadata(self) -> Union[dict, None]:
"""
Returning an empty dictionary means the controller has metadata
but no values. `None` means the controller has no metadata.
"""
raise NotImplementedError
@property
def scan_metadata_name(self) -> Union[str, None]:
"""
Default implementation returns self.name, can be overwritten in derived classes
Returns None when there is no name
"""
try:
return self.name
except AttributeError:
return None
@property
def strict_scan_metadata(self):
"""
Return whether metadata has to be reported only if the controller is involved in the scan
"""
return False
......@@ -156,6 +156,10 @@ class Lima(CounterController, HasMetadataForScan):
self, parents_list=["lima", "controllers"], children_list=[self._proxy]
)
@property
def strict_scan_metadata(self):
return True
def scan_metadata(self) -> dict:
return {"type": "lima"}
......
......@@ -113,6 +113,10 @@ class BaseMCA(CounterController, HasMetadataForScan):
self.initialize_attributes()
self.initialize_hardware()
@property
def strict_scan_metadata(self):
return True
def scan_metadata(self) -> dict:
return {"type": "mca"}
......
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