import logging

logger = logging.getLogger(__name__)

class DJIDroneAdapter:
    """大疆无人机适配器（模拟模式）"""
    
    def __init__(self):
        self.is_connected = False
        self.mock_mode = True  # 模拟模式，不需要真实硬件

    def connect(self):
        """连接无人机"""
        try:
            self.is_connected = True
            logger.info("成功连接大疆无人机（模拟模式）")
        except Exception as e:
            logger.error(f"连接失败: {str(e)}")
            raise

    def takeoff(self, height: float = 1.0):
        """起飞到指定高度（米）"""
        if not 1 <= height <= 10:
            raise ValueError("高度超出有效范围 (1-10 米)")
        
        if self.mock_mode:
            logger.info(f"模拟起飞到高度: {height}米")

    def land(self):
        """降落"""
        if self.mock_mode:
            logger.info("正在降落...")

    def emergency_stop(self):
        """紧急停止"""
        if self.mock_mode:
            logger.warning("已触发紧急停止（模拟模式）")

    def get_battery_status(self):
        """获取电池状态"""
        if self.mock_mode:
            return {"battery": 100, "mode": "mock"}
        return None

    def disconnect(self):
        """断开连接"""
        if self.is_connected:
            self.is_connected = False
            logger.info("已断开无人机连接")