|
|
@@ -1,35 +1,35 @@
|
|
|
-using YSAI.Core.communication.net.ws.client;
|
|
|
-using YSAI.Core.communication.net.ws.service;
|
|
|
-using YSAI.Unility;
|
|
|
+//using YSAI.Core.communication.net.ws.client;
|
|
|
+//using YSAI.Core.communication.net.ws.service;
|
|
|
+//using YSAI.Unility;
|
|
|
|
|
|
-WsServiceOperate tcpServiceOperate = WsServiceOperate.Instance(new WsServiceData.Basics() { LocalHostArray = new List<string> { "http://127.0.0.1:6688/" } });
|
|
|
-Console.WriteLine(tcpServiceOperate.On().ToJson().JsonFormatting());
|
|
|
+//WsServiceOperate tcpServiceOperate = WsServiceOperate.Instance(new WsServiceData.Basics() { LocalHostArray = new List<string> { "http://127.0.0.1:6688/" } });
|
|
|
+//Console.WriteLine(tcpServiceOperate.On().ToJson().JsonFormatting());
|
|
|
|
|
|
|
|
|
|
|
|
-WsClientOperate tcpClientOperate = WsClientOperate.Instance(new WsClientData.Basics());
|
|
|
-Console.WriteLine(tcpClientOperate.On().ToJson().JsonFormatting());
|
|
|
-tcpClientOperate.OnEvent += TcpClientOperate_OnEvent;
|
|
|
+//WsClientOperate tcpClientOperate = WsClientOperate.Instance(new WsClientData.Basics());
|
|
|
+//Console.WriteLine(tcpClientOperate.On().ToJson().JsonFormatting());
|
|
|
+//tcpClientOperate.OnEvent += TcpClientOperate_OnEvent;
|
|
|
|
|
|
|
|
|
-while (true)
|
|
|
-{
|
|
|
- Console.ReadLine();
|
|
|
- Console.WriteLine(tcpServiceOperate.Off().ToJson().JsonFormatting());
|
|
|
+//while (true)
|
|
|
+//{
|
|
|
+// Console.ReadLine();
|
|
|
+// Console.WriteLine(tcpServiceOperate.Off().ToJson().JsonFormatting());
|
|
|
|
|
|
- Console.ReadLine();
|
|
|
- Console.WriteLine(tcpClientOperate.Send(new byte[] { }).ToJson().JsonFormatting());
|
|
|
+// Console.ReadLine();
|
|
|
+// Console.WriteLine(tcpClientOperate.Send(new byte[] { }).ToJson().JsonFormatting());
|
|
|
|
|
|
- Console.ReadLine();
|
|
|
- Console.WriteLine(tcpServiceOperate.On().ToJson().JsonFormatting());
|
|
|
-}
|
|
|
+// Console.ReadLine();
|
|
|
+// Console.WriteLine(tcpServiceOperate.On().ToJson().JsonFormatting());
|
|
|
+//}
|
|
|
|
|
|
|
|
|
|
|
|
-void TcpClientOperate_OnEvent(object? sender, YSAI.Core.data.EventResult e)
|
|
|
-{
|
|
|
- Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
-}
|
|
|
+//void TcpClientOperate_OnEvent(object? sender, YSAI.Core.data.EventResult e)
|
|
|
+//{
|
|
|
+// Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
+//}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -788,104 +788,121 @@ void TcpClientOperate_OnEvent(object? sender, YSAI.Core.data.EventResult e)
|
|
|
// public string Description { get; set; }
|
|
|
//}
|
|
|
|
|
|
-//using System.Collections.Concurrent;
|
|
|
-//using YSAI.Core.data;
|
|
|
-//using YSAI.Log;
|
|
|
-//using YSAI.Opc.ua.client;
|
|
|
-//using YSAI.Unility;
|
|
|
+using System.Collections.Concurrent;
|
|
|
+using YSAI.Core.data;
|
|
|
+using YSAI.Log;
|
|
|
+using YSAI.Opc.ua.client;
|
|
|
+using YSAI.Unility;
|
|
|
|
|
|
-///// <summary>
|
|
|
-///// 读取Csv,返回行集合
|
|
|
-///// </summary>
|
|
|
-///// <param name="path"></param>
|
|
|
-///// <param name="hasTitle"></param>
|
|
|
-///// <returns></returns>
|
|
|
-//List<string> ReadCsv(string path, bool hasTitle)
|
|
|
-//{
|
|
|
-// if (!File.Exists(path))
|
|
|
-// return new List<string>();
|
|
|
+/// <summary>
|
|
|
+/// 读取Csv,返回行集合
|
|
|
+/// </summary>
|
|
|
+/// <param name="path"></param>
|
|
|
+/// <param name="hasTitle"></param>
|
|
|
+/// <returns></returns>
|
|
|
+List<string> ReadCsv(string path, bool hasTitle)
|
|
|
+{
|
|
|
+ if (!File.Exists(path))
|
|
|
+ return new List<string>();
|
|
|
+
|
|
|
+ var lines = File.ReadAllLines(path).ToList();
|
|
|
+ if (hasTitle)
|
|
|
+ {
|
|
|
+ lines.RemoveAt(0);
|
|
|
+ }
|
|
|
+ return lines;
|
|
|
+}
|
|
|
|
|
|
-// var lines = File.ReadAllLines(path).ToList();
|
|
|
-// if (hasTitle)
|
|
|
-// {
|
|
|
-// lines.RemoveAt(0);
|
|
|
-// }
|
|
|
-// return lines;
|
|
|
-//}
|
|
|
+//Address address = JsonTool.StringToJsonEntity<Address>(FileTool.FileToString("C:\\Users\\Shun\\Desktop\\[6032]Node_Address 202310120854271486.json"));
|
|
|
|
|
|
-////Address address = JsonTool.StringToJsonEntity<Address>(FileTool.FileToString("C:\\Users\\Shun\\Desktop\\[6032]Node_Address 202310120854271486.json"));
|
|
|
+Address address = new Address();
|
|
|
+address.SN = Guid.NewGuid().ToString();
|
|
|
+address.CreationTime = DateTime.Now;
|
|
|
+address.AddressArray = new List<AddressDetails>();
|
|
|
+List<string> strings = ReadCsv("C:\\Users\\Shun\\Desktop\\6022.csv", true);
|
|
|
+foreach (var item in strings)
|
|
|
+{
|
|
|
+ string[] str = item.Split(",");
|
|
|
+ string addressD = str[0].Replace("\"", "");
|
|
|
+ address.AddressArray.Add(new AddressDetails()
|
|
|
+ {
|
|
|
+ AddressName = $"ns=2;s=6022.6022.{addressD}",
|
|
|
+ SN = Guid.NewGuid().ToString()
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-//Address address = new Address();
|
|
|
-//address.SN = Guid.NewGuid().ToString();
|
|
|
-//address.CreationTime = DateTime.Now;
|
|
|
-//address.AddressArray = new List<AddressDetails>();
|
|
|
-//List<string> strings = ReadCsv("C:\\Users\\Shun\\Desktop\\6022.csv", true);
|
|
|
-//foreach (var item in strings)
|
|
|
+//address.AddressArray.Add(new AddressDetails()
|
|
|
//{
|
|
|
-// string[] str = item.Split(",");
|
|
|
-// string addressD = str[0].Replace("\"", "");
|
|
|
-// address.AddressArray.Add(new AddressDetails()
|
|
|
-// {
|
|
|
-// AddressName = $"ns=2;s=6022.6022.{addressD}",
|
|
|
-// SN = Guid.NewGuid().ToString()
|
|
|
-// });
|
|
|
-//}
|
|
|
-
|
|
|
-////address.AddressArray.Add(new AddressDetails()
|
|
|
-////{
|
|
|
-//// AddressName = $"ns=2;s=6022.6022.LAP5_DP2113_AUTO",
|
|
|
-//// SN = Guid.NewGuid().ToString()
|
|
|
-////});
|
|
|
-
|
|
|
-////address.AddressArray.Add(new AddressDetails()
|
|
|
-////{
|
|
|
-//// AddressName = $"ns=2;s=6022.6022.LAP5_DP2112_STATE_RUN",
|
|
|
-//// SN = Guid.NewGuid().ToString()
|
|
|
-////});
|
|
|
+// AddressName = $"ns=2;s=6022.6022.LAP5_DP2113_AUTO",
|
|
|
+// SN = Guid.NewGuid().ToString()
|
|
|
+//});
|
|
|
|
|
|
-//OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
+//address.AddressArray.Add(new AddressDetails()
|
|
|
//{
|
|
|
-// ServerUrl = "opc.tcp://192.168.2.220:49320",
|
|
|
-// CustomName = "YSAI 性能测试",
|
|
|
-// TaskNumber = 10,
|
|
|
-// TaskHandleInterval = 1,
|
|
|
-// SubscribeSingleGroupMaxCount = 1000,
|
|
|
+// AddressName = $"ns=2;s=6022.6022.LAP5_DP2112_STATE_RUN",
|
|
|
+// SN = Guid.NewGuid().ToString()
|
|
|
//});
|
|
|
-//Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
|
|
|
-//opcUaClientOperate.OnEvent += OpcUaClientOperate_OnEvent;
|
|
|
|
|
|
-//while (true)
|
|
|
-//{
|
|
|
-// Console.ReadLine();
|
|
|
-// OperateResult operateResult = opcUaClientOperate.Subscribe(address);
|
|
|
-// Console.WriteLine(operateResult.ToJson().JsonFormatting());
|
|
|
-//}
|
|
|
+OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
+{
|
|
|
+ ServerUrl = "opc.tcp://192.168.2.220:49320",
|
|
|
+ CustomName = "YSAI 性能测试",
|
|
|
+ TaskNumber = 10,
|
|
|
+ TaskHandleInterval = 1,
|
|
|
+ SubscribeSingleGroupMaxCount = 1000,
|
|
|
+});
|
|
|
+Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
|
|
|
+opcUaClientOperate.OnEvent += OpcUaClientOperate_OnEvent;
|
|
|
|
|
|
-//void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
|
|
|
-//{
|
|
|
-// switch (e.RType)
|
|
|
-// {
|
|
|
-// case YSAI.Core.@enum.ResultType.KeyValue:
|
|
|
+while (true)
|
|
|
+{
|
|
|
+ Console.ReadLine();
|
|
|
|
|
|
-// ConcurrentDictionary<string, AddressValue> pairs = e.GetRData<ConcurrentDictionary<string, AddressValue>>();
|
|
|
-// foreach (var item in pairs)
|
|
|
-// {
|
|
|
-// if (item.Value.AddressName.Equals("ns=2;s=6022.6022.LAP5_DP2112_STATE_RUN") || item.Value.AddressName.Equals("ns=2;s=6022.6022.LAP5_DP2113_AUTO"))
|
|
|
-// {
|
|
|
-// String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
|
|
|
-// LogHelper.Verbose(str);
|
|
|
-// }
|
|
|
+ OperateResult operateResult = opcUaClientOperate.Subscribe(address);
|
|
|
+ Console.WriteLine(operateResult.ToJson().JsonFormatting());
|
|
|
+ Console.ReadLine();
|
|
|
+ operateResult = opcUaClientOperate.UnSubscribe(address);
|
|
|
+ Console.WriteLine(operateResult.ToJson().JsonFormatting());
|
|
|
+ Console.ReadLine();
|
|
|
+ address = new Address();
|
|
|
+ address.SN = Guid.NewGuid().ToString();
|
|
|
+ address.CreationTime = DateTime.Now;
|
|
|
+ address.AddressArray = new List<AddressDetails>();
|
|
|
+ address.AddressArray.Add(new AddressDetails()
|
|
|
+ {
|
|
|
+ AddressName = $"6666",
|
|
|
+ SN = Guid.NewGuid().ToString()
|
|
|
+ });
|
|
|
+ operateResult = opcUaClientOperate.Subscribe(address);
|
|
|
+ Console.WriteLine(operateResult.ToJson().JsonFormatting());
|
|
|
|
|
|
-// //String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
|
|
|
-// //LogHelper.Verbose(str);
|
|
|
-// }
|
|
|
-// break;
|
|
|
+}
|
|
|
|
|
|
-// default:
|
|
|
-// //Console.WriteLine(e.Message);
|
|
|
-// break;
|
|
|
-// }
|
|
|
-//}
|
|
|
+void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
|
|
|
+{
|
|
|
+ switch (e.RType)
|
|
|
+ {
|
|
|
+ case YSAI.Core.@enum.ResultType.KeyValue:
|
|
|
+
|
|
|
+ ConcurrentDictionary<string, AddressValue> pairs = e.GetRData<ConcurrentDictionary<string, AddressValue>>();
|
|
|
+ foreach (var item in pairs)
|
|
|
+ {
|
|
|
+ if (item.Value.AddressName.Equals("ns=2;s=6022.6022.LAP5_DP2112_STATE_RUN") || item.Value.AddressName.Equals("ns=2;s=6022.6022.LAP5_DP2113_AUTO"))
|
|
|
+ {
|
|
|
+ String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
|
|
|
+ LogHelper.Verbose(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ //String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
|
|
|
+ //LogHelper.Verbose(str);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ //Console.WriteLine(e.Message);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//using Opc.Ua;
|
|
|
//using YSAI.Core.data;
|