# Copyright (c) Acconeer AB, 2023-2025
# All rights reserved

from acconeer.exptool import a121

from ._ref_app import PresenceWakeUpConfig, PresenceZoneConfig, RefAppConfig


def get_short_range_config() -> RefAppConfig:
    return RefAppConfig(
        wake_up_mode=True,
        wake_up_config=PresenceWakeUpConfig(
            start_m=0.5,
            end_m=1.0,
            frame_rate=2,
            sweeps_per_frame=16,
            automatic_subsweeps=True,
            signal_quality=30.0,
            hwaas=16,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.5,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=5,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=1,
            num_zones_for_wake_up=1,
        ),
        nominal_config=PresenceZoneConfig(
            start_m=0.06,
            end_m=1.0,
            frame_rate=10,
            sweeps_per_frame=16,
            automatic_subsweeps=True,
            signal_quality=30.0,
            hwaas=16,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.4,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=5,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=5,
        ),
    )


def get_medium_range_config() -> RefAppConfig:
    return RefAppConfig(
        wake_up_mode=True,
        wake_up_config=PresenceWakeUpConfig(
            start_m=1.5,
            end_m=2.5,
            frame_rate=2,
            sweeps_per_frame=16,
            automatic_subsweeps=True,
            signal_quality=20.0,
            hwaas=32,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.5,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=1,
            num_zones_for_wake_up=1,
        ),
        nominal_config=PresenceZoneConfig(
            start_m=0.3,
            end_m=2.5,
            frame_rate=12,
            sweeps_per_frame=16,
            automatic_subsweeps=True,
            signal_quality=20.0,
            hwaas=32,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.3,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=6,
        ),
    )


def get_long_range_config() -> RefAppConfig:
    return RefAppConfig(
        wake_up_mode=True,
        wake_up_config=PresenceWakeUpConfig(
            start_m=3,
            end_m=5,
            frame_rate=2,
            sweeps_per_frame=32,
            automatic_subsweeps=True,
            signal_quality=10.0,
            hwaas=48,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.4,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=5,
            num_zones_for_wake_up=2,
        ),
        nominal_config=PresenceZoneConfig(
            start_m=2,
            end_m=5,
            frame_rate=12,
            sweeps_per_frame=32,
            automatic_subsweeps=True,
            signal_quality=10.0,
            hwaas=48,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.2,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=0.8,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=5,
        ),
    )


def get_ceiling_config() -> RefAppConfig:
    return RefAppConfig(
        wake_up_mode=True,
        wake_up_config=PresenceWakeUpConfig(
            start_m=2,
            end_m=3.5,
            frame_rate=4,
            sweeps_per_frame=24,
            automatic_subsweeps=True,
            signal_quality=13.0,
            hwaas=32,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.5,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.25,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=0.5,
            inter_frame_presence_timeout=3,
            num_zones=1,
            num_zones_for_wake_up=1,
        ),
        nominal_config=PresenceZoneConfig(
            start_m=1.5,
            end_m=3.5,
            frame_rate=12,
            sweeps_per_frame=18,
            automatic_subsweeps=True,
            signal_quality=13.0,
            hwaas=18,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.2,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=0.8,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=6,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=1,
        ),
    )


def get_low_power_config() -> RefAppConfig:
    return RefAppConfig(
        wake_up_mode=True,
        wake_up_config=PresenceWakeUpConfig(
            start_m=0.38,
            end_m=0.67,
            frame_rate=0.7,
            automatic_subsweeps=False,
            signal_quality=20.0,
            sweeps_per_frame=8,
            hwaas=8,
            profile=a121.Profile.PROFILE_5,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.7,
            intra_frame_time_const=0.3,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1.2,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=5,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=0.5,
            inter_frame_presence_timeout=2,
            num_zones=1,
            num_zones_for_wake_up=1,
        ),
        nominal_config=PresenceZoneConfig(
            start_m=0.38,
            end_m=0.67,
            frame_rate=5,
            sweeps_per_frame=16,
            automatic_subsweeps=True,
            signal_quality=20.0,
            hwaas=8,
            inter_frame_idle_state=a121.IdleState.DEEP_SLEEP,
            intra_enable=True,
            intra_detection_threshold=1.4,
            intra_frame_time_const=0.15,
            intra_output_time_const=0.3,
            inter_enable=True,
            inter_detection_threshold=1,
            inter_frame_slow_cutoff=0.2,
            inter_frame_fast_cutoff=5,
            inter_frame_deviation_time_const=0.5,
            inter_output_time_const=2,
            inter_frame_presence_timeout=3,
            num_zones=1,
        ),
    )
