OPCUA学习笔记
序号应⽤
1客户端实例化
private OpcUaClient opcUaClient = new OpcUaClient();
await opcUaClient.ConnectServer("p://118.24.36.220:62547/DataAccessServer");
opcUaClient.Disconnect();
荷花的别称有哪些2节点读取操作
string value = opcUaClient.ReadNode<string>("ns=2;s=Machines/Machine A/Name");
float value = opcUaClient.ReadNode<float>("ns=2;s=Machines/Machine B/TestValueFloat");
3类型未知节点读取操作
Opc.Ua.DataValue value = opcUaClient.ReadNode("ns=2;s=Robots/RobotA/RobotMode")
尼采为什么疯了
大风车图片
4数据订阅
private void button2_Click( object nder, EventArgs e )
{
// sub
OpcUaClient.AddSubscription( "A", "ns=2;s=Machines/Machine B/TestValueFloat", SubCallback );
}
private void SubCallback(string key, MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs args ) {
if (InvokeRequired)
{
Invoke( new Action<string, MonitoredItem, MonitoredItemNotificationEventArgs>( SubCallback ), key,
monitoredItem, args );
return;
}
百合莲子粥的做法
if (key == "A")
{
// 如果有多个的订阅值都关联了当前的⽅法,可以通过key和monitoredItem来区分
MonitoredItemNotification notification = args.NotificationValue as MonitoredItemNotification;
许慎简介影字if (notification != null)
中间一点{
textBox3.Text = notification.Value.WrappedValue.Value.ToString( );
}
主营业务利润率
}
}