Browse Source

修改细节

Shun 2 years ago
parent
commit
7a788ff038

+ 0 - 3
src/YSAI.Beckhoff/YSAI.Beckhoff.csproj

@@ -19,7 +19,4 @@
     <PackageReference Include="Beckhoff.TwinCAT.Ads" Version="6.1.125" />
     <PackageReference Include="YSAI.Core" Version="23.328.40195" />
   </ItemGroup>
-  <!--<ItemGroup>
-    <ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-  </ItemGroup>-->
 </Project>

+ 0 - 3
src/YSAI.Can/YSAI.Can.csproj

@@ -23,7 +23,4 @@
       <HintPath>..\YSAI.Lib\YSAI.Can.Lib\Kvaser.CanLib.dll</HintPath>
     </Reference>
   </ItemGroup>
-  <!--<ItemGroup>
-    <ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-  </ItemGroup>-->
 </Project>

+ 1 - 0
src/YSAI.Core/YSAI.Core.csproj

@@ -20,4 +20,5 @@
     <PackageReference Include="YSAI.Model" Version="23.328.39019" />
     <PackageReference Include="Microsoft.ClearScript" Version="7.4.4" />
   </ItemGroup>
+  
 </Project>

+ 6 - 31
src/YSAI.Core/handler/AddressHandler.cs

@@ -34,9 +34,9 @@ namespace YSAI.Core.handler
         private static readonly string RelayBackupsLog = "Core/RelayBackups.log";
 
         /// <summary>
-        /// 转发容器
+        /// 转发操作
         /// </summary>
-        private static ConcurrentDictionary<RelayData.Basics, RelayOperate> RelayIoc = new ConcurrentDictionary<RelayData.Basics, RelayOperate>();
+        private static RelayOperate relayOperate = RelayOperate.Instance(new RelayData.Basics());
 
         /// <summary>
         /// 脚本容器
@@ -100,6 +100,7 @@ namespace YSAI.Core.handler
         /// 数据转发
         /// </summary>
         /// <param name="addressDetails">地址详情</param>
+        /// <param name="value">值</param>
         /// <returns></returns>
         public static Task Relay(AddressDetails addressDetails, string value)
         {
@@ -107,36 +108,10 @@ namespace YSAI.Core.handler
             {
                 if (addressDetails.AddressRelayParam != null)
                 {
-                    RelayData.Basics? basics = addressDetails.AddressRelayParam?.RelayBasics as RelayData.Basics;
-                    if (basics != null)
+                    OperateResult operateResult = relayOperate.Produce(addressDetails.AddressRelayParam?.Topic, value, addressDetails.AddressRelayParam?.ISns);
+                    if (!operateResult.State)
                     {
-                        if (!RelayIoc.ContainsKey(basics))
-                        {
-                            RelayOperate operate = RelayOperate.Instance(basics);
-                            RelayIoc.AddOrUpdate(basics, operate, (k, v) => operate);
-                            if (!basics.AutoOn)
-                            {
-                                OperateResult operateResult = RelayIoc[basics].On();
-                                if (!operateResult.State)
-                                {
-                                    LogHelper.Error($"转发打开失败:{operateResult.Message}", RelayLog);
-                                    RelayIoc.Remove(basics, out _);
-                                }
-                            }
-                        }
-
-                        if (RelayIoc.ContainsKey(basics))
-                        {
-                            OperateResult operateResult = RelayIoc[basics].Produce(addressDetails.AddressRelayParam?.Topic, value, addressDetails.AddressRelayParam?.ISns);
-                            if (!operateResult.State)
-                            {
-                                LogHelper.Error("{" + $"\"Topic\":\"{addressDetails.AddressRelayParam?.Topic}\",\"Content\":\"{value}\",\"ISns\":{addressDetails.AddressRelayParam?.ISns?.ToJson()}" + "}", RelayBackupsLog);
-                            }
-                        }
-                    }
-                    else
-                    {
-                        LogHelper.Error("使用了转发,但配置设置错误", RelayLog);
+                        LogHelper.Error("{" + $"\"Topic\":\"{addressDetails.AddressRelayParam?.Topic}\",\"Content\":\"{value}\",\"ISns\":{addressDetails.AddressRelayParam?.ISns?.ToJson()}" + "}", RelayBackupsLog, consoleShow: false);
                     }
                 }
             });

