Beispiel #1
0
        private void btnSetting_Click(object sender, EventArgs e)
        {
            if (cbbChannel.Text == "")
            {
                MessageBox.Show(res_man.GetString("Please choose one of channels", cul));
                return;
            }
            if (txtDataOffset.Text == "")
            {
                MessageBox.Show(res_man.GetString("Please set value to calib", cul));
                return;
            }


            int index;

            index = Int32.Parse(cbbChannel.SelectedItem.ToString()) - 1;
            byte channel = byte.Parse((index + 1).ToString());
            byte data    = byte.Parse(channels[index].data.ToString());
            byte dau     = byte.Parse(channels[index].dau.ToString());

            if (channels[index].unit == 175)
            {
                float tamp = data / 10;
                tamp = Convert.ToSingle((tamp / 1.8).ToString("0.0"));
                data = byte.Parse((tamp * 10).ToString());
            }

            dv35.USBOpen(host);
            //HIDFunction.hid_SetNonBlocking(dv35.dev, 1);
            Thread.Sleep(2000);
            if (!dv35.writeCalibOffset(channel, data, dau))
            {
                MessageBox.Show(res_man.GetString("Setting Calib fail", cul));
                dv35.Close();
                return;
            }
            else
            {
                MessageBox.Show(res_man.GetString("Setting successful", cul));
                dv35.Close();
            }

            btnSetting.Enabled = false;
            btnSetting.Refresh();
            Thread.Sleep(4000);
            btnSetting.Enabled = true;

            //for (int i = 0; i < cbbChannel.Items.Count; i++)
            //{
            //    index = Int32.Parse(cbbChannel.Items[i].ToString()) - 1;
            //    byte channel = byte.Parse((index + 1).ToString());
            //    byte data = byte.Parse(channels[index].data.ToString());
            //    byte dau = byte.Parse(channels[index].dau.ToString());
            //    if(!dv35.writeCalibOffset(channel, data, dau))
            //    {
            //        MessageBox.Show("Setting Calib fail!");
            //        dv35.Close();
            //        return;
            //    }
            //}
            //MessageBox.Show("Successfully!");
            //dv35.Close();
        }