|
|
@@ -1,65 +1,99 @@
|
|
|
using YSAI.Core.data;
|
|
|
-using YSAI.Core.@enum;
|
|
|
-using YSAI.Opc.ua.client;
|
|
|
+using YSAI.RabbitMQ;
|
|
|
using YSAI.Unility;
|
|
|
|
|
|
-
|
|
|
-//点位地址
|
|
|
-Address address = new Address();
|
|
|
-address.SN = Guid.NewGuid().ToString();
|
|
|
-address.CreationTime = DateTime.Now.ToLocalTime();
|
|
|
-address.AddressArray = new List<AddressDetails> {
|
|
|
- new AddressDetails()
|
|
|
- {
|
|
|
- AddressName = "ns=2;s=YT6022_VALUE_SJ2147_P_CUR_9",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- },
|
|
|
- new AddressDetails()
|
|
|
- {
|
|
|
- AddressName = "ns=2;s=YT6022_VALUE_SJ2147_W_P3",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
+RabbitMQOperate rabbitMQOperate = RabbitMQOperate.Instance(new RabbitMQData.Basics()
|
|
|
{
|
|
|
- CustomName = Guid.NewGuid().ToString(),
|
|
|
- Password = "ysai",
|
|
|
- ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
|
|
|
- UserName = "ysai",
|
|
|
+ ExChangeName = "VariableExchangeRead",
|
|
|
+ HostName = "192.168.2.200",
|
|
|
+ UserName = "ys",
|
|
|
+ Password = "ys123456",
|
|
|
+ Port = 5672,
|
|
|
SN = Guid.NewGuid().ToString()
|
|
|
});
|
|
|
-opcUaClientOperate.OnEvent += delegate (object? sender, EventResult e) { OpcUaClientOperate_OnEvent(sender, e, "▲▲▲"); };
|
|
|
-Console.WriteLine(opcUaClientOperate.OnAsync().Result.ToJson().JsonFormatting());
|
|
|
-Console.WriteLine(opcUaClientOperate.AddSubscribe(new System.Collections.Concurrent.ConcurrentDictionary<string, Address>() { ["ysai"]= address }).ToJson().JsonFormatting());
|
|
|
|
|
|
+OperateResult operateResult = rabbitMQOperate.On();
|
|
|
+Console.WriteLine(operateResult.ToJson());
|
|
|
|
|
|
|
|
|
-OpcUaClientOperate opcUaClientOperate2 = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
-{
|
|
|
- CustomName = Guid.NewGuid().ToString(),
|
|
|
- Password = "ysai",
|
|
|
- ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
|
|
|
- UserName = "ysai",
|
|
|
- SN = Guid.NewGuid().ToString()
|
|
|
-});
|
|
|
-opcUaClientOperate2.OnEvent += delegate (object? sender, EventResult e) { OpcUaClientOperate_OnEvent(sender, e, "■■■"); };
|
|
|
-Console.WriteLine(opcUaClientOperate2.OnAsync().Result.ToJson().JsonFormatting());
|
|
|
-Console.WriteLine(opcUaClientOperate.AddSubscribe(new System.Collections.Concurrent.ConcurrentDictionary<string, Address>() { ["ysai"] = address }).ToJson().JsonFormatting());
|
|
|
+rabbitMQOperate.OnEvent += RabbitMQOperate_OnEvent;
|
|
|
+operateResult = rabbitMQOperate.Consume("test");
|
|
|
+Console.WriteLine(operateResult.ToJson());
|
|
|
|
|
|
-void OpcUaClientOperate_OnEvent(object? sender, EventResult e,string name)
|
|
|
+while (true)
|
|
|
{
|
|
|
- Console.WriteLine(name);
|
|
|
- Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
+ Console.ReadLine();
|
|
|
+ operateResult = rabbitMQOperate.Produce("test",$"{new Random().NextDouble()}");
|
|
|
+ Console.WriteLine(operateResult.ToJson());
|
|
|
}
|
|
|
-
|
|
|
-while (true)
|
|
|
+void RabbitMQOperate_OnEvent(object? sender, EventResult e)
|
|
|
{
|
|
|
- Console.ReadKey();
|
|
|
+ Console.WriteLine(e.ToJson());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+//using YSAI.Core.data;
|
|
|
+//using YSAI.Core.@enum;
|
|
|
+//using YSAI.Opc.ua.client;
|
|
|
+//using YSAI.Unility;
|
|
|
+
|
|
|
+
|
|
|
+////点位地址
|
|
|
+//Address address = new Address();
|
|
|
+//address.SN = Guid.NewGuid().ToString();
|
|
|
+//address.CreationTime = DateTime.Now.ToLocalTime();
|
|
|
+//address.AddressArray = new List<AddressDetails> {
|
|
|
+// new AddressDetails()
|
|
|
+// {
|
|
|
+// AddressName = "ns=2;s=YT6022_VALUE_SJ2147_P_CUR_9",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// },
|
|
|
+// new AddressDetails()
|
|
|
+// {
|
|
|
+// AddressName = "ns=2;s=YT6022_VALUE_SJ2147_W_P3",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// }
|
|
|
+//};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
+//{
|
|
|
+// CustomName = Guid.NewGuid().ToString(),
|
|
|
+// Password = "ysai",
|
|
|
+// ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
|
|
|
+// UserName = "ysai",
|
|
|
+// SN = Guid.NewGuid().ToString()
|
|
|
+//});
|
|
|
+//opcUaClientOperate.OnEvent += delegate (object? sender, EventResult e) { OpcUaClientOperate_OnEvent(sender, e, "▲▲▲"); };
|
|
|
+//Console.WriteLine(opcUaClientOperate.OnAsync().Result.ToJson().JsonFormatting());
|
|
|
+//Console.WriteLine(opcUaClientOperate.AddSubscribe(new System.Collections.Concurrent.ConcurrentDictionary<string, Address>() { ["ysai"]= address }).ToJson().JsonFormatting());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//OpcUaClientOperate opcUaClientOperate2 = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
+//{
|
|
|
+// CustomName = Guid.NewGuid().ToString(),
|
|
|
+// Password = "ysai",
|
|
|
+// ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
|
|
|
+// UserName = "ysai",
|
|
|
+// SN = Guid.NewGuid().ToString()
|
|
|
+//});
|
|
|
+//opcUaClientOperate2.OnEvent += delegate (object? sender, EventResult e) { OpcUaClientOperate_OnEvent(sender, e, "■■■"); };
|
|
|
+//Console.WriteLine(opcUaClientOperate2.OnAsync().Result.ToJson().JsonFormatting());
|
|
|
+//Console.WriteLine(opcUaClientOperate.AddSubscribe(new System.Collections.Concurrent.ConcurrentDictionary<string, Address>() { ["ysai"] = address }).ToJson().JsonFormatting());
|
|
|
+
|
|
|
+//void OpcUaClientOperate_OnEvent(object? sender, EventResult e,string name)
|
|
|
+//{
|
|
|
+// Console.WriteLine(name);
|
|
|
+// Console.WriteLine(e.ToJson().JsonFormatting());
|
|
|
+//}
|
|
|
+
|
|
|
+//while (true)
|
|
|
+//{
|
|
|
+// Console.ReadKey();
|
|
|
+//}
|
|
|
+
|
|
|
////采集
|
|
|
//using (类 operate = new 类(new 类数据.Basics
|
|
|
//{
|
|
|
@@ -303,7 +337,7 @@ while (true)
|
|
|
// bytes = ByteTool.CombineBytes(bytes, 0, bytes.Length, array, 0, array.Length);
|
|
|
//}
|
|
|
|
|
|
-Console.WriteLine();
|
|
|
+//Console.WriteLine();
|
|
|
//Console.WriteLine(Guid.NewGuid().ToString().Replace("-", string.Empty).Trim().ToUpper());
|
|
|
|
|
|
//
|