|
|
@@ -1,16 +1,19 @@
|
|
|
|
|
|
+using System.Collections.Concurrent;
|
|
|
using YSAI.Core.data;
|
|
|
+using YSAI.Log;
|
|
|
using YSAI.Opc.ua.client;
|
|
|
using YSAI.Unility;
|
|
|
|
|
|
|
|
|
-
|
|
|
-Address address = JsonTool.StringToJsonEntity<Address>(FileTool.FileToString("C:\\Users\\Shun\\Desktop\\Address.json"));
|
|
|
+Address address = JsonTool.StringToJsonEntity<Address>(FileTool.FileToString("C:\\Users\\Shun\\Desktop\\[6032]Node_Address 202310120854271486.json"));
|
|
|
|
|
|
|
|
|
OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
{
|
|
|
- ServerUrl = "opc.tcp://192.168.2.220:49320",
|
|
|
+ ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
|
|
|
+ Password="ysai",
|
|
|
+ UserName="ysai",
|
|
|
CustomName = "YSAI 性能测试",
|
|
|
});
|
|
|
Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
|
|
|
@@ -25,16 +28,48 @@ while (true)
|
|
|
|
|
|
void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
|
|
|
{
|
|
|
- if (e.RData != null)
|
|
|
- {
|
|
|
- Console.ForegroundColor = ConsoleColor.Green;
|
|
|
- Console.WriteLine(e.RData.ToJson());
|
|
|
- }
|
|
|
- else
|
|
|
+ switch (e.RType)
|
|
|
{
|
|
|
- Console.ForegroundColor = ConsoleColor.Red;
|
|
|
- Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
+ case YSAI.Core.@enum.ResultType.KeyValue:
|
|
|
+ ConcurrentDictionary<string,AddressValue> pairs=e.RData as ConcurrentDictionary<string,AddressValue>;
|
|
|
+ foreach (var item in pairs)
|
|
|
+ {
|
|
|
+ String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
|
|
|
+
|
|
|
+ LogHelper.Verbose(str);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.KeyValueArray:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.Json:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.Bytes:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.String:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.Dynamic:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.OperateResult:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.Enum:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.All:
|
|
|
+ break;
|
|
|
+ case YSAI.Core.@enum.ResultType.NULL:
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+ //if (e.RData != null)
|
|
|
+ //{
|
|
|
+ // Console.ForegroundColor = ConsoleColor.Green;
|
|
|
+ // Console.WriteLine(e.RData.ToJson());
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // Console.ForegroundColor = ConsoleColor.Red;
|
|
|
+ // Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
|