+ 2 - 2
src/YSAI.Core/relay/RelayData.cs

@@ -10,12 +10,12 @@
             /// <summary>
             /// 库文件统一存放文件夹,绝对路径
             /// </summary>
-            public string? LibFolder { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}/lib/relay";
+            public string? LibFolder { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}lib\\relay";
 
             /// <summary>
             /// 库配置文件夹,绝对路径
             /// </summary>
-            public string? LibConfigFolder { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}/config/relay";
+            public string? LibConfigFolder { get; set; } = $"{AppDomain.CurrentDomain.BaseDirectory}config\\relay";
 
             /// <summary>
             /// 库配置唯一标识符键

+ 8 - 12
src/YSAI.Core/relay/RelayOperate.cs

@@ -81,7 +81,7 @@ namespace YSAI.Core.relay
         /// <summary>
         /// 实例容器集合
         /// </summary>
-        private ConcurrentDictionary<string, IRelay> InstanceIoc;
+        private ConcurrentDictionary<string, IRelay> InstanceIoc = new ConcurrentDictionary<string, IRelay>();
 
         /// <summary>
         /// 库类型容器
@@ -142,12 +142,6 @@ namespace YSAI.Core.relay
             //起一个新线程
             return Task.Factory.StartNew(() =>
             {
-                //实例容器实例化
-                if (InstanceIoc == null)
-                {
-                    InstanceIoc = new ConcurrentDictionary<string, IRelay>();
-                }
-
                 //程序集
                 if (TypeIoc == null)
                 {
@@ -434,7 +428,7 @@ namespace YSAI.Core.relay
                     }
                     Thread.Sleep(1000);
                 }
-            });
+            }, WatcherToken.Token);
         }
 
         /// <summary>
@@ -722,8 +716,11 @@ namespace YSAI.Core.relay
                             {
                                 foreach (var ISn in queueData.ISns)
                                 {
-                                    OperateResult operateResult = InstanceIoc[ISn].Produce(queueData.Topic, queueData.Content);
-                                    OnEventHandler(this, new EventResult(operateResult.State, operateResult.Message, operateResult.RData, operateResult.RType));
+                                    if (InstanceIoc.ContainsKey(ISn))
+                                    {
+                                        OperateResult operateResult = InstanceIoc[ISn].Produce(queueData.Topic, queueData.Content);
+                                        OnEventHandler(this, new EventResult(operateResult.State, operateResult.Message, operateResult.RData, operateResult.RType));
+                                    }
                                 }
                             }
                         }
@@ -762,7 +759,6 @@ namespace YSAI.Core.relay
             DataQueue = null;
             //清空
             InstanceIoc.Clear();
-            InstanceIoc = null;
             TypeIoc.Clear();
             TypeIoc = null;
 
