Exemplo n.º 1
0
        private void ConnectToDevice_Click(object sender, EventArgs e)
        {
            cnct.Address = DeviceList.Text;
            if (cnct.Connection() == "Error")
            {
                MessageBox.Show("Ошибка подключения к прибору  \n" + cnct.ErrorMessage);
            }
            string Info = cnct.Info();

            DeviceInfo.Text = "Информация о приборе: " + Info;
            cnct.CloseSession();
        }
Exemplo n.º 2
0
        private void Backgroundproccess_DoWork(object sender, DoWorkEventArgs e) //процедура фонового процесса (обращение к прибору)
        {
            //var cn=(IConnect)e.Argument;
            IConnect cnct = setting.NewConnect();

            //if (cn!=null) cnct.Mode = cn.Mode;
            //if (cn != null) cnct.Address = cn.Address;


            //(Connect)e.Argument;
            if (cnct.Connection() == "Error")
            {
                MessageBox.Show("Ошибка подключения к прибору");
            }

            for (long i = 0; !backgroundproccess.CancellationPending; i++)
            {
                while (true)
                {
                    string str_f = cnct.MeasFreq();
                    if (str_f == "VCH_Error_NotEnoughPhaseData")
                    {
                        continue;
                    }

                    double f = Conversion.Val(str_f.Replace(",", "."));

                    const int f0          = 5000000;
                    double    f_new       = 0;
                    string    time_string = "";

                    if (cnct.Type == "ConnectVCH308")
                    {
                        time_string = DateTime.Now.ToString();
                        f_new       = f;
                        backgroundproccess.ReportProgress((int)i, f_new);//возвращаем частоту
                    }
                    else
                    {
                        //time_last = DateTime.Now;
                        time_string = DateTime.Now.ToString();
                        f_new       = (f0 - f) / f0;
                        backgroundproccess.ReportProgress((int)i, f_new);//возвращаем частоту
                    }
                    if (backgroundproccess.CancellationPending)
                    {
                        cnct.CloseSession();
                        break;
                    }
                }
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string url     = @"http://172.20.10.2:8080";
            string hubName = "BroadCastHub";

            size   = bounds.Size;
            height = bounds.Height;
            width  = bounds.Width;
            userID = textBox1.Text;

            conObj = new Connect(this);
            conObj.Connection(url, hubName);
            conn = conObj.conn;
            hub  = conObj.hub;

            conObj.HubOnBool("StartBroadcast");

            textBox2.Text = conn.ConnectionId;
        }