C# OPCServer:使用KEPServer安装方法_如何添加仿真器与添加西门子S7PLC
OPCServer:使用KEPServer
https://www.cnblogs.com/ioufev/p/9366877.html
1.下载安装
实际OPCServer使用(450M,中文,破解时间限制):KEPServer V6,百度网盘 ,密码: ykj2
2. 添加仿真器或者硬件PLC S7-300,S7-1200
仿真器就选:Simulator
西门子硬件就选:siemens TCP/IP ethernet,
如果连接硬件:参考这里:https://www.cnblogs.com/txwtech/p/15218280.html
记得输入PLC 的IP
标记里面的地址:K0003是随便写的。连接了硬件PLC,就输入PLC的实际需要操作的地址即可。
程序链接:c# 连接KepServer仿真器demo(not free)
c#连接KEPServer后,写入数据,就可以观察其变化
public static void initOPC(List<Wms_OpcTagListModel> taglist) { InitOK = false; if (OpcLink != null) { OpcLink.Dispose(); } OpcLink = new DaClient(new Uri("opcda://127.0.0.1/KEPware.KEPServerEx.V6")); // Opc.Server[] servers = m_discovery.GetAvailableServers(Specification.COM_DA_20,“OPC服务器IP地址”,null); //opcda://127.0.0.1/Matrikon.OPC.Simulation.1 OpcLink.Options.DefaultMonitorInterval = 1000; OpcLink.Options.MaxPublishRequestCount = int.MaxValue; OpcLink.Options.MaxNotificationQueueSize = int.MaxValue; //OpcLink.Options.SessionTimeout = uint.MaxValue; OpcLink.Options.MaxMessageQueueSize = int.MaxValue; OpcLink.Options.MaxSubscriptionCount = int.MaxValue; //OpcLink.Options.SubscriptionLifetimeCount = uint.MaxValue; //OpcLink.Options.SubscriptionKeepAliveCount= int.MaxValue; OpcLink.Connect(); while (OpcLink.Status != OpcStatus.Connected) { Thread.Sleep(5); Console.WriteLine("连接失败"); } if (OpcLink.Status == OpcStatus.Connected) { Thread.Sleep(5); Console.WriteLine("连接成功"); } // OpcGroup group = OpcLink.AddGroup("opc"); // OpcLink.AddItems("opc", new string[] {"PLC.Device1.Start", "PLC.Device1.Allow" }); // group.DataChange += new OpcObeser().Group_DataChange; InitOK = true; string get_data = OpcLink.Read<string>("通道1.设备1.Tag1"); Console.WriteLine("PLC tag1 data: "+get_data); OpcLink.Write<string>("通道1.设备1.Tag1", "22"); Console.WriteLine("PLC write tag1 data"); Thread.Sleep(2000); string get_data2 = OpcLink.Read<string>("通道1.设备1.Tag1"); Console.WriteLine("changed PLC tag1 data: " + get_data2);
点击quick client,
欢迎讨论,相互学习。
cdtxw@foxmail.com