package com.its.onvif.cmra.server.dto;

public enum PtzDirection {
    PAN_LEFT("PAN_LEFT", 1, new PtzVector(-1f, 0f, 0f), "좌측 이동"),
    PAN_RIGHT("PAN_RIGHT", 2, new PtzVector(1f, 0f, 0f), "우측 이동"),
    TILT_UP("TILT_UP", 3, new PtzVector(0f, 1f, 0f), "위로 이동"),
    TILT_DOWN("TILT_DOWN", 4, new PtzVector(0f, -1f, 0f), "아래로 이동"),
    PAN_TILT_UP_LEFT("PAN_TILT_UP_LEFT", 5, new PtzVector(-1f, 1f, 0f), "좌측 위로 이동"),
    PAN_TILT_UP_RIGHT("PAN_TILT_UP_RIGHT", 6, new PtzVector(1f, 1f, 0f), "우측 위로 이동"),
    PAN_TILT_DOWN_LEFT("PAN_TILT_DOWN_LEFT", 7, new PtzVector(-1f, -1f, 0f), "좌측 아래로 이동"),
    PAN_TILT_DOWN_RIGHT("PAN_TILT_DOWN_RIGHT", 8, new PtzVector(1f, -1f, 0f), "우측 아래로 이동"),
    ZOOM_IN("ZOOM_IN", 9, new PtzVector(0f, 0f, 1f), "줌 인"),
    ZOOM_OUT("ZOOM_OUT", 10, new PtzVector(0f, 0f, -1f), "줌 아웃"),
    HOME("HOME", 11, new PtzVector(0f, 0f, 0f), "홈 위치 복귀");

    private final String label;
    private final int code;
    private final PtzVector vector;
    private final String description;

    PtzDirection(String label, int code, PtzVector vector, String description) {
        this.label = label;
        this.code = code;
        this.vector = vector;
        this.description = description;
    }

    public String getLabel() { return label; }
    public int getCode() { return code; }
    public PtzVector getVector() { return vector; }
    public String getDescription() { return description; }

    public static PtzDirection fromType(Integer type) {
        for (PtzDirection dir : values()) {
            if (dir.code == type) return dir;
        }
        throw new IllegalArgumentException("지원하지 않는 PTZ 타입입니다: " + type);
    }
    public static PtzDirection fromTypeOrStop(Integer type) {
        if (type == null || type == 0) return null; // for STOP case
        for (PtzDirection dir : values()) {
            if (dir.getCode() == type) return dir;
        }
        throw new IllegalArgumentException("지원하지 않는 PTZ 타입입니다: " + type);
    }

}
