import { ELocalStorageKey } from "../types";

export const getTextByModeCode = (code: number) => {
    let text = '';
    switch (code) {
        case 0:
            text = '待机';
            break;
        case 1:
            text = '起飞准备';
            break;
        case 2:
            text = '起飞准备完毕';
            break;
        case 3:
            text = '手动飞行';
            break;
        case 4:
            text = '自动起飞';
            break;
        case 5:
            text = '航线飞行';
            break;
        case 6:
            text = '全景拍照';
            break;
        case 7:
            text = '智能跟随';
            break;
        case 8:
            text = 'ADS-B 躲避';
            break;
        case 9:
            text = '自动返航';
            break;
        case 10:
            text = '自动降落';
            break;
        case 11:
            text = '强制降落';
            break;
        case 12:
            text = '三桨叶降落';
            break;
        case 13:
            text = '升级中';
            break;
        case 14:
            text = '未连接';
            break;
        case 15:
            text = 'APAS';
            break;
        case 16:
            text = '虚拟摇杆状态';
            break;
        case 17:
            text = '指令飞行';
            break;
        case 18:
            text = '空中 RTK 收敛模式';
            break;
        default:
            break;
    }
    return text;
}

export const getTextByDockModeCode = (code: number) => {
    let text = '';
    switch (code) {
        case -1:
            text = '设备已离线';
            break;
        case 0:
            text = '空闲中';
            break;
        case 1:
            text = '现场调试';
            break;
        case 2:
            text = '远程调试';
            break;
        case 3:
            text = '固件升级中';
            break;
        case 4:
            text = '作业中';
            break;
        default:
            break;
    }
    return text;
}

export const getTextByDockTaskCode = (code: number) => {
    let text = '';
    switch (code) {
        case 0:
            text = '作业准备中';
            break;
        case 1:
            text = '飞行作业中';
            break;
        case 2:
            text = '作业后状态恢复';
            break;
        case 3:
            text = '自定义飞行区更新中';
            break;
        case 4:
            text = '地形障碍物更新中';
            break;
        case 5:
            text = '任务空闲';
            break;
        case 255:
            text = '飞行器异常';
            break;
        case 256:
            text = '未知状态';
            break;
        default:
            break;
    }
    return text;
}

export const getWindDirection = (code: number) => {
    let text = '';
    switch (code) {
        case 1:
            text = 'N';
            break;
        case 2:
            text = 'NE';
            break;
        case 3:
            text = 'E';
            break;
        case 4:
            text = 'SE';
            break;
        case 5:
            text = 'S';
            break;
        case 6:
            text = 'SW';
            break;
        case 7:
            text = 'W';
            break;
        case 8:
            text = 'NW';
            break;
        default:
            break;
    }
    return text;
}

// 获取项目ID
export const getWorkspaceId = () => {
    return localStorage.getItem(ELocalStorageKey.WorkspaceId) || '';
}