package com.example.administrator.wingcool_gt9_apk;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbRequest;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class DataAnalysis extends AppCompatActivity
        implements   OpenDevicesReceiver.OpenDevicesListener, View.OnClickListener {
    private Context mAlertContext;
    //MainActivity mMainAct = new MainActivity();
    private byte[] mRawdataBytes = new byte[44 * 72 * 2 + 64 * 2];
    private int[] mManualRefInt = new int[44 * 72 + 64];
    private int[] datatemp = new int[44 * 72 + 64];
    private int[] iDataShow = new int[44 * 72 + 64];
    private static final int RAWDATA_MESSAGE = 0;
    private static final int LOG1_MESSAG = 1;
    private static final int CLEAR_MESSAGE= 2;
    private static final int LOG2_MESSAGE = 3;
    private static final int CONNECTED_SUCCESS = 4;
    private static final int DIFF_MESSAGE = 5;
    private static final int MANUALDIFF_MESSAGE = 6;
    private static final int TEST_DATA_MESSAGE = 7;
    private static final int STYLUS_DATA_MESSAGE = 8;

    private static final String USB_ACTION = "com.host2device";
    private static final String ACTION_USB_PERMISSION = "com.host2device.USB_PERMISSION";
    private ExecutorService mThreadPool;
    private UsbManager mUsbManager;
    private OpenDevicesReceiver daOpenDevicesReceiver;
    private UsbDeviceConnection mUsbDeviceConnection;
    private UsbRequest mUsbRequest = new UsbRequest();
    private UsbEndpoint mUsbEndpointOut;
    private UsbEndpoint mUsbEndpointIn;
    private int iProductId;
    private byte byProductType = 0;
    private static final byte GT9 = 0x01;
    private static final byte GT7 = 0x02;

    private Button btn_RawdataShow;
    private Button btn_DiffdataShow;
    private Button btn_ReffdataShow;
    private Button btn_ManualdiffdataShow;
    private Button btn_Manualreff;
    private Button btn_StylusDataShow;
    private Button btn_Test;
    private Button btn_Stop;

    private byte[] mBytes = new byte[1024];

    private EditText edt_RowNum;
    private EditText edt_ColNum;
    private EditText edt_Maximum;
    private EditText edt_Minimum;
    private EditText edt_TestiInformation;  //显示测试过程信息

    private boolean isReceiverMessage = true;
    private boolean isNeedFindDevice  = true;

    private UsbInterface mUsbInterface;
    private Context mContext;

    private byte showAddressHigh;
    private byte showAddressLow;  //需要显示的 address
    private int colnum;
    private int rownum;
    private int iMaximum;  //存放外部输入的最大值测试阈值
    private int iMinimum;  //存放外部输入的最小值测试阈值
    private byte byMaximumOverCount;  //最大值超过阈值的次数
    private byte byMinimumOverCount;  //最小值超过阈值的次数
    private byte byTestCount;  //统计测试的帧数
    private byte byReTestCount;  //重新测试的测试，最多测试4次输出判定结果
    private boolean bTestMaxResult,bTestMinResult;  //测试结果pass或者fail;
    private TextView tvMaximum;      //显示最大值
    private TextView tvMinimum;      //显示最小值
    private TextView tvDataContent;  //显示当前处于何种数值模式：原始值、差值、基准……
    private TextView tvMAD;          //显示最大相邻偏差
    private TextView mtextView;
    private byte byDisplayFrame = 8;   //间隔显示帧数
    private byte byDisplayFrameCount = 8;   //用于间隔显示计数

    public String stTestLog;   //最大最小值测试信息存放字符串
    String stTestLogShow= "";  //最大最小值测试信息合并起来存放字符串

    public String Update_log;  //短路测试信息存放字符串
    String updateLogShow= "";  //短路测试信息合并起来存放字符串

    private byte showFlag = 0;  //
    private byte btTestStep = 0;

    private boolean bShowDataFlag = false;

    private EditText edtShortCircuitInfo;  //the info of short circuit test

    private GridLayout textGridLayout;

    private static final byte gt9110h_short_dsp_code[] = {
        0x02,0x0c,(byte)0xb7,(byte)0x8f,0x08,0x7e,0x00,0x7f,0x71,0x7d,0x00,0x7b,0x01,0x7a,(byte)0xa5,0x79,
        (byte)0xc1,0x12,0x09,0x1f,(byte)0xe5,0x08,0x70,0x03,0x02,0x01,(byte)0xbb,(byte)0xd3,(byte)0x94,0x04,0x40,0x03,
        0x02,0x01,(byte)0xbb,(byte)0xe4,(byte)0xf5,0x0a,(byte)0xf5,0x09,0x74,0x54,0x25,0x09,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,
        (byte)0x88,(byte)0xf5,(byte)0x83,(byte)0xe0,0x25,0x0a,(byte)0xf5,0x0a,0x05,0x09,(byte)0xe5,0x09,(byte)0xb4,0x08,(byte)0xe9,(byte)0xe5,
        0x08,0x25,0x0a,(byte)0xf5,0x0a,(byte)0x90,(byte)0x88,0x5d,(byte)0xe0,(byte)0xf4,0x04,0x65,0x0a,0x60,0x07,(byte)0x90,
        (byte)0x88,0x01,0x74,0x10,(byte)0xf0,0x22,(byte)0x90,0x42,0x5d,(byte)0xe0,(byte)0xf5,0x0c,(byte)0x90,0x42,0x62,(byte)0xe0,
        (byte)0xf5,0x0d,0x12,0x0e,0x67,(byte)0xc2,0x0a,0x12,0x15,0x39,(byte)0xc2,0x08,(byte)0xe4,(byte)0xf5,0x09,(byte)0xe5,
        0x09,(byte)0xc3,(byte)0x95,0x08,0x40,0x03,0x02,0x00,(byte)0xff,(byte)0xe5,0x09,0x25,(byte)0xe0,0x24,0x54,(byte)0xf5,
        (byte)0x82,(byte)0xe4,0x34,(byte)0x88,(byte)0xf5,(byte)0x83,(byte)0xe0,(byte)0xf5,0x0b,(byte)0xe5,0x09,0x25,(byte)0xe0,0x24,0x55,(byte)0xf5,
        (byte)0x82,(byte)0xe4,0x34,(byte)0x88,(byte)0xf5,(byte)0x83,(byte)0xe0,(byte)0xf5,0x0a,0x24,0x00,0x12,0x01,(byte)0xfc,0x12,0x01,
        (byte)0xbc,0x12,0x03,0x04,0x24,(byte)0xc1,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,(byte)0xf5,(byte)0x83,(byte)0xe5,0x0b,0x12,
        0x03,0x03,0x24,(byte)0xc2,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,(byte)0xf5,(byte)0x83,(byte)0xe5,0x0a,0x12,0x03,0x03,
        0x24,(byte)0xc3,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,(byte)0xf5,(byte)0x83,(byte)0xe5,0x0f,(byte)0xf0,(byte)0xe5,0x10,0x12,0x02,
        0x33,(byte)0xf0,0x12,0x01,(byte)0xea,0x12,0x01,(byte)0xbc,0x12,0x03,0x04,0x24,(byte)0xc5,(byte)0xf5,(byte)0x82,(byte)0xe4,
        0x34,(byte)0xa5,0x12,0x02,0x64,(byte)0x95,0x10,(byte)0x90,(byte)0x88,0x04,(byte)0xe0,(byte)0x95,0x0f,0x50,0x03,0x12,
        0x02,(byte)0xdb,0x12,0x02,0x35,0x12,0x01,(byte)0xf9,(byte)0xe4,(byte)0xf0,0x05,0x09,0x02,0x00,0x6f,(byte)0x90,
        (byte)0x88,0x5c,(byte)0xe0,(byte)0xff,(byte)0xf4,0x70,0x03,0x02,0x01,(byte)0xbb,(byte)0xef,(byte)0xd3,(byte)0x94,0x0e,0x40,0x03,
        0x02,0x01,(byte)0xbb,(byte)0x8f,0x0a,(byte)0xe4,0x2f,0x12,0x01,(byte)0xfc,0x12,0x01,(byte)0xd3,(byte)0x90,(byte)0xa5,(byte)0xd9,
        (byte)0xe5,0x0a,(byte)0xf0,(byte)0xa3,(byte)0xe5,0x0f,(byte)0xf0,(byte)0xa3,(byte)0xe5,0x10,(byte)0xf0,(byte)0xe4,(byte)0xf5,0x09,(byte)0xe5,0x09,
        (byte)0x90,0x0f,(byte)0xcb,(byte)0x93,(byte)0xf5,0x0b,0x12,0x02,0x45,(byte)0xe0,0x60,0x30,(byte)0xe5,0x0b,0x65,0x0a,
        0x60,0x2a,(byte)0xe4,0x12,0x01,(byte)0xea,0x12,0x01,(byte)0xd3,(byte)0xe5,0x09,0x25,(byte)0xe0,0x24,(byte)0xdc,(byte)0xf5,
        (byte)0x82,(byte)0xe4,0x34,(byte)0xa5,0x12,0x02,0x64,(byte)0x95,0x10,(byte)0x90,(byte)0x88,0x04,(byte)0xe0,(byte)0x95,0x0f,0x50,
        0x03,0x12,0x02,(byte)0xdb,0x12,0x02,0x35,0x12,0x01,(byte)0xf9,(byte)0xe4,(byte)0xf0,0x05,0x09,(byte)0xe5,0x09,
        (byte)0xc3,(byte)0x94,0x2a,0x40,(byte)0xb9,(byte)0xe4,(byte)0xf5,0x0f,(byte)0xf5,0x10,(byte)0x90,(byte)0xa6,0x30,(byte)0xf0,(byte)0xa3,(byte)0xf0,
        (byte)0xf5,0x09,0x74,(byte)0xc1,0x25,0x09,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,(byte)0xf5,(byte)0x83,(byte)0xe0,0x25,0x10,
        (byte)0xf5,0x10,(byte)0xe4,0x35,0x0f,(byte)0xf5,0x0f,0x05,0x09,(byte)0xe5,0x09,(byte)0xb4,0x71,(byte)0xe4,(byte)0xc3,(byte)0xe4,
        (byte)0x95,0x10,(byte)0xfe,(byte)0xe4,(byte)0x95,0x0f,(byte)0x90,(byte)0xa6,0x30,(byte)0xf0,(byte)0xa3,(byte)0xce,(byte)0xf0,(byte)0x90,0x42,0x5d,
        (byte)0xe5,0x0c,(byte)0xf0,(byte)0xe5,0x0d,0x12,0x02,0x4f,0x12,0x15,0x0d,0x22,0x74,0x02,(byte)0xf0,(byte)0xc2,
        0x0a,(byte)0x85,0x0a,0x11,0x12,0x16,0x5c,(byte)0x8f,0x0e,0x7d,0x01,0x12,0x0f,(byte)0xf5,(byte)0x8e,0x0f,
        (byte)0x8f,0x10,0x22,0x74,0x02,(byte)0xf0,(byte)0xc2,0x0a,(byte)0x85,0x0a,0x11,0x12,0x16,0x5c,(byte)0x8f,0x0e,
        0x7d,0x01,0x12,0x0f,(byte)0xf5,(byte)0x8e,0x0f,(byte)0x8f,0x10,0x22,0x25,0x0a,(byte)0xff,(byte)0xe4,0x34,0x32,
        (byte)0xfe,(byte)0xef,0x64,0x03,(byte)0xf5,(byte)0x82,(byte)0x8e,(byte)0x83,(byte)0xe4,(byte)0xf0,0x25,0x0b,(byte)0xff,(byte)0xe4,0x34,0x32,
        (byte)0xfe,(byte)0xef,0x64,0x03,(byte)0xf5,(byte)0x82,(byte)0x8e,(byte)0x83,0x22,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0xf0,0x34,(byte)0x8e,(byte)0xf5,
        (byte)0x83,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,0x22,0x7e,0x00,0x7f,0x06,0x7d,0x00,0x7b,0x01,0x7a,
        (byte)0x80,0x79,(byte)0xb3,0x22,(byte)0x90,0x42,0x0e,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0x90,0x42,0x02,(byte)0xe0,0x54,
        (byte)0xfe,(byte)0xf0,0x22,(byte)0xa3,(byte)0xf0,(byte)0x90,0x32,0x42,(byte)0xe4,(byte)0xf0,(byte)0xa3,(byte)0xf0,(byte)0x90,0x42,(byte)0x82,0x22,
        (byte)0x90,0x0f,(byte)0xcb,(byte)0x93,(byte)0xff,0x24,0x4f,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x80,(byte)0xf5,(byte)0x83,0x22,(byte)0x90,
        0x42,0x62,(byte)0xf0,(byte)0x90,0x42,0x7d,0x74,0x02,(byte)0xf0,0x22,(byte)0x90,0x42,0x0e,(byte)0xe0,0x44,0x01,
        (byte)0xf0,0x7f,0x01,0x22,(byte)0xf5,(byte)0x83,(byte)0xe5,0x0f,(byte)0xf0,(byte)0xe5,0x10,(byte)0xa3,(byte)0xf0,(byte)0xc3,(byte)0x90,(byte)0x88,
        0x05,(byte)0xe0,0x22,0x74,0x31,0x2f,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x80,(byte)0xf5,(byte)0x83,0x22,(byte)0xf5,(byte)0x82,
        (byte)0xe4,0x35,(byte)0x83,(byte)0xf5,(byte)0x83,(byte)0xe4,(byte)0xf0,(byte)0xa3,(byte)0xf0,0x22,(byte)0xa3,(byte)0xa3,(byte)0xa3,0x75,(byte)0xf0,0x02,
        0x02,0x09,0x13,0x74,0x08,0x2c,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x88,(byte)0xf5,(byte)0x83,0x22,0x74,0x32,
        0x2c,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x88,(byte)0xf5,(byte)0x83,0x22,0x13,0x13,0x13,0x54,0x1f,0x24,(byte)0xb3,
        (byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x80,(byte)0xf5,(byte)0x83,(byte)0xef,(byte)0xf0,0x22,(byte)0x85,0x0c,(byte)0x82,(byte)0x85,0x0b,(byte)0x83,
        (byte)0xa3,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,(byte)0xe5,0x08,0x25,(byte)0xe0,0x22,(byte)0xfd,(byte)0xe4,0x34,0x32,(byte)0xfc,
        (byte)0xed,0x64,0x03,(byte)0xf5,(byte)0x82,(byte)0x8c,(byte)0x83,(byte)0xee,(byte)0xf0,0x0f,0x22,(byte)0xd2,0x08,(byte)0x90,(byte)0x88,0x01,
        (byte)0xe0,0x44,0x01,(byte)0xf0,0x22,(byte)0xee,0x54,0x7f,(byte)0xfe,(byte)0xc3,(byte)0x90,(byte)0x88,0x52,(byte)0xe0,(byte)0x9f,(byte)0x90,
        (byte)0x88,0x51,(byte)0xe0,(byte)0x9e,0x22,(byte)0xf8,(byte)0xeb,0x4f,(byte)0xff,(byte)0xea,0x4e,(byte)0xfe,(byte)0xe9,0x4d,(byte)0xfd,(byte)0xe8,
        0x4c,(byte)0xfc,0x22,(byte)0xf0,(byte)0xe5,0x09,0x75,(byte)0xf0,0x06,(byte)0xa4,0x22,(byte)0xe0,(byte)0xf8,(byte)0xa3,(byte)0xe0,(byte)0xf9,
        (byte)0xa3,(byte)0xe0,(byte)0xfa,(byte)0xa3,(byte)0xe0,(byte)0xfb,(byte)0xe8,0x22,(byte)0x90,0x41,(byte)0xfe,(byte)0xe0,0x44,0x02,(byte)0xf0,(byte)0xa3,
        0x74,0x0f,(byte)0xf0,0x22,(byte)0x90,0x41,(byte)0xfe,(byte)0xe0,0x44,0x01,(byte)0xf0,0x22,(byte)0xf5,(byte)0x82,(byte)0xe4,0x3e,
        (byte)0xf5,(byte)0x83,(byte)0xec,(byte)0xf0,(byte)0xa3,(byte)0xed,(byte)0xf0,0x22,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,0x75,(byte)0xf0,0x06,
        (byte)0xed,(byte)0xa4,0x22,0x54,0x07,(byte)0xff,0x74,0x01,(byte)0xc8,(byte)0xef,(byte)0xc8,0x08,0x22,0x25,(byte)0xe0,0x24,
        0x31,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,0x22,0x25,(byte)0xe0,0x24,(byte)0x85,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa5,
        0x22,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,0x22,(byte)0xe4,(byte)0xf5,0x0f,(byte)0xf5,0x10,
        (byte)0x90,0x42,0x5d,(byte)0xe0,(byte)0xf5,0x0a,(byte)0x90,0x42,0x62,(byte)0xe0,(byte)0xf5,0x0b,0x12,0x0e,0x67,(byte)0xc2,
        0x0a,0x12,0x15,0x39,(byte)0xe4,(byte)0x90,(byte)0x88,0x02,(byte)0xf0,(byte)0xf5,0x08,(byte)0xe5,0x08,(byte)0x90,0x0f,(byte)0xcb,
        (byte)0x93,0x12,0x02,0x45,(byte)0xe0,0x70,0x03,0x02,0x04,(byte)0x94,(byte)0xc2,0x08,(byte)0x90,0x0f,(byte)0xdf,(byte)0xe4,
        (byte)0x93,0x24,0x00,0x12,0x01,(byte)0xfc,0x74,0x02,(byte)0xf0,(byte)0xaf,0x08,0x12,0x14,(byte)0xb5,(byte)0xe5,0x08,
        (byte)0x90,0x0f,(byte)0xcb,(byte)0x93,(byte)0xf5,0x0c,(byte)0x90,(byte)0x88,0x02,(byte)0xe0,0x75,(byte)0xf0,(byte)0x95,(byte)0xa4,0x24,0x60,
        (byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0xf0,0x34,(byte)0x88,(byte)0xaf,(byte)0x82,(byte)0xf5,0x0f,(byte)0x8f,0x10,(byte)0xf5,(byte)0x83,(byte)0xe0,0x44,
        (byte)0x80,(byte)0xf0,(byte)0xe5,0x0c,0x54,0x7f,(byte)0xff,(byte)0xe0,0x54,(byte)0x80,0x4f,(byte)0xf0,(byte)0xd2,0x0a,(byte)0x85,0x0c,
        0x11,0x12,0x04,(byte)0xae,(byte)0xe5,0x0d,(byte)0xf0,(byte)0xa3,(byte)0xe5,0x0e,(byte)0xf0,(byte)0x85,0x10,(byte)0x82,(byte)0x85,0x0f,
        (byte)0x83,(byte)0xe5,0x08,0x12,0x02,(byte)0x8a,(byte)0xe5,0x0d,(byte)0xf0,(byte)0xe5,0x0e,0x12,0x02,0x33,(byte)0xf0,(byte)0xfe,
        0x7f,0x54,(byte)0xfd,(byte)0xe5,0x10,0x24,0x03,(byte)0xfb,(byte)0xe4,0x35,0x0f,(byte)0xfa,(byte)0xc9,(byte)0xeb,(byte)0xc9,0x7b,
        0x01,0x12,0x09,0x1f,(byte)0xe5,0x08,0x04,(byte)0xf5,0x09,(byte)0xe5,0x09,(byte)0xc3,(byte)0x94,0x2a,0x50,0x37,
        (byte)0xe5,0x09,0x12,0x02,0x40,(byte)0xe0,0x60,0x2b,(byte)0xd2,0x0a,(byte)0x8f,0x11,0x12,0x04,(byte)0xae,(byte)0xa3,
        (byte)0xa3,0x75,(byte)0xf0,0x02,(byte)0xe5,0x09,0x12,0x09,0x13,(byte)0xe5,0x0d,(byte)0xf0,(byte)0xa3,(byte)0xe5,0x0e,0x12,
        0x02,0x6c,(byte)0x95,0x0e,(byte)0x90,(byte)0x88,0x04,(byte)0xe0,(byte)0x95,0x0d,0x50,0x03,0x12,0x02,(byte)0xdb,0x12,
        0x02,0x35,(byte)0xf0,0x05,0x09,(byte)0x80,(byte)0xc2,(byte)0xd2,0x0a,(byte)0xe5,0x10,0x24,0x57,(byte)0xf5,0x12,(byte)0xe4,
        0x35,0x0f,(byte)0xf5,0x11,(byte)0x85,0x08,0x13,0x12,0x0b,0x48,(byte)0xaf,0x10,(byte)0xae,0x0f,0x12,0x11,
        (byte)0xd9,(byte)0x85,0x10,(byte)0x82,(byte)0x85,0x0f,(byte)0x83,(byte)0xa3,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,(byte)0xe5,0x08,0x25,
        (byte)0xe0,0x24,(byte)0xa1,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa4,0x12,0x02,0x0f,0x30,0x08,0x06,(byte)0x90,(byte)0x88,
        0x02,(byte)0xe0,0x04,(byte)0xf0,0x05,0x08,(byte)0xe5,0x08,(byte)0xc3,(byte)0x94,0x2a,0x50,0x03,0x02,0x03,(byte)0x8b,
        (byte)0x90,0x42,0x5d,(byte)0xe5,0x0a,(byte)0xf0,(byte)0xe5,0x0b,0x12,0x02,0x4f,0x02,0x15,0x0d,0x12,0x16,
        0x5c,(byte)0x8f,0x0c,0x7d,0x01,0x12,0x0f,(byte)0xf5,(byte)0x8e,0x0d,(byte)0x8f,0x0e,(byte)0x85,0x10,(byte)0x82,(byte)0x85,
        0x0f,(byte)0x83,(byte)0xa3,0x22,(byte)0xe4,(byte)0xf5,0x0b,(byte)0xf5,0x0c,(byte)0x90,0x42,0x5d,(byte)0xe0,(byte)0xf5,0x09,(byte)0x90,
        0x42,0x62,(byte)0xe0,(byte)0xf5,0x0a,0x12,0x0e,0x67,(byte)0xc2,0x0a,0x12,0x15,0x39,(byte)0xe4,(byte)0x90,(byte)0x88,
        0x03,(byte)0xf0,(byte)0xf5,0x08,(byte)0xe5,0x08,0x30,(byte)0xe0,0x03,0x02,0x05,(byte)0xf1,0x74,0x31,0x25,0x08,
        0x12,0x02,0x76,(byte)0xe0,0x70,0x03,0x02,0x05,(byte)0xf1,(byte)0xc2,0x08,(byte)0xad,0x08,(byte)0x90,(byte)0x88,0x03,
        (byte)0xe0,0x75,(byte)0xf0,0x41,(byte)0xa4,0x24,(byte)0xd2,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0xf0,0x34,(byte)0xa0,(byte)0xaf,(byte)0x82,(byte)0xf5,
        0x0b,(byte)0x8f,0x0c,(byte)0xf5,(byte)0x83,(byte)0xe0,0x54,0x7f,(byte)0xf0,(byte)0xed,0x54,0x7f,(byte)0xff,(byte)0xe0,0x54,(byte)0x80,
        0x4f,(byte)0xf0,(byte)0xed,(byte)0xc3,0x13,(byte)0xfc,0x24,0x2c,0x12,0x01,(byte)0xfc,0x74,0x02,(byte)0xf0,(byte)0xed,(byte)0xc3,
        (byte)0x94,0x10,0x50,0x1a,(byte)0x90,0x32,0x46,(byte)0xc0,(byte)0x83,(byte)0xc0,(byte)0x82,0x74,0x01,0x7e,0x00,(byte)0xc8,
        (byte)0xed,(byte)0xc8,0x08,(byte)0x80,0x05,(byte)0xc3,0x33,(byte)0xce,0x33,(byte)0xce,(byte)0xd8,(byte)0xf9,(byte)0x80,0x1c,(byte)0x90,0x32,
        0x44,(byte)0xc0,(byte)0x83,(byte)0xc0,(byte)0x82,(byte)0xed,0x24,(byte)0xf0,(byte)0xff,0x74,0x01,0x7e,0x00,(byte)0xc8,(byte)0xef,(byte)0xc8,
        0x08,(byte)0x80,0x05,(byte)0xc3,0x33,(byte)0xce,0x33,(byte)0xce,(byte)0xd8,(byte)0xf9,(byte)0xff,(byte)0xe0,0x4e,(byte)0xfe,(byte)0xa3,(byte)0xe0,
        0x4f,(byte)0xff,(byte)0xd0,(byte)0x82,(byte)0xd0,(byte)0x83,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0xcf,(byte)0xec,(byte)0xcf,0x7d,0x01,
        0x12,0x0f,(byte)0xf5,(byte)0x85,0x0c,(byte)0x82,(byte)0x85,0x0b,(byte)0x83,(byte)0xa3,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0x85,
        0x0c,(byte)0x82,(byte)0x85,0x0b,(byte)0x83,(byte)0xe5,0x08,0x12,0x02,(byte)0x8a,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0x90,
        0x32,0x44,0x12,0x08,(byte)0xe2,0x00,0x00,0x00,0x00,(byte)0xc2,0x0a,(byte)0xe5,0x0c,0x24,0x03,(byte)0xf5,
        0x12,(byte)0xe4,0x35,0x0b,(byte)0xf5,0x11,(byte)0x85,0x08,0x13,0x12,0x0b,0x48,(byte)0xaf,0x0c,(byte)0xae,0x0b,
        0x12,0x12,0x1b,0x12,0x02,(byte)0xba,0x24,(byte)0xf5,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa4,0x12,0x02,0x0f,
        0x12,0x02,(byte)0xba,0x24,(byte)0xf7,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0xa4,0x12,0x02,0x0f,0x30,0x08,0x06,
        (byte)0x90,(byte)0x88,0x03,(byte)0xe0,0x04,(byte)0xf0,(byte)0xe5,0x08,(byte)0xc3,0x13,0x24,0x2c,0x12,0x01,(byte)0xfc,(byte)0xe4,
        (byte)0xf0,0x05,0x08,(byte)0xe5,0x08,(byte)0xc3,(byte)0x94,0x1d,0x50,0x03,0x02,0x04,(byte)0xe4,(byte)0x90,0x42,0x5d,
        (byte)0xe5,0x09,(byte)0xf0,(byte)0x90,0x42,0x62,(byte)0xe5,0x0a,0x12,0x02,0x52,0x02,0x15,0x0d,(byte)0x90,0x50,
        (byte)0x96,0x74,(byte)0xaa,(byte)0xf0,(byte)0x90,0x41,(byte)0x83,(byte)0xe0,0x44,0x08,(byte)0xf0,0x7d,0x48,0x7f,0x01,0x12,
        0x13,(byte)0xf9,(byte)0x90,0x42,0x51,0x74,0x03,(byte)0xf0,(byte)0xc2,(byte)0xaf,0x12,0x16,(byte)0xa5,(byte)0x90,0x42,0x3a,
        (byte)0xe4,(byte)0xf0,(byte)0xa3,0x04,(byte)0xf0,(byte)0x90,0x50,(byte)0x8b,0x74,0x14,(byte)0xf0,(byte)0x90,0x50,(byte)0x8a,(byte)0xf0,0x12,
        0x09,(byte)0x86,(byte)0x90,0x60,0x2f,0x74,0x07,(byte)0xf0,0x7f,0x3b,0x12,0x16,(byte)0xc9,(byte)0xe4,(byte)0x90,(byte)0x88,
        0x04,(byte)0xf0,(byte)0xa3,(byte)0xf0,(byte)0x90,(byte)0x88,0x53,(byte)0xf0,(byte)0xfe,0x7f,0x0a,(byte)0xfd,0x7b,0x01,0x7a,(byte)0x88,
        0x79,0x54,0x12,0x09,0x1f,(byte)0x90,(byte)0x88,0x5c,0x74,(byte)0xff,(byte)0xf0,(byte)0x90,0x50,(byte)0x96,(byte)0xe0,(byte)0xb4,
        (byte)0xaa,0x03,0x00,(byte)0x80,(byte)0xf6,0x12,0x0d,(byte)0xe2,(byte)0x90,(byte)0x88,0x04,(byte)0xe0,0x70,0x02,(byte)0xa3,(byte)0xe0,
        0x60,0x03,(byte)0xd3,(byte)0x80,0x01,(byte)0xc3,0x40,0x08,(byte)0x90,(byte)0x88,0x01,0x74,0x10,(byte)0xf0,(byte)0x80,0x4d,
        (byte)0xe4,(byte)0x90,(byte)0x88,0x00,(byte)0xf0,0x12,0x0c,0x04,0x7e,0x00,0x7f,0x48,0x7d,0x00,0x7b,0x01,
        0x7a,(byte)0xa4,0x79,(byte)0xa1,0x12,0x09,0x1f,0x7e,0x00,0x7f,0x48,0x7d,0x00,0x7b,0x01,0x7a,
        (byte)0xa5,0x79,0x31,0x12,0x09,0x1f,(byte)0xe4,(byte)0x90,(byte)0x88,0x01,(byte)0xf0,(byte)0x90,(byte)0x88,0x53,(byte)0xe0,(byte)0xff,
        0x12,0x00,0x03,0x12,0x03,0x6b,0x12,0x04,(byte)0xc4,0x12,0x0a,0x73,(byte)0x90,(byte)0x88,0x00,(byte)0xe0,
        0x44,0x08,(byte)0xf0,0x12,0x07,0x55,(byte)0x90,(byte)0x88,0x00,(byte)0xe0,0x44,(byte)0x80,(byte)0xf0,(byte)0x90,(byte)0x88,0x00,
        0x74,(byte)0x88,(byte)0xf0,(byte)0x90,0x41,(byte)0xef,0x74,0x0f,(byte)0xf0,(byte)0x90,0x41,(byte)0xee,(byte)0xe0,0x44,0x02,(byte)0xf0,
        (byte)0xe0,(byte)0xff,0x54,0x01,(byte)0xf4,0x54,0x01,(byte)0xfe,(byte)0xef,0x54,(byte)0xfe,0x4e,(byte)0xf0,(byte)0xe0,(byte)0xff,0x54,
        0x01,(byte)0xf4,0x54,0x01,(byte)0xfe,(byte)0xef,0x54,(byte)0xfe,0x4e,(byte)0xf0,(byte)0xe0,0x54,(byte)0xfd,(byte)0xf0,0x70,(byte)0xfe,
        0x60,(byte)0xfc,0x60,0x40,0x70,0x3e,0x12,0x16,0x00,0x12,0x16,0x19,0x12,0x16,(byte)0xd5,(byte)0xe4,
        (byte)0xff,0x12,0x16,(byte)0x8c,0x12,0x15,(byte)0xe5,0x12,0x16,(byte)0xb1,(byte)0xe4,(byte)0xfb,(byte)0xfd,(byte)0xfc,(byte)0xff,(byte)0xfe,
        0x12,0x12,0x5d,(byte)0xe4,(byte)0xfb,(byte)0xfd,(byte)0xfc,(byte)0xff,(byte)0xfe,0x12,0x10,(byte)0xfa,(byte)0xe4,(byte)0xfb,(byte)0xfd,(byte)0xfc,
        (byte)0xff,(byte)0xfe,0x12,0x12,(byte)0xde,(byte)0xe4,(byte)0xff,(byte)0xfe,0x12,0x14,(byte)0x89,0x12,0x16,0x19,0x12,0x16,
        0x00,0x12,0x16,(byte)0xd5,0x22,(byte)0x90,0x42,0x5d,(byte)0xe0,(byte)0x90,(byte)0x80,(byte)0xa8,(byte)0xf0,(byte)0x90,0x42,0x62,
        (byte)0xe0,(byte)0x90,(byte)0x80,(byte)0xa9,(byte)0xf0,0x12,0x0e,0x67,(byte)0xc2,0x0a,0x12,0x15,0x39,0x12,0x02,0x53,
        (byte)0xe4,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,(byte)0xff,(byte)0xc3,(byte)0x94,0x1e,0x40,0x03,0x02,
        0x08,0x79,(byte)0xef,0x12,0x03,0x57,0x12,0x02,(byte)0x83,0x12,0x02,0x73,(byte)0xe0,0x70,0x03,0x02,
        0x08,0x70,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,(byte)0xa3,(byte)0xf0,(byte)0x90,0x32,0x44,(byte)0xc0,(byte)0x83,(byte)0xc0,(byte)0x82,0x12,
        0x03,0x0b,(byte)0xc0,(byte)0xe0,(byte)0xe9,(byte)0xc0,(byte)0xe0,(byte)0xe4,0x7f,0x01,(byte)0xfe,(byte)0xfd,(byte)0xfc,(byte)0x90,(byte)0x80,(byte)0xa7,
        (byte)0xe0,(byte)0xf9,(byte)0xf8,0x12,0x08,(byte)0xc3,(byte)0xd0,(byte)0xe0,(byte)0xf9,(byte)0xd0,(byte)0xe0,0x12,0x02,(byte)0xf5,(byte)0xd0,(byte)0x82,
        (byte)0xd0,(byte)0x83,0x12,0x08,(byte)0xd6,(byte)0x90,0x42,(byte)0x81,(byte)0xe0,0x54,0x3f,(byte)0xf0,0x12,0x08,(byte)0x8b,(byte)0x90,
        (byte)0x80,(byte)0xaa,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0x90,0x32,0x44,0x12,0x08,(byte)0xe2,0x00,0x00,0x00,
        0x00,0x12,0x08,(byte)0x8b,(byte)0x90,(byte)0x80,(byte)0xac,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0xd3,(byte)0x94,0x00,(byte)0xee,
        0x64,(byte)0x80,(byte)0x94,(byte)0x80,0x40,0x1c,(byte)0x90,(byte)0x80,(byte)0xab,(byte)0xe0,0x24,(byte)0xb5,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xaa,
        (byte)0xe0,0x34,(byte)0xff,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xad,(byte)0xe0,0x24,(byte)0xb5,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xac,(byte)0xe0,0x34,
        (byte)0xff,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xaa,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,(byte)0xa3,(byte)0xe0,(byte)0xfc,(byte)0xa3,(byte)0xe0,(byte)0xfd,
        0x12,0x14,0x2a,(byte)0xa3,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xaa,0x12,0x03,0x61,(byte)0xfd,
        0x75,(byte)0xf0,0x06,(byte)0xa4,0x24,(byte)0xa8,0x12,0x02,0x09,(byte)0x90,(byte)0x80,(byte)0xac,0x12,0x03,0x38,0x24,
        (byte)0xaa,0x12,0x02,0x09,(byte)0x90,(byte)0x80,(byte)0xae,0x12,0x03,0x38,0x24,(byte)0xac,0x12,0x02,0x09,0x12,
        0x02,(byte)0xe5,0x50,0x09,(byte)0x90,(byte)0x88,0x01,(byte)0xe0,0x44,0x08,(byte)0xf0,(byte)0x80,0x07,(byte)0xe4,(byte)0x90,(byte)0x80,
        (byte)0xae,(byte)0xf0,(byte)0xa3,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xae,0x12,0x03,0x61,0x12,0x03,0x57,0x12,0x02,0x0f,
        (byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,0x04,(byte)0xf0,0x02,0x07,0x75,(byte)0x90,(byte)0x80,(byte)0xa8,(byte)0xe0,(byte)0x90,0x42,0x5d,
        (byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xa9,(byte)0xe0,0x12,0x02,0x4f,0x02,0x15,0x0d,(byte)0x90,(byte)0x80,(byte)0xa7,(byte)0xe0,(byte)0xc3,
        0x13,(byte)0xff,0x12,0x0d,0x5c,0x22,(byte)0xbb,0x01,0x0c,(byte)0xe5,(byte)0x82,0x29,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0x83,
        0x3a,(byte)0xf5,(byte)0x83,(byte)0xe0,0x22,0x50,0x06,(byte)0xe9,0x25,(byte)0x82,(byte)0xf8,(byte)0xe6,0x22,(byte)0xbb,(byte)0xfe,0x06,
        (byte)0xe9,0x25,(byte)0x82,(byte)0xf8,(byte)0xe2,0x22,(byte)0xe5,(byte)0x82,0x29,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0x83,0x3a,(byte)0xf5,(byte)0x83,
        (byte)0xe4,(byte)0x93,0x22,(byte)0xe8,0x60,0x0f,(byte)0xef,(byte)0xc3,0x33,(byte)0xff,(byte)0xee,0x33,(byte)0xfe,(byte)0xed,0x33,(byte)0xfd,
        (byte)0xec,0x33,(byte)0xfc,(byte)0xd8,(byte)0xf1,0x22,(byte)0xec,(byte)0xf0,(byte)0xa3,(byte)0xed,(byte)0xf0,(byte)0xa3,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,
        (byte)0xf0,0x22,(byte)0xa8,(byte)0x82,(byte)0x85,(byte)0x83,(byte)0xf0,(byte)0xd0,(byte)0x83,(byte)0xd0,(byte)0x82,0x12,0x08,(byte)0xf9,0x12,0x08,
        (byte)0xf9,0x12,0x08,(byte)0xf9,0x12,0x08,(byte)0xf9,(byte)0xe4,0x73,(byte)0xe4,(byte)0x93,(byte)0xa3,(byte)0xc5,(byte)0x83,(byte)0xc5,(byte)0xf0,
        (byte)0xc5,(byte)0x83,(byte)0xc8,(byte)0xc5,(byte)0x82,(byte)0xc8,(byte)0xf0,(byte)0xa3,(byte)0xc5,(byte)0x83,(byte)0xc5,(byte)0xf0,(byte)0xc5,(byte)0x83,(byte)0xc8,(byte)0xc5,
        (byte)0x82,(byte)0xc8,0x22,(byte)0xa4,0x25,(byte)0x82,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0xf0,0x35,(byte)0x83,(byte)0xf5,(byte)0x83,0x22,(byte)0xef,
        0x4e,0x60,0x12,(byte)0xef,0x60,0x01,0x0e,(byte)0xed,(byte)0xbb,0x01,0x0b,(byte)0x89,(byte)0x82,(byte)0x8a,(byte)0x83,(byte)0xf0,
        (byte)0xa3,(byte)0xdf,(byte)0xfc,(byte)0xde,(byte)0xfa,0x22,(byte)0x89,(byte)0xf0,0x50,0x07,(byte)0xf7,0x09,(byte)0xdf,(byte)0xfc,(byte)0xa9,(byte)0xf0,
        0x22,(byte)0xbb,(byte)0xfe,(byte)0xfc,(byte)0xf3,0x09,(byte)0xdf,(byte)0xfc,(byte)0xa9,(byte)0xf0,0x22,(byte)0xbb,0x01,0x06,(byte)0x89,(byte)0x82,
        (byte)0x8a,(byte)0x83,(byte)0xe0,0x22,0x50,0x02,(byte)0xe7,0x22,(byte)0xbb,(byte)0xfe,0x02,(byte)0xe3,0x22,(byte)0x89,(byte)0x82,(byte)0x8a,
        (byte)0x83,(byte)0xe4,(byte)0x93,0x22,(byte)0xf8,(byte)0xbb,0x01,0x0d,(byte)0xe5,(byte)0x82,0x29,(byte)0xf5,(byte)0x82,(byte)0xe5,(byte)0x83,0x3a,
        (byte)0xf5,(byte)0x83,(byte)0xe8,(byte)0xf0,0x22,0x50,0x06,(byte)0xe9,0x25,(byte)0x82,(byte)0xc8,(byte)0xf6,0x22,(byte)0xbb,(byte)0xfe,0x05,
        (byte)0xe9,0x25,(byte)0x82,(byte)0xc8,(byte)0xf2,0x22,(byte)0x90,0x40,0x13,(byte)0xe0,0x54,(byte)0xfd,(byte)0xf0,(byte)0xe0,0x54,(byte)0xfb,
        (byte)0xf0,(byte)0x90,0x30,0x10,0x74,0x0f,(byte)0xf0,(byte)0x90,0x30,(byte)0xaa,(byte)0xe0,0x54,(byte)0xf0,0x44,0x07,(byte)0xf0,
        (byte)0x90,0x42,0x7d,0x74,0x02,(byte)0xf0,(byte)0x90,0x42,(byte)0x82,(byte)0xe4,(byte)0xf0,(byte)0x90,0x32,0x42,(byte)0xf0,(byte)0xa3,
        (byte)0xf0,(byte)0xa3,0x12,0x08,(byte)0xe2,0x15,0x55,0x55,0x55,(byte)0x90,0x30,0x15,0x74,0x01,(byte)0xf0,(byte)0x90,
        0x30,0x13,0x74,0x07,(byte)0xf0,(byte)0x90,0x30,0x0c,0x74,0x03,(byte)0xf0,(byte)0x90,0x42,0x5f,0x74,0x01,
        (byte)0xf0,(byte)0x90,0x30,(byte)0xab,(byte)0xe0,0x44,0x40,(byte)0xf0,(byte)0x90,0x30,0x06,0x74,0x0f,(byte)0xf0,(byte)0x90,0x30,
        0x0b,(byte)0xe0,0x54,(byte)0xf0,(byte)0xf0,(byte)0x90,0x30,0x1b,0x74,0x04,(byte)0xf0,(byte)0x90,0x30,0x11,0x74,0x1d,
        0x12,0x16,0x7f,(byte)0x90,0x42,0x56,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,0x5a,(byte)0xf0,(byte)0x90,0x42,0x62,0x74,
        0x04,(byte)0xf0,(byte)0x90,0x42,0x77,0x74,0x2b,(byte)0xf0,(byte)0x90,0x30,0x1c,(byte)0xe4,(byte)0xf0,(byte)0x90,0x60,0x2f,
        (byte)0xe0,0x54,(byte)0xc7,0x44,0x08,(byte)0xf0,(byte)0xe0,0x54,(byte)0xf8,(byte)0xf0,(byte)0x90,0x37,0x33,(byte)0xe0,0x54,(byte)0xdf,
        (byte)0xf0,(byte)0x90,0x42,0x5b,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,0x60,(byte)0xf0,(byte)0xa3,(byte)0xf0,(byte)0x90,0x42,0x5e,0x04,
        (byte)0xf0,(byte)0x90,0x42,0x7a,(byte)0xf0,(byte)0x90,0x42,0x79,(byte)0xf0,(byte)0x90,0x42,0x7f,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,
        0x7e,0x04,(byte)0xf0,(byte)0x90,0x42,(byte)0x80,(byte)0xe0,0x54,(byte)0xdf,(byte)0xf0,(byte)0x90,0x37,0x33,(byte)0xe0,0x54,(byte)0xfb,
        (byte)0xf0,(byte)0xe0,0x44,0x01,(byte)0xf0,(byte)0xe0,0x44,0x02,(byte)0xf0,0x7f,(byte)0xfa,0x12,0x16,0x31,0x7f,0x08,
        0x12,0x10,0x4f,0x7f,0x0b,0x12,0x0f,0x3c,(byte)0x90,0x30,0x22,(byte)0xe4,(byte)0xf0,(byte)0x90,0x40,0x48,
        0x04,(byte)0xf0,0x22,(byte)0x90,0x42,0x5d,(byte)0xe0,(byte)0x90,(byte)0x80,(byte)0xa8,(byte)0xf0,(byte)0x90,0x42,0x62,(byte)0xe0,(byte)0x90,
        (byte)0x80,(byte)0xa9,(byte)0xf0,0x12,0x0e,0x67,(byte)0xc2,0x0a,0x12,0x15,0x39,(byte)0x90,0x42,0x7d,0x74,0x01,
        (byte)0xf0,(byte)0xe4,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,(byte)0xff,(byte)0xc3,(byte)0x94,0x2a,0x40,0x03,
        0x02,0x0b,0x2c,(byte)0xef,0x12,0x03,0x4d,0x12,0x02,(byte)0x83,(byte)0xef,0x12,0x02,0x40,(byte)0xe0,0x60,
        0x72,(byte)0xc2,0x0a,(byte)0x8f,0x11,0x12,0x16,0x5c,(byte)0x90,(byte)0x80,(byte)0xa7,(byte)0xef,(byte)0xf0,(byte)0x90,0x42,(byte)0x81,
        (byte)0xe0,0x54,0x3f,(byte)0xf0,0x12,0x0b,0x3e,(byte)0x90,(byte)0x80,(byte)0xaa,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,0x7f,(byte)0xff,
        0x12,0x14,(byte)0xb5,0x7f,(byte)0xff,0x12,0x14,(byte)0xe1,(byte)0x90,(byte)0x80,(byte)0xa7,(byte)0xe0,(byte)0xff,0x12,0x0b,0x3e,
        (byte)0x90,(byte)0x80,(byte)0xac,(byte)0xf0,(byte)0xfc,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0xfd,(byte)0x90,(byte)0x80,(byte)0xaa,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,
        (byte)0xff,0x12,0x14,0x2a,(byte)0x90,(byte)0x80,(byte)0xae,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,0x12,0x02,(byte)0xe5,0x50,
        0x09,(byte)0x90,(byte)0x88,0x01,(byte)0xe0,0x44,0x08,(byte)0xf0,(byte)0x80,0x07,(byte)0xe4,(byte)0x90,(byte)0x80,(byte)0xae,(byte)0xf0,(byte)0xa3,
        (byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xae,(byte)0xe0,(byte)0xfe,(byte)0xa3,(byte)0xe0,(byte)0xff,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,0x12,0x03,0x4d,
        0x12,0x02,0x0f,(byte)0x90,(byte)0x80,(byte)0xa6,(byte)0xe0,0x04,(byte)0xf0,0x02,0x0a,(byte)0x96,(byte)0x90,(byte)0x80,(byte)0xa8,(byte)0xe0,
        (byte)0x90,0x42,0x5d,(byte)0xf0,(byte)0x90,(byte)0x80,(byte)0xa9,(byte)0xe0,0x12,0x02,0x4f,0x02,0x15,0x0d,0x12,0x0d,
        0x5c,(byte)0xef,0x24,0x3c,(byte)0xff,(byte)0xe4,0x3e,0x22,0x7e,0x00,0x7f,0x3c,0x7d,0x00,(byte)0xaa,0x11,
        (byte)0xa9,0x12,0x7b,0x01,0x12,0x09,0x1f,(byte)0xe4,(byte)0xf5,0x14,0x74,0x31,0x25,0x14,0x12,0x02,
        0x76,(byte)0xe0,0x70,0x03,0x02,0x0b,(byte)0xeb,0x20,0x0a,0x06,(byte)0xe5,0x13,0x65,0x14,0x60,0x7b,
        0x20,0x0a,0x0c,(byte)0xe5,0x14,(byte)0xc3,(byte)0x95,0x13,0x50,0x05,(byte)0xe5,0x14,0x30,(byte)0xe0,0x6c,0x20,
        0x0a,0x1c,(byte)0x90,(byte)0x88,0x5e,(byte)0xe0,0x30,(byte)0xe0,0x15,(byte)0xe5,0x13,0x54,(byte)0xfe,(byte)0xff,(byte)0xe5,0x14,
        0x54,(byte)0xfe,0x6f,(byte)0x90,0x42,(byte)0x83,0x70,0x03,(byte)0xf0,(byte)0x80,0x03,0x74,0x01,(byte)0xf0,(byte)0xaf,0x14,
        0x12,0x12,(byte)0x9e,0x7d,0x01,0x12,0x0f,(byte)0xf5,(byte)0x85,0x12,(byte)0x82,(byte)0x85,0x11,(byte)0x83,0x75,(byte)0xf0,
        0x02,(byte)0xe5,0x14,0x12,0x09,0x13,(byte)0xee,(byte)0xf0,(byte)0xef,0x12,0x02,0x6b,(byte)0x9f,(byte)0x90,(byte)0x88,0x04,
        (byte)0xe0,(byte)0x9e,0x50,0x16,(byte)0xd2,0x08,(byte)0x90,(byte)0x88,0x01,(byte)0xe0,(byte)0xff,0x30,0x0a,0x04,0x7e,0x04,
        (byte)0x80,0x02,0x7e,0x02,(byte)0xef,0x4e,(byte)0x90,(byte)0x88,0x01,(byte)0xf0,(byte)0x90,0x42,0x7d,(byte)0xe0,0x54,(byte)0xfd,
        (byte)0xf0,(byte)0x90,0x32,0x44,0x12,0x08,(byte)0xe2,0x00,0x00,0x00,0x00,0x05,0x14,(byte)0xe5,0x14,(byte)0xc3,
        (byte)0x94,0x1e,0x50,0x03,0x02,0x0b,0x5a,(byte)0x90,(byte)0x88,0x5e,(byte)0xe0,0x30,(byte)0xe0,0x05,(byte)0x90,0x42,
        (byte)0x83,(byte)0xe4,(byte)0xf0,0x22,(byte)0x90,0x41,0x07,(byte)0xe4,(byte)0xf0,(byte)0x90,0x41,0x06,0x74,0x06,(byte)0xf0,(byte)0x90,
        0x41,0x05,(byte)0xe4,(byte)0xf0,(byte)0x90,0x41,0x04,0x74,0x0f,(byte)0xf0,(byte)0x90,0x42,0x0b,0x74,0x05,(byte)0xf0,
        (byte)0x90,0x42,0x0a,(byte)0xe0,0x44,0x02,(byte)0xf0,(byte)0xe0,0x44,0x01,(byte)0xf0,(byte)0xa3,0x74,0x08,(byte)0xf0,(byte)0x90,
        0x42,0x0a,(byte)0xe0,0x44,0x02,(byte)0xf0,(byte)0x90,0x41,0x09,0x74,0x03,(byte)0xf0,(byte)0x90,0x42,0x02,(byte)0xe0,
        0x44,0x02,(byte)0xf0,(byte)0x90,0x42,0x0e,(byte)0xe0,0x44,0x02,(byte)0xf0,(byte)0x90,0x42,0x06,(byte)0xe0,0x54,(byte)0xfd,
        (byte)0xf0,0x12,0x03,0x18,(byte)0x90,0x42,0x03,(byte)0xf0,(byte)0x90,0x42,0x07,(byte)0xf0,(byte)0x90,0x42,0x0f,(byte)0xf0,
        (byte)0x90,(byte)0x80,(byte)0xb3,0x74,0x01,(byte)0xf0,(byte)0xfb,0x7a,(byte)0x80,0x79,(byte)0xb3,(byte)0xf5,0x17,0x7f,0x03,0x12,
        0x11,(byte)0x94,(byte)0xe4,(byte)0x90,(byte)0x80,(byte)0xb3,(byte)0xf0,0x12,0x02,0x1d,0x75,0x17,0x01,0x7f,0x04,0x12,
        0x11,(byte)0x94,(byte)0xe4,(byte)0x90,(byte)0x80,(byte)0xb3,(byte)0xf0,0x12,0x02,0x1d,0x75,0x17,0x01,0x7f,0x05,0x12,
        0x11,(byte)0x94,(byte)0x90,(byte)0x80,(byte)0xb3,0x74,0x60,(byte)0xf0,0x12,0x02,0x1d,0x75,0x17,0x01,0x7f,0x19,
        0x12,0x11,(byte)0x94,0x12,0x02,0x17,0x12,0x09,0x1f,0x12,0x02,0x1d,0x75,0x17,0x06,0x7f,
        0x13,0x12,0x11,(byte)0x94,0x02,0x15,(byte)0x84,(byte)0xc2,(byte)0xaf,0x12,0x16,(byte)0xa5,0x78,(byte)0xff,(byte)0xe4,(byte)0xf6,
        (byte)0xd8,(byte)0xfd,(byte)0x90,(byte)0x80,0x00,0x7f,0x00,0x7e,0x50,(byte)0xe4,(byte)0xf0,(byte)0xa3,(byte)0xdf,(byte)0xfc,(byte)0xde,(byte)0xfa,
        0x75,(byte)0xa0,(byte)0xbe,0x75,(byte)0x89,0x00,0x75,(byte)0x81,(byte)0xff,0x02,0x0d,0x17,0x02,0x06,0x0e,(byte)0xe4,
        (byte)0x93,(byte)0xa3,(byte)0xf8,(byte)0xe4,(byte)0x93,(byte)0xa3,0x40,0x03,(byte)0xf6,(byte)0x80,0x01,(byte)0xf2,0x08,(byte)0xdf,(byte)0xf4,(byte)0x80,
        0x29,(byte)0xe4,(byte)0x93,(byte)0xa3,(byte)0xf8,0x54,0x07,0x24,0x0c,(byte)0xc8,(byte)0xc3,0x33,(byte)0xc4,0x54,0x0f,0x44,
        0x20,(byte)0xc8,(byte)0x83,0x40,0x04,(byte)0xf4,0x56,(byte)0x80,0x01,0x46,(byte)0xf6,(byte)0xdf,(byte)0xe4,(byte)0x80,0x0b,0x01,
        0x02,0x04,0x08,0x10,0x20,0x40,(byte)0x80,(byte)0x90,0x16,0x6e,(byte)0xe4,0x7e,0x01,(byte)0x93,0x60,(byte)0xbc,
        (byte)0xa3,(byte)0xff,0x54,0x3f,0x30,(byte)0xe5,0x09,0x54,0x1f,(byte)0xfe,(byte)0xe4,(byte)0x93,(byte)0xa3,0x60,0x01,0x0e,
        (byte)0xcf,0x54,(byte)0xc0,0x25,(byte)0xe0,0x60,(byte)0xa8,0x40,(byte)0xb8,(byte)0xe4,(byte)0x93,(byte)0xa3,(byte)0xfa,(byte)0xe4,(byte)0x93,(byte)0xa3,
        (byte)0xf8,(byte)0xe4,(byte)0x93,(byte)0xa3,(byte)0xc8,(byte)0xc5,(byte)0x82,(byte)0xc8,(byte)0xca,(byte)0xc5,(byte)0x83,(byte)0xca,(byte)0xf0,(byte)0xa3,(byte)0xc8,(byte)0xc5,
        (byte)0x82,(byte)0xc8,(byte)0xca,(byte)0xc5,(byte)0x83,(byte)0xca,(byte)0xdf,(byte)0xe9,(byte)0xde,(byte)0xe7,(byte)0x80,(byte)0xbe,(byte)0xef,0x54,0x0f,(byte)0xff,
        (byte)0x90,0x30,0x38,(byte)0xe0,0x54,(byte)0xf0,0x4f,(byte)0xf0,(byte)0xa3,0x74,0x01,(byte)0xf0,(byte)0x90,0x30,0x18,0x74,
        (byte)0xc0,(byte)0xf0,(byte)0xa3,(byte)0xe4,(byte)0xf0,(byte)0x90,(byte)0x80,0x30,0x04,(byte)0xf0,(byte)0x90,(byte)0x88,0x06,(byte)0xe0,(byte)0xfe,(byte)0xa3,
        (byte)0xe0,(byte)0xff,0x12,0x15,0x60,(byte)0x90,0x30,0x03,(byte)0xe4,(byte)0xf0,0x30,(byte)0xff,(byte)0xfd,(byte)0x90,0x30,0x03,
        0x74,0x01,(byte)0xf0,0x7f,(byte)0x96,0x12,0x16,0x31,(byte)0xe4,(byte)0xf5,0x1b,(byte)0xf5,0x1c,(byte)0xfd,0x7c,(byte)0xc0,
        0x7b,(byte)0xc8,(byte)0xfa,(byte)0xeb,0x25,(byte)0xe0,(byte)0xff,(byte)0xea,0x33,(byte)0xfe,(byte)0xed,0x2f,(byte)0xf5,(byte)0x82,(byte)0xec,0x3e,
        (byte)0xf5,(byte)0x83,(byte)0xe0,(byte)0xa2,(byte)0xe7,0x13,(byte)0xfe,(byte)0xa3,(byte)0xe0,0x13,0x25,0x1c,(byte)0xf5,0x1c,(byte)0xee,0x35,
        0x1b,(byte)0xf5,0x1b,0x0b,(byte)0xbb,0x00,0x01,0x0a,(byte)0xba,0x01,(byte)0xd8,(byte)0xbb,0x08,(byte)0xd5,(byte)0xe5,0x1c,
        (byte)0xae,0x1b,0x78,0x05,(byte)0xce,(byte)0xa2,(byte)0xe7,0x13,(byte)0xce,0x13,(byte)0xd8,(byte)0xf8,(byte)0xf5,0x1c,(byte)0x8e,0x1b,
        (byte)0xff,0x22,(byte)0xe4,(byte)0xfe,(byte)0xfd,(byte)0xfc,0x12,0x02,(byte)0x93,(byte)0xe0,0x2d,(byte)0xfd,0x0c,(byte)0xbc,0x2a,(byte)0xf6,
        (byte)0xe4,(byte)0xfc,0x12,0x02,(byte)0x9e,(byte)0xe0,0x2d,(byte)0xfd,0x0c,(byte)0xbc,0x1e,(byte)0xf6,(byte)0xed,0x70,0x02,0x7e,
        0x01,(byte)0x90,(byte)0x88,0x50,(byte)0xe0,0x2d,0x60,0x02,0x7e,0x01,(byte)0xee,0x60,0x16,(byte)0xe4,(byte)0xfc,0x12,
        0x02,(byte)0x93,(byte)0xec,(byte)0xf0,0x0c,(byte)0xbc,0x2a,(byte)0xf7,(byte)0xe4,(byte)0xfc,0x12,0x02,(byte)0x9e,(byte)0xec,(byte)0xf0,0x0c,
        (byte)0xbc,0x1e,(byte)0xf7,0x7c,0x2a,(byte)0x90,(byte)0x80,0x4f,(byte)0xe4,(byte)0xf0,(byte)0xa3,(byte)0xdc,(byte)0xfc,0x7c,0x1e,(byte)0x90,
        (byte)0x80,0x31,(byte)0xe4,(byte)0xf0,(byte)0xa3,(byte)0xdc,(byte)0xfc,(byte)0xe4,(byte)0xfc,0x12,0x02,(byte)0x93,(byte)0xe0,(byte)0xff,(byte)0xc3,(byte)0x94,
        0x2a,0x50,0x09,0x74,0x4f,0x2f,0x12,0x02,0x47,0x74,0x01,(byte)0xf0,0x0c,(byte)0xbc,0x2a,(byte)0xe9,
        (byte)0xe4,(byte)0xfc,0x12,0x02,(byte)0x9e,(byte)0xe0,(byte)0xff,(byte)0xc3,(byte)0x94,0x1e,0x50,0x06,0x12,0x02,0x73,0x74,
        0x01,(byte)0xf0,0x0c,(byte)0xbc,0x1e,(byte)0xec,0x22,(byte)0x90,0x42,0x56,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,0x5a,(byte)0xf0,
        (byte)0x90,0x42,0x60,(byte)0xf0,(byte)0xa3,(byte)0xf0,(byte)0x90,0x42,0x5d,0x74,0x03,(byte)0xf0,(byte)0x90,0x42,0x62,0x04,
        (byte)0xf0,(byte)0x90,0x30,0x16,(byte)0xe4,(byte)0xf0,(byte)0xa3,0x74,0x75,(byte)0xf0,(byte)0x90,0x30,0x09,0x74,0x06,(byte)0xf0,
        (byte)0x90,0x42,0x7d,0x74,0x01,(byte)0xf0,(byte)0x90,0x30,0x1f,(byte)0xe0,0x44,0x01,(byte)0xf0,(byte)0x90,0x37,0x33,
        (byte)0xe0,0x44,0x04,(byte)0xf0,(byte)0x90,0x30,0x1e,0x74,0x05,(byte)0xf0,(byte)0x90,0x32,0x42,(byte)0xe4,(byte)0xf0,(byte)0xa3,
        (byte)0xf0,(byte)0xa3,0x12,0x08,(byte)0xe2,0x00,0x00,0x00,0x00,(byte)0x90,0x42,(byte)0x82,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,
        0x5f,0x04,(byte)0xf0,(byte)0x90,0x42,(byte)0x81,(byte)0xe0,0x44,0x01,(byte)0xf0,0x7f,(byte)0xff,0x12,0x14,(byte)0xb5,0x7f,
        (byte)0xff,0x02,0x14,(byte)0xe1,(byte)0xcb,(byte)0xef,(byte)0xcb,(byte)0xca,(byte)0xee,(byte)0xca,(byte)0xe4,(byte)0xf5,0x3b,(byte)0xf5,0x3a,(byte)0xf5,
        0x39,(byte)0xf5,0x38,(byte)0x8b,(byte)0x82,(byte)0x8a,(byte)0x83,(byte)0xe4,(byte)0x93,(byte)0xff,0x60,0x47,(byte)0xc3,(byte)0x94,0x30,0x40,
        0x3b,(byte)0xef,(byte)0xd3,(byte)0x94,0x39,0x50,0x35,(byte)0xaf,0x3b,(byte)0xae,0x3a,(byte)0xad,0x39,(byte)0xac,0x38,0x78,
        0x04,0x12,0x08,(byte)0xc3,(byte)0x8f,0x3b,(byte)0x8e,0x3a,(byte)0x8d,0x39,(byte)0x8c,0x38,(byte)0xe4,(byte)0x93,0x24,(byte)0xd0,
        (byte)0xff,(byte)0xe4,0x34,(byte)0xff,(byte)0xfe,(byte)0xe4,(byte)0xfc,(byte)0xfd,(byte)0xe5,0x3b,0x2f,(byte)0xf5,0x3b,(byte)0xe5,0x3a,0x3e,
        (byte)0xf5,0x3a,(byte)0xed,0x35,0x39,(byte)0xf5,0x39,(byte)0xec,0x35,0x38,(byte)0xf5,0x38,0x0b,(byte)0xbb,0x00,0x01,
        0x0a,(byte)0x80,(byte)0xb0,(byte)0xaf,0x3b,(byte)0xae,0x3a,(byte)0xad,0x39,(byte)0xac,0x38,0x22,(byte)0xef,(byte)0xb4,0x0c,0x00,
        0x50,0x4b,(byte)0x90,0x0f,0x49,(byte)0xf8,0x28,0x28,0x73,0x02,0x0f,0x6d,0x02,0x0f,0x6d,0x02,
        0x0f,0x6d,0x02,0x0f,0x6d,0x02,0x0f,0x6d,0x02,0x0f,0x6d,0x02,0x0f,0x6d,0x02,0x0f,
        0x73,0x02,0x0f,0x79,0x02,0x0f,0x7f,0x02,0x0f,(byte)0x85,0x02,0x0f,(byte)0x8b,0x7c,0x0f,0x7d,
        (byte)0xe0,(byte)0x80,0x1e,0x7c,0x07,0x7d,(byte)0xf0,(byte)0x80,0x18,0x7c,0x07,0x7d,(byte)0xf8,(byte)0x80,0x12,0x7c,
        0x07,0x7d,(byte)0xfc,(byte)0x80,0x0c,0x7c,0x07,0x7d,(byte)0xfe,(byte)0x80,0x06,(byte)0x80,0x00,0x7c,0x07,0x7d,
        (byte)0xff,(byte)0x90,0x37,0x26,(byte)0xec,(byte)0xf0,(byte)0xa3,(byte)0xed,(byte)0xf0,0x22,0x47,0x54,0x39,0x30,0x30,0x36,
        0x40,0x42,0x35,0x2d,0x41,0x70,0x72,0x20,0x30,0x36,0x20,0x32,0x30,0x31,0x37,0x2d,
        0x31,0x37,0x3a,0x35,0x39,0x3a,0x31,0x36,0x00,0x30,0x34,0x2f,0x30,0x36,0x2f,0x31,
        0x37,0x00,0x31,0x37,0x3a,0x35,0x39,0x3a,0x31,0x36,0x00,0x00,0x01,0x02,0x03,0x04,
        0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,
        0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,
        0x25,0x26,0x27,0x28,0x29,(byte)0x8f,0x15,(byte)0x8d,0x16,(byte)0xe4,(byte)0xf5,0x17,(byte)0xf5,0x18,(byte)0xf5,0x19,
        (byte)0xf5,0x1a,0x12,0x0d,0x5c,(byte)0x8e,0x17,(byte)0x8f,0x18,(byte)0xe5,0x16,0x60,0x0f,(byte)0x90,0x30,0x1e,
        0x74,(byte)0x86,(byte)0xf0,(byte)0xaf,0x15,0x12,0x0d,0x5c,(byte)0x8e,0x19,(byte)0x8f,0x1a,(byte)0xd3,(byte)0xe5,0x18,(byte)0x95,
        0x1a,(byte)0xe5,0x19,0x64,(byte)0x80,(byte)0xf8,(byte)0xe5,0x17,0x64,(byte)0x80,(byte)0x98,0x40,0x0c,(byte)0xe5,0x18,(byte)0x95,
        0x1a,(byte)0xff,(byte)0xe5,0x17,(byte)0x95,0x19,(byte)0xfe,(byte)0x80,0x0b,(byte)0xc3,(byte)0xe5,0x1a,(byte)0x95,0x18,(byte)0xff,(byte)0xe5,
        0x19,(byte)0x95,0x17,(byte)0xfe,(byte)0x8e,0x17,(byte)0x8f,0x18,(byte)0x90,0x30,0x1e,0x74,0x05,(byte)0xf0,0x22,(byte)0xef,
        (byte)0xb4,0x09,0x00,0x50,0x46,(byte)0x90,0x10,0x5c,(byte)0xf8,0x28,0x28,0x73,0x02,0x10,0x77,0x02,
        0x10,0x77,0x02,0x10,0x77,0x02,0x10,0x77,0x02,0x10,0x7d,0x02,0x10,(byte)0x83,0x02,0x10,
        (byte)0x89,0x02,0x10,(byte)0x8f,0x02,0x10,(byte)0x95,0x7c,0x00,0x7d,(byte)0xe0,(byte)0x80,0x22,0x7c,0x00,0x7d,
        (byte)0xf0,(byte)0x80,0x1c,0x7c,0x00,0x7d,(byte)0xf8,(byte)0x80,0x16,0x7c,0x00,0x7d,(byte)0xfc,(byte)0x80,0x10,0x7c,
        0x00,0x7d,(byte)0xfe,(byte)0x80,0x0a,0x7c,0x00,0x7d,(byte)0xff,(byte)0x80,0x04,0x7c,0x0f,0x7d,(byte)0xff,(byte)0x90,
        0x37,0x24,(byte)0xec,(byte)0xf0,(byte)0xa3,(byte)0xed,(byte)0xf0,0x22,(byte)0x8b,0x22,(byte)0x8a,0x23,(byte)0x89,0x24,(byte)0xe4,(byte)0xf5,
        0x2a,(byte)0xf5,0x2b,(byte)0xe5,0x29,0x15,0x29,(byte)0xae,0x28,0x70,0x02,0x15,0x28,0x4e,0x60,0x33,
        (byte)0xab,0x25,(byte)0xaa,0x26,(byte)0xa9,0x27,0x12,0x09,0x4b,(byte)0xff,(byte)0xab,0x22,(byte)0xaa,0x23,(byte)0xa9,0x24,
        0x05,0x2b,(byte)0xe5,0x2b,(byte)0xac,0x2a,0x70,0x02,0x05,0x2a,0x14,(byte)0xf5,(byte)0x82,(byte)0x8c,(byte)0x83,(byte)0xef,
        0x12,0x09,0x64,(byte)0xef,0x60,(byte)0xcd,0x74,0x01,0x25,0x27,(byte)0xf5,0x27,(byte)0xe4,0x35,0x26,(byte)0xf5,
        0x26,(byte)0x80,(byte)0xc0,(byte)0xab,0x22,(byte)0xaa,0x23,(byte)0xa9,0x24,0x22,(byte)0x8e,0x08,(byte)0x8f,0x09,(byte)0x8c,0x0a,
        (byte)0x8d,0x0b,(byte)0xd2,(byte)0xb5,(byte)0xc2,(byte)0xb2,(byte)0xc2,(byte)0xb1,0x7f,0x3b,0x12,0x16,(byte)0x8c,(byte)0xe4,(byte)0xff,0x12,
        0x16,(byte)0x8c,(byte)0xaf,0x08,0x12,0x16,(byte)0x8c,(byte)0xaf,0x09,0x12,0x16,(byte)0x8c,0x7f,0x08,(byte)0xd2,(byte)0xb0,
        (byte)0xc2,(byte)0xb0,(byte)0xdf,(byte)0xfa,(byte)0xc2,(byte)0xb5,(byte)0x85,0x0b,(byte)0x82,(byte)0x85,0x0a,(byte)0x83,0x7e,(byte)0x80,0x7f,0x04,
        (byte)0xd2,(byte)0xb0,(byte)0xa2,(byte)0xb4,0x33,(byte)0xa2,(byte)0xb7,0x33,(byte)0xc2,(byte)0xb0,(byte)0xdf,(byte)0xf4,0x12,0x16,(byte)0xd5,(byte)0xde,
        (byte)0xed,(byte)0xdb,(byte)0xe9,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x22,(byte)0x8f,0x1d,(byte)0x8d,0x1e,(byte)0x90,0x42,0x0e,(byte)0xe0,
        0x54,(byte)0xfe,(byte)0xf0,(byte)0xe4,(byte)0xf5,0x1f,(byte)0xe5,0x1f,(byte)0xc3,(byte)0x95,0x1e,0x50,0x36,0x7f,(byte)0xe1,0x12,
        0x13,0x25,(byte)0xe5,0x1d,0x25,0x1f,(byte)0xff,0x12,0x13,0x25,0x12,0x02,0x2b,0x12,0x13,(byte)0x92,
        0x74,(byte)0xb2,0x25,0x1f,(byte)0xf5,(byte)0x82,(byte)0xe4,0x34,(byte)0x80,(byte)0xf5,(byte)0x83,(byte)0xef,(byte)0xf0,0x12,0x02,0x5a,
        0x12,0x16,0x31,(byte)0x90,0x42,0x02,0x12,0x02,0x5d,0x12,0x16,0x31,0x12,0x02,0x24,0x05,
        0x1f,(byte)0x80,(byte)0xc3,0x22,(byte)0x8b,0x14,(byte)0x8a,0x15,(byte)0x89,0x16,(byte)0xcd,(byte)0xef,(byte)0xcd,0x12,0x13,0x1c,
        (byte)0xcf,(byte)0xed,(byte)0xcf,0x12,0x13,0x25,(byte)0xe4,(byte)0xfd,(byte)0xed,(byte)0xc3,(byte)0x95,0x17,0x50,0x15,(byte)0xab,0x14,
        (byte)0xaa,0x15,(byte)0xa9,0x16,(byte)0x8d,(byte)0x82,0x75,(byte)0x83,0x00,0x12,0x08,(byte)0x96,(byte)0xff,0x12,0x13,0x25,
        0x0d,(byte)0x80,(byte)0xe5,0x12,0x02,0x2b,0x12,0x02,0x5a,0x12,0x16,0x31,(byte)0x90,0x42,0x02,0x12,
        0x02,0x5d,0x12,0x16,0x31,0x12,0x02,0x24,0x22,(byte)0xe4,(byte)0xf5,0x11,(byte)0xf5,0x12,(byte)0x8e,0x13,
        (byte)0x8f,0x14,(byte)0x8f,(byte)0x82,(byte)0x8e,(byte)0x83,(byte)0xe5,(byte)0x82,0x24,(byte)0x93,0x12,0x02,0x7e,(byte)0xfd,0x05,0x14,
        (byte)0xe5,0x14,(byte)0xaa,0x13,0x70,0x02,0x05,0x13,0x14,(byte)0xf5,(byte)0x82,(byte)0x8a,(byte)0x83,(byte)0xe0,0x25,0x12,
        (byte)0xf5,0x12,(byte)0xe4,0x35,0x11,(byte)0xf5,0x11,0x0d,(byte)0xbd,(byte)0x95,(byte)0xe3,(byte)0xc3,(byte)0xe4,(byte)0x95,0x12,(byte)0xfd,
        (byte)0xe4,(byte)0x95,0x11,(byte)0xfc,(byte)0xef,0x24,(byte)0x93,0x12,0x03,0x2c,0x22,(byte)0xe4,(byte)0xf5,0x0d,(byte)0xf5,0x0e,
        (byte)0x8e,0x0f,(byte)0x8f,0x10,(byte)0x8f,(byte)0x82,(byte)0x8e,(byte)0x83,(byte)0xe5,(byte)0x82,0x24,0x3f,0x12,0x02,0x7e,(byte)0xfd,
        0x05,0x10,(byte)0xe5,0x10,(byte)0xaa,0x0f,0x70,0x02,0x05,0x0f,0x14,(byte)0xf5,(byte)0x82,(byte)0x8a,(byte)0x83,(byte)0xe0,
        0x25,0x0e,(byte)0xf5,0x0e,(byte)0xe4,0x35,0x0d,(byte)0xf5,0x0d,0x0d,(byte)0xbd,0x41,(byte)0xe3,(byte)0xc3,(byte)0xe4,(byte)0x95,
        0x0e,(byte)0xfd,(byte)0xe4,(byte)0x95,0x0d,(byte)0xfc,(byte)0xef,0x24,0x3f,0x12,0x03,0x2c,0x22,(byte)0x8e,0x08,(byte)0x8f,
        0x09,(byte)0x8c,0x0a,(byte)0x8d,0x0b,(byte)0xd2,(byte)0xb5,(byte)0xc2,(byte)0xb2,(byte)0xc2,(byte)0xb1,0x7f,0x03,0x12,0x16,(byte)0x8c,
        (byte)0xe4,(byte)0xff,0x12,0x16,(byte)0x8c,(byte)0xaf,0x08,0x12,0x16,(byte)0x8c,(byte)0xaf,0x09,0x12,0x16,(byte)0x8c,(byte)0x85,
        0x0b,(byte)0x82,(byte)0x85,0x0a,(byte)0x83,0x7f,(byte)0x80,0x7e,0x08,(byte)0xd2,(byte)0xb0,(byte)0xa2,(byte)0xb4,0x33,(byte)0xc2,(byte)0xb0,
        (byte)0xde,(byte)0xf7,0x12,0x16,(byte)0xd5,(byte)0xdf,(byte)0xf0,(byte)0xdb,(byte)0xec,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x22,(byte)0x8f,0x15,
        (byte)0xe5,0x15,0x30,(byte)0xe0,0x07,(byte)0x90,0x42,0x7d,(byte)0xe0,0x44,0x02,(byte)0xf0,(byte)0x90,0x32,0x44,(byte)0xc0,
        (byte)0x83,(byte)0xc0,(byte)0x82,0x12,0x03,0x0b,(byte)0xc0,(byte)0xe0,(byte)0xe9,(byte)0xc0,(byte)0xe0,(byte)0xe4,0x7f,0x01,(byte)0xfe,(byte)0xfd,
        (byte)0xfc,(byte)0xa9,0x15,(byte)0xc8,(byte)0xe9,(byte)0xc8,0x12,0x08,(byte)0xc3,(byte)0xd0,(byte)0xe0,(byte)0xf9,(byte)0xd0,(byte)0xe0,0x12,0x02,
        (byte)0xf5,(byte)0xd0,(byte)0x82,(byte)0xd0,(byte)0x83,0x12,0x08,(byte)0xd6,(byte)0xe5,0x15,(byte)0xc3,0x13,(byte)0xff,0x22,(byte)0x8e,0x08,
        (byte)0x8f,0x09,(byte)0x8c,0x0a,(byte)0x8d,0x0b,(byte)0xd2,(byte)0xb5,(byte)0xc2,(byte)0xb2,0x12,0x16,(byte)0xb1,(byte)0xc2,(byte)0xb1,0x7f,
        0x02,0x12,0x16,(byte)0x8c,(byte)0xe4,(byte)0xff,0x12,0x16,(byte)0x8c,(byte)0xaf,0x0a,0x12,0x16,(byte)0x8c,(byte)0xaf,0x0b,
        0x12,0x16,(byte)0x8c,(byte)0x85,0x09,(byte)0x82,(byte)0x85,0x08,(byte)0x83,(byte)0xe0,(byte)0xa3,(byte)0xff,0x12,0x16,(byte)0x8c,(byte)0xdb,
        (byte)0xf8,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x12,0x15,(byte)0xe5,0x12,0x16,(byte)0xbd,0x22,(byte)0x90,0x42,0x0e,(byte)0xe0,
        0x54,(byte)0xfe,(byte)0xf0,0x7f,(byte)0xe0,0x12,0x03,0x18,0x12,0x03,0x24,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0xe4,
        (byte)0xfe,(byte)0xef,(byte)0x90,0x42,0x02,0x30,(byte)0xe7,0x06,(byte)0xe0,0x44,0x01,(byte)0xf0,(byte)0x80,0x04,(byte)0xe0,0x54,
        (byte)0xfe,(byte)0xf0,(byte)0x90,0x42,0x0e,(byte)0xe0,0x44,0x01,(byte)0xf0,(byte)0xef,0x25,(byte)0xe0,(byte)0xff,(byte)0xe0,0x54,(byte)0xfe,
        (byte)0xf0,0x0e,(byte)0xbe,0x08,(byte)0xdc,0x12,0x03,0x24,0x22,(byte)0xd3,0x10,(byte)0xaf,0x01,(byte)0xc3,(byte)0xc0,(byte)0xd0,
        (byte)0x8e,0x3c,(byte)0x8f,0x3d,0x12,0x15,(byte)0xc6,(byte)0xef,0x60,(byte)0xfa,(byte)0x85,0x3d,(byte)0x82,(byte)0x85,0x3c,(byte)0x83,
        (byte)0xe0,0x70,0x03,(byte)0xd3,(byte)0x80,0x01,(byte)0xc3,(byte)0x92,0x0c,0x30,0x0c,0x09,(byte)0x85,0x3d,(byte)0x82,(byte)0x85,
        0x3c,(byte)0x83,0x74,0x01,(byte)0xf0,0x12,0x16,(byte)0xcf,(byte)0xa2,0x0c,(byte)0xe4,0x33,(byte)0xff,(byte)0xd0,(byte)0xd0,(byte)0x92,
        (byte)0xaf,0x22,(byte)0xe4,(byte)0xff,(byte)0xfe,(byte)0x90,0x41,(byte)0xfe,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0x90,0x42,0x0e,(byte)0xe0,
        0x44,0x01,(byte)0xf0,(byte)0xee,0x25,(byte)0xe0,(byte)0xfe,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0x90,0x42,0x17,(byte)0xe0,(byte)0xc4,
        0x13,0x13,0x13,0x54,0x01,0x30,(byte)0xe0,0x01,0x0e,0x0f,(byte)0xef,(byte)0xc3,(byte)0x94,0x08,0x40,(byte)0xdc,
        0x12,0x03,0x24,(byte)0xcf,(byte)0xee,(byte)0xcf,0x22,0x75,0x25,(byte)0xff,0x75,0x26,0x0f,0x75,0x27,(byte)0x9a,
        0x75,0x28,0x00,0x75,0x29,0x1f,0x7b,0x01,0x7a,(byte)0x80,0x79,0x10,0x12,0x10,(byte)0xa8,0x7e,
        0x0f,0x7f,(byte)0xb9,0x12,0x0e,(byte)0xd4,(byte)0x90,(byte)0x80,0x02,0x12,0x08,(byte)0xd6,0x7e,0x0f,0x7f,(byte)0xc2,
        0x12,0x0e,(byte)0xd4,(byte)0x90,(byte)0x80,0x06,0x02,0x08,(byte)0xd6,(byte)0xce,(byte)0xed,(byte)0xce,(byte)0xef,0x14,0x60,0x09,
        0x04,0x70,0x26,(byte)0x90,0x40,0x33,(byte)0xe4,(byte)0xf0,0x22,(byte)0x90,0x42,0x53,(byte)0xe0,0x54,(byte)0xdf,(byte)0xf0,
        (byte)0x90,0x42,0x6c,(byte)0xe4,(byte)0xf0,(byte)0x90,0x42,0x69,(byte)0xf0,(byte)0xa3,0x12,0x16,0x7f,(byte)0xcf,(byte)0xee,(byte)0xcf,
        0x12,0x14,0x5b,(byte)0x90,0x40,0x33,0x74,0x01,(byte)0xf0,0x22,(byte)0xc3,(byte)0xef,(byte)0x9d,(byte)0xfb,(byte)0xee,(byte)0x9c,
        (byte)0xfa,(byte)0xc3,(byte)0xef,(byte)0x9d,(byte)0xec,0x64,(byte)0x80,(byte)0xf8,(byte)0xee,0x64,(byte)0x80,(byte)0x98,0x50,0x07,(byte)0xc3,(byte)0xe4,
        (byte)0x9b,(byte)0xfb,(byte)0xe4,(byte)0x9a,(byte)0xfa,(byte)0xd3,(byte)0xef,(byte)0x94,0x00,(byte)0xee,0x64,(byte)0x80,(byte)0x94,(byte)0x80,0x40,0x04,
        (byte)0xca,0x44,(byte)0x80,(byte)0xca,(byte)0xce,(byte)0xea,(byte)0xce,(byte)0xcf,(byte)0xeb,(byte)0xcf,0x22,(byte)0xcd,(byte)0xef,(byte)0xcd,(byte)0xed,0x54,
        0x03,0x75,(byte)0xf0,0x10,(byte)0xa4,(byte)0xff,(byte)0x90,0x42,(byte)0x80,(byte)0xe0,(byte)0xfa,(byte)0xa3,(byte)0xe0,0x54,(byte)0xcf,(byte)0xfb,
        (byte)0xea,0x45,(byte)0xf0,(byte)0xfe,(byte)0xeb,0x4f,(byte)0xff,(byte)0x90,0x42,(byte)0x80,(byte)0xee,(byte)0xf0,(byte)0xa3,(byte)0xef,(byte)0xf0,(byte)0xed,
        0x13,0x13,0x54,0x3f,(byte)0x90,0x42,0x6b,(byte)0xf0,0x22,(byte)0x8e,0x08,(byte)0x8f,0x09,(byte)0xd2,(byte)0xb5,(byte)0xc2,
        (byte)0xb2,0x12,0x16,(byte)0xb1,(byte)0xc2,(byte)0xb1,0x7f,0x20,0x12,0x16,(byte)0x8c,(byte)0xe4,(byte)0xff,0x12,0x16,(byte)0x8c,
        (byte)0xaf,0x08,0x12,0x16,(byte)0x8c,(byte)0xaf,0x09,0x12,0x16,(byte)0x8c,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x12,0x15,
        (byte)0xe5,0x12,0x16,(byte)0xbd,0x22,(byte)0x8f,0x11,0x12,0x02,0x17,0x12,0x09,0x1f,(byte)0xe5,0x11,(byte)0xf4,
        0x60,0x11,(byte)0xe5,0x11,0x12,0x03,0x43,(byte)0x80,0x02,(byte)0xc3,0x33,(byte)0xd8,(byte)0xfc,(byte)0xff,(byte)0xe5,0x11,
        0x12,0x02,(byte)0xa9,0x12,0x02,0x1d,0x75,0x17,0x06,0x7f,0x07,0x12,0x11,(byte)0x94,0x02,0x15,
        (byte)0x84,(byte)0x8f,0x12,0x12,0x02,0x17,0x12,0x09,0x1f,(byte)0xe5,0x12,(byte)0xf4,0x60,0x11,(byte)0xe5,0x12,
        0x12,0x03,0x43,(byte)0x80,0x02,(byte)0xc3,0x33,(byte)0xd8,(byte)0xfc,(byte)0xff,(byte)0xe5,0x12,0x12,0x02,(byte)0xa9,0x12,
        0x02,0x1d,0x75,0x17,0x06,0x7f,0x0d,0x12,0x11,(byte)0x94,0x02,0x15,(byte)0x84,(byte)0x90,0x30,0x1f,
        (byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0x90,0x37,0x33,(byte)0xe0,0x54,(byte)0xfb,(byte)0xf0,(byte)0x90,0x30,0x39,(byte)0xe4,(byte)0xf0,
        (byte)0x90,0x30,0x05,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0xe0,0x54,(byte)0xfb,(byte)0xf0,(byte)0x90,0x42,0x5f,0x74,0x03,
        (byte)0xf0,(byte)0x90,0x42,(byte)0x81,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,0x22,(byte)0xe4,(byte)0xff,(byte)0xa2,0x0a,(byte)0xe4,0x33,(byte)0xfe,
        (byte)0xef,(byte)0xc3,0x13,0x24,0x2c,0x12,0x02,(byte)0xcb,(byte)0xbf,0x1e,(byte)0xf0,(byte)0xe4,(byte)0xff,(byte)0xa2,0x0a,(byte)0xe4,
        0x33,(byte)0xfe,(byte)0xef,(byte)0x90,0x0f,(byte)0xcb,(byte)0x93,0x24,0x00,0x12,0x02,(byte)0xcb,(byte)0xbf,0x2a,(byte)0xee,0x22,
        (byte)0xcd,(byte)0xef,(byte)0xcd,(byte)0xcc,(byte)0xee,(byte)0xcc,(byte)0xd3,(byte)0xed,(byte)0x94,(byte)0xfa,(byte)0xec,(byte)0x94,0x00,0x40,0x0f,0x7f,
        (byte)0xfa,0x12,0x16,0x31,0x74,0x06,0x2d,(byte)0xfd,0x74,(byte)0xff,0x3c,(byte)0xfc,(byte)0x80,(byte)0xe8,(byte)0xcf,(byte)0xed,
        (byte)0xcf,0x02,0x16,0x31,0x12,0x13,0x1c,0x7f,0x02,0x12,0x13,0x25,0x7f,0x01,0x12,0x13,
        0x25,0x12,0x02,0x2b,0x12,0x02,0x5a,0x12,0x16,0x31,(byte)0x90,0x42,0x02,0x12,0x02,0x5d,
        0x12,0x16,0x31,0x12,0x02,0x24,0x22,(byte)0xd3,0x10,(byte)0xaf,0x01,(byte)0xc3,(byte)0x90,0x40,(byte)0xa4,(byte)0xe0,
        (byte)0xf5,0x34,(byte)0x85,(byte)0xdd,0x35,(byte)0x85,(byte)0xde,0x36,(byte)0x85,(byte)0xdf,0x37,(byte)0x92,(byte)0xaf,(byte)0xaf,0x37,(byte)0xae,
        0x36,(byte)0xad,0x35,(byte)0xac,0x34,0x22,(byte)0xd3,0x10,(byte)0xaf,0x01,(byte)0xc3,(byte)0xc0,(byte)0xd0,(byte)0x90,0x40,(byte)0xdf,
        0x74,0x0d,(byte)0xf0,(byte)0x90,0x40,(byte)0xfd,(byte)0xe0,(byte)0xb4,0x0d,0x04,0x7f,0x01,(byte)0x80,0x02,0x7f,0x00,
        (byte)0xd0,(byte)0xd0,(byte)0x92,(byte)0xaf,0x22,(byte)0xc2,(byte)0xb1,0x7f,0x05,0x12,0x16,(byte)0x8c,0x7f,0x07,(byte)0xd2,(byte)0xb0,
        (byte)0xc2,(byte)0xb0,(byte)0xdf,(byte)0xfa,(byte)0xd2,(byte)0xb0,(byte)0xa2,(byte)0xb4,(byte)0x92,0x0a,(byte)0xc2,(byte)0xb0,0x20,0x0a,(byte)0xe6,0x22,
        (byte)0xd2,(byte)0xb5,(byte)0xc2,(byte)0xb2,0x12,0x16,(byte)0xb1,(byte)0xc2,(byte)0xb1,0x7f,0x60,0x12,0x16,(byte)0x8c,(byte)0xc2,(byte)0xb0,
        (byte)0xd2,(byte)0xb1,0x12,0x15,(byte)0xe5,0x12,0x16,(byte)0xbd,0x22,(byte)0xc2,(byte)0xb1,0x7f,0x05,0x12,0x16,(byte)0x8c,
        0x7f,0x08,(byte)0xd2,(byte)0xb0,(byte)0xa2,(byte)0xb4,0x33,(byte)0xc2,(byte)0xb0,(byte)0xdf,(byte)0xf7,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,(byte)0xff,
        0x22,(byte)0x90,0x40,(byte)0xa7,(byte)0xe0,(byte)0xfe,(byte)0x90,0x40,(byte)0xa7,(byte)0xe0,(byte)0xc3,(byte)0x9e,(byte)0xc3,(byte)0x9f,0x40,0x03,
        (byte)0xd3,(byte)0x80,0x01,(byte)0xc3,0x50,(byte)0xf0,0x22,(byte)0xd3,0x10,(byte)0xaf,0x01,(byte)0xc3,(byte)0x90,0x40,(byte)0xa6,(byte)0xe0,
        (byte)0xf5,0x3e,(byte)0x85,(byte)0xdf,0x3f,(byte)0x92,(byte)0xaf,(byte)0xae,0x3e,(byte)0xaf,0x3f,0x22,(byte)0xa2,0x0a,(byte)0x92,0x0b,
        (byte)0x90,0x42,(byte)0x82,0x74,0x01,(byte)0xf0,(byte)0xaf,0x11,0x12,0x14,(byte)0xe1,0x7f,0x0c,0x22,0x01,0x20,
        0x00,0x4a,(byte)0x80,0x00,0x42,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xf0,
        (byte)0x90,0x42,0x53,(byte)0xe0,0x54,(byte)0xfe,(byte)0xf0,(byte)0xe0,0x54,(byte)0xfd,(byte)0xf0,0x22,(byte)0xef,0x7f,0x08,0x33,
        (byte)0x92,(byte)0xb6,(byte)0xd2,(byte)0xb0,(byte)0xc2,(byte)0xb0,(byte)0xdf,(byte)0xf7,0x22,(byte)0xd3,0x10,(byte)0xaf,0x01,(byte)0xc3,(byte)0xc0,(byte)0xd0,
        (byte)0xd0,(byte)0xd0,(byte)0x92,(byte)0xaf,0x22,(byte)0x90,0x40,0x4b,0x74,0x03,(byte)0xf0,(byte)0x90,0x40,0x4a,(byte)0xe4,(byte)0xf0,
        0x22,(byte)0xc2,(byte)0xb1,0x7f,0x06,0x12,0x16,(byte)0x8c,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x22,(byte)0xc2,(byte)0xb1,0x7f,
        0x04,0x12,0x16,(byte)0x8c,(byte)0xc2,(byte)0xb0,(byte)0xd2,(byte)0xb1,0x22,(byte)0x90,0x40,(byte)0xe3,(byte)0xef,(byte)0xf0,0x22,(byte)0x90,
        0x40,(byte)0xdf,(byte)0xe4,(byte)0xf0,0x22,(byte)0xf0,(byte)0xa3,0x22,
    };

    private byte GT9xxxShortConfig[] = {
        //短路阀值设置
        //0x00,0x32,0x00,0x96,0x00,0x14,
        0x00,0x32,0x00,(byte)0x96,
        //需要把配置中的通道配置读取出来 此处先写入固定值!
        //驱动通道
        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,
        //感应通道
        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
        //其它
        (byte)0x9E,0x00,0x14,0x00,
    };

    private byte GT7xxxShortConfig[] = {
            0x24,0x27,0x26,0x25,0x28,0x2A,0x29,0x2B,0x2C,0x2E,0x2D,0x34,0x2F,0x30,0x31,0x35,0x33,0x32,
            0x36,0x37,0x39,0x38,0x3C,0x3A,0x3D,0x3B,0x3E,0x47,0x45,0x44,0x46,0x42,0x41,0x43,0x3F,0x40,
            0x03,0x00,0x01,0x06,0x05,0x02,0x08,0x04,0x07,0x09,0x0B,0x0A,0x10,0x0D,0x0C,0x11,0x0F,0x0E,
            0x12,0x14,0x13,0x15,0x16,0x17,0x18,0x19,0x1A,0x23,0x22,0x21,0x1E,0x1F,0x1B,0x1C,0x20,0x1D,
            (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,0x27,0x2A,0x29,0x28,0x2B,0x26,0x24,0x25,0x23,0x21,0x22,0x20,0x1E,0x1F,
            0x1D,0x1C,0x1A,0x1B,0x18,0x19,0x17,0x16,0x11,0x12,0x14,0x13,0x15,0x0E,0x0F,0x10,0x0B,0x0C,
            0x0D,0x08,0x09,0x0A,0x06,0x04,0x07,0x02,0x05,0x03,0x01,0x00,(byte)0xFF,(byte)0xFF,0x00,0x00,0x64,0x00,
            0x20,0x03,0x20,0x03,0x20,0x03,(byte)0xC8,0x00,(byte)0xF4,0x01,(byte)0xF4,0x01,(byte)0xF4,0x01,(byte)0xF4,0x01,0x00,0x00,
            0x00,0x00,0x00,0x00,0x04,0x00,0x06,0x00,0x44,0x00,0x59,0x00,0x4B,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xE2,0x0A,
    };

    //GT7 配置界面显示和短路通道上报map
    private byte DrvMap[] = {
            66,65,63,64,61,62,60,59,57,58,56,54,55,53,51,52,50,45,48,47,46,49,
            66,65,62,64,60,63,59,61,56,57,58,53,54,55,50,51,52,45,46,48,47,49,
    };

    private byte SenMap[] = {
            0,3,2,1,4,6,5,7,8,10,9,12,13,14,17,16,11,15,18,19,21,20,23,25,22,
            24,26,43,44,41,40,42,38,37,39,36,1,2,5,0,7,4,3,8,6,9,11,10,14,13,
            17,16,12,15,18,20,19,21,22,23,24,25,26,41,42,44,39,40,43,38,37,36,
    };


    private byte[] bypCfgDrv = new byte[46];
    private byte[] bypCfgSen = new byte[76];

    private byte[] bypDrvShortFlag = new byte[46];
    private byte[] bypSenShortFlag = new byte[76];

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dataanalysis);
        mAlertContext = DataAnalysis.this;
        //ConstantsActivity.activityList.add(this);
        //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        //switchLanguage(ConstantsActivity.langae);
        InitButton();
        InitEditText();
        InitListener();
        InitData();
        initTextView();
		openDevices();
    }

    //核心设置的代码
    protected void switchLanguage(String language) {
        Resources resources = getResources();
        Configuration config = resources.getConfiguration();
        DisplayMetrics dm = resources.getDisplayMetrics();
        switch (language) {
            case "zh":
                config.locale = Locale.CHINESE;
                resources.updateConfiguration(config, dm);
                break;
            case "en":
                config.locale = Locale.ENGLISH;
                resources.updateConfiguration(config, dm);
                break;
            default:
                config.locale = Locale.US;
                resources.updateConfiguration(config, dm);
                break;
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    private void InitButton(){
        btn_RawdataShow = (Button) findViewById(R.id.rawdata);
        btn_DiffdataShow = (Button) findViewById(R.id.diffdata);
        btn_ReffdataShow = (Button) findViewById(R.id.reffdata);
        btn_ManualdiffdataShow = (Button) findViewById(R.id.manualdiff);
        btn_Manualreff = (Button) findViewById(R.id.manualreff);
        btn_StylusDataShow = (Button) findViewById(R.id.stylusdata);
        btn_Test = (Button) findViewById(R.id.testting);
        btn_Stop = (Button) findViewById(R.id.stop);

        //btn_RawdataShow.setEnabled(false);
        //btn_DiffdataShow.setEnabled(false);
        //btn_ReffdataShow.setEnabled(false);
        //btn_ManualdiffdataShow.setEnabled(false);
        btn_Manualreff.setEnabled(false);
        //btn_StylusDataShow.setEnabled(false);
        //btn_Stop.setEnabled(false);
    }

    private void InitEditText(){
        edt_RowNum = (EditText) findViewById(R.id.inputrownum);
        edt_ColNum = (EditText) findViewById(R.id.inputcolnum);
        edt_Maximum = (EditText) findViewById(R.id.inputmaximum);
        edt_Minimum = (EditText) findViewById(R.id.inputminimum);
        edt_TestiInformation = (EditText) findViewById(R.id.maxandmintestinfo);  //显示测试过程信息
        edt_TestiInformation.setKeyListener(null);

        edtShortCircuitInfo = (EditText) findViewById(R.id.shortcircuitinfo);
        edtShortCircuitInfo.setKeyListener(null);
    }

    private void InitListener(){
        btn_RawdataShow.setOnClickListener(this);
        btn_DiffdataShow.setOnClickListener(this);
        btn_ReffdataShow.setOnClickListener(this);
        btn_ManualdiffdataShow.setOnClickListener(this);
        btn_Manualreff.setOnClickListener(this);
        btn_StylusDataShow.setOnClickListener(this);
        btn_Test.setOnClickListener(this);
        btn_Stop.setOnClickListener(this);
    }

    private void InitData(){
        btn_RawdataShow.setEnabled(false);
        btn_DiffdataShow.setEnabled(false);
        btn_ReffdataShow.setEnabled(false);
        btn_ManualdiffdataShow.setEnabled(false);
        btn_Manualreff.setEnabled(false);
        btn_StylusDataShow.setEnabled(false);
        btn_Test.setEnabled(false);

        textGridLayout = (GridLayout)findViewById(R.id.AllGridLayout);
    }

    /**
     * 打开设备 , 让车机和手机端连起来
     */
    public void openDevices() {

        mThreadPool = Executors.newFixedThreadPool(5);
        mContext = getApplicationContext();
        mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
        //列举设备(手机)
        daOpenDevicesReceiver = new OpenDevicesReceiver(this);
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                SystemClock.sleep(1000);
                PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), 0);
                IntentFilter intentFilter = new IntentFilter(USB_ACTION);

                registerReceiver(daOpenDevicesReceiver, intentFilter);
                while(isNeedFindDevice) {
                    SystemClock.sleep(100);
                    HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
                    if (deviceList != null) {
                        for (UsbDevice usbDevice : deviceList.values()) {
                            //int productId = usbDevice.getProductId();
                            int vendorId = usbDevice.getVendorId();
                            if ((vendorId == 0x27C0)          //之前VID错误了，做兼容
                                    ||(vendorId == 0x27C6)    //汇顶的VID
                                    ||(vendorId == 0x222A)    //奕力的VID
                                    ||(vendorId == 0x056A))   //8191主动笔和Wacom主动笔
                            {
                                if (mUsbManager.hasPermission(usbDevice)) {
                                    initDevice();
                                } else {
                                    mUsbManager.requestPermission(usbDevice, pendingIntent);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                }
            }   //ThreadPool
        });
    }

    /**
     * 初始化设备(手机) , 当手机进入Accessory模式后 , 手机的PID会变为Google定义的2个常量值其中的一个 ,
     */
    private void initDevice() {
        HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
        Collection<UsbDevice> values = deviceList.values();
        if (!values.isEmpty()) {
            for (UsbDevice usbDevice : values) {
                //int productId = usbDevice.getProductId();
                int vendorId = usbDevice.getVendorId();
                //if (productId == 0x0818 || productId == 0x0001 )
                if ((vendorId == 0x27C0)          //之前VID错误了，做兼容
                        ||(vendorId == 0x27C6)    //汇顶的VID
                        ||(vendorId == 0x222A)    //奕力的VID
                        ||(vendorId == 0x056A))   //8191主动笔和Wacom主动笔
                {
                    if (mUsbManager.hasPermission(usbDevice)) {

                        UsbInterface usbInterface = usbDevice.getInterface(1);

                        for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
                            UsbEndpoint ep = usbInterface.getEndpoint(i);

                            if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
                                //mUsbEndpointIn = ep;
                                mUsbEndpointOut = ep;
                            } else {
                                //mUsbEndpointOut = ep;
                                mUsbEndpointIn = ep;
                            }
                        }

                        if ((null == mUsbEndpointIn) || (null == mUsbEndpointOut)) {
                            mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
                            if (mUsbDeviceConnection!=null) {
                                int i = mUsbDeviceConnection.controlTransfer(0x00, 0x09,
                                        0x002, 0, null, 0, 100);
                                SystemClock.sleep(1000);
                                if (i >= 0) {
                                    //mHandler.sendEmptyMessage(DEBUG_MESSAGE_SUCCESS);
                                } else {
                                    //mHandler.sendEmptyMessage(DEBUG_MESSAGE_ERROR);
                                }
                            }
                        } else {
                            isNeedFindDevice = false;
                            mUsbInterface = usbInterface;
                            mUsbDeviceConnection = mUsbManager.openDevice(usbDevice);
                            mUsbDeviceConnection.claimInterface(mUsbInterface, true);
                            if(null != mUsbEndpointIn){
                                iProductId = usbDevice.getProductId();
                                if ((iProductId == 0x0819) || (iProductId == 0x8191) || (iProductId == 0x0528))
                                {
                                    byProductType = GT7;
                                }
                                mHandler.sendEmptyMessage(CONNECTED_SUCCESS);
                            }
                        }
                    } else {
                        mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(""), 0));
                    }
                }
            }
        } else {
            // finish();
        }
    }

    private byte iicByteData[]={
            //0    1   2     3    4    5    6
            0x03,0x00,0x0f,0x00,0x00,0x00,0x01,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    };
    private byte iicWriteData[]={
            //0    1   2     3    4    5    6
            0x03,0x00,0x0f,0x00,0x00,0x00,0x39,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    };

    //发送命令，使得S818可以通过IIC向GT9的固定地址读取任意bytes的数据
    private boolean iicRead(byte addressHigh,byte addressLow,byte[] wBuffer,int length) {

        int i;

        iicByteData[1] = 0x00; //read GT9 command
        iicByteData[2] = 0x0f; //no command
        iicByteData[3] = addressHigh;
        iicByteData[4] = addressLow;
        iicByteData[5] = 0x00;
        iicByteData[6] = 63;  //length 一次接收63个数据

        for (int j = 7; j < 64; j++) {
            iicByteData[j] = 0x00;
        }

        int address1 = ((addressHigh&0xff)<<8);
        int address2 = addressLow&0xff;
        int address = address1|address2;

        int sendTimes = length/63;  //预计是向下取整，所以+1

        if ((length % 63) != 0)
        {
            sendTimes += 1;   //预计是向下取整，所以+1
        }

        for (int k = 0; k < sendTimes; k++) {
            int finalOffset = k*63; //每次只能发57bytes数据
            int offset = k*64;

            if(length - (finalOffset ) < 63) {

                iicByteData[6] = (byte) (length - (finalOffset));  //length
            }
            else
            {
                iicByteData[6] = 63;
            }

            //发送读取命令
            i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointOut, iicByteData, 0, 0x40, 100);
            if (i != 0x40)
                return false;  //传输失败
            // SystemClock.sleep(1);

            isReceiverMessage = false;  //先关闭循环接收信息

            //接收数据
            i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointIn, wBuffer, offset, 0x40, 3000);

            if (i != 0x40) {
                return false;
            }

            address = address + 63;
            iicByteData[3] = (byte)(address>>8);
            iicByteData[4] = (byte)address;
        }

        //将report id从数组中去除
        //byte[] temperBuffer =new byte[length];
        if(true) {
            int count1 = 0;
            for (int k = 0; k < length; k++) {
                if (k % 63 == 0) {
                    count1++;
                }

                wBuffer[k] = wBuffer[k + count1];

            }
        }
        return true;
    }
    //发送命令，使得S818可以通过IIC向GT9的固定地址写任意bytes的数据
    private  boolean iicWrite(byte addressHigh,byte addressLow,byte[] wBuffer,int offset,int length) {
        int i;

        iicWriteData[1] = 0x01; //write GT9 command
        iicWriteData[2] = 0x0f; //no command
        iicWriteData[3] = addressHigh;
        iicWriteData[4] = addressLow;
        iicWriteData[5] = 0x00;
        iicWriteData[6] = 0x39;  //length

        int address1 = ((addressHigh&0xff)<<8);
        int address2 = addressLow&0xff;
        int address = address1|address2;

        int sendTimes = length/57 + 1;  //预计是向下取整，所以+1

        for (int k = 0; k < sendTimes; k++) {
            int finalOffset = offset + k*57; //每次只能发57bytes数据

            if(length - (finalOffset -offset) < 57) {

                iicWriteData[6] = (byte) (length - (finalOffset -offset));  //length
            }
            else
            {
                iicWriteData[6] = 0x39;
            }

            int j;
            for (j = 7; j < iicWriteData[6] + 7; j++) {
                iicWriteData[j] = wBuffer[finalOffset + j -7];
            }
            for (; j < 64; j++) {
                iicWriteData[j] = 0;
            }
            i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointOut, iicWriteData, 0, 0x40, 100);

            if (i != 0x40) {
                return false;
            }

            address = address + 57;
            iicWriteData[3] = (byte)((address & 0xff00) >> 8);
            iicWriteData[4] = (byte)(address & 0xff);
        }

        return true;
    }


    //发送命令，使得S818可以通过IIC向GT9的固定地址写1byte数据
    private  boolean iicByteWrite(byte addressHigh,byte addressLow,byte subCommand,byte data) {
        int i;

        iicByteData[1] = 0x01; //write GT9 command
        iicByteData[2] = subCommand;
        iicByteData[3] = addressHigh;
        iicByteData[4] = addressLow;
        iicByteData[5] = 0x00;
        iicByteData[6] = 0x01;  //length

        iicByteData[7] = data;
        if ((null == mUsbEndpointIn) || (null == mUsbEndpointOut)){
            i=0;
        }
        else {
            i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointOut, iicByteData, 0, 0x40, 100);
        }
        // i = 0;
        if(i == 0x40)
            return true;
        else
            return false;
    }

    //发送命令，使得S818可以通过IIC向GT9的固定地址读取1byte数据
    private byte iicByteRead(byte addressHigh,byte addressLow) {

        iicByteData[1] = 0x00; //read GT9 command
        iicByteData[2] = 0x0f;  //no command
        iicByteData[3] = addressHigh;
        iicByteData[4] = addressLow;
        iicByteData[5] = 0x00;   //length
        iicByteData[6] = 0x01;   //lengthlow

        iicByteData[7] = 0x00;

        int i;

        i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointOut, iicByteData, 0, 0x40, 100);
        if (i != 0x40)
            return 0x77;  //用0x77来表示传输失败

        //SystemClock.sleep(12);  //加长时间，避免数据显示错乱乱闪
        SystemClock.sleep(24);  //加长时间，避免数据显示错乱乱闪

        isReceiverMessage = false;  //先关闭循环接收信息

        i = mUsbDeviceConnection.bulkTransfer(mUsbEndpointIn, mBytes, 0, 0x40, 3000);

        //SystemClock.sleep(12);  //加长时间，避免数据显示错乱乱闪
        SystemClock.sleep(24);  //加长时间，避免数据显示错乱乱闪

        if (i == 0x40)
            return mBytes[1];
        else
            return 0x77;  //用0x77来表示传输失败
    }

    private boolean changeToDebugMode() {

        byte maddressHigh = (byte) 0x80;
        byte maddressLow = (byte) 0x40;
        byte msubcommand = (byte) 0x06;   //ENTRY_DEBUG_MODE
        byte mdata = (byte) 0x01;

        if (byProductType == GT7) {
            iicByteWrite((byte) 0x80, (byte) 0x41, (byte) 0x0f, (byte) 0x00);
            iicByteWrite((byte) 0x80, (byte) 0x42, (byte) 0x0f, (byte) 0xff);
        }

        if (!iicByteWrite(maddressHigh, maddressLow, msubcommand, mdata)) {
            return false;
        }

        return true;
    }

    private boolean changeToNormalMode() {

        if (byProductType == GT7) {
            iicByteWrite((byte) 0x80, (byte) 0x41, (byte) 0x0f, (byte) 0x00);
            iicByteWrite((byte) 0x80, (byte) 0x42, (byte) 0x0f, (byte) 0x00);
        }

        byte maddressHigh = (byte)0x80;
        byte maddressLow = (byte)0x40;
        byte msubcommand =0x07 ;  //QUIT_DEBUG_MODE
        byte mdata = (byte)0x00;

        if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {

            return false;
        }

        return true;
    }

    private boolean getRawdata() {

        byte maddressHigh;
        byte maddressLow;  //rawdata address
        byte msubcommand = (byte)0x0d;  //  READ_SYNC
        byte mdata;
        int ilength = colnum * rownum * 2;

        if (showFlag == 8)
        {
            ilength = (colnum + rownum + 2) * 2;
        }

        if(!iicRead(showAddressHigh,showAddressLow,mRawdataBytes,ilength)) {  //读取rawData
            return false;
        }

        int tempcol = 0;
        int i = 0;

        if (showFlag != 8)  {
            //控制行数
            for (int row = 0; row < rownum; row++) {  //Sen
                //控制列数
                for (int col = 0; col < colnum; col++) {  //Drv

                    int idtemp = (row + tempcol * rownum);

                    switch (showFlag){
                        case 1:  //GT9的rawdata
                        case 2:  //manual diffdata
                        case 4:  //reffdata
                        case 7:  //GT7的rawdata低位在前
                            idtemp = idtemp * 2;
                            if (byProductType == GT7)  //GT7的低位在前
                            {
                                datatemp[i] = ((mRawdataBytes[idtemp + 1] & 0xFF) << 8) + (mRawdataBytes[idtemp] & 0xFF);
                            }else{
                                datatemp[i] = ((mRawdataBytes[idtemp] & 0xFF) << 8) + (mRawdataBytes[idtemp + 1] & 0xFF);
                            }
                            break;

                        case 3:  //GT9的diffdata
                            datatemp[i] = (mRawdataBytes[idtemp] & 0xFF);
                            break;

                        default:
                            break;
                    }

                    tempcol++;

                    i++;
                }
                tempcol = 0;
            }
        }

        while(bShowDataFlag == true){  //上一次的数据显示还没结束则一直等待
            SystemClock.sleep(1);
        }

        for (i = 0; i < 72 * 44; i++) {
            iDataShow[i] = datatemp[i];
        }

        maddressHigh = (byte)0x81;
        if (byProductType == GT7)
        {
            maddressHigh = (byte)0x82;
        }
        maddressLow = (byte)0x4E;  // SYNC address
        msubcommand = 0x0f;        //  READ_SYNC
        mdata = (byte)0x00;

        if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
            return false;
        }

        return true;
    }

    public void initTextView() {
        //mtextView = (TextView) findViewById(R.id.textView);
        tvMaximum = (TextView) findViewById(R.id.maximumshow);
        tvMinimum = (TextView) findViewById(R.id.minimumshow);
        tvDataContent = (TextView) findViewById(R.id.datacontentshow);
        tvMAD = (TextView) findViewById(R.id.madshow);
    }

    int count = 1000;
    private void showRawdata() {

        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {

                byte syncFlag = 1;

                byte maddressHigh = (byte) 0x81;
                byte maddressLow = (byte) 0x4E;  //SYNC address
                byte msubcommand = (byte) 0x0f;
                byte mdata = (byte) 0x00;

                if (byProductType == GT7) {
                    maddressHigh = (byte) 0x82;
                }

                if (showFlag == 6)
                {
                    btTestStep = 1;  //

                    if (byProductType == GT7)
                    {
                        GT7xxxShortTestProc();
                    }else{
                        GT9xxxShortTestProc();
                    }

                    SystemClock.sleep(100);

                    btTestStep = 2;

                    changeToDebugMode();

                    stTestLogShow = "";

                    stTestLog = getResources().getString(R.string.startmaxmintest);
                    stTestLogShow = stTestLogShow.concat(stTestLog);
                }

                while(showFlag != 4) {

                    if(count-- == 0)
                    {
                        count = 0;
                    }

                    while(true) {
                        //轮询读取0x814E，如果非0，则读取rawdata
                        maddressHigh = (byte) 0x81;
                        if (byProductType == GT7)
                        {
                            maddressHigh = (byte) 0x82;

                        }

                        maddressLow = (byte) 0x4E;
                        syncFlag = iicByteRead(maddressHigh, maddressLow);

                        //while ((syncFlag == 0 )|| (syncFlag == 0x77)) {
                        if (((syncFlag == 0) || (syncFlag == 0x77)) ){
                            SystemClock.sleep(1);
                            //mHandler.sendEmptyMessage(LOG1_MESSAG);
                        }
                        else
                        {
                            if (showFlag != 6) {
                                if (byDisplayFrame == byDisplayFrameCount) {
                                    for (int i = 0; i < mRawdataBytes.length; i++) {
                                        mRawdataBytes[i] = (byte) 0x00;
                                    }
                                }
                            }

                            break;
                        }
                    }
                    if (byDisplayFrame == byDisplayFrameCount) {

                        if ((showFlag != 6) && (showFlag != 8) && (showFlag != 5) && (count < 999)) {  //测试模式、读取主动笔数据和停止时
                            byDisplayFrameCount = 0;
                        }

                        if (getRawdata() == true) {

                            switch (showFlag) {
                                case 1:// GT9XXX and GT7XXX rawdata
                                case 7:// GT7XXX diffdata

                                    mHandler.sendEmptyMessage(RAWDATA_MESSAGE);

                                    break;
                                case 2://manual diff
                                    if (count == 999)   //第一帧备份rawdata作为基准
                                    {
                                        if (byProductType == GT7) {
                                            for (int i = 0; i < 44 * 72; i++) {
                                                //int j = i / 2;
                                                mManualRefInt[i] = iDataShow[i];//((mRawdataBytes[i + 1] & 0xFF) << 8) + (mRawdataBytes[i] & 0xFF);
                                                //i++;
                                            }
                                        } else {
                                            for (int i = 0; i < 42 * 30; i++) {
                                                //int j = i / 2;
                                                mManualRefInt[i] = iDataShow[i];//((mRawdataBytes[i] & 0xFF) << 8) + (mRawdataBytes[i + 1] & 0xFF);
                                                //i++;
                                            }
                                        }

                                    }

                                    mHandler.sendEmptyMessage(MANUALDIFF_MESSAGE);
                                    // mHandler.sendEmptyMessage(RAWDATA_MESSAGE);
                                    break;
                                case 3://diffdata
                                    mHandler.sendEmptyMessage(DIFF_MESSAGE);
                                    break;
                                case 5:  //stop
                                    changeToNormalMode();
                                    SystemClock.sleep(40);
                                    showFlag = 4;
                                    count = 1000;
                                    btTestStep = 0;
                                    SystemClock.sleep(10);
                                    break;
                                case 6:  //test
                                    mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                                    break;
                                case 8:  //stylusdata
                                    mHandler.sendEmptyMessage(STYLUS_DATA_MESSAGE);
                                    break;
                                default:
                                    break;
                            }
                        } else {
                            iicByteWrite(maddressHigh, maddressLow, msubcommand, mdata);
                        }

                    }
                    else{
                        byDisplayFrameCount++;

                        iicByteWrite(maddressHigh, maddressLow, msubcommand, mdata);
                    }
                }
            }   //ThreadPool
        });   //ThreadPool
        //   return true;
    }

    Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            StringBuilder stringBuilder = new StringBuilder("");
            int idtemp;
            int i = 0;
            int tempcol = 0;
            int temprow = 0;
            boolean flag = false;
            String dv;
            int maxdata;
            int mindata;
            int itemp;  //临时存放

            bShowDataFlag = true;  //开始显示

            switch (msg.what) {
                case RAWDATA_MESSAGE://

                    textGridLayout.removeAllViews();

                    maxdata = 0;
                    mindata = 65535;
                    i = 0;

                    //控制行数
                    for (int row = 0; row < rownum; row++) {  //Sen
                        //控制列数
                        for (int col = 0; col < colnum + 1; col++) {  //Drv

                            TextView textView = new TextView(mContext);
                            GridLayout.LayoutParams params = new GridLayout.LayoutParams();

                            if (col == 0)
                            {
                                dv = Integer.toString(row);
                                //if (row < 10){
                                //    dv = "0" + dv;
                                //}

                                //stringBuilder.append(dv);
                                //stringBuilder.append("│");

                            }else{
                                //idtemp = (row + tempcol * rownum) * 2;
                                if (byProductType == GT7)  //GT7的低位在前
                                {
                                    //iDataShow[i] = ((mRawdataBytes[idtemp + 1] & 0xFF) << 8) + (mRawdataBytes[idtemp] & 0xFF);

                                    if ((showFlag == 7) && (iDataShow[i] > 10)){  //GT7XXX diffdata
                                        textView.setTextColor(Color.parseColor("#FF0000"));
                                    }

                                }else{
                                    //iDataShow[i] = ((mRawdataBytes[idtemp] & 0xFF) << 8) + (mRawdataBytes[idtemp + 1] & 0xFF);
                                }

                                dv = Integer.toString(iDataShow[i]);

                                //stringBuilder.append(dv + "│");

                                tempcol++;

                                //获取最大值
                                if (iDataShow[i] > maxdata){
                                    maxdata = iDataShow[i];
                                }
                                //获取最小值
                                if (iDataShow[i] < mindata){
                                    mindata = iDataShow[i];
                                }

                                i++;

                                params.width = 42;
                            }


                            textView.setText(dv);
                            textView.setGravity(Gravity.CENTER);
                            params.setMargins(2,1,2,1);

                            textGridLayout.addView(textView,params);


                        }
                        tempcol = 0;
                        //stringBuilder.append("\n");

                    }

                    //mtextView.setText(stringBuilder.toString());
                    tvMaximum.setText(Integer.toString(maxdata));
                    tvMinimum.setText(Integer.toString(mindata));
                    break;

                case CLEAR_MESSAGE://清除数据
                    mtextView.setText("");
                    break;

                case CONNECTED_SUCCESS: //连接成功
                    btn_RawdataShow.setEnabled(true);
                    btn_DiffdataShow.setEnabled(true);
                    btn_ReffdataShow.setEnabled(true);
                    btn_ManualdiffdataShow.setEnabled(true);
                    //btn_Manualreff.setEnabled(false);
                    btn_StylusDataShow.setEnabled(true);
                    btn_Test.setEnabled(true);
                    break;

                case DIFF_MESSAGE://
                    textGridLayout.removeAllViews();

                    maxdata = 0;
                    mindata = 255;
                    for (int row = 0; row < rownum; row++) {  //Sen
                        //控制列数
                        for (int col = 0; col < colnum + 1; col++) {  //Drv

                            TextView textView = new TextView(mContext);
                            GridLayout.LayoutParams params = new GridLayout.LayoutParams();

                            if (col == 0){
                                dv = Integer.toString(row);
                                //if (row < 10){
                                //    dv = "0" + dv;
                                //}

                                //stringBuilder.append(dv);
                                //stringBuilder.append("│");
                            }else{
                                //idtemp = row + tempcol * rownum;
                                //datatemp[i] = (mRawdataBytes[idtemp] & 0xFF);
                                dv = Integer.toString(datatemp[i]);

                                //stringBuilder.append(dv + "│");

                                tempcol++;

                                //获取最大值
                                if (datatemp[i] > maxdata){
                                    maxdata = datatemp[i];
                                }
                                //获取最小值
                                if (datatemp[i] < mindata){
                                    mindata = datatemp[i];
                                }

                                if (datatemp[i] > 10){
                                    textView.setTextColor(Color.parseColor("#FF0000"));
                                }

                                i++;

                                params.width = 40;
                            }

                            //textView.setMinimumWidth(8);
                            textView.setText(dv);
                            textView.setGravity(Gravity.CENTER);
                            params.setMargins(2,1,2,1);
                            //params.width = 45;

                            textGridLayout.addView(textView,params);
                        }
                        tempcol = 0;
                        //stringBuilder.append("\n");
                    }
                    //mtextView.setText(stringBuilder.toString());
                    tvMaximum.setText(Integer.toString(maxdata));
                    tvMinimum.setText(Integer.toString(mindata));
                    break;
                case  MANUALDIFF_MESSAGE:



                    textGridLayout.removeAllViews();
                    maxdata = -32767;
                    mindata = 32768;
                    for (int row = 0; row < rownum; row++) {  //Sen
                        //控制列数
                        for (int col = 0; col < colnum + 1; col++) {  //Drv

                            TextView textView = new TextView(mContext);
                            GridLayout.LayoutParams params = new GridLayout.LayoutParams();

                            if (col == 0){

                                dv = Integer.toString(row);
                                //if (row < 10){
                                //    dv = "0" + dv;
                                //}

                                //stringBuilder.append(dv);
                                //stringBuilder.append("│");

                            }else{

                                //idtemp = row + tempcol * rownum;
                                //if (byProductType == GT7)  //GT7的低位在前
                                //{
                                //    iDataShow[i] = ((mRawdataBytes[idtemp * 2 + 1] & 0xFF) << 8) + (mRawdataBytes[idtemp * 2] & 0xFF);
                                //}else{
                                //    iDataShow[i] = ((mRawdataBytes[idtemp * 2] & 0xFF) << 8) + (mRawdataBytes[idtemp * 2 + 1] & 0xFF);
                                //}

                                iDataShow[i] = mManualRefInt[i] - iDataShow[i];
                                dv = Integer.toString(iDataShow[i]);

                                //stringBuilder.append(dv + "│");

                                tempcol++;

                                //获取最大值
                                if (iDataShow[i] > maxdata){
                                    maxdata = iDataShow[i];
                                }
                                //获取最小值
                                if (iDataShow[i] < mindata){
                                    mindata = iDataShow[i];
                                }

                                if (iDataShow[i] > 30){
                                    textView.setTextColor(Color.parseColor("#FF0000"));
                                }else if (iDataShow[i] < -30){
                                    textView.setTextColor(Color.parseColor("#0000FF"));
                                }

                                i++;

                                params.width = 40;
                            }


                            textView.setText(dv);
                            textView.setGravity(Gravity.CENTER);
                            params.setMargins(2,1,2,1);
                            //params.width = 45;
                            textGridLayout.addView(textView,params);
                        }
                        tempcol = 0;
                        //stringBuilder.append("\n");
                    }
                    //mtextView.setText(stringBuilder.toString());
                    tvMaximum.setText(Integer.toString(maxdata));
                    tvMinimum.setText(Integer.toString(mindata));


                    break;

                case TEST_DATA_MESSAGE:  //
                    if (1 == btTestStep)
                    {
                        edt_TestiInformation.setText("");
                        edtShortCircuitInfo.setText(Update_log);
                        edtShortCircuitInfo.setSelection(edtShortCircuitInfo.getText().length());

                        break;
                    }else if (btTestStep == 2) {

                        int imaxdataid = 65535;
                        int imindataid = 65535;

                        maxdata = 0;
                        mindata = 65535;
                        i = 0;

                        textGridLayout.removeAllViews();

                        //控制行数
                        for (int row = 0; row < rownum; row++) {
                            //控制列数
                            for (int col = 0; col < colnum; col++) {

                                idtemp = (row + col * rownum) * 2;
                                if (byProductType == GT7)  //GT7的低位在前
                                {
                                    datatemp[i] = ((mRawdataBytes[idtemp + 1] & 0xFF) << 8) + (mRawdataBytes[idtemp] & 0xFF);
                                } else {
                                    datatemp[i] = ((mRawdataBytes[idtemp] & 0xFF) << 8) + (mRawdataBytes[idtemp + 1] & 0xFF);
                                }

                                //获取最大值
                                if (datatemp[i] > maxdata) {
                                    maxdata = datatemp[i];
                                    imaxdataid = i;

                                }
                                //获取最小值
                                if (datatemp[i] < mindata) {
                                    mindata = datatemp[i];
                                    imindataid = i;
                                }

                                i++;

                            }
                        }
                        /*
                        if (maxdata > iMaximum)  //统计最大值大于阈值的次数
                        {
                            byMaximumOverCount++;
                        }

                        if (mindata < iMinimum)  //统计最小值小于阈值的次数
                        {
                            byMinimumOverCount++;
                        }
                        */

                        if (maxdata > mindata * 2)  //统计最大值大于阈值的次数
                        {
                            byMaximumOverCount++;
                        }

                        byTestCount++;
                        stTestLog = getResources().getString(R.string.sampling) + Integer.toString(byTestCount) + getResources().getString(R.string.frame);

                        if (byTestCount >= 16) {
                            stTestLogShow = "";

                            stTestLog = getResources().getString(R.string.maxmintestfinish);
                            stTestLogShow = stTestLogShow.concat(stTestLog);

                        /*
                            stTestLog = "最大值超过阈值的次数：" + Integer.toString(byMaximumOverCount);
                            stTestLogShow = stTestLogShow.concat(stTestLog);
                            stTestLogShow = stTestLogShow.concat("\n");

                            stTestLog = "最小值超过阈值的次数：" + Integer.toString(byMinimumOverCount);
                            stTestLogShow = stTestLogShow.concat(stTestLog);
                            stTestLogShow = stTestLogShow.concat("\n");
                        */
                            if (byMaximumOverCount >= 15) {
                                bTestMaxResult = false;
                                stTestLog = getResources().getString(R.string.maxoutrange);
                                stTestLogShow = stTestLogShow.concat(stTestLog);
                            } else if (byMaximumOverCount < 2) {
                                bTestMaxResult = true;
                                //stTestLog = "最大值测试pass，";
                                //stTestLogShow = stTestLogShow.concat(stTestLog);
                            } else {
                                bTestMaxResult = false;
                                stTestLog = getResources().getString(R.string.maxisrisk);
                                stTestLogShow = stTestLogShow.concat(stTestLog);
                            }


                            if (byMinimumOverCount >= 15) {
                                bTestMinResult = false;
                                stTestLog = getResources().getString(R.string.minoutrange);
                                stTestLogShow = stTestLogShow.concat(stTestLog);
                            } else if (byMinimumOverCount < 2) {
                                bTestMinResult = true;
                                //stTestLog = "最小值测试pass。";
                                //stTestLogShow = stTestLogShow.concat(stTestLog);
                            } else {
                                bTestMinResult = false;
                                stTestLog = getResources().getString(R.string.minisrisk);
                                stTestLogShow = stTestLogShow.concat(stTestLog);
                            }

                            if ((bTestMaxResult == true) && (bTestMinResult == true)) {
                                stTestLog = getResources().getString(R.string.testpass);
                            } else {
                                stTestLog = getResources().getString(R.string.testng);
                            }

                            i = 0;
                            //控制行数
                            for (int row = 0; row < rownum; row++) {
                                //控制列数
                                for (int col = 0; col < colnum + 1; col++) {

                                    TextView textView = new TextView(mContext);
                                    GridLayout.LayoutParams params = new GridLayout.LayoutParams();

                                    if (col == 0) {
                                        dv = Integer.toString(row);
                                    } else {

                                        dv = Integer.toString(datatemp[i]);

                                        if ((bypDrvShortFlag[col - 1] == 0x55) || (bypSenShortFlag[row] == 0x55)) {
                                            textView.setTextColor(Color.parseColor("#FF0000"));  //红色
                                        }

                                        if (bTestMaxResult == false) {
                                            if (imaxdataid == i) {  //最大值
                                                textView.setTextColor(Color.parseColor("#FFFF00"));  //黄色
                                            } else if (imindataid == i) {  //最小值
                                                textView.setTextColor(Color.parseColor("#FFFF00"));  //黄色
                                            }

                                        }

                                        params.width = 42;

                                        i++;
                                    }

                                    textView.setText(dv);
                                    textView.setGravity(Gravity.CENTER);
                                    params.setMargins(2, 1, 2, 1);
                                    textGridLayout.addView(textView, params);
                                }
                            }

                            showFlag = 5;  //stop
                            btTestStep = 0;
                            btn_RawdataShow.setEnabled(true);
                            btn_DiffdataShow.setEnabled(true);
                            btn_ReffdataShow.setEnabled(true);
                            btn_ManualdiffdataShow.setEnabled(true);
                            btn_Manualreff.setEnabled(false);
                            btn_StylusDataShow.setEnabled(true);
                            btn_Test.setEnabled(true);
                        }
                        edt_TestiInformation.setText(stTestLogShow + stTestLog);
                        edt_TestiInformation.setSelection(edt_TestiInformation.getText().length());
                    }
                    break;

                case STYLUS_DATA_MESSAGE:
                    int layindex = 0;

                    textGridLayout.removeAllViews();

                    for (int index = 0; index < (rownum + colnum + 2); index++) {  //驱动和感应数据之间留有2个空位为0

                        if ((index == colnum) || (index == (colnum + 1)))  //跳过两个空位
                        {
                            layindex = 0; //开始感应数据的排列

                            continue;
                        }

                        TextView textView = new TextView(mContext);
                        GridLayout.LayoutParams params = new GridLayout.LayoutParams();

                        datatemp[index] = ((mRawdataBytes[index * 2 + 1] & 0xFF) << 8) + (mRawdataBytes[index * 2] & 0xFF);

                        dv = Integer.toString(datatemp[index]);

                        if (datatemp[index] > 80) {
                            textView.setTextColor(Color.parseColor("#FF0000"));
                        }

                        layindex++;

                        params.width = 40;

                        textView.setText(dv);
                        textView.setGravity(Gravity.CENTER);
                        params.setMargins(2,1,2,1);

                        if (index < colnum) {  //驱动数据排列
                            params.columnSpec = GridLayout.spec(0, 1);  //列的位置
                            params.rowSpec = GridLayout.spec(layindex, 1);   //行的位置
                        }else{  //感应数据排列
                            params.columnSpec = GridLayout.spec(layindex,1);  //列的位置
                            params.rowSpec = GridLayout.spec(0,1);   //行的位置
                        }
                        //params.width = 45;
                        textGridLayout.addView(textView, params);
                    }

                    break;

                default:
                    break;
            }   //end of switch (msg.what)

            bShowDataFlag = false;  //显示结束
        }
    };

    //-----------------------------------GT9 short circuit test code start----------------------------------------------------------------------//
    private int GT9xxxGetRxIndex(int nSensor)
    {
        for (int i = 0; i < 30; i++)
        {
            if (GT9xxxShortConfig[4 + 42 + i] == nSensor)
            {
                return i;
            }
        }
        return 255;
    }

    private int GT9xxxGetTxIndex(int nDriver)
    {
        if (nDriver >= 26)
        {
            nDriver += 1;
        }
        for (int i = 0; i < 42; i++)
        {
            if (GT9xxxShortConfig[4 + i] == nDriver)
            {
                return i;
            }
        }
        return 255;
    }

    boolean memCmp(byte[] sBuffer,byte[] deBuffer,int offset,int length) {

        try {

            for (int i = 0; i < length; i++) {
                if (sBuffer[i] != deBuffer[offset + i]) {
                    StringBuilder stringBuilder = new StringBuilder("sBuffer[i]=");
                    int v = sBuffer[i] & 0xFF;
                    String hv = Integer.toHexString(v);
                    stringBuilder.append(hv);
                    stringBuilder.append(",dBuffer[offset + i]=");

                    v = deBuffer[offset + i]& 0xFF;
                    hv = Integer.toHexString(v);
                    stringBuilder.append(hv);
                    stringBuilder.append(",i=");

                    stringBuilder.append(i);
                    stringBuilder.append(",offset=");
                    stringBuilder.append(offset);
                    stringBuilder.append(".\n");


                    for (int j = 0; j < 129; i++) {

                        v = sBuffer[i+j] & 0xFF;
                        hv = Integer.toHexString(v);
                        stringBuilder.append(hv);
                        stringBuilder.append(",");
                    }
                    return false;
                }
            }
        } catch (ArithmeticException e) {
            e.printStackTrace();
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }

        return true;
    }

    boolean recallCheck(byte addressHigh,byte addressLow,byte[] dBuffer,int offset,int length)
    {
        byte[] recallBuf =new byte[length+0x3000];

        if (!iicRead(addressHigh, addressLow, recallBuf, length)) {
            return false;
        }
        if (!memCmp(recallBuf, dBuffer, offset, length)) {  //recallBuf为回读的数据,dBuffer为源数据
            return false;
        }

        return true;
    }

    private boolean LoadShortFw() {
        byte maddressHigh = (byte)0x80;
        byte maddressLow = (byte)0x40;
        byte msubcommand =0x04 ;  //rst IC
        byte mdata = (byte)0x00;

        if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
            Update_log = "[Short-Circuit Test]Touch IC reset failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        for (int k = 0; k < 5; k++)
        {
            //nTryTimes--;
            maddressHigh = (byte)0x41;
            maddressLow = (byte)0x80;  //_rRW_MISCTL__SWRST_B0_
            msubcommand =0x0f ;  //no command
            mdata = (byte)0x0C;

            iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata);
            //if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
            //    return false;

            SystemClock.sleep(30);

            maddressHigh = (byte)0x40;
            maddressLow = (byte)0xB0;  //_bRW_MISCTL__TMR0_EN
            mdata = (byte)0x00;

            iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata);
            //if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
            //    return false;

            SystemClock.sleep(14);
        }

        maddressHigh = (byte)0x40;
        maddressLow = (byte)0x10;
        msubcommand =0x0f ;  //no command
        mdata = (byte)0x00;

        if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
            return false;

        SystemClock.sleep(30);

        maddressHigh = (byte)0x41;
        maddressLow = (byte)0x80;  //_rRW_MISCTL__SWRST_B0_

        if (0x0C != iicByteRead(maddressHigh,maddressLow))
        {
            Update_log = "[Short-Circuit Test]Hold IC failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(30);

        maddressHigh = (byte)0x40;
        maddressLow = (byte)0xB0;  //_rRW_MISCTL__SWRST_B0_
        if (0x00 != iicByteRead(maddressHigh,maddressLow))
        {
            Update_log = "[Short-Circuit Test]Disable watch dog failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(10);

        maddressHigh = (byte)0x40;
        maddressLow = (byte)0x4B;  //_bRW_MISCTL__CACHE_EN
        mdata = (byte)0x00;
        msubcommand =0x0f ;  //no command
        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Clear cache enable failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x41;
        maddressLow = (byte)0x90;  //_rRW_MISCTL__BOOTCTL_B0_
        mdata = (byte)0x02;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Set _rRW_MISCTL__BOOTCTL_B0_ failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x40;
        maddressLow = (byte)0x48;  //_bRW_MISCTL__SRAM_BANK
        mdata = (byte)0x00;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Select _bRW_MISCTL__SRAM_BANK failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x40;
        maddressLow = (byte)0x49;  //_bRW_MISCTL__MEM_CD_EN
        mdata = (byte)0x01;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Enable _bRW_MISCTL__MEM_CD_EN failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0xC0;
        maddressLow = (byte)0x00;   //_bRW_MISCTL__SRAM_BANK   3

        if (!iicWrite(maddressHigh, maddressLow, gt9110h_short_dsp_code, 0, gt9110h_short_dsp_code.length))
        {
            Update_log = "Burn 8k short circuit Fw failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            return false;
        }

        SystemClock.sleep(25);

        if (!recallCheck(maddressHigh, maddressLow, gt9110h_short_dsp_code, 0, gt9110h_short_dsp_code.length))
        {
            Update_log = "Recall check 8k short circuit FW failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(25);

        maddressHigh = (byte)0x50;
        maddressLow = (byte)0x95;  //_rRW_MISCTL__CLR_IC_RUN
        mdata = (byte)0x00;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Clear IC run flag failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x42;
        maddressLow = (byte)0x18;  //_rRW_MISCTL__BOOT_OPT_B0_
        mdata = (byte)0x03;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Set _rRW_MISCTL__BOOT_OPT_B0_ failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x41;
        maddressLow = (byte)0x84;  //_bWO_MISCTL__CPU_SWRST_PULSE
        mdata = (byte)0x01;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Stop reset CPU failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        SystemClock.sleep(15);

        maddressHigh = (byte)0x41;
        maddressLow = (byte)0x80;  //_rRW_MISCTL__SWRST_B0_
        mdata = (byte)0x08;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Set _rRW_MISCTL__SWRST_B0_ failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }

        return true;
    }

    private boolean SendShortConfig()
    {
        byte maddressHigh;
        byte maddressLow;
        byte msubcommand =0x0f ;  //no command
        byte mdata = (byte)0x00;

        //GetDlgItem(IDC_EDIT_CH2CH_SHORT_THR)->GetWindowText(str);
        int wData = 50;// _ttoi(str);
        GT9xxxShortConfig[0] = (byte)(wData >> 8);
        GT9xxxShortConfig[1] = (byte)(wData & 0xFF);

        //GetDlgItem(IDC_EDIT_CH2GND2AVDD_SHORT_THR)->GetWindowText(str);
        wData = 0x96;// 128;// _ttoi(str);
        GT9xxxShortConfig[2] = (byte)(wData >> 8);
        GT9xxxShortConfig[3] = (byte)(wData & 0xFF);

        //GetDlgItem(IDC_EDIT_WAIT_FOR_STABLE)->GetWindowText(str);
        wData = 20;// _ttoi(str);
        GT9xxxShortConfig[77] = (byte)(wData >> 8);
        GT9xxxShortConfig[78] = (byte)(wData & 0xFF);

        for(int i = 4; i < 4 + 42; i++)
        {
            GT9xxxShortConfig[i] = bypCfgDrv[i - 4];  //DRV
        }

        int temp = 4 + 42;

        for(int i = temp; i < temp + 30; i++)
        {
            GT9xxxShortConfig[i] = bypCfgSen[i - temp];   //SEN
        }

        int ichecksum = 0;
        for (int i = 4; i < 4 + 42 + 30; i++)
        {
            int k = GT9xxxShortConfig[i] & 0xFF;
            ichecksum = ichecksum + k;
        }

        GT9xxxShortConfig[4 + 42 + 30] = (byte) (256 - ichecksum % 256);

        GT9xxxShortConfig[79] = 0;

        SystemClock.sleep(60);

        maddressHigh = (byte)0x50;
        maddressLow = (byte)0x95;  //_rRW_MISCTL__CLR_IC_RUN

        int i;
        for (i = 0; i < 3; i++)
        {
            if ((byte)0xAA == iicByteRead(maddressHigh,maddressLow))
            {
                break;
            }

            SystemClock.sleep(30);
        }

        if (3 == i)
        {
            Update_log = "Short circuit test init failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            return false;
        }

        maddressHigh = (byte)0x88;
        maddressLow = (byte)0x04;

        if (!iicWrite(maddressHigh, maddressLow, GT9xxxShortConfig, 0, 80)) {

            Update_log = "Send short circuit config failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            return false;

        }

        SystemClock.sleep(13);

        maddressHigh = (byte)0x50;
        maddressLow = (byte)0x95;  //_rRW_MISCTL__CLR_IC_RUN
        mdata = (byte)0x04;

        if (!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata))
        {
            Update_log = "[Short-Circuit Test]Step9 set _rRW_MISCTL__CLR_IC_RUN failed!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return false;
        }


        SystemClock.sleep(1000);

        maddressHigh = (byte)0x88;
        maddressLow = (byte)0x00;

        temp = 1000;

        while(temp > 0)
        {
            temp--;

            if ((byte)0x88 == iicByteRead(maddressHigh,maddressLow))
            {
                SystemClock.sleep(30);

                return true;
            }

            SystemClock.sleep(20);
        }

        Update_log = "Short circuit test failed!";
        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

        return false;
    }


    private boolean CalculateShort()
    {
        byte maddressHigh = (byte)0x88;
        byte maddressLow = (byte)0x01;

        byte testResult = iicByteRead(maddressHigh,maddressLow);

        byte[] m_diffCode = new byte[144*2];
        byte[] m_txShortData = new byte[6258];
        byte[] m_rxShortData = new byte[975];

        byte shortPinNum;
        int wSelfCode;
        int[] wTxShortCode = new int[42];
        int[] wRxShortCode = new int[30];

        int wShortThreshold = 0x32;

        boolean bFailed = false;

        for (int i = 0; i < 46; i++) {
            bypDrvShortFlag[i] = (byte)255;
        }
        for (int i = 0; i < 76; i++) {
            bypSenShortFlag[i] = (byte)255;
        }

        /* step3-1 判断是否有短路 */
        if (0x00 == testResult)
        {
            Update_log = getResources().getString(R.string.shorttestfinish);
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
		    return true;
        }

        /* step3-2 获取短路的通道个数*/
        maddressHigh = (byte)0x88;
        maddressLow = (byte)0x02;
        byte txShortNum = iicByteRead(maddressHigh,maddressLow);

        maddressHigh = (byte)0x88;
        maddressLow = (byte)0x03;
        byte rxShortNum = iicByteRead(maddressHigh,maddressLow);


        final byte TX_TO_TX_SHORT = 1;
        final byte RX_TO_RX_SHORT = 2;
        final byte TX_TO_RX_SHORT = 4;
        final byte TRX_TO_GNDAVDD_SHORT = 8;

        int ishortpin1,ishortpin2;

        /* step3-5 输出短路通道号和阻抗*/
        Update_log = "";

        /* step3-5-1 计算TX与TX的阻抗*/
        if (TX_TO_TX_SHORT == (testResult & TX_TO_TX_SHORT)
                || TX_TO_RX_SHORT == (testResult & TX_TO_RX_SHORT))
        {
            /* step3-4 逐个获取_ptTxShortResult[i]记为 V2  */
            maddressHigh = (byte)0x88;
            maddressLow = (byte)0x60;
            if(!iicRead(maddressHigh,maddressLow,m_txShortData,txShortNum * 149)) {  //读取rawData
                Update_log = "[Short-Circuit Test]Step3-4-1 cal impedance of Tx&Tx failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return false;
            }

            for (int i = 0; i < txShortNum; i++)
            {
                //初始化数组
                int offSet = i * 149;
                shortPinNum = (byte)(m_txShortData[0 + offSet] & 0x7F);
                wSelfCode = (m_txShortData[1 + offSet] << 8) + m_txShortData[2 + offSet];
                offSet = offSet + 3;
                for (int j = shortPinNum; j < 42; j++)
                {
                    wTxShortCode[j] = (m_txShortData[offSet + (j << 1)] << 8) + m_txShortData[offSet + (j << 1) + 1];

                    if (wTxShortCode[j] > wShortThreshold)
                    {
                        int Resistance;
                        if ((j < 15 && shortPinNum < 15)
                                || (j >= 15 && shortPinNum >= 15 && j <= 29 && shortPinNum <= 29)
                                || (j > 29 && shortPinNum > 29))
                        {
                            Resistance = (int)(wSelfCode * 40) / wTxShortCode[j] - 40;
                        }
                        else
                        {
                            Resistance = (int)(wSelfCode * 60) / wTxShortCode[j] - 60;
                        }

                        if (Resistance < 0)
                            Resistance = 0;

                        ishortpin1 = GT9xxxGetTxIndex(shortPinNum & 0x7F);
                        ishortpin2 = GT9xxxGetTxIndex(j);

                        Update_log = Update_log.concat("[Short-Circuit Test]Tx" + Integer.toString(ishortpin1) + " and Tx"
                                + Integer.toString(ishortpin2) + ": " + Integer.toString(Resistance) + "K Ohm\n");

                        if (Resistance > 800)
                        {
                            //AppendMessage(str, MESSAGE_PAY_ATTENTION);

                            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                            continue;
                        }
                        //AppendMessage(str, MESSAGE_ERR);
                        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                        bFailed = true;

                        bypDrvShortFlag[shortPinNum & 0x7F] = 0x55;
                        bypDrvShortFlag[j] = 0x55;
                    }
                }
                offSet = offSet + 84;

                for (int j = shortPinNum; j < 30; j++)
                {
                    wRxShortCode[j] = (m_txShortData[(j << 1) + offSet] << 8) + m_txShortData[(j << 1) + offSet + 1];
                    if (wRxShortCode[j] > wShortThreshold)
                    {
                        int Resistance;
                        if ((j & 0x01) == 0x01)
                        {
                            Resistance = (int)(wSelfCode * 60) / wRxShortCode[j] - 40;
                        }
                        else
                        {
                            Resistance = (int)(wSelfCode * 60) / wRxShortCode[j] - 60;
                        }

                        if (Resistance < 0)
                            Resistance = 0;

                        ishortpin1 = GT9xxxGetTxIndex(shortPinNum & 0x7F);
                        ishortpin2 = GT9xxxGetRxIndex(j);

                        Update_log = Update_log.concat("[Short-Circuit Test]Tx" + Integer.toString(ishortpin1) + " and Rx"
                                + Integer.toString(ishortpin2) + ": " + Integer.toString(Resistance) + "K Ohm\n");

                        if (Resistance > 800)
                        {
                            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                            continue;
                        }

                        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                        bFailed = true;

                        bypDrvShortFlag[shortPinNum & 0x7F] = 0x55;
                        bypSenShortFlag[j] = 0x55;
                    }
                }
            }
        }

        if (RX_TO_RX_SHORT == (testResult & RX_TO_RX_SHORT))
        {
            maddressHigh = (byte)0xA0;
            maddressLow = (byte)0xD2;
            if(!iicRead(maddressHigh,maddressLow,m_rxShortData,rxShortNum * 65)) {  //读取rawData
                Update_log = "[Short-Circuit Test]Step3-4-2 cal impedance of Rx&Rx failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return false;
            }

            for (int i = 0; i < rxShortNum; i++)
            {
                //初始化数组
                int offSet = i * 65;
                shortPinNum = (byte)(m_rxShortData[0 + offSet] & 0x7F);
                wSelfCode = (m_rxShortData[1 + offSet] << 8) + m_rxShortData[2 + offSet];
                offSet = offSet + 3;
                for (int j = 0; j < 30; j++)
                {
                    wRxShortCode[j] = (m_rxShortData[offSet + (j << 1)] << 8) + m_rxShortData[offSet + (j << 1) + 1];

                    if (wRxShortCode[j] > wShortThreshold)
                    {
                        int Resistance;

                        Resistance = (int)(wSelfCode * 60) / wRxShortCode[j] - 60;

                        if (Resistance < 0)
                            Resistance = 0;

                        ishortpin1 = GT9xxxGetRxIndex(shortPinNum & 0x7F);
                        ishortpin2 = GT9xxxGetRxIndex(j);

                        Update_log = Update_log.concat("[Short-Circuit Test]Rx" + Integer.toString(ishortpin1) + " and Rx"
                                + Integer.toString(ishortpin2) + ": " + Integer.toString(Resistance) + "K Ohm\n");

                        if (Resistance > 800)
                        {
                            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                            continue;
                        }

                        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

                        bFailed = true;

                        bypSenShortFlag[shortPinNum & 0x7F] = 0x55;
                        bypSenShortFlag[j] = 0x55;
                    }
                }
            }
        }

        if (TRX_TO_GNDAVDD_SHORT == (testResult & TRX_TO_GNDAVDD_SHORT))
        {
            maddressHigh = (byte)0xA5;
            maddressLow = (byte)0x31;
            if(!iicRead(maddressHigh,maddressLow,m_diffCode,144)) {  //读取rawData
                Update_log = "[Short-Circuit Test]cal impedance of TRX to GNDAVDD failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return false;
            }

            for (int i = 0; i < 42 + 30; i++)
            {
                int DiffData = (int)(m_diffCode[(i << 1)] << 8) + (int)m_diffCode[(i << 1) + 1];

                int Resistance;

                if ((DiffData & 0x7fff) == 0)
                    DiffData += 1;

                if ((DiffData & 0x8000) == 0x8000)
                {
                    Resistance = (int)(1 / ((DiffData & 0x7FFF) / 0.9 * 0.7 / 1024 / (3.3 - 0.9) / 40) - 40);
                }
                else
                {
                    Resistance = (int)(52662.85 / DiffData - 40);
                }

                if (Resistance < 0)
                    Resistance = 0;

                if (i < 42)
                {
                    ishortpin1 = GT9xxxGetTxIndex(i);

                    if ((DiffData & 0x8000) == 0x8000)
                    {
                        if (Resistance < 800)
                            Update_log = Update_log.concat("[Short-Circuit Test]Tx" + Integer.toString(ishortpin1) + " and AVDD: " + Integer.toString(Resistance) + "K Ohm\n");
                    }
                    else
                    {
                        if (Resistance < 800)
                            Update_log = Update_log.concat("[Short-Circuit Test]Tx" + Integer.toString(ishortpin1) + " and GND: " + Integer.toString(Resistance) + "K Ohm\n");
                    }
                }
                else
                {
                    ishortpin1 = GT9xxxGetRxIndex(i - 42);

                    if ((DiffData & 0x8000) == 0x8000)
                    {
                        if (Resistance < 800)
                            Update_log = Update_log.concat("[Short-Circuit Test]Rx" + Integer.toString(ishortpin1) + " and AVDD: " + Integer.toString(Resistance) + "K Ohm\n");
                    }
                    else
                    {
                        if (Resistance < 800)
                            Update_log = Update_log.concat("[Short-Circuit Test]Rx" + Integer.toString(ishortpin1) + " and GND: " + Integer.toString(Resistance) + "K Ohm\n");
                    }
                }
                if (Resistance > 800)
                {
                    continue;
                }
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                bFailed = true;

                if (i < 42) {
                    bypDrvShortFlag[i] = 0x55;
                }else{
                    bypSenShortFlag[i - 42] = 0x55;
                }
            }
        }

        if (!bFailed)
        {
            return true;
        }

        return false;
    }

    private void GT9xxxShortTestProc()
    {
        byte maddressHigh = (byte)0x80;
        byte maddressLow = (byte)0x40;
        byte msubcommand =0x04 ;  //rst IC
        byte mdata = (byte)0x00;

        Update_log = "";
        updateLogShow = "";

        Update_log = getResources().getString(R.string.startshorttest);
        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

        if (!LoadShortFw())
        {
            Update_log += ", load FW failed, test is NG!!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
                Update_log += "Reset touch IC failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return;
            }
            return;
        }

        if (!SendShortConfig())
        {
            Update_log += ", send config failed, test is NG!!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
                Update_log += "Reset touch IC failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return;
            }
            return;
        }

        if (!CalculateShort())
        {
            Update_log += getResources().getString(R.string.shorttestng);
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

            if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
                Update_log = "Reset touch IC failed!";
                mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
                return;
            }
            return;
        }

        if(!iicByteWrite(maddressHigh,maddressLow,msubcommand,mdata)) {
            Update_log = "Reset touch IC failed, short-circuit test NG!!";
            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
            return;
        }

        Update_log += getResources().getString(R.string.testpass);
        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);
    }

    //------------------------------------GT9 short circuit test code end------------------------------------------------------------------//

    //------------------------------------GT7 short circuit test code start----------------------------------------------------------------//
    private int GT7xxxGetRxIndex(byte[] pbyRxAlign, int nSensor)
    {
        for (int i = 0; i < 72; i++)
        {
            if (pbyRxAlign[i] == nSensor)
            {
                return i;
            }
        }
        return 255;
    }
    private int GT7xxxGetTxIndex(byte[] pTxAlign, int nDriver)
    {
        for (int i = 0; i < 44; i++)
        {
            if (pTxAlign[i] == nDriver)
            {
                return i;
            }
        }
        return 255;
    }

    private void GT7xxxShortTestProc()
    {
        byte ShortTestResult = 0;

        Update_log = "";
        updateLogShow = "";

        Update_log = getResources().getString(R.string.startshorttest);
        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

        iicByteWrite((byte)0x43,(byte)0x7c,(byte)0x0f,(byte)0x00);
        SystemClock.sleep(15);
        iicByteWrite((byte)0x80,(byte)0x41,(byte)0x0f,(byte)0x00);  //0x8041,command data
        iicByteWrite((byte)0x80,(byte)0x42,(byte)0x0f,(byte)0xC0);  //0x8042,command checksum
        SystemClock.sleep(15);
        iicByteWrite((byte)0x80,(byte)0x40,(byte)0x0f,(byte)0x40);  //0x8040,0x40:通知FW进入短路测试状态

        SystemClock.sleep(350);

        for (int i = 0; i < 76; i++)
        {
            GT7xxxShortConfig[i] = (byte) i;

            if (i > 72)
                GT7xxxShortConfig[i] = (byte) 255;
        }

        for (int i = 0; i < 46; i++)
        {
            GT7xxxShortConfig[i + 76] = (byte) i;

            if (i > 44)
                GT7xxxShortConfig[i + 76] = (byte) 255;
        }

        for (int i = 0; i < 46; i++) {
            bypDrvShortFlag[i] = (byte)255;
        }
        for (int i = 0; i < 76; i++) {
            bypSenShortFlag[i] = (byte)255;
        }

        byte[] pConfigDrv = new byte[46];
        byte[] pConfigSen = new byte[76];

        //m_ConfigBak.m_nSenHalfNum = 22;
        //m_ConfigBak.m_nDrvHalfNum = 22;
        //m_ConfigBak.m_nSenMaxNum = 72;
        //m_ConfigBak.m_nDrvMaxNum = 44;

        //if (m_pDlg->m_bBackConfigOKFlag)
        {
            int k = 0;
            for (int i = 0; i < 36; i++) //SenHalfNumber=36
            {
                int ch = bypCfgSen[i];

                if (ch == 255)
                    continue;

                for (int j = 0; j < 36; j++)  //SenHalfNumber=36
                {
                    if (SenMap[j] == ch)
                    {
                        pConfigSen[k++] = (byte)(j + 36);  //SenHalfNumber=36
                        break;
                    }
                }
            }

            for (int i = 36; i < 72; i++)
            {
                int ch = bypCfgSen[i];

                if (ch == 255)
                    continue;

                if (i < 72)
                {
                    for (int j = 36; j < 72; j++)
                    {
                        if (SenMap[j] == ch)
                        {
                            pConfigSen[k++] = (byte)(j - 36);
                            break;
                        }
                    }
                }
            }

            k = 0;
            for (int i = 0; i < 22; i++)  //DrvHalfNmuber=22
            {
                int ch = bypCfgDrv[i];

                if (ch == 255)
                    continue;

                for (int j = 0; j < 22; j++)  //DrvHalfNmuber=22
                {
                    if (DrvMap[j] == ch)
                    {
                        pConfigDrv[k++] = (byte)(22 + j);  //DrvHalfNmuber=22
                        break;
                    }
                }
            }
            for (int i = 23; i < 23 + 44 - 22; i++)  //DrvMaxNum=44
            {
                int ch = bypCfgDrv[i];

                if (ch == 255)
                    continue;

                for (int j = 22; j < 44; j++)  //DrvMaxNum=44
                {
                    if (DrvMap[j] == ch)
                    {
                        pConfigDrv[k++] = (byte)(j - 22);  //DrvHalfNmuber=22
                        break;
                    }
                }

            }
        }

        int wCheckSum = 0;
        for (int i = 0; i < GT7xxxShortConfig.length - 2; i += 2)
        {
            wCheckSum += (int)((GT7xxxShortConfig[i + 1]& 0xff) << 8) + (int)(GT7xxxShortConfig[i] & 0xff);
        }
        wCheckSum = 0 - wCheckSum;
        GT7xxxShortConfig[GT7xxxShortConfig.length - 2] = (byte)(wCheckSum & 0xff);
        GT7xxxShortConfig[GT7xxxShortConfig.length - 1] = (byte)(wCheckSum >> 8);

        int temp = 2000;

        while(temp > 0)
        {
            temp--;

            if ((byte)0x01 == iicByteRead((byte)0x80,(byte)0x4A))  //为1则继续往下
            {
                SystemClock.sleep(30);

                break;
            }

            SystemClock.sleep(20);
        }

        if (temp != 0)
        {
            if (iicWrite((byte)0x81, (byte)0x18, GT7xxxShortConfig, 0, GT7xxxShortConfig.length))  //下发正确，继续往下
            {
                SystemClock.sleep(8);
                iicByteWrite((byte)0x80,(byte)0x41,(byte)0x0f,(byte)0x00);  //0x8041,command data
                iicByteWrite((byte)0x80,(byte)0x42,(byte)0x0f,(byte)0xBF);  //0x8042,command checksum
                SystemClock.sleep(15);
                iicByteWrite((byte)0x80,(byte)0x40,(byte)0x0f,(byte)0x41);  //0x8040,0x40:通知FW已完成参数配置
                SystemClock.sleep(15);

                temp = 100;

                while(temp > 0)
                {
                    temp--;

                    if ((byte)0x40 == iicByteRead((byte)0x80,(byte)0x4A))  //为0x40则继续往下
                    {
                        SystemClock.sleep(30);

                        break;
                    }

                    SystemClock.sleep(20);
                }

                if (temp != 0)
                {
                    SystemClock.sleep(6000);  //6s

                    temp = 3000;

                    while(temp > 0)
                    {
                        temp--;

                        if ((byte)0x43 == iicByteRead((byte)0x80,(byte)0x4A))  //为0x43则继续往下
                        {
                            SystemClock.sleep(30);

                            break;
                        }

                        SystemClock.sleep(20);
                    }

                    if (temp != 0)
                    {
                        ShortTestResult = iicByteRead((byte)0x8A,(byte)0xC0);

                        if (ShortTestResult == 0)
                        {
                            iicByteWrite((byte)0x41,(byte)0x80,(byte)0x0f,(byte)0x01);  //0x4180 set 0x01

                            SystemClock.sleep(500);

                            iicByteRead((byte)0x80,(byte)0x00);  //read 0x8000

                            iicByteWrite((byte)0x80,(byte)0x41,(byte)0x0f,(byte)0x00);  //0x8041,command data
                            iicByteWrite((byte)0x80,(byte)0x42,(byte)0x0f,(byte)0x56);  //0x8042,command checksum

                            iicByteWrite((byte)0x80,(byte)0x40,(byte)0x0f,(byte)0xAA);  //0x8040,0xAA：关闭HID-IIC模式

                            Update_log = getResources().getString(R.string.shorttestfinish) + getResources().getString(R.string.testpass);
                            mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

                            return;
                        }
                    }
                }
            }
        }

        Update_log = "";

        if (ShortTestResult != 0)
        {
            byte ShortResisNum = iicByteRead((byte)0x8A,(byte)0xC2);
            byte[] buf = new byte[128];  //长度要大于64
            String str;

            for (int i = 0; i < (int)((ShortResisNum & 0xFF) * 4); i += 4)
            {
                temp = (int)(0x8AC4 + (byte)i);

                iicRead((byte)((temp&0xff00) >> 8),(byte)(temp&0x00ff),buf,4);

                if ((buf[1] & 0x80) != 0)
                {
                    int ch = buf[1] & 0x7F;
                    ch = GT7xxxGetTxIndex(pConfigDrv, ch);
                    if (ch == 255)
                        continue;

                    bypDrvShortFlag[ch] = (byte)0x55;
                    Update_log = Update_log.concat("[Short-Circuit Test]Tx" + Integer.toString(ch) + " and ");

                }
                else
                {
                    int ch = buf[1] & 0xFF;

                    ch = GT7xxxGetRxIndex(pConfigSen, ch);
                    if (ch == 255)
                        continue;

                    bypSenShortFlag[ch] = (byte)0x55;
                    Update_log = Update_log.concat("[Short-Circuit Test]Rx" + Integer.toString(ch) + " and ");
                }

                if (buf[0] == (byte)0xF0)
                {
                    Update_log = Update_log.concat("GND:");
                }
                else if (buf[0] == (byte)0xF1)
                {
                    Update_log = Update_log.concat("AVDD:");
                }
                else if ((buf[0] & 0x80) != 0)
                {
                    int ch = buf[0] & 0x7F;
                    ch = GT7xxxGetTxIndex(pConfigDrv, ch);
                    if (ch == 255)
                        continue;

                    bypDrvShortFlag[ch] = (byte)0x55;
                    Update_log = Update_log.concat("Tx" + Integer.toString(ch) + ": ");
                }
                else
                {
                    int ch = buf[0];

                    ch = GT7xxxGetRxIndex(pConfigSen, ch);
                    if (ch == 255)
                        continue;

                    bypSenShortFlag[ch] = (byte)0x55;
                    Update_log = Update_log.concat("Rx" + Integer.toString(ch) + ": ");
                }

                if ((int)((buf[2]&0xFF) * 256) + (buf[3]&0xFF) > 800)
                {

                    continue;
                }

                Update_log = Update_log.concat(Integer.toString((int)((buf[2]&0xFF) * 256) + (buf[3]&0xFF)) + "K ohm" + "\n");
            }
        }

        Update_log += getResources().getString(R.string.shorttestng);
        mHandler.sendEmptyMessage(TEST_DATA_MESSAGE);

        SystemClock.sleep(2000);

        iicByteWrite((byte)0x41,(byte)0x80,(byte)0x0f,(byte)0x01);  //0x4180 set 0x01

        SystemClock.sleep(500);

        iicByteRead((byte)0x80,(byte)0x00);  //read 0x8000

        iicByteWrite((byte)0x80,(byte)0x41,(byte)0x0f,(byte)0x00);  //0x8041,command data
        iicByteWrite((byte)0x80,(byte)0x42,(byte)0x0f,(byte)0x56);  //0x8042,command checksum

        iicByteWrite((byte)0x80,(byte)0x40,(byte)0x0f,(byte)0xAA);  //0x8040,0xAA：关闭HID-IIC模式
    }

    //------------------------------------GT7 short circuit test code end------------------------------------------------------------------//

    @Override
    public void onClick(final View view) {

        int checksum;
        int checksum2;
        byte addressH;
        byte addressL;

        if ((edt_ColNum.getText().length() == 0) || (edt_RowNum.getText().length() == 0)){

            if (byProductType == GT7)
            {
                addressH = (byte)0x80;
                addressL = (byte)0x50;

                iicRead(addressH,addressL,mBytes,444);

                checksum = 0;
                checksum2 = 0;
                for (int i = 0; i < 444; i++) {
                    int k = mBytes[i] & 0xFF;
                    if (i < 213)
                    {
                        checksum = checksum + k;
                    }
                    else {
                        checksum2 = checksum2 + k;
                    }
                }
                if((checksum % 256 == 0) && (checksum2 % 256 == 0))  //校验和正确
                {
                    colnum = (mBytes[381] & 0xFF) + (mBytes[383] & 0xFF);  //DRV
                    rownum = (mBytes[380] & 0xFF) + (mBytes[382] & 0xFF);  //SEN

                    edt_ColNum.setText(Integer.toString(colnum));
                    edt_RowNum.setText(Integer.toString(rownum));

                    for (int i = 0; i < 44; i++) {
                        bypCfgDrv[i] = mBytes[289 + i];
                    }

                    for (int i = 0; i < 72; i++) {
                        bypCfgSen[i] = mBytes[215 + i];
                    }
                }
                else {
                    Toast.makeText(this, getResources().getString(R.string.cfgerror), Toast.LENGTH_SHORT).show();
                    return;
                }
            }else{

                addressH = (byte)0x80;
                addressL = (byte)0x47;
                iicRead(addressH, addressL, mBytes,186);

                checksum = 0;
                for (int i = 0; i < 186; i++) {
                    int k = mBytes[i] & 0xFF;
                    checksum = checksum + k;
                }
                if(checksum % 256 == 0)  //校验和正确
                {
                    colnum = (mBytes[27] & 0x1F) + (mBytes[28] & 0x1F);
                    rownum = (mBytes[29] & 0x0F) + ((mBytes[29] & 0xFF) >> 4);

                    edt_ColNum.setText(Integer.toString(colnum));
                    edt_RowNum.setText(Integer.toString(rownum));

                    for (int i = 0; i < 42; i++) {
                        bypCfgDrv[i] = mBytes[142 + i];
                    }

                    for (int i = 0; i < 30; i++) {
                        bypCfgSen[i] = mBytes[112 + i];
                    }
                }
                else {
                    Toast.makeText(this, getResources().getString(R.string.cfgerror), Toast.LENGTH_SHORT).show();
                    return;
                }
            }

        }else{
            colnum = (byte) Integer.parseInt(edt_ColNum.getText().toString(),10);
            rownum = (byte) Integer.parseInt(edt_RowNum.getText().toString(), 10);
        }

        if (colnum == 0){  //DRV
            colnum = 42;
            if (byProductType == GT7)
            {
                colnum = 44;
            }
            edt_ColNum.setText(Integer.toString(colnum));
        }

        if (rownum == 0){  //SEN
            rownum = 30;
            if (byProductType == GT7)
            {
                rownum = 72;
            }
            edt_RowNum.setText(Integer.toString(rownum));
        }

        if (showFlag != 8) {
            textGridLayout.removeAllViews();

            textGridLayout.setColumnCount(colnum + 1);
            textGridLayout.setRowCount(rownum);
        }
        
        byDisplayFrame = 0;
        byDisplayFrameCount = 0;
        if (byProductType == GT7)  //GT7 数据多，要多加时间间隔
        {
            byDisplayFrame = 8;
            byDisplayFrameCount = 8;
        }

        btn_RawdataShow.setEnabled(false);
        btn_DiffdataShow.setEnabled(false);
        btn_ReffdataShow.setEnabled(false);
        btn_ManualdiffdataShow.setEnabled(false);
        btn_Manualreff.setEnabled(false);
        btn_StylusDataShow.setEnabled(false);
        btn_Test.setEnabled(false);

        switch (view.getId()) {
            case R.id.rawdata:   //Read RawData
                showFlag =1;

                changeToDebugMode();
                //count = 1000;
                showAddressHigh = (byte)0x8b;
                showAddressLow = (byte)0x98;
                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0xbf;
                    showAddressLow = (byte)0xf0;
                }
                if(count == 1000){
                    tvDataContent.setText("[" + getResources().getString(R.string.rawdata) + "]");
                    showRawdata();
                }

                break;

            case R.id.diffdata:
                showFlag = 3;
                if (byProductType == GT7)
                {
                    showFlag = 7; //GT7系列的差值是2bytes，按照RawData的方式去显示
                }

                changeToDebugMode();
                showAddressHigh = (byte)0xbb;
                showAddressLow = (byte)0x10;
                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0x8a;
                    showAddressLow = (byte)0xc0;
                }
                if(count == 1000) {
                    tvDataContent.setText("[" + getResources().getString(R.string.diffdata) + "]");
                    showRawdata();
                }
                break;

            case R.id.reffdata:
                showFlag =4;
                count = 1000;
                showAddressHigh = (byte)0x81;
                showAddressLow = (byte)0xc0;
                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0xa5;
                    showAddressLow = (byte)0x58;
                }
                tvDataContent.setText("[" + getResources().getString(R.string.reffdata) + "]");
                getRawdata();
                mHandler.sendEmptyMessage(RAWDATA_MESSAGE);
                btn_RawdataShow.setEnabled(true);
                btn_DiffdataShow.setEnabled(true);
                btn_ReffdataShow.setEnabled(true);
                btn_ManualdiffdataShow.setEnabled(true);
                //btn_Manualreff.setEnabled(false);
                btn_StylusDataShow.setEnabled(true);
                btn_Test.setEnabled(true);
                break;

            case R.id.manualdiff:
                showFlag =2;
                btn_Manualreff.setEnabled(true);
                changeToDebugMode();
                showAddressHigh = (byte)0x8b;
                showAddressLow = (byte)0x98;
                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0xbf;
                    showAddressLow = (byte)0xf0;
                }
                if(count == 1000) {
                    tvDataContent.setText("[" + getResources().getString(R.string.manualdiff) + "]");
                    showRawdata();
                }
                else
                {
                    count = 1000;
                }
                break;
				
			case R.id.manualreff:  //set up manual ref
                showFlag = 2;
                btn_Manualreff.setEnabled(true);
                count = 1000;

                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0xbf;
                    showAddressLow = (byte)0xf0;
                }
                else {
                    showAddressHigh = (byte)0x8b;
                    showAddressLow = (byte)0x98;
                }
                break;

            case R.id.stylusdata:  //主动笔数据
                if (byProductType == GT7)  //GT7系列才显示
                {
                    showFlag = 8;

                    changeToDebugMode();

                    textGridLayout.removeAllViews();

                    textGridLayout.setColumnCount(rownum + 1);  //列数=感应数
                    textGridLayout.setRowCount(colnum + 1); //行数=驱动数

                    showAddressHigh = (byte)0xDD;
                    showAddressLow = (byte)0x58;

                    if(count == 1000) {
                        tvDataContent.setText("[" + getResources().getString(R.string.stylusdata) + "]");
                        showRawdata();
                    }
                }
                break;

            case R.id.testting:  //start test

                if (edt_Maximum.getText().length() == 0)
                {
                    //edt_Maximum.setText(Integer.toString(3500));
                    iMaximum = 3500;
                }
                else
                {
                    iMaximum = Integer.parseInt(edt_Maximum.getText().toString(),10);
                }

                if (edt_Minimum.getText().length() == 0)
                {
                    //edt_Minimum.setText(Integer.toString(1750));
                    iMinimum = 1750;
                }
                else
                {
                    iMinimum = Integer.parseInt(edt_Minimum.getText().toString(),10);
                }

                if((iMinimum < (iMaximum / 2)) || (iMinimum > iMaximum))
                {
                    Toast.makeText(this, getResources().getString(R.string.thresholdlimit), Toast.LENGTH_SHORT).show();
                    btn_RawdataShow.setEnabled(true);
                    btn_DiffdataShow.setEnabled(true);
                    btn_ReffdataShow.setEnabled(true);
                    btn_ManualdiffdataShow.setEnabled(true);
                    //btn_Manualreff.setEnabled(false);
                    btn_StylusDataShow.setEnabled(true);
                    btn_Test.setEnabled(true);
                    break;
                }

                showFlag = 6;
                byTestCount = 0;
                byMaximumOverCount = 0;
                byMinimumOverCount = 0;
                byReTestCount = 0;
                //count = 1000;
                showAddressHigh = (byte)0x8b;
                showAddressLow = (byte)0x98;
                if (byProductType == GT7)
                {
                    showAddressHigh = (byte)0xbf;
                    showAddressLow = (byte)0xf0;
                }
                if(count == 1000){
                    //tvDataContent.setText("["+getResources().getString(R.string.rawdata)+"]");
                    showRawdata();
                }

                break;

            case R.id.stop:    //back
                showFlag = 5;

                btn_RawdataShow.setEnabled(true);
                btn_DiffdataShow.setEnabled(true);
                btn_ReffdataShow.setEnabled(true);
                btn_ManualdiffdataShow.setEnabled(true);
                btn_Manualreff.setEnabled(false);
                btn_StylusDataShow.setEnabled(true);
                btn_Test.setEnabled(true);
                //count = 1000;
                //changeToNormalMode();
                break;
				
            default:
                break;
        }
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();

        if (mUsbDeviceConnection != null) {
            mUsbDeviceConnection.releaseInterface(mUsbInterface);
            mUsbDeviceConnection.close();
            mUsbDeviceConnection = null;
        }
        mUsbEndpointIn = null;
        mUsbEndpointOut = null;
        isReceiverMessage = false;
        isNeedFindDevice = false;
        mThreadPool.shutdownNow();
        // unregisterReceiver(mUsbDetachedReceiver);
        unregisterReceiver(daOpenDevicesReceiver);
    }

    //第一次点击事件发生的时间
    //private long mExitTime;

    /**
     * 点击两次返回退出app
     */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            /*
            if ((System.currentTimeMillis() - mExitTime) > 2000) {
                Object mHelperUtils;
                Toast.makeText(this, "再按一次退出APP", Toast.LENGTH_SHORT).show();
                //System.currentTimeMillis()系统当前时间
                mExitTime = System.currentTimeMillis();
            } else {
                finish();
            }

             */
            switch (showFlag){
                case 1:  //GT9 rawdata
                case 2:  //manualdiff
                case 3:  //diffdata
                case 6:  //test
                case 7:  //GT738X rawdata
                case 8:  //stylusdata
                    showFlag = 5;

                    btn_RawdataShow.setEnabled(true);
                    btn_DiffdataShow.setEnabled(true);
                    btn_ReffdataShow.setEnabled(true);
                    btn_ManualdiffdataShow.setEnabled(true);
                    btn_Manualreff.setEnabled(false);
                    btn_StylusDataShow.setEnabled(true);
                    btn_Test.setEnabled(true);

                    break;
                case 4:  //test end
                case 5:  //stop
                default:
                    finish();
                    break;
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
