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

from ...bliss_globals import setup_globals
from ...bm08.exafs_plotter import Bm08ExafsProcessor
from ...resources import resource_filename


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

        defaults.setdefault("queue", "celery")
        defaults.setdefault("workflow", resource_filename("exafs", "exafs.ows"))
        defaults.setdefault("_scan_type", "Kscan")
        counters = defaults.setdefault("_counters", dict())

        if self._HAS_BLISS:
            energy_unit = setup_globals.energy.unit or "eV"
            counters.setdefault(
                "Kscan",
                {
                    "mu_name": "mu",
                    "mon_name": "mu",
                    "min_log": True,
                    "energy_name": "energy",
                    "energy_unit": energy_unit,
                },
            )

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