from typing import Any
from typing import Dict
from typing import Optional

from ..exafs import scan_utils
from ..exafs.processor import ExafsProcessor


class Bm08ExafsProcessor(ExafsProcessor):

    def __init__(
        self,
        config: Optional[Dict[str, Any]] = None,
        defaults: Optional[Dict[str, Any]] = None,
    ) -> None:
        if defaults is None:
            defaults = {}

        defaults.setdefault(
            "workflow", "/home/opd08/ewoks/resources/dau_bm08/online_exafs_plots.ows"
        )
        defaults.setdefault("queue", "online")
        defaults.setdefault("_scan_type", "Kscan")
        counters = defaults.setdefault("_counters", dict())
        counters.setdefault(
            "Kscan",
            {
                "mu_name": "I1_eh2",
                "mon_name": "I0_eh2",
                "min_log": True,
                "energy_name": "energy",
                "energy_unit": "keV",
            },
        )

        super().__init__(config=config, defaults=defaults)

    def _scan_type_from_scan(self, scan: scan_utils.ScanType) -> Optional[str]:
        scan_parameters = scan.scan_info.get("scan_parameters", {})
        return scan_parameters.get("scan_type")

    def _multi_xas_scan(self, scan: scan_utils.ScanType) -> bool:
        return False

    def _multi_xas_subscan_size(self, scan: scan_utils.ScanType) -> int:
        raise NotImplementedError
