Browse Source

版本更新

Shun 2 years ago
parent
commit
326d44c626

+ 2 - 2
src/YSAI.AllenBradley/YSAI.AllenBradley.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38333</Version>
+    <Version>23.331.41061</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Beckhoff/YSAI.Beckhoff.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,6 +17,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Beckhoff.TwinCAT.Ads" Version="6.1.125" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Can/YSAI.Can.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,7 +16,7 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Kvaser.CanLib">

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

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

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

@@ -108,11 +108,6 @@ namespace YSAI.Core.relay
         /// </summary>
         private ConcurrentQueue<QueueData> DataQueue;
 
-        /// <summary>
-        /// 全局TOKEN
-        /// </summary>
-        private CancellationTokenSource tokenSource;
-
         /// <summary>
         /// 队列里面的数据
         /// </summary>
@@ -142,16 +137,17 @@ namespace YSAI.Core.relay
             //起一个新线程
             return Task.Factory.StartNew(() =>
             {
-                //程序集
-                if (TypeIoc == null)
+                //打开失败监控
+                if (OnFailToken == null)
                 {
-                    TypeIoc = new ConcurrentDictionary<string, Type>();
+                    OnFailToken = new CancellationTokenSource();
+                    OnFailTask = OnFailTaskHandler(OnFailToken);
                 }
 
-                //生命周期
-                if (tokenSource == null)
+                //程序集
+                if (TypeIoc == null)
                 {
-                    tokenSource = new CancellationTokenSource();
+                    TypeIoc = new ConcurrentDictionary<string, Type>();
                 }
 
                 if (basics != null)
@@ -558,6 +554,60 @@ namespace YSAI.Core.relay
             }
         }
 
+        /// <summary>
+        /// 打开失败的实例对象,用于重新打开使用
+        /// </summary>
+        private ConcurrentDictionary<string, IRelay> OnFailIoc = new ConcurrentDictionary<string, IRelay>();
+
+        /// <summary>
+        /// 打开失败处理任务的生命周期
+        /// </summary>
+        private CancellationTokenSource OnFailToken;
+
+        /// <summary>
+        /// 打开失败任务处理间隔
+        /// </summary>
+        private int OnFailTaskHandlerInterval = 1000;
+
+        /// <summary>
+        /// 打开失败的任务
+        /// </summary>
+        private Task OnFailTask;
+
+        /// <summary>
+        /// 打开失败重新打开的任务
+        /// </summary>
+        /// <returns></returns>
+        private Task OnFailTaskHandler(CancellationTokenSource tokenSource)
+        {
+            return Task.Factory.StartNew(() =>
+            {
+                //打开成功的SN
+                List<string> OnSucceedSN = new List<string>();
+                while (!tokenSource.IsCancellationRequested)
+                {
+                    //重新打开
+                    foreach (var item in OnFailIoc)
+                    {
+                        if (item.Value.On().State)
+                        {
+                            OnSucceedSN.Add(item.Key);
+                        }
+                    }
+                    //打开成功后从失败的IOC中移除
+                    foreach (var item in OnSucceedSN)
+                    {
+                        OnFailIoc.Remove(item, out _);
+                    }
+                    //清空打开成功的数组
+                    OnSucceedSN.Clear();
+                    //休眠时间
+                    Thread.Sleep(OnFailTaskHandlerInterval);
+                }
+            }, tokenSource.Token);
+        }
+
+
         /// <summary>
         /// 通过配置创建实例
         /// </summary>
@@ -579,8 +629,14 @@ namespace YSAI.Core.relay
                 //自动打开
                 if (basics.AutoOn)
                 {
-                    //执行打开方法
+                    //执行打开方法 
                     OperateResult operateResult = instance.On();
+                    //如果打开状态为失败
+                    if (!operateResult.State)
+                    {
+                        //添加到打开失败重新打开流程中
+                        OnFailIoc.AddOrUpdate(InstanceIocSN, instance, (k, v) => instance);
+                    }
                     //抛出信息
                     OnEventHandler(this, new EventResult(operateResult.State, $"{InstanceIocSN} 实例创建成功,自动打开{(operateResult.State ? "成功" : "失败")}"));
                 }
@@ -741,6 +797,12 @@ namespace YSAI.Core.relay
         /// </summary>
         public void Dispose()
         {
+            if (OnFailToken != null)
+            {
+                OnFailToken.Cancel();
+                OnFailTask.Wait();
+                OnFailTask.Dispose();
+            }
             //任务清空
             if (TaskArray != null)
             {

+ 2 - 2
src/YSAI.DB/YSAI.DB.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -21,6 +21,6 @@
     <PackageReference Include="System.Data.OracleClient" Version="1.0.8" />
     <PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
     <PackageReference Include="System.Data.SQLite" Version="1.0.118" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

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

@@ -7,7 +7,7 @@
   </PropertyGroup>
 	<ItemGroup>
 		<FrameworkReference Include="Microsoft.AspNetCore.App" />
-		<PackageReference Include="YSAI.Core" Version="23.331.38048" />
+		<PackageReference Include="YSAI.Core" Version="23.331.40279" />
 	</ItemGroup>
 
 	<!--<ItemGroup>

+ 2 - 2
src/YSAI.Mewtocol/YSAI.Mewtocol.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,6 +17,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="Mewtocol.NET" Version="0.8.1" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Mitsubishi/YSAI.Mitsubishi.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Modbus/YSAI.Modbus.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -18,6 +18,6 @@
   <ItemGroup>
     <PackageReference Include="NModbus" Version="3.0.81" />
     <PackageReference Include="NModbus.Serial" Version="3.0.81" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 2
src/YSAI.Omron/YSAI.Omron.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -16,6 +16,6 @@
     <Description>$(DescriptionType):$(DescriptionName) ( $(DescriptionDetails) )</Description>
   </PropertyGroup>
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

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

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,7 +17,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.372.76" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
   <!--<ItemGroup>
     <ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

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

@@ -9,7 +9,7 @@
 	<ItemGroup>
 		<PackageReference Include="RabbitMQ.Client" Version="6.7.0" />
 		<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
-		<PackageReference Include="YSAI.Core" Version="23.331.38048" />
+		<PackageReference Include="YSAI.Core" Version="23.331.40279" />
 		<FrameworkReference Include="Microsoft.AspNetCore.App" />
 	</ItemGroup>
 

+ 2 - 2
src/YSAI.Siemens/YSAI.Siemens.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.331.38334</Version>
+    <Version>23.331.41062</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>
@@ -17,6 +17,6 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="S7netplus" Version="0.20.0" />
-    <PackageReference Include="YSAI.Core" Version="23.331.38048" />
+    <PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 </Project>

+ 2 - 0
src/YSAI.Test.All/Program.cs

@@ -58,6 +58,7 @@ for (int i = 0; i < strings.Count; i++)
     string addressD = str[0].Replace("\"", "");
     if (i % 2 == 0)
     {
+        //走脚本解析
         address.AddressArray.Add(new AddressDetails()
         {
             AddressName = $"ns=2;s=6022.6022.{addressD}",
@@ -82,6 +83,7 @@ for (int i = 0; i < strings.Count; i++)
     }
     else
     {
+        //走反射解析流程
         address.AddressArray.Add(new AddressDetails()
         {
             AddressName = $"ns=2;s=6022.6022.{addressD}",

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

@@ -17,7 +17,7 @@
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
-	<PackageReference Include="YSAI.Core" Version="23.331.38048" />
+	<PackageReference Include="YSAI.Core" Version="23.331.40279" />
   </ItemGroup>
 
   <ItemGroup>