import ctypes
from collections.abc import Iterable
from datetime import timedelta
from typing import Self
import numpy as np
from pyautd3.derive import datagram
from pyautd3.derive.derive_builder import builder
from pyautd3.derive.derive_datagram import datagram_with_segment
from pyautd3.driver.datagram.datagram import Datagram
from pyautd3.driver.datagram.gain import Gain
from pyautd3.driver.datagram.stm.stm_sampling_config import STMSamplingConfig
from pyautd3.driver.datagram.with_segment import DatagramS
from pyautd3.driver.defined.freq import Freq
from pyautd3.driver.firmware.fpga import LoopBehavior
from pyautd3.driver.firmware.fpga.sampling_config import SamplingConfig
from pyautd3.driver.firmware.fpga.transition_mode import TransitionMode
from pyautd3.driver.geometry import Geometry
from pyautd3.native_methods.autd3capi import NativeMethods as Base
from pyautd3.native_methods.autd3capi_driver import DatagramPtr
from pyautd3.native_methods.autd3capi_driver import GainPtr
from pyautd3.native_methods.autd3capi_driver import GainSTMMode
from pyautd3.native_methods.autd3capi_driver import GainSTMPtr
from pyautd3.native_methods.autd3capi_driver import Segment
from pyautd3.native_methods.autd3capi_driver import TransitionModeWrap
from pyautd3.native_methods.autd3capi_driver import LoopBehavior as _LoopBehavior
from pyautd3.native_methods.utils import _validate_ptr
from datetime import timedelta
from pyautd3.driver.datagram.with_timeout import DatagramWithTimeout
from pyautd3.driver.datagram.with_parallel_threshold import DatagramWithParallelThreshold
from pyautd3.native_methods.autd3capi_driver import Segment, TransitionModeWrap
from pyautd3.driver.datagram.with_segment import DatagramWithSegment



class GainSTM(DatagramS[GainSTMPtr], Datagram):
    _gains: np.ndarray
    _stm_sampling_config: STMSamplingConfig
    def __private_init__(self: GainSTM, sampling_config: STMSamplingConfig, gains: list[Gain]) -> None: ...
    def __init__(self: GainSTM, config: SamplingConfig | Freq[float] | timedelta, iterable: Iterable[Gain]) -> None: ...
    def _raw_ptr(self: GainSTM, geometry: Geometry) -> GainSTMPtr: ...
    def _ptr(self: GainSTM, gains: np.ndarray) -> GainSTMPtr: ...
    def _datagram_ptr(self: GainSTM, geometry: Geometry) -> DatagramPtr: ...
    def _into_segment(self: GainSTM, ptr: GainSTMPtr, segment: Segment, transition_mode: TransitionModeWrap | None) -> DatagramPtr: ...
    def _sampling_config_intensity(self: GainSTM, ) -> SamplingConfig: ...
    def _sampling_config_phase(self: GainSTM, ) -> SamplingConfig: ...
    def with_mode(self: GainSTM, mode: GainSTMMode) -> GainSTM: ...
    def with_loop_behavior(self: GainSTM, loop_behavior: _LoopBehavior) -> GainSTM: ...
    def with_timeout(self: GainSTM, timeout: timedelta | None) -> DatagramWithTimeout[GainSTM]: ...
    def with_parallel_threshold(self: GainSTM, threshold: int | None) -> DatagramWithParallelThreshold[GainSTM]: ...
    def with_segment(self: GainSTM, segment: Segment, transition_mode: TransitionModeWrap | None) -> DatagramWithSegment[GainSTM]: ...
    @classmethod
    def nearest(cls, config: Freq[float] | timedelta, iterable: Iterable[Gain]) -> GainSTM: ...
    @property
    def freq(self: GainSTM) -> Freq[float]: ...
    @property
    def period(self: GainSTM) -> timedelta: ...
    @property
    def sampling_config(self: GainSTM) -> SamplingConfig: ...
    @property
    def mode(self: GainSTM) -> GainSTMMode: ...
    @property
    def loop_behavior(self: GainSTM) -> _LoopBehavior: ...
