from collections.abc import Callable
from datetime import timedelta
from typing import Self
from pyautd3.driver.link import Link, LinkBuilder
from pyautd3.link.soem.adapter import EtherCATAdapter
from pyautd3.link.soem.status import Status
from pyautd3.link.soem.thread_priority import ThreadPriority
from pyautd3.native_methods.autd3capi import ControllerPtr
from pyautd3.native_methods.autd3capi import NativeMethods as Base
from pyautd3.native_methods.autd3capi_driver import HandlePtr, LinkBuilderPtr, LinkPtr, SyncMode
from pyautd3.native_methods.autd3capi_link_soem import NativeMethods as LinkSOEM
from pyautd3.native_methods.autd3capi_link_soem import ProcessPriority, ThreadPriorityPtr, TimerStrategy
from pyautd3.native_methods.autd3capi_link_soem import Status as _Status
from pyautd3.native_methods.utils import _validate_ptr



class _SOEMBuilder(LinkBuilder[SOEM]):
    def __init__(self, ) -> None: ...
    def _link_builder_ptr(self, ) -> LinkBuilderPtr: ...
    def _resolve_link(self, handle: HandlePtr, ptr: ControllerPtr) -> SOEM: ...
    def with_ifname(self, ifname: str) -> _SOEMBuilder: ...
    def with_buf_size(self, buf_size: int) -> _SOEMBuilder: ...
    def with_send_cycle(self, send_cycle: timedelta) -> _SOEMBuilder: ...
    def with_sync0_cycle(self, sync0_cycle: timedelta) -> _SOEMBuilder: ...
    def with_err_handler(self, err_handler: Callable[[int, Status], None] | None) -> _SOEMBuilder: ...
    def with_timer_strategy(self, timer_strategy: TimerStrategy) -> _SOEMBuilder: ...
    def with_sync_mode(self, sync_mode: SyncMode) -> _SOEMBuilder: ...
    def with_sync_tolerance(self, sync_tolerance: timedelta) -> _SOEMBuilder: ...
    def with_sync_timeout(self, sync_timeout: timedelta) -> _SOEMBuilder: ...
    def with_state_check_interval(self, state_check_interval: timedelta) -> _SOEMBuilder: ...
    def with_process_priority(self, process_priority: ProcessPriority) -> _SOEMBuilder: ...
    def with_thread_priority(self, thread_priority: ThreadPriorityPtr) -> _SOEMBuilder: ...
    @property
    def ifname(self) -> str: ...
    @property
    def buf_size(self) -> int: ...
    @property
    def send_cycle(self) -> timedelta: ...
    @property
    def sync0_cycle(self) -> timedelta: ...
    @property
    def err_handler(self) -> Callable[[int, Status], None] | None: ...
    @property
    def timer_strategy(self) -> TimerStrategy: ...
    @property
    def sync_mode(self) -> SyncMode: ...
    @property
    def sync_tolerance(self) -> timedelta: ...
    @property
    def sync_timeout(self) -> timedelta: ...
    @property
    def state_check_interval(self) -> timedelta: ...
    @property
    def process_priority(self) -> ProcessPriority: ...
    @property
    def thread_priority(self) -> ThreadPriorityPtr: ...

class SOEM(Link):
    def __init__(self, handle: HandlePtr, ptr: LinkPtr, err_handler: None) -> None: ...
    @staticmethod
    def enumerate_adapters() -> list[EtherCATAdapter]: ...
    @staticmethod
    def builder() -> _SOEMBuilder: ...
