package com.phlx.anchorcollect.util;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


public class ConstantUtil {


    /**
     * 是否保持屏幕常亮
     */
    public static boolean isKeepScreenLight = true;

    public static int MODULE_TYPE_SELECTED = 2;
    public static int LABEL_TYPE_SELECTED = 0;


    public static String PERFORMANCE_MULTI_LABEL="多标签";
    public static String PERFORMANCE_COMMON="常规";
    public static String PERFORMANCE_FAST="近距离快盘";
    /**
     * 当前测试设备的类型
     */
    public static boolean R2000 = true;
    public static boolean R2000Plus = false;
    public static boolean MagicRF = false;

    /**
     * 蓝牙类型
     */
    public static String BLUETOOTH_TYPE_BT = "经典蓝牙";
    public static String BLUETOOTH_TYPE_BLE = "低功耗蓝牙";
    /**
     * 设备直连单片机，单片机连接设备
     */
    public static boolean RM70XX = false;
    public static boolean RM600X = false;
    public static boolean RM601X = false;
    public static boolean RM600XPlus = false;
    /**
     * RM70XX 模式下，单片机连接的设备类型
     */
    public static boolean RM70XX_R2000=true;
    public static boolean RM70XX_MagicRF;
    public static boolean RM70XX_R2000Plus;

    /**
     *  设备是否连接
     */
    public static boolean IS_MODULE_CONNECTED;

    /**
     * 标签测试类型
     */
    public static boolean Label_6C = true;
    public static boolean Label_6B = false;
    public static boolean Label_GB = false;
    public static boolean Label_GJB = false;

    /**
     * 设备的版本号
     */
    public static String VERSION = "";
    public static String SERIAL_VERSION = "";
    /**
     * 单片机的版本号
     */
    public static String RM70XX_VERSION = "";
    public static String RM70XX_SERIAL_VERSION = "";
    /**
     * 单片机连接的设备类型
     */
    public static String RM70XX_TYPE = "";


    public static UUID uuid_service = null;
    public static UUID uuid_notify = null;
    public static UUID uuid_indicate = null;
    public static UUID uuid_write = null;
    public final static String STR_UUID = "00001101-0000-1000-8000-00805F9B34FB";


    private static Map<String, String> firmMap;
    private static Map<String, Map<String, String>> modelMap;

    static {

        firmMap = new HashMap<>();
        modelMap = new HashMap<>();
        firmMap.put("01", "Impinj");
        firmMap.put("02", "Texas Instruments");
        firmMap.put("03", "Alien Technology");
        firmMap.put("04", "Intelleflex");
        firmMap.put("05", "Atmel");
        firmMap.put("06", "NXP Semiconductors");
        firmMap.put("07", "ST Microelectronics");
        firmMap.put("08", "EP Microelectronics");
        firmMap.put("09", "Motorola");
        firmMap.put("0A", "Sentech Snd Bhd");
        firmMap.put("0B", "EM Microelectronics");
        firmMap.put("0C", "Renesas Technology Corp");
        firmMap.put("0D", "Mstar");
        firmMap.put("0E", "Tyco International");
        firmMap.put("0F", "Quanray Electronics");
        firmMap.put("10", "Fujitsu");
        firmMap.put("11", "LSIS");
        firmMap.put("12", "CAEN RFID Srl");
        firmMap.put("13", "Productivity Engineeering Gesellschaftfure IC Design mbH");
        firmMap.put("14", "Federal Electric Corp");
        firmMap.put("15", "ON Semiconductor");
        firmMap.put("16", "Ramtron");
        firmMap.put("17", "Tego");
        firmMap.put("18", "Ceitec S.A.");
        firmMap.put("19", "CPA Wernher von Braun");
        firmMap.put("1A", "TransCore");
        firmMap.put("1B", "Notionz");
        firmMap.put("1C", "Invengo");
        firmMap.put("1D", "Kilpway");
        firmMap.put("1E", "Longjing Microelectronics Co.Ltd.");
        firmMap.put("1F", "Chipus Microelectronics");
        firmMap.put("81", "华大");
        //Impinj---01
        Map<String, String> map01 = new HashMap<>();
        map01.put("093", "Monza3");
        map01.put("104", "Monza3");
        map01.put("105", "Monza4QT");
        map01.put("10C", "Monza4QE");
        map01.put("100", "Monza4QD");
        map01.put("130", "Monza5");
        modelMap.put("01", map01);
        //Alien----03
        Map<String, String> map03 = new HashMap<>();
        map03.put("411", "Alien H2");
        map03.put("412", "Alien H3");
        map03.put("413", "Alien H3");
        map03.put("414", "Alien H4");
        modelMap.put("03", map03);

        //NXP-----06
        Map<String, String> map06 = new HashMap<>();
        map06.put("00X", "NXP");
        map06.put("001", "UCODE EPC G2");
        map06.put("003", "nxp_G2XM");
        map06.put("004", "nxp_G2XL");
        map06.put("806", "nxp_G2iL");
        map06.put("807", "nxp_G2iL+");
        map06.put("80A", "nxp_G2iM");
        map06.put("80B", "nxp_G2iM+");
        modelMap.put("06", map06);
        //坤锐 Quanray Electronics------0F
        Map<String, String> map0F = new HashMap<>();
        map0F.put("351", "无型号");
        modelMap.put("0F", map0F);
        //华大-------81
        Map<String, String> map81 = new HashMap<>();
        map81.put("000", "无型号");
        modelMap.put("81", map81);


    }

    public static String getFirm(String firmKey) {
        if (firmMap.containsKey(firmKey)) {
            return firmMap.get(firmKey);
        } else {
            return "未知厂家标签";
        }
    }

    public static String getModel(String firmKey, String modelKey) {
        if (modelMap.containsKey(firmKey)) {
            Map<String, String> map = modelMap.get(firmKey);
            if (map.containsKey(modelKey)) {
                return map.get(modelKey);
            } else {
                return "未知型号标签";
            }
        } else {
            return "未知型号标签";
        }
    }

    /**
     * 判断十六进制
     */
    public static boolean IsHex(String str) {
        boolean b = false;

        char[] c = str.toUpperCase().toCharArray();
        for (char aC : c) {
            if ((aC >= '0' && aC <= '9') || (aC >= 'A' && aC <= 'F')) {
                b = true;
            } else {
                b = false;
                break;
            }
        }
        return b;
    }
}
