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

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

Generated by: madsci new module --template module/liquid_handler
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 liquid handler 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)",
    )

    # Liquid handler specific configuration
    tip_capacity: int = Field(
        default=8,
        description="Number of tip channels available on the liquid handler",
    )

    max_volume_ul: float = Field(
        default=1000.0,
        description="Maximum pipette volume in microliters",
    )


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

    This class defines settings specific to the hardware interface,
    such as connection parameters, retry behavior, and pipetting defaults.
    """

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

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

    default_speed_ul_per_s: float = Field(
        default=100.0,
        description="Default pipetting speed in microliters per second",
    )


class {{ module_name | pascal_case }}AspirateCommand(BaseModel):
    """Command to aspirate liquid using the {{ module_name }} liquid handler.

    Use this model to define the parameters for an aspirate operation.
    """

    volume_ul: float = Field(description="Volume to aspirate in microliters")
    speed_ul_per_s: Optional[float] = Field(
        default=None,
        description="Aspiration speed in microliters per second (uses default if None)",
    )
    well: Optional[str] = Field(
        default=None,
        description="Well identifier to aspirate from (e.g., 'A1')",
    )


class {{ module_name | pascal_case }}DispenseCommand(BaseModel):
    """Command to dispense liquid using the {{ module_name }} liquid handler.

    Use this model to define the parameters for a dispense operation.
    """

    volume_ul: float = Field(description="Volume to dispense in microliters")
    speed_ul_per_s: Optional[float] = Field(
        default=None,
        description="Dispense speed in microliters per second (uses default if None)",
    )
    well: Optional[str] = Field(
        default=None,
        description="Well identifier to dispense into (e.g., 'A1')",
    )


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

    Use this model to define the structure of results from liquid handling 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",
    )
