示例#1
0
文件: Calib35.cs 项目: xanhnv/Pexo16
        private void Calib35_Load(object sender, EventArgs e)
        {
            switch (mGlobal.language)
            {
            case "Spanish":
                cul = CultureInfo.CreateSpecificCulture("es-ES");
                break;

            case "Korean":
                cul = CultureInfo.CreateSpecificCulture("ko-KR");
                break;

            case "Japanese":
                cul = CultureInfo.CreateSpecificCulture("ja-JP");
                break;

            default:
                cul = CultureInfo.CreateSpecificCulture("en-US");
                break;
            }

            label1.Text     = res_man.GetString("Chanel", cul);
            label4.Text     = res_man.GetString("Unit", cul);
            label2.Text     = res_man.GetString("Data offset", cul);
            btnSetting.Text = res_man.GetString("Write Setting", cul);


            cbbChannel.Items.Clear();

            string channel1 = "";
            string channel2 = "";
            string channel3 = "";
            string channel4 = "";

            dv35          = Device35.DelInstance();
            dv35          = Device35.Instance;
            dv35.Channels = new Channel[4];
            for (int i = 0; i < 4; i++)
            {
                dv35.Channels[i] = new Channel();
            }

            dv35.USBOpen(host);

            //HIDFunction.hid_SetNonBlocking(dv35.dev, 1);

            Thread.Sleep(200);

            byte[] buf = new byte[64];
            dv35.readSettingDevice();
            if (dv35.byteLogging == 68)
            {
                MessageBox.Show("Logger is recording. Please stop to calibrate");
                dv35.Close();
                this.Close();
            }
            dv35.readInfo4Device(ref buf);
            Thread.Sleep(2000);
            dv35.readSettingChannel();

            dv35.Close();

            byte[] temp1 = new byte[7];
            for (int i = 0; i < 7; i++)
            {
                if (buf[2 + i] != 0)
                {
                    temp1[i] = buf[2 + i];
                }
            }
            channel1 += Encoding.UTF8.GetString(temp1);

            byte[] temp2 = new byte[7];
            for (int i = 0; i < 7; i++)
            {
                if (buf[9 + i] != 0)
                {
                    temp2[i] = buf[9 + i];
                }
            }
            channel2 += Encoding.UTF8.GetString(temp2);

            byte[] temp3 = new byte[7];
            for (int i = 0; i < 7; i++)
            {
                if (buf[16 + i] != 0)
                {
                    temp3[i] = buf[16 + i];
                }
            }
            channel3 += Encoding.UTF8.GetString(temp3);

            byte[] temp4 = new byte[7];
            for (int i = 0; i < 7; i++)
            {
                if (buf[23 + i] != 0)
                {
                    temp4[i] = buf[23 + i];
                }
            }
            channel4 += Encoding.UTF8.GetString(temp4);

            if (channel1 == "PEXO-37")
            {
                cbbChannel.Items.Add("1");
                channels[0].unit = dv35.Channels[0].Unit;
            }
            else if (channel1 == "PEXO-40")
            {
                cbbChannel.Items.Add("1");
                channels[0].unit = 2;
            }

            if (channel2 == "PEXO-37")
            {
                cbbChannel.Items.Add("2");
                channels[1].unit = dv35.Channels[1].Unit;
            }
            else if (channel2 == "PEXO-40")
            {
                cbbChannel.Items.Add("2");
                channels[1].unit = 2;
            }

            if (channel3 == "PEXO-37")
            {
                cbbChannel.Items.Add("3");
                channels[2].unit = dv35.Channels[2].Unit;
            }
            else if (channel3 == "PEXO-40")
            {
                cbbChannel.Items.Add("3");
                channels[2].unit = 2;
            }

            if (channel4 == "PEXO-37")
            {
                cbbChannel.Items.Add("4");
                channels[3].unit = dv35.Channels[3].Unit;
            }
            else if (channel4 == "PEXO-40")
            {
                cbbChannel.Items.Add("4");
                channels[3].unit = 2;
            }

            //cbbChannel.Text = cbbChannel.Items[0].ToString();
            //cbbSign.Text = cbbSign.Items[0].ToString();
            cbbUnit.DropDownStyle = ComboBoxStyle.DropDownList;

            if (cbbUnit.Items.Count > 0)
            {
                cbbUnit.Text = cbbUnit.Items[0].ToString();
            }
            if (cbbChannel.Items.Count > 0)
            {
                cbbChannel.Text = cbbChannel.Items[0].ToString();
            }
        }