package com.sxyz.rfid.widgets;

/*
 * Copyright (C) 2019, Urovo Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @Author: rocky
 * @Date: 20-7-13上午11:21
 */

import android.device.scanner.configuration.Symbology;
import android.text.TextUtils;
import android.util.SparseArray;

public final class OEMSymbologyId {
    //ScanManager 方法获取扫描头类型 getOutputParameter(7);
    public static final int TYPE_SE955 = 2;//Zebra
    public static final int TYPE_SE4750 = 4; // Zebra
    public static final int TYPE_HONYWARE = 3;//HoneyWell

    public static final int TYPE_N6703 = 5;//HoneyWell

    public static final int TYPE_N3680 = 6;//HoneyWell

    public static final int TYPE_N6603 = 8;//HoneyWell

    public static final int TYPE_SE2100 = 9;//Zebra

    public static final int TYPE_SE4710 = 13;//Zebra

    public static final int TYPE_SE2030 = 15;//N603



    public  static int getSymbologyId(int type){
        int result=HoneyWellEngine;
        switch (type)
        {
            case TYPE_SE955:
            case TYPE_SE4750:
            case TYPE_SE2100:
            case TYPE_SE4710:
                result=ZebraEngine;
            break;
            case TYPE_HONYWARE:
            case TYPE_N6703:
            case TYPE_N3680:
            case TYPE_N6603:
                result=HoneyWellEngine;
                break;
            case TYPE_SE2030:
                result=CommonEngine;
                break;
        }
        return result;
    }

    static {
        loadHoneyWellTable();
        loadZebraTable();
        loadCommonTable();
    }
    //-----------------------------------------------------------------------------
    //  Hand Held Products Symbology ID characters
    //-----------------------------------------------------------------------------
    public static final int HSM_SYMID_AZTEC = 'z';
    public static final int HSM_SYMID_CODABAR = 'a';
    public static final int HSM_SYMID_CODE11 = 'h';
    public static final int HSM_SYMID_CODE128 = 'j';
    public static final int HSM_SYMID_EAN128 = 'I';
    public static final int HSM_SYMID_CODE39 = 'b';
    public static final int HSM_SYMID_CODE49 = 'l';
    public static final int HSM_SYMID_CODE93 = 'i';
    public static final int HSM_SYMID_COMPOSITE = 'y';
    public static final int HSM_SYMID_DATAMATRIX = 'w';
    public static final int HSM_SYMID_EAN8 = 'D';
    public static final int HSM_SYMID_EAN13 = 'd';
    public static final int HSM_SYMID_INT25 = 'e';
    public static final int HSM_SYMID_MAXICODE = 'x';
    public static final int HSM_SYMID_MICROPDF = 'R';
    public static final int HSM_SYMID_PDF417 = 'r';
    public static final int HSM_SYMID_POSTNET = 'P';
    public static final int HSM_SYMID_OCR = 'O';
    public static final int HSM_SYMID_QR = 's';
    public static final int HSM_SYMID_RSS = 'y';
    public static final int HSM_SYMID_UPCA = 'c';
    public static final int HSM_SYMID_UPCE = 'E';
    public static final int HSM_SYMID_ISBT = 'j';
    public static final int HSM_SYMID_BPO = 'B';
    public static final int HSM_SYMID_CANPOST = 'C';
    public static final int HSM_SYMID_AUSPOST = 'A';
    public static final int HSM_SYMID_IATA25 = 'f';
    public static final int HSM_SYMID_CODABLOCK = 'q';
    public static final int HSM_SYMID_JAPOST = 'J';
    public static final int HSM_SYMID_PLANET = 'L';
    public static final int HSM_SYMID_DUTCHPOST = 'K';
    public static final int HSM_SYMID_MSI = 'g';
    public static final int HSM_SYMID_TLC39 = 'T';
    public static final int HSM_SYMID_TRIOPTIC = '=';
    public static final int HSM_SYMID_CODE32 = '<';
    public static final int HSM_SYMID_STRT25 = 'f';
    public static final int HSM_SYMID_MATRIX25 = 'm';
    public static final int HSM_SYMID_PLESSEY = 'n';
    public static final int HSM_SYMID_CHINAPOST = 'Q';
    public static final int HSM_SYMID_KOREAPOST = '?';
    public static final int HSM_SYMID_TELEPEN = 't';
    public static final int HSM_SYMID_CODE16K = 'o';
    public static final int HSM_SYMID_POSICODE = 'W';
    public static final int HSM_SYMID_COUPONCODE = 'c';
    public static final int HSM_SYMID_USPS4CB = 'M';
    public static final int HSM_SYMID_IDTAG = 'N';
    public static final int HSM_SYMID_LABELIV = '>';
    public static final int HSM_SYMID_LABELV = ',';
    public static final int HSM_SYMID_GS1_128 = 'I';
    public static final int HSM_SYMID_HANXIN = 'H';
    public static final int HSM_SYMID_GRIDMATRIX = 'x';
    private static SparseArray<String> zebraTable;
    private static SparseArray<String> honeyWellTable;
    private static SparseArray<String> commonTable;
    private final static int HoneyWellEngine = 0;
    private final static int ZebraEngine = 1;
    private final static int CommonEngine = 2;

