Просмотр исходного кода

1. 修改底层通信协议发送返回函数中的字节对象
2. 版本更新

Shun 2 лет назад
Родитель
Сommit
6d285b7b1f

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

@@ -5,7 +5,7 @@
 		<ImplicitUsings>enable</ImplicitUsings>
 		<Nullable>enable</Nullable>
 		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-		<Version>1.0.0.2</Version>
+		<Version>1.0.0.3</Version>
 		<Authors>Shun</Authors>
 		<Company>YSAI</Company>
 		<Product>SCADA</Product>
@@ -14,7 +14,7 @@
 
 	<ItemGroup>
 		<PackageReference Include="Beckhoff.TwinCAT.Ads" Version="6.1.86" />
-		<PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+		<PackageReference Include="YSAI.Core" Version="1.0.0.65" />
 	</ItemGroup>
 
 	<!--<ItemGroup>

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

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.28</Version>
+	  <Version>1.0.0.29</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -17,7 +17,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
   <ItemGroup>

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

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
     <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-    <Version>1.0.0.64</Version>
+    <Version>1.0.0.65</Version>
     <Authors>Shun</Authors>
     <Company>YSAI</Company>
     <Product>SCADA</Product>

+ 2 - 1
src/YSAI.DAQ/YSAI.Core/communication/net/tcp/client/TcpClientOperate.cs

