"""Type definitions for {{ module_name }}.

This module contains all Pydantic models, settings, and type definitions
for the {{ module_name }} robot arm module.

Generated by: madsci new module --template module/robot_arm
Template version: {{ template_version }}
"""

from typing import Literal, Optional

from madsci.node_module import RestNodeConfig
from pydantic import BaseModel, Field


class {{ module_name | pascal_case }}NodeConfig(RestNodeConfig):
    """Configuration for the {{ module_name | pascal_case }} node.

    This class defines all configuration options for the robot arm node.
    Values can be set via environment variables, config files, or programmatically.
    """

    # Server configuration
    node_url: str = Field(
        default="http://localhost:{{ port }}/",
        description="URL where the node REST API is served",
    )

    # Interface configuration
    interface_type: Literal["real", "fake"] = Field(
        default="real",
        description="Which interface to use (real or fake)",
    )

    # Device configuration
    device_number: int = Field(
        default=0,
        description="Device number for multi-device setups",
    )

    wait_time: float = Field(
        default=2.0,
        description="Time to wait while running an action, in seconds (simulates hardware timing)",
    )

    # Robot arm specific configuration
    default_speed: float = Field(
        default=50.0,
        description="Default movement speed in mm/s",
    )


class {{ module_name | pascal_case }}InterfaceConfig(BaseModel):
    """Configuration for the {{ module_name | pascal_case }} hardware interface.

    This class defines settings specific to the robot arm hardware interface,
    such as connection parameters, retry behavior, and workspace bounds.
    """

    connection_timeout: float = Field(
        default=10.0,
        description="Timeout for establishing connection to the robot arm, in seconds",
    )

    retry_count: int = Field(
        default=3,
        description="Number of retries for failed operations",
    )

    workspace_bounds: dict = Field(
        default_factory=lambda: {
            "x_min": 0,
            "x_max": 500,
            "y_min": 0,
            "y_max": 500,
            "z_min": 0,
            "z_max": 300,
        },
        description="Workspace boundaries for the robot arm in mm",
    )


class {{ module_name | pascal_case }}Position(BaseModel):
    """Position of the robot arm end-effector.

    Represents a 3D position with optional rotation for the robot arm.
    """

    x: float = Field(description="X coordinate in mm")
    y: float = Field(description="Y coordinate in mm")
    z: float = Field(description="Z coordinate in mm")
    r: Optional[float] = Field(
        default=None,
        description="Rotation angle in degrees (optional)",
    )


class {{ module_name | pascal_case }}Result(BaseModel):
    """Result from a {{ module_name }} robot arm operation.

    Use this model to define the structure of results from robot arm operations.
    """

    success: bool = Field(description="Whether the operation succeeded")
    data: Optional[dict] = Field(
        default=None,
        description="Result data from the operation",
    )
    error_message: Optional[str] = Field(
        default=None,
        description="Error message if operation failed",
    )