@@ -1053,7 +1049,7 @@ namespace YSAI.Core.relay
                 }
                 if (FailMessage.Count > 0)
                 {
-                    return Break(SN, false, $"存在 {FailMessage.Count} 失败信息", FailMessage, ResultType.Json);
+                    return Break(SN, false, $"存在 {FailMessage.Count} 失败信息,{FailMessage.ToJson()}", FailMessage, ResultType.Json);
                 }
                 else
                 {

+ 7 - 0
src/YSAI.DAQ.sln

@@ -135,6 +135,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Redis", "YSAI.Redis\YS
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Model", "YSAI.Model\YSAI.Model.csproj", "{2E999BFE-9128-4BAD-9BB5-88C20295BE61}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YSAI.Rest", "YSAI.Rest\YSAI.Rest.csproj", "{6A818E8C-144C-46E7-8C66-B66CD85487C0}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -365,6 +367,10 @@ Global
 		{2E999BFE-9128-4BAD-9BB5-88C20295BE61}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2E999BFE-9128-4BAD-9BB5-88C20295BE61}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{2E999BFE-9128-4BAD-9BB5-88C20295BE61}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6A818E8C-144C-46E7-8C66-B66CD85487C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6A818E8C-144C-46E7-8C66-B66CD85487C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6A818E8C-144C-46E7-8C66-B66CD85487C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6A818E8C-144C-46E7-8C66-B66CD85487C0}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -431,6 +437,7 @@ Global
 		{E3F6DC4A-57F4-436F-86C5-6B2F782AA2C9} = {12CB0510-7B1E-4518-AA3B-412A4D323D42}
 		{F917D5C2-A067-47F3-8E18-1CD2C95FEC29} = {F23C3553-3FE7-4ECC-9BBA-8C498C3B4398}
 		{2E999BFE-9128-4BAD-9BB5-88C20295BE61} = {D60224CF-7F12-453B-851E-B5C01F9D2BBE}
+		{6A818E8C-144C-46E7-8C66-B66CD85487C0} = {9D8EDBBA-7A97-4D84-9B12-7FCC2F834046}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {5D5D3927-6714-40C0-84EA-44C5BA4C5E87}

+ 0 - 3
src/YSAI.DB/YSAI.DB.csproj

@@ -23,7 +23,4 @@
     <PackageReference Include="System.Data.SQLite" Version="1.0.118" />
     <PackageReference Include="YSAI.Core" Version="23.328.40195" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 0 - 3
src/YSAI.Kafka/YSAI.Kafka.csproj

@@ -19,7 +19,4 @@
     <PackageReference Include="Confluent.Kafka" Version="2.3.0" />
     <PackageReference Include="YSAI.Model" Version="23.328.39019" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 0 - 3
src/YSAI.Modbus/YSAI.Modbus.csproj

@@ -20,7 +20,4 @@
     <PackageReference Include="NModbus.Serial" Version="3.0.81" />
     <PackageReference Include="YSAI.Core" Version="23.328.40195" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 1 - 1
src/YSAI.Model/YSAI.Model.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.328.39019</Version>
+    <Version>23.331.25128</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>

+ 1 - 5
src/YSAI.Model/data/AddressRelay.cs