@@ -325,7 +325,8 @@ namespace YSAI.Core.communication.net.tcp.client
                     if (reverseBack.State)
                     {
                         CancellationTokenSource token = new CancellationTokenSource();
-                        byte[] Byte = new byte[] { };
+                        
+                        byte[] Byte = new byte[1024 * 1024];
                         bool Status = Task.Run(() =>
                         {
                             while (!token.IsCancellationRequested)

+ 2 - 2
src/YSAI.DAQ/YSAI.Core/communication/net/udp/UdpOperate.cs

@@ -300,7 +300,7 @@ namespace YSAI.Core.communication.net.udp
                     if (reverseBack.State)
                     {
                         CancellationTokenSource token = new CancellationTokenSource();
-                        byte[] Byte = new byte[] { };
+                        byte[] Byte = new byte[1024 * 1024];
                         bool Status = Task.Run(() =>
                         {
                             while (!token.IsCancellationRequested)
@@ -367,7 +367,7 @@ namespace YSAI.Core.communication.net.udp
                     if (reverseBack.State)
                     {
                         CancellationTokenSource token = new CancellationTokenSource();
-                        byte[] Byte = new byte[] { };
+                        byte[] Byte = new byte[1024 * 1024];
                         bool Status = Task.Run(() =>
                         {
                             while (!token.IsCancellationRequested)

+ 1 - 1
src/YSAI.DAQ/YSAI.Core/communication/net/ws/client/WsClientOperate.cs

@@ -334,7 +334,7 @@ namespace YSAI.Core.communication.net.ws.client
                     if (reverseBack.State)
                     {
                         CancellationTokenSource token = new CancellationTokenSource();
-                        byte[] Byte = new byte[] { };
+                        byte[] Byte = new byte[1024 * 1024];
                         bool Status = Task.Run(() =>
                         {
                             while (!token.IsCancellationRequested)

+ 1 - 1
src/YSAI.DAQ/YSAI.Core/communication/serial/SerialOperate.cs

@@ -260,7 +260,7 @@ namespace YSAI.Core.communication.serial
                     if (reverseBack.State)
                     {
                         CancellationTokenSource token = new CancellationTokenSource();
-                        byte[] Byte = new byte[] { };
+                        byte[] Byte = new byte[1024 * 1024];
                         bool Status = Task.Run(() =>
                         {
                             while (!token.IsCancellationRequested)

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

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.28</Version>
+	  <Version>1.0.0.29</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -18,7 +18,7 @@
 		<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="1.0.0.64" />
+		<PackageReference Include="YSAI.Core" Version="1.0.0.65" />
 	</ItemGroup>
 	<!--<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core\YSAI.Core.csproj" />

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

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

+ 2 - 2
src/YSAI.DAQ/YSAI.Kafka/YSAI.Kafka.csproj

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.29</Version>
+	  <Version>1.0.0.30</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -14,7 +14,7 @@
 
   <ItemGroup>
     <PackageReference Include="Confluent.Kafka" Version="2.3.0" />
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 	
 	<!--<ItemGroup>

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

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.28</Version>
+	  <Version>1.0.0.29</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -15,7 +15,7 @@
 	<ItemGroup>
     <PackageReference Include="NModbus" Version="3.0.80" />
     <PackageReference Include="NModbus.Serial" Version="3.0.80" />
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
 	<!--<ItemGroup>

+ 2 - 2
src/YSAI.DAQ/YSAI.Mqtt/YSAI.Mqtt.csproj

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.31</Version>
+	  <Version>1.0.0.32</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -15,7 +15,7 @@
   <ItemGroup>
     <PackageReference Include="MQTTnet" Version="4.3.1.873" />
     <PackageReference Include="MQTTnet.AspNetCore" Version="4.3.1.873" />
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
 	<!--<ItemGroup>

+ 2 - 2
src/YSAI.DAQ/YSAI.Netty/YSAI.Netty.csproj

@@ -5,7 +5,7 @@
 		<ImplicitUsings>enable</ImplicitUsings>
 		<Nullable>enable</Nullable>
 		<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-		<Version>1.0.0.3</Version>
+		<Version>1.0.0.4</Version>
 		<Authors>Shun</Authors>
 		<Company>YSAI</Company>
 		<Product>SCADA</Product>
@@ -14,6 +14,6 @@
 	<ItemGroup>
 		<PackageReference Include="DotNetty.Handlers" Version="0.7.5" />
 		<PackageReference Include="DotNetty.Transport" Version="0.7.5" />
-		<PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+		<PackageReference Include="YSAI.Core" Version="1.0.0.65" />
 	</ItemGroup>
 </Project>

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

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.38</Version>
+	  <Version>1.0.0.39</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -13,7 +13,7 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.372.56" />
-	<PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+	<PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
 

+ 168 - 53
src/YSAI.DAQ/YSAI.Opc/ua/client/OpcUaClientOperate.cs

@@ -125,6 +125,159 @@ namespace YSAI.Opc.ua.client
         #endregion
 
         #region 私有函数
+        /// <summary>
+        /// OPCUA 订阅状态集合
+        /// </summary>
+        private Dictionary<SubscriptionChangeMask, string> StateChangedStatus = new Dictionary<SubscriptionChangeMask, string>
+        {
+           { SubscriptionChangeMask.None, "订阅没有改变" },
+           { SubscriptionChangeMask.Created,"在服务器上创建订阅" },
+           { SubscriptionChangeMask.Deleted,"在服务器上删除订阅" },
+           { SubscriptionChangeMask.Modified,"在服务器上修改订阅" },
+           { SubscriptionChangeMask.ItemsAdded,"被监视的项目被添加到订阅中(但没有在服务器上创建)" },
+           { SubscriptionChangeMask.ItemsRemoved,"被监控的项目被删除到订阅(但没有在服务器上删除)" },
+           { SubscriptionChangeMask.ItemsCreated,"在服务器上创建监视项" },
+           { SubscriptionChangeMask.ItemsDeleted,"在服务器上删除监控项" },
+           { SubscriptionChangeMask.ItemsModified,"在服务器上修改监控项" },
+           { SubscriptionChangeMask.Transferred,"订阅在服务器上被转移" }
+        };
+
+        private Dictionary<PublishStateChangedMask, string> PublishStatusChangedStatus = new Dictionary<PublishStateChangedMask, string>
+        {
+           { PublishStateChangedMask.None, "发布状态没有改变" },
+           { PublishStateChangedMask.Stopped,"停止发布" },
+           { PublishStateChangedMask.Recovered,"发布恢复" },
+           { PublishStateChangedMask.KeepAlive,"收到keep alive消息" },
+           { PublishStateChangedMask.Republish,"重新发布丢失的消息" },
+           { PublishStateChangedMask.Transferred,"发布被转移到其他节点" },
+           { PublishStateChangedMask.Timeout,"发布超时" }
+        };
+
+        /// <summary>
+        /// 枚举类型
+        /// </summary>
+        private enum EnumType
+        {
+            StateChanged,
+            PublishStatusChanged
+        }
+
+        /// <summary>
+        /// 订阅状态枚举解析
+        /// </summary>
+        /// <param name=""></param>
+        /// <returns></returns>
+        private string EnumParse(string enumStr,EnumType type)
+        {
+            try
+            {
+                if (enumStr.Contains(","))
+                {
+                    string[] Es = enumStr.Split(",");
+                    string Info = string.Empty;
+                    foreach (var item in Es)
+                    {
+                        switch (type)
+                        {
+                            case EnumType.StateChanged:
+                                Info += $"( {StateChangedStatus[(SubscriptionChangeMask)Enum.Parse(typeof(SubscriptionChangeMask), item)]} )";
+                                break;
+                            case EnumType.PublishStatusChanged:
+                                Info += $"( {PublishStatusChangedStatus[(PublishStateChangedMask)Enum.Parse(typeof(PublishStateChangedMask), item)]} )";
+                                break;
+                        }
+                    }
+                    return Info.Replace(")(", ") (");
+                }
+                else
+                {
+                    switch (type)
+                    {
+                        case EnumType.StateChanged:
+                            return StateChangedStatus[(SubscriptionChangeMask)Enum.Parse(typeof(SubscriptionChangeMask), enumStr)];
+                        case EnumType.PublishStatusChanged:
+                            return PublishStatusChangedStatus[(PublishStateChangedMask)Enum.Parse(typeof(PublishStateChangedMask), enumStr)];
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                return ex.Message;
+            }
+            return "null";
+        }
+        /// <summary>
+        /// 订阅状态
+        /// </summary>
+        private void Subscription_StateChanged(Subscription subscription, SubscriptionStateChangedEventArgs e, string tag)
+        {
+#if DEBUG
+            string Message = EnumParse(e.Status.ToString(), EnumType.StateChanged);
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\",\"StatusCode\":\"{e.Status}\",\"StatusMessage\":\"{Message}\"" + "}";
+            LogHelper.Verbose($"订阅状态\r\n{MessageJson.JsonFormatting()}", $"{TAG}/StateChanged.log");
+#endif
+        }
+        /// <summary>
+        /// 指示订阅的发布状态已停止或已恢复
+        /// </summary>
+        private void Subscription_PublishStatusChanged(Subscription subscription, PublishStateChangedEventArgs e)
+        {
+#if DEBUG
+            string Message = EnumParse(e.Status.ToString(), EnumType.PublishStatusChanged);
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\",\"StatusCode\":\"{e.Status}\",\"StatusMessage\":\"{Message}\"" + "}";
+            LogHelper.Verbose($"指示订阅的发布状态已停止或已恢复\r\n{MessageJson.JsonFormatting()}", $"{TAG}/PublishError.log");
+#endif
+        }
+        /// <summary>
+        /// 处理发布响应时发生异常
+        /// </summary>
+        private void ClientSession_PublishError(ISession session, PublishErrorEventArgs e)
+        {
+#if DEBUG
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\",\"StatusCode\":\"{e.Status}\"" + "}";
+            LogHelper.Verbose($"处理发布响应时发生异常\r\n{MessageJson.JsonFormatting()}", $"{TAG}/PublishError.log");
+#endif
+        }
+        /// <summary>
+        /// 发布请求即将确认序列号
+        /// </summary>
+        private void ClientSession_PublishSequenceNumbersToAcknowledge(ISession session, PublishSequenceNumbersToAcknowledgeEventArgs e)
+        {
+#if DEBUG
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\"" + "}";
+            LogHelper.Verbose($"发布请求即将确认序列号\r\n{MessageJson.JsonFormatting()}", $"{TAG}/PublishSequenceNumbersToAcknowledge.log");
+#endif
+        }
+        /// <summary>
+        /// 会话正在结束
+        /// </summary>
+        private void ClientSession_SessionClosing(object? sender, EventArgs e)
+        {
+#if DEBUG
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\"" + "}";
+            LogHelper.Verbose($"会话正在结束\r\n{MessageJson.JsonFormatting()}", $"{TAG}/SessionClosing.log");
+#endif
+        }
+        /// <summary>
+        /// 会话配置更改
+        /// </summary>
+        private void ClientSession_SessionConfigurationChanged(object? sender, EventArgs e)
+        {
+#if DEBUG
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\"" + "}";
+            LogHelper.Verbose($"会话配置更改\r\n{MessageJson.JsonFormatting()}", $"{TAG}/SessionConfigurationChanged.log");
+#endif
+        }
+        /// <summary>
+        /// 添加或删除订阅
+        /// </summary>
+        private void ClientSession_SubscriptionsChanged(object? sender, EventArgs e)
+        {
+#if DEBUG
+            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\"" + "}";
+            LogHelper.Verbose($"添加或删除订阅\r\n{MessageJson.JsonFormatting()}", $"{TAG}/SubscriptionsChanged.log");
+#endif
+        }
 
         int ConnectedCounet = 0;
         /// <summary>
@@ -245,9 +398,6 @@ namespace YSAI.Opc.ua.client
             }
         }
 
-
-
-
         /// <summary>
         /// 当数据变化更新
         /// </summary>
@@ -946,7 +1096,7 @@ namespace YSAI.Opc.ua.client
                         subscription.DisplayName = Tag;  //订阅的显示名称
                         subscription.TimestampsToReturn = TimestampsToReturn.Both;  //与通知消息一起返回的时间戳
                         subscription.StateChanged += delegate (Subscription subscription, SubscriptionStateChangedEventArgs e) { Subscription_StateChanged(subscription, e, Tag); };  //订阅状态
-
+                        subscription.PublishStatusChanged += Subscription_PublishStatusChanged;   //指示订阅的发布状态已停止或已恢复
                         //监控项集合                                                                                                                                                    
                         List<MonitoredItem> monitoredItems = new List<MonitoredItem>();
 
@@ -989,55 +1139,7 @@ namespace YSAI.Opc.ua.client
             }
             return Break("AddSubscribe", true);
         }
-
-        /// <summary>
-        /// OPCUA 订阅状态集合
-        /// </summary>
-        private Dictionary<SubscriptionChangeMask, string> SubscribeStatus = new Dictionary<SubscriptionChangeMask, string>
-        {
-           { SubscriptionChangeMask.None, "订阅没有改变" },
-           { SubscriptionChangeMask.Created,"在服务器上创建订阅" },
-           { SubscriptionChangeMask.Deleted,"在服务器上删除订阅" },
-           { SubscriptionChangeMask.Modified,"在服务器上修改订阅" },
-           { SubscriptionChangeMask.ItemsAdded,"被监视的项目被添加到订阅中(但没有在服务器上创建)" },
-           { SubscriptionChangeMask.ItemsRemoved,"被监控的项目被删除到订阅(但没有在服务器上删除)" },
-           { SubscriptionChangeMask.ItemsCreated,"在服务器上创建监视项" },
-           { SubscriptionChangeMask.ItemsDeleted,"在服务器上删除监控项" },
-           { SubscriptionChangeMask.ItemsModified,"在服务器上修改监控项" },
-           { SubscriptionChangeMask.Transferred,"订阅在服务器上被转移" }
-        };
-        /// <summary>
-        /// 订阅状态枚举解析
-        /// </summary>
-        /// <param name=""></param>
-        /// <returns></returns>
-        private string EnumParse(string enumStr)
-        {
-            if (enumStr.Contains(","))
-            {
-                string[] Es = enumStr.Split(",");
-                string Info = string.Empty;
-                foreach (var item in Es)
-                {
-                    Info += $"( {SubscribeStatus[(SubscriptionChangeMask)Enum.Parse(typeof(SubscriptionChangeMask), item)]} )";
-                }
-                return Info.Replace(")(", ") (");
-            }
-            else
-            {
-                return SubscribeStatus[(SubscriptionChangeMask)Enum.Parse(typeof(SubscriptionChangeMask), enumStr)];
-            }
-        }
-
-        //订阅状态
-        private void Subscription_StateChanged(Subscription subscription, SubscriptionStateChangedEventArgs e, string tag)
-        {
-            string Message = EnumParse(e.Status.ToString());
-            string MessageJson = "{" + $"\"Uri\":\"{basics.ServerUrl}\",\"CustomName\":\"{basics.CustomName}\",\"StatusCode\":\"{e.Status}\",\"StatusMessage\":\"{Message}\"" + "}";
-#if DEBUG
-            OnEventHandler(this, new EventResult(true, Message, MessageJson));
-#endif
-        }
+       
 
         /// <summary>
         ///  移除订阅 通过节点来移除订阅,移除指定节点的订阅,没有也返回成功
@@ -1360,6 +1462,17 @@ namespace YSAI.Opc.ua.client
                 //当从服务器到达一个存活状态或检测到一个错误时将被引发
                 clientSession.KeepAlive += new KeepAliveEventHandler(Session_KeepAlive);
 
+                //添加或删除订阅
+                clientSession.SubscriptionsChanged += ClientSession_SubscriptionsChanged;
+                //会话配置更改
+                clientSession.SessionConfigurationChanged += ClientSession_SessionConfigurationChanged;
+                //会话正在结束
+                clientSession.SessionClosing += ClientSession_SessionClosing;
+                //发布请求即将确认序列号
+                clientSession.PublishSequenceNumbersToAcknowledge += ClientSession_PublishSequenceNumbersToAcknowledge;
+                //处理发布响应时发生异常
+                clientSession.PublishError += ClientSession_PublishError;
+
                 //当队列为空,初始化队列
                 if (DataQueue == null)
                 {
@@ -1389,6 +1502,8 @@ namespace YSAI.Opc.ua.client
             }
         }
 
+      
+
         public Task<OperateResult> OffAsync()
         {
             return Task.Run(() => Off());

+ 2 - 2
src/YSAI.DAQ/YSAI.RabbitMQ/YSAI.RabbitMQ.csproj

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.30</Version>
+	  <Version>1.0.0.31</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -14,7 +14,7 @@
 
   <ItemGroup>
     <PackageReference Include="RabbitMQ.Client" Version="6.6.0" />
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
   <ItemGroup>

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

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

+ 2 - 2
src/YSAI.DAQ/YSAI.S7/YSAI.S7.csproj

@@ -5,7 +5,7 @@
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
 	  <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
-	  <Version>1.0.0.27</Version>
+	  <Version>1.0.0.28</Version>
 	  <Authors>Shun</Authors>
 	  <Company>YSAI</Company>
 	  <Product>SCADA</Product>
@@ -14,7 +14,7 @@
 
 	<ItemGroup>
     <PackageReference Include="S7netplus" Version="0.20.0" />
-    <PackageReference Include="YSAI.Core" Version="1.0.0.64" />
+    <PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
 	<!--<ItemGroup>

+ 78 - 46
src/YSAI.DAQ/YSAI.Test.All/Program.cs

@@ -1,45 +1,58 @@
 
+using System.Text;
+using YSAI.Core.communication.net.tcp.client;
+using YSAI.Core.data;
 
-using System.Diagnostics;
-using YSAI.Unility;
-
-/// <summary>
-/// 开关
-/// </summary>
-Stopwatch stopwatch = null;
-/// <summary>
-/// 开始记录
-/// </summary>
-void StartRecord()
+TcpClientOperate tcpClientOperate = TcpClientOperate.Instance(new TcpClientData.Basics 
 {
-    if (stopwatch == null)
-    {
-        stopwatch = new Stopwatch();
-    }
-    stopwatch.Start(); //  开始监视代码运行时间
-}
-/// <summary>
-/// 停止记录
-/// </summary>
-/// <returns>时,分,秒,毫秒</returns>
-(int hours, int minutes, int seconds, int milliseconds) StopRecord()
-{
-    stopwatch.Stop(); //  停止监视
-    TimeSpan timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间
-    int hours = timespan.Hours; // 总小时
-    int minutes = timespan.Minutes;  // 总分钟
-    int seconds = timespan.Seconds;  //  总秒数
-    int milliseconds = timespan.Milliseconds;  //  总毫秒数
-    stopwatch.Restart();//复位
-    return (hours, minutes, seconds, milliseconds);
-}
-
-while (true)
-{
-    StartRecord();
-    Console.ReadLine();
-    Console.WriteLine(StopRecord().ToJson());
-}
+    InterruptReconnection=false
+});
+
+tcpClientOperate.On();
+
+OperateResult operateResult = tcpClientOperate.SendWait(Encoding.ASCII.GetBytes("S"));
+Console.WriteLine();
+
+//using System.Diagnostics;
+//using YSAI.Unility;
+
+///// <summary>
+///// 开关
+///// </summary>
+//Stopwatch stopwatch = null;
+///// <summary>
+///// 开始记录
+///// </summary>
+//void StartRecord()
+//{
+//    if (stopwatch == null)
+//    {
+//        stopwatch = new Stopwatch();
+//    }
+//    stopwatch.Start(); //  开始监视代码运行时间
+//}
+///// <summary>
+///// 停止记录
+///// </summary>
+///// <returns>时,分,秒,毫秒</returns>
+//(int hours, int minutes, int seconds, int milliseconds) StopRecord()
+//{
+//    stopwatch.Stop(); //  停止监视
+//    TimeSpan timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间
+//    int hours = timespan.Hours; // 总小时
+//    int minutes = timespan.Minutes;  // 总分钟
+//    int seconds = timespan.Seconds;  //  总秒数
+//    int milliseconds = timespan.Milliseconds;  //  总毫秒数
+//    stopwatch.Restart();//复位
+//    return (hours, minutes, seconds, milliseconds);
+//}
+
+//while (true)
+//{
+//    StartRecord();
+//    Console.ReadLine();
+//    Console.WriteLine(StopRecord().ToJson());
+//}
 
 
 
@@ -489,7 +502,7 @@ while (true)
 ///// <param name="path"></param>
 ///// <param name="hasTitle"></param>
 ///// <returns></returns>
-// List<string> ReadCsv(string path, bool hasTitle)
+//List<string> ReadCsv(string path, bool hasTitle)
 //{
 //    if (!File.Exists(path))
 //        return new List<string>();
@@ -520,12 +533,27 @@ while (true)
 //    });
 //}
 
-// OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
+////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()
+////});
+
+
+
+
+//OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
 //{
 //    ServerUrl = "opc.tcp://192.168.2.220:49320",
 //    CustomName = "YSAI 性能测试",
-//    TaskNumber=10,
-//    TaskHandleInterval=1
+//    TaskNumber = 10,
+//    TaskHandleInterval = 1
 //});
 //Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
 //opcUaClientOperate.OnEvent += OpcUaClientOperate_OnEvent;
@@ -542,12 +570,16 @@ while (true)
 //    switch (e.RType)
 //    {
 //        case YSAI.Core.@enum.ResultType.KeyValue:
-//            ConcurrentDictionary<string, AddressValue> pairs = e.RData as ConcurrentDictionary<string, AddressValue>;
+
+//            ConcurrentDictionary<string, AddressValue> pairs = e.GetRData<ConcurrentDictionary<string, AddressValue>>(); 
 //            foreach (var item in pairs)
 //            {
-//                String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
+//                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);
+//                    LogHelper.Verbose(str);
+//                }
 //            }
 //            break;
 //        default:

+ 1 - 1
src/YSAI.DAQ/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="1.0.0.64" />
+	<PackageReference Include="YSAI.Core" Version="1.0.0.65" />
   </ItemGroup>
 
   <ItemGroup>