from collections.abc import Sequence

from ophyd_async.core import PathProvider, SignalR, StandardDetector

from ._blob_arm_logic import BlobArmLogic
from ._blob_data_logic import BlobDataLogic
from ._blob_trigger_logic import BlobTriggerLogic
from ._pattern_generator import PatternGenerator


class SimBlobDetector(StandardDetector):
    """Simulates a detector and writes Blobs to file."""

    def __init__(
        self,
        path_provider: PathProvider,
        pattern_generator: PatternGenerator | None = None,
        config_sigs: Sequence[SignalR] = (),
        name: str = "",
    ) -> None:
        self.pattern_generator = pattern_generator or PatternGenerator()
        self.add_detector_logics(
            BlobTriggerLogic(pattern_generator=self.pattern_generator),
            BlobArmLogic(pattern_generator=self.pattern_generator),
            BlobDataLogic(
                path_provider=path_provider, pattern_generator=self.pattern_generator
            ),
        )
        self.add_config_signals(*config_sigs)
        super().__init__(name=name)