@@ -5,14 +5,10 @@
     /// </summary>
     public class AddressRelay
     {
-        /// <summary>
-        /// 转发的基础数据
-        /// </summary>
-        public object RelayBasics { get; set; }
         /// <summary>
         /// 主题
         /// </summary>
-        public string Topic { get; set; }
+        public string? Topic { get; set; }
         /// <summary>
         /// 实例SN,为空则所有打开的转发实例都转发
         /// </summary>

+ 14 - 10
src/YSAI.Model/interface/IOrAbstract.cs

@@ -1,5 +1,5 @@
-using YSAI.Model.data;
-using YSAI.Log;
+using YSAI.Log;
+using YSAI.Model.data;
 using YSAI.Unility;
 
 namespace YSAI.Model.@interface
@@ -56,12 +56,13 @@ namespace YSAI.Model.@interface
         /// <param name="Message">消息</param>
         /// <param name="RData">结果值</param>
         /// <param name="Exception">异常对象</param>
+        /// <param name="ConsoleShow">控制台显示</param>
         /// <returns>统一结果</returns>
-        protected Task<OperateResult> BreakAsync(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null)
+        protected Task<OperateResult> BreakAsync(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null, bool ConsoleShow = true)
         {
             return Task.Run(() =>
             {
-                return Break(MethodName, State, Message, RData, RType, Exception);
+                return Break(MethodName, State, Message, RData, RType, Exception, ConsoleShow);
             });
         }
 
@@ -73,15 +74,16 @@ namespace YSAI.Model.@interface
         /// <param name="Message">消息</param>
         /// <param name="RData">结果值</param>
         /// <param name="Exception">异常对象</param>
+        /// <param name="ConsoleShow">控制台显示</param>
         /// <returns>统一结果</returns>
-        protected OperateResult Break(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null)
+        protected OperateResult Break(string MethodName, bool State, string? Message = null, object? RData = null, @enum.ResultType RType = @enum.ResultType.Null, Exception? Exception = null, bool ConsoleShow = true)
         {
             //返回运行时间(毫秒)
             int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
             //消息数据组织
             string message = $"[ {TAG} ]( {MethodName} {(State ? "成功" : "异常")} ){(string.IsNullOrEmpty(Message) ? string.Empty : $" : {Message}")}";
             //异常则输出日志
-            if (!State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", Exception); }
+            if (!State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", Exception, ConsoleShow); }
             //返回状态
             return new OperateResult(State, message, runTime, RData, RType);
         }
@@ -91,12 +93,13 @@ namespace YSAI.Model.@interface
         /// </summary>
         /// <param name="MethodName">方法名</param>
         /// <param name="result">结果</param>
+        /// <param name="ConsoleShow">控制台显示</param>
         /// <returns>统一结果</returns>
-        protected Task<OperateResult> BreakAsync(string MethodName, OperateResult result)
+        protected Task<OperateResult> BreakAsync(string MethodName, OperateResult result, bool ConsoleShow = true)
         {
             return Task.Run(() =>
             {
-                return Break(MethodName, result);
+                return Break(MethodName, result, ConsoleShow);
             });
         }
 
@@ -105,15 +108,16 @@ namespace YSAI.Model.@interface
         /// </summary>
         /// <param name="MethodName">方法名</param>
         /// <param name="result">结果</param>
+        /// <param name="ConsoleShow">控制台显示</param>
         /// <returns>统一结果</returns>
-        protected OperateResult Break(string MethodName, OperateResult result)
+        protected OperateResult Break(string MethodName, OperateResult result, bool ConsoleShow = true)
         {
             //返回运行时间(毫秒)
             int runTime = TimeTool.Instance($"{TAG}.{MethodName}").StopRecord().milliseconds;
             //消息数据组织
             string message = $"[ {TAG} ]( {MethodName} {(result.State ? "成功" : "异常")} ){(string.IsNullOrEmpty(result.Message) ? string.Empty : $" : {result.Message}")}";
             //异常则输出日志
-            if (!result.State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log"); }
+            if (!result.State) { LogHelper.Error(message, $"{TAG}/{MethodName}.log", consoleShow: ConsoleShow); }
             //返回状态
             return new OperateResult(result.State, message, runTime, result.RData, result.RType);
         }

+ 0 - 3
src/YSAI.Mqtt/YSAI.Mqtt.csproj

@@ -20,7 +20,4 @@
     <PackageReference Include="MQTTnet.AspNetCore" Version="4.3.1.873" />
     <PackageReference Include="YSAI.Model" Version="23.328.39019" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 2 - 9
src/YSAI.Opc/YSAI.Opc.csproj

@@ -15,18 +15,11 @@
     <DescriptionDetails>工业标准通信协议 - Tcp [ UaClient、UaService ]、ComServer [ DaClient ]、Http [ DaHttp ]</DescriptionDetails>
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
-  <ItemGroup>
-    <None Remove="Opc.Ua.Client.Config.xml" />
-    <None Remove="Opc.Ua.Service.Config.xml" />
-  </ItemGroup>
   <ItemGroup>
     <PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.372.76" />
-    <PackageReference Include="YSAI.Core" Version="23.328.40195" />
+    <!--<PackageReference Include="YSAI.Core" Version="23.328.40195" />-->
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
   <ItemGroup>
-    <Folder Include="da\lib\" />
+    <ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
   </ItemGroup>
 </Project>

+ 4 - 7
src/YSAI.RabbitMQ/YSAI.RabbitMQ.csproj

@@ -10,16 +10,13 @@
     <Company>YSAI</Company>
     <Product>SCADA</Product>
     <GenerateDocumentationFile>True</GenerateDocumentationFile>
-    <DescriptionType>转发协议</DescriptionType>
-    <DescriptionName>RabbitMQ</DescriptionName>
-    <DescriptionDetails>Publish、Consume</DescriptionDetails>
-    <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
+	<DescriptionType>转发协议</DescriptionType>
+	<DescriptionName>RabbitMQ</DescriptionName>
+	<DescriptionDetails>Publish、Consume</DescriptionDetails>
+	<Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="RabbitMQ.Client" Version="6.7.0" />
     <PackageReference Include="YSAI.Model" Version="23.328.39019" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 22 - 0
src/YSAI.Rest/YSAI.Rest.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk">
+	<PropertyGroup>
+		<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
+		<ImplicitUsings>enable</ImplicitUsings>
+		<Nullable>enable</Nullable>
+		<Version>23.328.39458</Version>
+		<PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
+		<PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
+		<Authors>Shun</Authors>
+		<Company>YSAI</Company>
+		<Product>SCADA</Product>
+		<GenerateDocumentationFile>True</GenerateDocumentationFile>
+		<DescriptionType>扩展工具</DescriptionType>
+		<DescriptionName>Rest</DescriptionName>
+		<DescriptionDetails>Client [ Publish、Subscribe ]、Service</DescriptionDetails>
+		<Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
+	</PropertyGroup>
+	<ItemGroup>
+		<PackageReference Include="RabbitMQ.Client" Version="6.7.0" />
+		<PackageReference Include="YSAI.Model" Version="23.328.39019" />
+	</ItemGroup>
+</Project>

+ 12 - 0
src/YSAI.Rest/client/Class1.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YSAI.Rest.client
+{
+    internal class Class1
+    {
+    }
+}

+ 12 - 0
src/YSAI.Rest/service/Class1.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace YSAI.Rest.service
+{
+    internal class Class1
+    {
+    }
+}

+ 0 - 3
src/YSAI.Siemens/YSAI.Siemens.csproj

@@ -19,7 +19,4 @@
     <PackageReference Include="S7netplus" Version="0.20.0" />
     <PackageReference Include="YSAI.Core" Version="23.328.40195" />
   </ItemGroup>
-  <!--<ItemGroup>
-		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />
-	</ItemGroup>-->
 </Project>

+ 148 - 25
src/YSAI.Test.All/Program.cs

@@ -1,40 +1,163 @@
-using YSAI.Redis;
+using System.Collections.Concurrent;
+using YSAI.Log;
+using YSAI.Model.data;
+using YSAI.Model.@enum;
+using YSAI.Opc.ua.client;
 using YSAI.Unility;
 
-RedisOperate redisOperate = RedisOperate.Instance(new RedisData.Basics
+/// <summary>
+/// 读取Csv,返回行集合
+/// </summary>
+/// <param name="path"></param>
+/// <param name="hasTitle"></param>
+/// <returns></returns>
+List<string> ReadCsv(string path, bool hasTitle)
 {
-    CStr = "127.0.0.1:6379",
-    DBI = 0,
-    Expiry = 86400000,
-    TAG = "Shun:",
-    UseTAG = true,
-});
-Console.WriteLine(redisOperate.On().ToJson().JsonFormatting());
-Console.WriteLine(redisOperate.KeyDelete("*"));
-for (int i = 0; i < 100; i++)
-{
-    Console.WriteLine(i);
-    string xmlstr = new data().ToXml();
-    Console.WriteLine(redisOperate.StringSet($"A{i}", new data()));
-    Console.WriteLine(redisOperate.StringGet<data>($"A{i}").ToJson());
+    if (!File.Exists(path))
+        return new List<string>();
+
+    var lines = File.ReadAllLines(path).ToList();
+    if (hasTitle)
+    {
+        lines.RemoveAt(0);
+    }
+    return lines;
 }
 
+//RelayOperate relayOperate = RelayOperate.Instance(new RelayData.Basics());
+
+
+
 
+//Thread.Sleep(5000);
 
-Console.WriteLine(redisOperate.Off().ToJson().JsonFormatting());
 
 
-public class data
+
+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)
 {
-    public double a { get; set; } = new Random().NextDouble();
-    public double b { get; set; } = new Random().NextDouble();
-    public double c { get; set; } = new Random().NextDouble();
-    public double d { get; set; } = new Random().NextDouble();
-    public double e { get; set; } = new Random().NextDouble();
-    public double f { get; set; } = new Random().NextDouble();
-    public double g { get; set; } = new Random().NextDouble();
+    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(),
+
+        AddressRelayParam = new AddressRelay
+        {
+            ISns = new List<string> { "YSAI.Mqtt.client.MqttClientOperate.mqtt1", "YSAI.Mqtt.client.MqttClientOperate.mqtt2" },
+            Topic = $"TEST/{addressD}"
+        }
+    }); ;
 }
 
+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;
+
+while (true)
+{
+    Console.ReadLine();
+
+    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());
+
+}
+
+void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
+{
+    switch (e.RType)
+    {
+        case 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 YSAI.Redis;
+//using YSAI.Unility;
+
+//RedisOperate redisOperate = RedisOperate.Instance(new RedisData.Basics
+//{
+//    CStr = "127.0.0.1:6379",
+//    DBI = 0,
+//    Expiry = 86400000,
+//    TAG = "Shun:",
+//    UseTAG = true,
+//});
+//Console.WriteLine(redisOperate.On().ToJson().JsonFormatting());
+//Console.WriteLine(redisOperate.KeyDelete("*"));
+//for (int i = 0; i < 100; i++)
+//{
+//    Console.WriteLine(i);
+//    string xmlstr = new data().ToXml();
+//    Console.WriteLine(redisOperate.StringSet($"A{i}", new data()));
+//    Console.WriteLine(redisOperate.StringGet<data>($"A{i}").ToJson());
+//}
+
+
+
+//Console.WriteLine(redisOperate.Off().ToJson().JsonFormatting());
+
+
+//public class data
+//{
+//    public double a { get; set; } = new Random().NextDouble();
+//    public double b { get; set; } = new Random().NextDouble();
+//    public double c { get; set; } = new Random().NextDouble();
+//    public double d { get; set; } = new Random().NextDouble();
+//    public double e { get; set; } = new Random().NextDouble();
+//    public double f { get; set; } = new Random().NextDouble();
+//    public double g { get; set; } = new Random().NextDouble();
+//}
+
 
 
 

+ 0 - 5
src/YSAI.Test.All/YSAI.Test.All.csproj

@@ -8,13 +8,8 @@
 	<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
   </PropertyGroup>
 
-  <ItemGroup>
-    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
-  </ItemGroup>
-
   <ItemGroup>
     <ProjectReference Include="..\YSAI.Opc\YSAI.Opc.csproj" />
-    <ProjectReference Include="..\YSAI.Redis\YSAI.Redis.csproj" />
   </ItemGroup>
 
 

+ 3 - 6
src/YSAI.Test.Console/Program.cs

@@ -1,11 +1,8 @@
 
+using YSAI.Mqtt.client;
+using YSAI.Unility;
 
-
-
-
-
-
-Console.WriteLine();
+Console.WriteLine(new MqttClientData.Basics().ToJson().JsonFormatting());