@WPF也工控机西门子通过OPC通讯方式进行数据上的交互
初始化以及读取写入的方法:
namespace OPC
{
public partial class MainWindow
{
OPCServer MyOpcServer;
OPCGroup MyOpcGroup;
public OPCItem Item1, Item2, Item3
public string OPCStart()//初始化以及监控点位
{
try
{
MyOpcServer = new OPCServer();
MyOpcServer.Connect("OPC.SimaticNet");
MyOpcGroup = MyOpcServer.OPCGroups.Add("MyGroup1");
MyOpcGroup.IsActive = true;
Item1 = MyOpcGroup.OPCItems.AddItem("S7:[S7_Connection_1]DB44,X0.3", 1);
Item2 = MyOpcGroup.OPCItems.AddItem("S7:[S7_Connection_1]DB44,X0.4", 2);//标签名称或地址名
Item3 = MyOpcGroup.OPCItems.AddItem("S7:[S7_Connection_1]DB44,X0.5", 3);
return "ok";
}
catch (System.Exception ex)