from abc import ABC, abstractmethod
from .logger import setup_logging, get_logger

from .schemas import PTZPosition

setup_logging()


class BaseController(ABC):
    """Базовый класс контроллера"""

    def __init__(self, ip: str, port: int = 80, home_pos: list[float] | None = None):
        self.ip = ip
        self.port = port
        self.home_position = PTZPosition(*home_pos) if home_pos else PTZPosition()
        self._connection = False
        self._last_update = 0
        self.logger = get_logger(self.__class__.__name__)

    @property
    @abstractmethod
    def connection(self) -> bool:
        pass

    @property
    @abstractmethod
    def position(self) -> list[float]:
        pass

    @abstractmethod
    def rc_control(self, *channels: int):
        pass

    @abstractmethod
    def goto(self, pan: int, tilt: int, zoom: int):
        pass

    @abstractmethod
    def goto_preset(self, preset_id: int):
        pass