    public static String stringFromSymbologyType(int engineType, int symbologyType) {
        if(engineType == HoneyWellEngine) {
            String value = honeyWellTable.get(symbologyType);
            if(TextUtils.isEmpty(value)) {
                return "Undefined";
            } else {
                return value;
            }
        } else if(engineType == ZebraEngine) {
            String value = zebraTable.get(symbologyType);
            if(TextUtils.isEmpty(value)) {
                return "Undefined";
            } else {
                return value;
            }
        } else if(engineType == CommonEngine){
            String value = commonTable.get(symbologyType);
            if(TextUtils.isEmpty(value)) {
                return "Undefined";
            } else {
                return value;
            }
        } else {
            return "Undefined";
        }
    }
    private static void loadCommonTable() {
        commonTable = new SparseArray<String>();
        commonTable.put(Symbology.CODE39.toInt(), "Code 39");
        commonTable.put(Symbology.CODABAR.toInt(), "Codabar");
        commonTable.put(Symbology.CODE128.toInt(), "Code 128");
        commonTable.put(Symbology.DISCRETE25.toInt(), "Discrete (Standard) 2 of 5");
        //commonTable.put(HSM_SYMID_IATA25, "IATA");
        commonTable.put(Symbology.INTERLEAVED25.toInt(), "Interleaved 2 of 5");
        commonTable.put(Symbology.CODE93.toInt(), "Code 93");
        commonTable.put(Symbology.UPCA.toInt(), "UPC-A");
        commonTable.put(Symbology.UPCE.toInt(), "UPC-E0");
        commonTable.put(Symbology.UPCE1.toInt(), "UPC-E1");
        commonTable.put(Symbology.EAN8.toInt(), "EAN-8");
        commonTable.put(Symbology.EAN13.toInt(), "EAN-13");
        commonTable.put(Symbology.CODE11.toInt(), "Code 11");
        //commonTable.put(HSM_SYMID_CODE49, "Code 49");
        commonTable.put(Symbology.MSI.toInt(), "MSI");
        ///commonTable.put(HSM_SYMID_EAN128, "EAN-128");
        commonTable.put(Symbology.PDF417.toInt(), "PDF-417");
        //commonTable.put(HSM_SYMID_CODE16K, "Code 16K");
//        commonTable.put(Symbology.CODABLOCK_A.toInt(), "Codablock A");
//        commonTable.put(Symbology.CODABLOCK_F.toInt(), "Codablock F");
        commonTable.put(Symbology.TRIOPTIC.toInt(), "Code 39 Trioptic");
        ///commonTable.put(HSM_SYMID_COUPONCODE, "Coupon Code");
   //     commonTable.put(Symbology.TELEPEN.toInt(), "Telepen");
        //commonTable.put(HSM_SYMID_ISBT, "ISBT-128");
        commonTable.put(Symbology.MICROPDF417.toInt(), "Micro PDF");
        commonTable.put(Symbology.DATAMATRIX.toInt(), "DataMatrix");
        commonTable.put(Symbology.QRCODE.toInt(), "QR Code");
        commonTable.put(Symbology.POSTAL_POSTNET.toInt(), "PostNet US");
        commonTable.put(Symbology.POSTAL_PLANET.toInt(), "Planet Code");
        commonTable.put(Symbology.CODE32.toInt(), "Code 32");
        commonTable.put(Symbology.POSTAL_JAPAN.toInt(), "Japan Postal");
        commonTable.put(Symbology.POSTAL_AUSTRALIAN.toInt(), "Australian Postal");
        commonTable.put(Symbology.POSTAL_KIX.toInt(), "Dutch Postal");
        commonTable.put(Symbology.MAXICODE.toInt(), "MaxiCode");
      //  commonTable.put(Symbology.CANADA_POST.toInt(), "Canadian Postal");
        commonTable.put(Symbology.AZTEC.toInt(), "Aztec");
        commonTable.put(Symbology.GS1_14.toInt(), "GS1 DataBar 14");
        commonTable.put(Symbology.GS1_LIMIT.toInt(), "GS1 DataBar Limited");
        commonTable.put(Symbology.GS1_EXP.toInt(), "GS1 DataBar Expanded");
        commonTable.put(Symbology.POSTAL_UPUFICS.toInt(), "USPS 4CB");
        commonTable.put(Symbology.POSTAL_4STATE.toInt(), "UPU 4State");
        //commonTable.put(HSM_SYMID_POSICODE, "PosiCode");
        commonTable.put(Symbology.MATRIX25.toInt(), "Matrix 2 of 5");
        commonTable.put(Symbology.COMPOSITE_CC_AB.toInt(), "Composite CC-A/B");
        commonTable.put(Symbology.COMPOSITE_CC_C.toInt(), "Composite CC-C");
     //   commonTable.put(Symbology.GRIDMATRIX.toInt(), "Grid Matrix");
        commonTable.put(Symbology.GS1_128.toInt(), "GS1 128");
        //commonTable.put(HSM_SYMID_LABELV, "LABELV");
        //commonTable.put(HSM_SYMID_LABELIV, "LABELIV");
       // commonTable.put(Symbology.COMPOSITE_TLC_39.toInt(), "TLC-39");
        //commonTable.put(HSM_SYMID_PLESSEY, "Plessey");
        commonTable.put(Symbology.CHINESE25.toInt(), "Chinese 2 of 5");
//        commonTable.put(Symbology.KOREA_POST.toInt(), "Korean 3 of 5");
//        commonTable.put(Symbology.NEC25.toInt(), "NEC 2 of 5");
//        commonTable.put(Symbology.HANXIN.toInt(), "Han Xin");
//        commonTable.put(Symbology.DOTCODE.toInt(), "Dot Code");
        //commonTable.put(HSM_SYMID_OCR, "OCR");
    }
    private static void loadHoneyWellTable(){
        honeyWellTable = new SparseArray<String>();
        honeyWellTable.put(HSM_SYMID_CODE39, "Code 39");
        honeyWellTable.put(HSM_SYMID_CODABAR, "Codabar");
        honeyWellTable.put(HSM_SYMID_CODE128, "Code 128");
        honeyWellTable.put(HSM_SYMID_STRT25, "Discrete (Standard) 2 of 5");
        honeyWellTable.put(HSM_SYMID_IATA25, "IATA");
        honeyWellTable.put(HSM_SYMID_INT25, "Interleaved 2 of 5");
        honeyWellTable.put(HSM_SYMID_CODE93, "Code 93");
        honeyWellTable.put(HSM_SYMID_UPCA, "UPC-A");
        honeyWellTable.put(HSM_SYMID_UPCE, "UPC-E0");
        honeyWellTable.put(HSM_SYMID_EAN8, "EAN-8");
        honeyWellTable.put(HSM_SYMID_EAN13, "EAN-13");
        honeyWellTable.put(HSM_SYMID_CODE11, "Code 11");
        honeyWellTable.put(HSM_SYMID_CODE49, "Code 49");
        honeyWellTable.put(HSM_SYMID_MSI, "MSI");
        honeyWellTable.put(HSM_SYMID_EAN128, "EAN-128");
        ///honeyWellTable.put(HSM_SYMID_UPCE, "UPC-E1");
        honeyWellTable.put(HSM_SYMID_PDF417, "PDF-417");
        honeyWellTable.put(HSM_SYMID_CODE16K, "Code 16K");
        honeyWellTable.put(HSM_SYMID_CODABLOCK, "Codablock");
        honeyWellTable.put(HSM_SYMID_TRIOPTIC, "Code 39 Trioptic");
        //honeyWellTable.put(HSM_SYMID_COUPONCODE, "Coupon Code");
        honeyWellTable.put(HSM_SYMID_TELEPEN, "Telepen");
//        honeyWellTable.put(HSM_SYMID_ISBT, "ISBT-128");
        honeyWellTable.put(HSM_SYMID_MICROPDF, "Micro PDF");
        honeyWellTable.put(HSM_SYMID_DATAMATRIX, "DataMatrix");
        honeyWellTable.put(HSM_SYMID_QR, "QR Code");
        honeyWellTable.put(HSM_SYMID_POSTNET, "PostNet US");
        honeyWellTable.put(HSM_SYMID_PLANET, "Planet Code");
        honeyWellTable.put(HSM_SYMID_CODE32, "Code 32");
        honeyWellTable.put(HSM_SYMID_JAPOST, "Japan Postal");
        honeyWellTable.put(HSM_SYMID_AUSPOST, "Australian Postal");
        honeyWellTable.put(HSM_SYMID_DUTCHPOST, "Dutch Postal");
        honeyWellTable.put(HSM_SYMID_MAXICODE, "MaxiCode");
        honeyWellTable.put(HSM_SYMID_CANPOST, "Canadian Postal");
        honeyWellTable.put(HSM_SYMID_AZTEC, "Aztec");
        honeyWellTable.put(HSM_SYMID_RSS, "GS1 DataBar");
        honeyWellTable.put(HSM_SYMID_USPS4CB, "USPS 4CB");
        honeyWellTable.put(HSM_SYMID_BPO, "UPU 4State");//British post(BPO 4-State)
        honeyWellTable.put(HSM_SYMID_POSICODE, "PosiCode");
        honeyWellTable.put(HSM_SYMID_MATRIX25, "Matrix 2 of 5");
        honeyWellTable.put(HSM_SYMID_COMPOSITE, "Composite CC-A/B");
        //honeyWellTable.put(HSM_SYMID_GRIDMATRIX, "Grid Matrix");
//        honeyWellTable.put(HSM_SYMID_GS1_128, "GS1 128");
        honeyWellTable.put(HSM_SYMID_LABELV, "LABELV");
        honeyWellTable.put(HSM_SYMID_LABELIV, "LABELIV");
        honeyWellTable.put(HSM_SYMID_TLC39, "TLC-39");
        honeyWellTable.put(HSM_SYMID_PLESSEY, "Plessey");
        honeyWellTable.put(HSM_SYMID_CHINAPOST, "Chinese 2 of 5");
        honeyWellTable.put(HSM_SYMID_KOREAPOST, "Korean 3 of 5");
        honeyWellTable.put(HSM_SYMID_IDTAG, "Standard 2 of 5");
        honeyWellTable.put(HSM_SYMID_HANXIN, "Han Xin");
        honeyWellTable.put(HSM_SYMID_OCR, "OCR");
    }
    private static void loadZebraTable() {
        zebraTable = new SparseArray<String>();
        zebraTable.put(1, "Code 39");
        zebraTable.put(2, "Codabar");
        zebraTable.put(3, "Code 128");
        zebraTable.put(4, "Discrete (Standard) 2 of 5");
        zebraTable.put(5, "IATA");
        zebraTable.put(6, "Interleaved 2 of 5");
        zebraTable.put(7, "Code 93");
        zebraTable.put(8, "UPC-A");
        zebraTable.put(9, "UPC-E0");
        zebraTable.put(10, "EAN-8");
        zebraTable.put(11, "EAN-13");
        zebraTable.put(12, "Code 11");
        zebraTable.put(13, "Code 49");
        zebraTable.put(14, "MSI");
        zebraTable.put(15, "EAN-128");
        zebraTable.put(16, "UPC-E1");
        zebraTable.put(17, "PDF-417");
        zebraTable.put(18, "Code 16K");
        zebraTable.put(19, "Code 39 Full ASCII");
        zebraTable.put(20, "UPC-D");
        zebraTable.put(21, "Code 39 Trioptic");
        zebraTable.put(22, "Bookland");
        zebraTable.put(23, "Coupon Code");
        zebraTable.put(24, "NW-7");
        zebraTable.put(25, "ISBT-128");
        zebraTable.put(26, "Micro PDF");
        zebraTable.put(27, "DataMatrix");
        zebraTable.put(28, "QR Code");
        zebraTable.put(29, "Micro PDF CCA");
        zebraTable.put(30, "PostNet US");
        zebraTable.put(31, "Planet Code");
        zebraTable.put(32, "Code 32");
        zebraTable.put(33, "ISBT-128 Con");
        zebraTable.put(34, "Japan Postal");
        zebraTable.put(35, "Australian Postal");
        zebraTable.put(36, "Dutch Postal");
        zebraTable.put(37, "MaxiCode");
        zebraTable.put(38, "Canadian Postal");
        zebraTable.put(39, "UK Postal");
        zebraTable.put(40, "Macro PDF");
        zebraTable.put(41, "Macro QR");
        zebraTable.put(44, "Micro QR");
        zebraTable.put(45, "Aztec");
        zebraTable.put(46, "Aztec Rune");
        zebraTable.put(48, "GS1 DataBar-14");
        zebraTable.put(49, "GS1 DataBar Limited");
        zebraTable.put(50, "GS1 DataBar Expanded");
        zebraTable.put(52, "USPS 4CB");
        zebraTable.put(53, "UPU 4State");
        zebraTable.put(54, "ISSN");
        zebraTable.put(55, "Scanlet");
        zebraTable.put(56, "CueCode");
        zebraTable.put(57, "Matrix 2 of 5");
        zebraTable.put(72, "UPC-A + 2 Supplemental");
        zebraTable.put(73, "UPC-E0 + 2 Supplemental");
        zebraTable.put(74, "EAN-8 + 2 Supplemental");
        zebraTable.put(75, "EAN-13 + 2 Supplemental");
        zebraTable.put(80, "UPC-E1 + 2 Supplemental");
        zebraTable.put(81, "CCA EAN-128");
        zebraTable.put(82, "CCA EAN-13");
        zebraTable.put(83, "CCA EAN-8");
        zebraTable.put(84, "CCA GS1 DataBar Expanded");
        zebraTable.put(85, "CCA GS1 DataBar Limited");
        zebraTable.put(86, "CCA GS1 DataBar-14");
        zebraTable.put(87, "CCA UPC-A");
        zebraTable.put(88, "CCA UPC-E");
        zebraTable.put(89, "CCC EAN-128");
        zebraTable.put(90, "TLC-39");
        zebraTable.put(97, "CCB EAN-128");
        zebraTable.put(98, "CCB EAN-13");
        zebraTable.put(99, "CCB EAN-8");
        zebraTable.put(100, "CCB GS1 DataBar Expanded");
        zebraTable.put(101, "CCB GS1 DataBar Limited");
        zebraTable.put(102, "CCB GS1 DataBar-14");
        zebraTable.put(103, "CCB UPC-A");
        zebraTable.put(104, "CCB UPC-E");
        zebraTable.put(105, "Signature Capture");
        zebraTable.put(114, "Chinese 2 of 5");
        zebraTable.put(115, "Korean 3 of 5");
        zebraTable.put(136, "UPC-A + 5 supplemental");
        zebraTable.put(137, "UPC-E0 + 5 supplemental");
        zebraTable.put(138, "EAN-8 + 5 supplemental");
        zebraTable.put(139, "EAN-13 + 5 supplemental");
        zebraTable.put(144, "UPC-E1 + 5 Supplemental");
        zebraTable.put(154, "Macro Micro PDF");
        zebraTable.put(180, "GS1 Databar Coupon");
        zebraTable.put(183, "Han Xin");
    }
}
