public Dictionary <string, string> GetValues(List <string> blocks)
        {
            if (!this.Connected)
            {
                throw new Exception("还未连接到OPC服务");
            }

            FlashLamp();
            return(_client.GetValues(blocks));
        }
Beispiel #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (client == null)
            {
                return;
            }
            timer1.Stop();

            Dictionary <string, string> values = client.GetValues(items);

            foreach (ListViewItem i in listView1.Items)
            {
                try
                {
                    i.SubItems[1].Text = values[i.SubItems[0].Text];
                }
                catch { timer1.Start(); }
            }

            timer1.Start();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            OPCServiceClient.OPCServiceClient client = new OPCServiceClient.OPCServiceClient("127.0.0.1", 9100);

            client.BadBlockDetected += Client_BadBlockDetected;
            if (client.Connect())
            {
                client.SetValue("tag1", "1");
                string tagValue1 = client.GetValue("tag1");

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("tag2", "20");
                dic.Add("tag3", "0");
                client.SetValues(dic);

                dic = client.GetValues(new List <string>()
                {
                    "tag2", "tag3"
                });
                client.Disconnect();
            }
        }