|
|
@@ -1,89 +1,77 @@
|
|
|
-using Newtonsoft.Json.Linq;
|
|
|
-using System.Collections.Concurrent;
|
|
|
+using System.Collections.Concurrent;
|
|
|
using YSAI.Core.data;
|
|
|
using YSAI.Core.@interface;
|
|
|
using YSAI.Core.subscription;
|
|
|
-using YSAI.Unility;
|
|
|
|
|
|
-namespace YSAI.Test.All
|
|
|
+//地址参数
|
|
|
+Address address = new Address()
|
|
|
{
|
|
|
- internal class Program
|
|
|
+ SN = Guid.NewGuid().ToString(),
|
|
|
+ AddressArray = new List<AddressDetails>()
|
|
|
+};
|
|
|
+for (int i = 0; i < 1000000; i++)
|
|
|
+{
|
|
|
+ address.AddressArray.Add(new AddressDetails
|
|
|
{
|
|
|
- static void Main(string[] args)
|
|
|
- {
|
|
|
- //地址参数
|
|
|
- Address address = new Address()
|
|
|
- {
|
|
|
- SN = Guid.NewGuid().ToString(),
|
|
|
- AddressArray = new List<AddressDetails>()
|
|
|
- };
|
|
|
- for (int i = 0; i < 1000000; i++)
|
|
|
- {
|
|
|
- address.AddressArray.Add(new AddressDetails
|
|
|
- {
|
|
|
- SN = $"测试{i}号采集",
|
|
|
- AddressName = $"TEST{i}"
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- TEST tEST = new TEST();
|
|
|
-
|
|
|
- SubscribeOperate subscribeOperate = SubscribeOperate.Instance(new SubscribeData.Basics()
|
|
|
- {
|
|
|
- Address = address,
|
|
|
- Function = tEST.Read,
|
|
|
- });
|
|
|
- subscribeOperate.OnEvent += SubscribeOperate_OnEvent;
|
|
|
- OperateResult operateResult = subscribeOperate.On();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- while (true)
|
|
|
- {
|
|
|
- Thread.Sleep(1000);
|
|
|
- }
|
|
|
- }
|
|
|
+ SN = $"测试{i}号采集",
|
|
|
+ AddressName = $"TEST{i}"
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
- private static void SubscribeOperate_OnEvent(object? sender, EventResult e)
|
|
|
- {
|
|
|
|
|
|
- ConcurrentDictionary<string, AddressValue> param = e.RData as ConcurrentDictionary<string, AddressValue>;
|
|
|
- foreach (var item in param)
|
|
|
- {
|
|
|
- Console.WriteLine(item.Value.AddressName);
|
|
|
- Console.WriteLine(item.Value.Value);
|
|
|
- Console.WriteLine("---------------------");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- public class TEST: IBaseAbstract
|
|
|
- {
|
|
|
- protected override string LogHead => "[ TEST 操作 ]";
|
|
|
- protected override string ClassName => "TEST";
|
|
|
- public OperateResult Read(Address address)
|
|
|
- {
|
|
|
- Depart("Read");
|
|
|
- //节点数据
|
|
|
- ConcurrentDictionary<string, AddressValue> param = new ConcurrentDictionary<string, AddressValue>();
|
|
|
- foreach (var item in address.AddressArray)
|
|
|
- {
|
|
|
- //数据处理
|
|
|
- AddressValue addressValue = YSAI.Core.data.AddressHandler.ExecuteDispose(item, new Random().NextDouble().ToString());
|
|
|
|
|
|
- //AddressValue addressValue = YSAI.Core.data.AddressHandler.ExecuteDispose(item, "1");
|
|
|
+TEST tEST = new TEST();
|
|
|
|
|
|
- //数据添加
|
|
|
- param.AddOrUpdate(item.AddressName, addressValue, (k, v) => addressValue);
|
|
|
- }
|
|
|
- return Break("Read", true, RData: param, RType: Core.@enum.ResultType.KeyValue);
|
|
|
- }
|
|
|
+SubscribeOperate subscribeOperate = SubscribeOperate.Instance(new SubscribeData.Basics()
|
|
|
+{
|
|
|
+ Address = address,
|
|
|
+ Function = tEST.Read,
|
|
|
+});
|
|
|
+subscribeOperate.OnEvent += SubscribeOperate_OnEvent;
|
|
|
+OperateResult operateResult = subscribeOperate.On();
|
|
|
|
|
|
|
|
|
|
|
|
+while (true)
|
|
|
+{
|
|
|
+ Thread.Sleep(1000);
|
|
|
+}
|
|
|
+void SubscribeOperate_OnEvent(object? sender, EventResult e)
|
|
|
+{
|
|
|
|
|
|
+ ConcurrentDictionary<string, AddressValue> param = e.RData as ConcurrentDictionary<string, AddressValue>;
|
|
|
+ foreach (var item in param)
|
|
|
+ {
|
|
|
+ Console.WriteLine(item.Value.AddressName);
|
|
|
+ Console.WriteLine(item.Value.Value);
|
|
|
+ Console.WriteLine("---------------------");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class TEST : IBaseAbstract
|
|
|
+{
|
|
|
+ protected override string LogHead => "[ TEST 操作 ]";
|
|
|
+ protected override string ClassName => "TEST";
|
|
|
+ public OperateResult Read(Address address)
|
|
|
+ {
|
|
|
+ Depart("Read");
|
|
|
+ //节点数据
|
|
|
+ ConcurrentDictionary<string, AddressValue> param = new ConcurrentDictionary<string, AddressValue>();
|
|
|
+ foreach (var item in address.AddressArray)
|
|
|
+ {
|
|
|
+ //数据处理
|
|
|
+ AddressValue addressValue = YSAI.Core.data.AddressHandler.ExecuteDispose(item, new Random().NextDouble().ToString());
|
|
|
+
|
|
|
+ //AddressValue addressValue = YSAI.Core.data.AddressHandler.ExecuteDispose(item, "1");
|
|
|
+
|
|
|
+ //数据添加
|
|
|
+ param.AddOrUpdate(item.AddressName, addressValue, (k, v) => addressValue);
|
|
|
}
|
|
|
+ return Break("Read", true, RData: param, RType: Core.@enum.ResultType.KeyValue);
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|