"""Module for the retrieval processors."""
from __future__ import annotations
import enum
from dataclasses import dataclass
[docs]
class ProcessorName(str, enum.Enum):
"""Preprocessors for data from the archiver.
https://epicsarchiver.readthedocs.io/en/latest/user/userguide.html#processing-of-data
"""
[docs]
FIRSTSAMPLE = "firstSample"
[docs]
LASTSAMPLE = "lastSample"
[docs]
FIRSTFILL = "firstFill"
[docs]
IGNOREFLYERS = "ignoreflyers"
[docs]
POPVARIANCE = "popvariance"
[docs]
OPTIMIZED = "optimized"
[docs]
OPTIMLASTSAMPLE = "optimLastSample"
[docs]
CAPLOTBINNING = "caplotbinning"
@dataclass
[docs]
class Processor:
"""Representation of a preprocessor."""
[docs]
processor_name: ProcessorName
[docs]
def calc_pv_name(self, pv: str) -> str:
"""Calculate PV Name to request from the archiver.
Args:
pv (str): base pv name
Returns:
str: the preprocessor string
"""
if self.bin_size:
return f"{self.processor_name.value}_{self.bin_size}({pv})"
return f"{self.processor_name.value}({pv})"