Преглед изворни кода

1. 修改DB采集问题
2. 优化DB采集的返回数据格式
3. 工具新增DB数据采集
4. 采集转发版本更新

Shun пре 2 година
родитељ
комит
ec2cae1455

+ 8 - 1
README.md

@@ -588,7 +588,14 @@ while(true)
 #### 2024-1-2
 1. 新增转发模块工具,kafka、NetMQ、RabbitMQ、Netty
 
-#### 2021-1-3
+#### 2024-1-3
 1. 修改工具细节
 2. 优化已存在的问题
+3. 新增Windows窗体示例
+4. 新增Windows动画效果示例
+
+#### 2024-1-4
+1. 修改DB采集问题
+2. 优化DB采集的返回数据格式
+3. 工具新增DB数据采集
 

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

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

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

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

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

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

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

@@ -98,8 +98,8 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="YSAI.Mqtt" Version="23.360.30183" />
-    <PackageReference Include="YSAI.Opc" Version="23.361.15983" />
+    <PackageReference Include="YSAI.Mqtt" Version="24.4.7470" />
+    <PackageReference Include="YSAI.Opc" Version="24.4.7470" />
   </ItemGroup>
 
   <ItemGroup>

+ 0 - 22
src/YSAI.DB/DBData.cs

@@ -48,27 +48,5 @@ namespace YSAI.DB
             Oracle,
             SQLite
         }
-
-        /// <summary>
-        /// 扩展参数
-        /// </summary>
-        public class ExtendParam
-        {
-            /// <summary>
-            /// 读取
-            /// </summary>
-            public class Read
-            {
-                /// <summary>
-                /// sql语句
-                /// </summary>
-                public string Sql { get; set; }
-
-                /// <summary>
-                /// 需要的列名,针对数据库读取设置
-                /// </summary>
-                public List<string> ColumnName { get; set; }
-            }
-        }
     }
 }

+ 60 - 54
src/YSAI.DB/DBOperate.cs

@@ -14,7 +14,6 @@ using YSAI.Model.@enum;
 using YSAI.Model.@interface;
 using YSAI.Model.tool;
 using YSAI.Unility;
-using static YSAI.DB.DBData;
 
 namespace YSAI.DB
 {
@@ -456,48 +455,27 @@ namespace YSAI.DB
         /// <param name="Data"></param>
         /// <param name="Columns"></param>
         /// <returns></returns>
-        private List<ConcurrentDictionary<string, AddressValue>> Analysis(JArray Data, List<string> Columns, AddressDetails addressDetails)
+        private ConcurrentDictionary<string, AddressValue> Analysis(AddressDetails addressDetails, JArray? Data = null)
         {
+            ConcurrentDictionary<string, AddressValue> retData = new ConcurrentDictionary<string, AddressValue>();
+
+            //值
+            object? value = Data != null ? Data.ToJson() : null;
+
             //判断是不是虚拟点
             if (VAM.IsVirtualAddress(addressDetails))
             {
-                List<ConcurrentDictionary<string, AddressValue>> retDatas = new List<ConcurrentDictionary<string, AddressValue>>();
-                ConcurrentDictionary<string, AddressValue> retData = new ConcurrentDictionary<string, AddressValue>();
                 //值
-                object? value = VAM.Read(addressDetails);
-
-                //处理
-                AddressValue? addressValue = YSAI.Core.handler.AddressHandler.ExecuteDispose(addressDetails, value);
-
-                //添加进字典
-                retData.AddOrUpdate(addressDetails.AddressName, addressValue, (k, v) => addressValue);
-
-                //添加到字典集合
-                retDatas.Add(retData);
-
-                return retDatas;  //组织好数据返回
+                value = VAM.Read(addressDetails);
             }
-            else
-            {
-                List<ConcurrentDictionary<string, AddressValue>> retDatas = new List<ConcurrentDictionary<string, AddressValue>>();
-                foreach (var item in Data)
-                {
-                    ConcurrentDictionary<string, AddressValue> retData = new ConcurrentDictionary<string, AddressValue>();
-                    foreach (var column in Columns)
-                    {
-                        //值
-                        object? value = Convert.ToString(item[column]);
 
-                        //处理
-                        AddressValue? addressValue = YSAI.Core.handler.AddressHandler.ExecuteDispose(addressDetails, value);
+            //处理
+            AddressValue? addressValue = YSAI.Core.handler.AddressHandler.ExecuteDispose(addressDetails, value);
 
-                        //添加进字典   哪个表的哪个字段    值
-                        retData.AddOrUpdate(column, addressValue, (k, v) => addressValue);
-                    }
-                    retDatas.Add(retData);
-                }
-                return retDatas;  //组织好数据返回
-            }
+            //添加进字典
+            retData.AddOrUpdate(addressDetails.AddressName, addressValue, (k, v) => addressValue);
+
+            return retData;
         }
 
         #region 同步队列形式执行SQL,确保执行此sql在此程序中是唯一执行
@@ -656,13 +634,23 @@ namespace YSAI.DB
         {
             //开始记录运行时间
             string SN = Depart("Read");
+            if (!GetStatus().State)
+            {
+                return Break(SN, false, "未连接");
+            }
             try
             {
+                //失败信息
+                List<string> FailMessage = new List<string>();
                 List<ConcurrentDictionary<string, AddressValue>> RetData = new List<ConcurrentDictionary<string, AddressValue>>();
                 foreach (var item in address.AddressArray)
                 {
                     if (!item.IsEnable) continue;
-
+                    if (string.IsNullOrWhiteSpace(item.AddressName))
+                    {
+                        FailMessage.Add("[ AddressName ] 不能为空,DB操作时此属性为SQL语句");
+                        continue;
+                    }
                     //是不是虚拟地址
                     bool IsVA = false;
                     //初始化虚拟地址
@@ -670,19 +658,13 @@ namespace YSAI.DB
 
                     if (IsVA)
                     {
-                        RetData.AddRange(Analysis(null, null, item));
+                        RetData.Add(Analysis(item));
                     }
                     else
                     {
-                        ExtendParam.Read read = item.AddressExtendParam as ExtendParam.Read;
-                        if (read == null)
-                        {
-                            read = JsonTool.StringToJsonEntity<ExtendParam.Read>(item.AddressExtendParam.ToString());
-                        }
-                        //列名
-                        List<string> ColumnName = read.ColumnName;
                         //组织sql
-                        string sql = (item.AddressExtendParam as ExtendParam.Read).Sql;
+                        string sql = item.AddressName;
+
                         //查询结果对象
                         object obj = null;
                         try
@@ -699,20 +681,27 @@ namespace YSAI.DB
                         }
                         if (obj == null)  //查询结果为空
                         {
-                            return Break(SN, false, "查询结果为空");
+                            FailMessage.Add($"[ {item.AddressName} ] 查询结果为空");
                         }
 
-                        RetData.AddRange(Analysis(JArray.FromObject(obj), ColumnName, item));
+                        RetData.Add(Analysis(item, JArray.FromObject(obj)));
                     }
                 }
-                if (RetData.Count > 0)
+                if (FailMessage.Count > 0)
                 {
-                    //返回数据
-                    return Break(SN, true, RData: RetData, RType: ResultType.KeyValueArray);
+                    return Break(SN, false, $"存在 {FailMessage.Count} 失败信息", FailMessage, ResultType.Object);
                 }
                 else
                 {
-                    return Break(SN, false, "查询结果为空");
+                    if (RetData.Count > 0)
+                    {
+                        //返回数据
+                        return Break(SN, true, RData: RetData, RType: ResultType.KeyValueArray);
+                    }
+                    else
+                    {
+                        return Break(SN, false, "查询结果为空");
+                    }
                 }
             }
             catch (Exception ex)
@@ -729,6 +718,10 @@ namespace YSAI.DB
         public OperateResult Subscribe(Address address)
         {
             string SN = Depart("Subscribe");
+            if (!GetStatus().State)
+            {
+                return Break(SN, false, "未连接");
+            }
             try
             {
                 if (subscribeOperate == null)
@@ -768,6 +761,10 @@ namespace YSAI.DB
         public OperateResult UnSubscribe(Address address)
         {
             string SN = Depart("UnSubscribe");
+            if (!GetStatus().State)
+            {
+                return Break(SN, false, "未连接");
+            }
             try
             {
                 if (subscribeOperate != null)
@@ -815,10 +812,14 @@ namespace YSAI.DB
         {
             return Task.Run(() => On());
         }
-
+        /// <summary>
+        /// 连接状态
+        /// </summary>
+        private bool ConnectionStatus = false;
         public OperateResult On()
         {
-            return Break(Depart("On"), true);
+            ConnectionStatus = true;
+            return Break(Depart("On"), ConnectionStatus);
         }
 
         public Task<OperateResult> OffAsync()
@@ -829,6 +830,10 @@ namespace YSAI.DB
         public OperateResult Off()
         {
             string SN = Depart("Off");
+            if (!GetStatus().State)
+            {
+                return Break(SN, false, "未连接");
+            }
             if (subscribeOperate != null)
             {
                 OperateResult operateResult = subscribeOperate.Off();
@@ -838,12 +843,13 @@ namespace YSAI.DB
                 }
                 subscribeOperate = null;
             }
+            ConnectionStatus = false;
             return Break(SN, true);
         }
 
         public OperateResult GetStatus()
         {
-            return Break(Depart("GetStatus"), true, "已连接", OutputLog: false);
+            return Break(Depart("GetStatus"), ConnectionStatus, ConnectionStatus ? "已连接" : "未连接", OutputLog: false);
         }
 
         public Task<OperateResult> GetStatusAsync()

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

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

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

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

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

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

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

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

+ 1 - 1
src/YSAI.Modbus/ModbusOperate.cs

@@ -2468,7 +2468,7 @@ namespace YSAI.Modbus
 
                 if (FailMessage.Count > 0)
                 {
-                    return Break(SN, false, "存在一个或多个失败信息", FailMessage);
+                    return Break(SN, false, $"存在 {FailMessage.Count} 失败信息", FailMessage);
                 }
                 return Break(SN, true, "写入成功");
             }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 1 - 1
src/YSAI.Relay.Samples/YSAI.Relay.Samples.csproj

@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="YSAI.Mqtt" Version="23.360.30183" />
+    <PackageReference Include="YSAI.Mqtt" Version="24.4.7470" />
   </ItemGroup>
 
 </Project>

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

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

+ 1 - 1
src/YSAI.Tool.Wpf/Main.xaml.cs

@@ -32,7 +32,7 @@ namespace YSAI.Tool.Wpf
                     if (navigationViews.Count > 0)
                     {
                         //第一次打开显示的界面
-                        navigationViews[0].Navigate(typeof(YSAI.Tool.Wpf.views.UaClient));
+                        navigationViews[0].Navigate(typeof(YSAI.Tool.Wpf.views.DB));
                     }
                 });
             });

+ 14 - 14
src/YSAI.Tool.Wpf/YSAI.Tool.Wpf.csproj

@@ -23,21 +23,21 @@
 		<PackageReference Include="PropertyTools.Wpf" Version="3.1.0" />
 		<PackageReference Include="WPF-UI" Version="3.0.0-preview.13" />
 		<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2210.55" />
-		<PackageReference Include="YSAI.AllenBradley" Version="23.361.15983" />
-		<PackageReference Include="YSAI.Beckhoff" Version="23.361.15983" />
-		<PackageReference Include="YSAI.DB" Version="23.361.15983" />
-		<PackageReference Include="YSAI.Kafka" Version="23.352.38022" />
-		<PackageReference Include="YSAI.Mewtocol" Version="23.361.15983" />
-		<PackageReference Include="YSAI.Mitsubishi" Version="23.361.15983" />
-		<PackageReference Include="YSAI.Modbus" Version="23.363.33780" />
-		<PackageReference Include="YSAI.Mqtt" Version="23.360.30183" />
-		<PackageReference Include="YSAI.NetMQ" Version="23.352.38022" />
-		<PackageReference Include="YSAI.Netty" Version="24.2.10799" />
-		<PackageReference Include="YSAI.Omron" Version="23.361.15983" />
-		<PackageReference Include="YSAI.Opc" Version="23.361.15983" />
-		<PackageReference Include="YSAI.RabbitMQ" Version="24.2.13445" />
+		<PackageReference Include="YSAI.AllenBradley" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Beckhoff" Version="24.4.7470" />
+		<PackageReference Include="YSAI.DB" Version="24.4.29768" />
+		<PackageReference Include="YSAI.Kafka" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Mewtocol" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Mitsubishi" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Modbus" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Mqtt" Version="24.4.7470" />
+		<PackageReference Include="YSAI.NetMQ" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Netty" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Omron" Version="24.4.7470" />
+		<PackageReference Include="YSAI.Opc" Version="24.4.7470" />
+		<PackageReference Include="YSAI.RabbitMQ" Version="24.4.7470" />
 		<PackageReference Include="YSAI.Redis" Version="23.352.38022" />
-		<PackageReference Include="YSAI.Siemens" Version="23.361.20326" />
+		<PackageReference Include="YSAI.Siemens" Version="24.4.7470" />
 	</ItemGroup>
 	<ItemGroup>
 		<ProjectReference Include="..\YSAI.Core.Wpf\YSAI.Core.Wpf.csproj" />

+ 27 - 0
src/YSAI.Tool.Wpf/controllers/DBController.cs

@@ -0,0 +1,27 @@
+using System.Windows;
+using YSAI.DB;
+using YSAI.Tool.Wpf.template;
+using static YSAI.DB.DBData;
+namespace YSAI.Tool.Wpf.controllers
+{
+    public class DBController : DaqController<Basics>
+    {
+        public DBController()
+        {
+            //初始化基础数据
+            BasicsData = new Basics();
+            //工具标题
+            ToolTitle = "DB 工具";
+            //配置文件名
+            FileName = typeof(DBData).Name;
+            //Ascii是否显示
+            AsciiVisibility = Visibility.Collapsed;
+            //Hex是否显示
+            HexVisibility = Visibility.Collapsed;
+            //信息格式;  0 ASCII ; 1 HEX
+            InfoFormat = 0;
+            //设置采集对象
+            Daq = new DBOperate();
+        }
+    }
+}

+ 1 - 0
src/YSAI.Tool.Wpf/controllers/MainController.cs

@@ -36,6 +36,7 @@ namespace YSAI.Tool.Wpf.controllers
                             CreationControl("[ OpcDa ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.DaClient)),
                             CreationControl("[ OpcDa Http ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.DaHttp)),
                             CreationControl("[ Modbus ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.Modbus)),
+                            CreationControl("[ DB ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.DB)),
                             CreationControl("[ 罗克韦尔 ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.AllenBradley)),
                             CreationControl("[ 倍福 ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.Beckhoff)),
                             CreationControl("[ 松下 ]", SymbolRegular.DesktopFlow24, typeof(YSAI.Tool.Wpf.views.Mewtocol)),

+ 25 - 5
src/YSAI.Tool.Wpf/template/DaqController.cs

@@ -360,6 +360,8 @@ namespace YSAI.Tool.Wpf.template
                     catch (Exception ex)
                     {
                         Output($"数据格式不正确:{ex.Message}");
+
+                        _write = false;
                         return;
                     }
                     //写入
@@ -451,14 +453,32 @@ namespace YSAI.Tool.Wpf.template
         /// <param name="e"></param>
         private void Communication_OnEvent(object? sender, EventResult e)
         {
-            if (e.RData != null && e.RData is ConcurrentDictionary<string, AddressValue>)
+            if (e.RData != null && (e.RData is ConcurrentDictionary<string, AddressValue> || e.RData is List<ConcurrentDictionary<string, AddressValue>>))
             {
-                ConcurrentDictionary<string, AddressValue>? pairs = e.GetRData<ConcurrentDictionary<string, AddressValue>>();
-                if (pairs != null)
+                if (e.RData is ConcurrentDictionary<string, AddressValue>)
+                {
+                    ConcurrentDictionary<string, AddressValue>? pairs = e.GetRData<ConcurrentDictionary<string, AddressValue>>();
+                    if (pairs != null)
+                    {
+                        foreach (var itemc in pairs)
+                        {
+                            Output($"{e.Message}\r\n键:{itemc.Key}\r\n值:{itemc.Value.Value}\r\n", false);
+                        }
+                    }
+                }
+
+                if (e.RData is List<ConcurrentDictionary<string, AddressValue>>)
                 {
-                    foreach (var itemc in pairs)
+                    List<ConcurrentDictionary<string, AddressValue>>? pairs = e.GetRData<List<ConcurrentDictionary<string, AddressValue>>>();
+                    if (pairs != null)
                     {
-                        Output($"{e.Message}\r\n键:{itemc.Key}\r\n值:{itemc.Value.Value}\r\n", false);
+                        foreach (var itemc in pairs)
+                        {
+                            foreach (var item in itemc)
+                            {
+                                Output($"{e.Message}\r\n键:{item.Key}\r\n值:{item.Value.Value}\r\n", false);
+                            }
+                        }
                     }
                 }
             }

+ 20 - 0
src/YSAI.Tool.Wpf/views/DB.xaml

@@ -0,0 +1,20 @@
+<UserControl x:Class="YSAI.Tool.Wpf.views.DB"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:local="clr-namespace:YSAI.Tool.Wpf.views"
+             xmlns:c="clr-namespace:YSAI.Tool.Wpf.controllers"
+             Background="{DynamicResource ContentBackgroundPicture}">
+
+    <!--资源加载-->
+    <UserControl.Resources>
+        <ResourceDictionary Source="pack://application:,,,/YSAI.Tool.Wpf;component/template/DaqView.xaml" />
+    </UserControl.Resources>
+    <!--控制器绑定-->
+    <UserControl.DataContext>
+        <c:DBController />
+    </UserControl.DataContext>
+    <!--内容控件加载-->
+    <ContentControl Content="{Binding}" ContentTemplate="{DynamicResource DAQ}"/>
+</UserControl>

+ 28 - 0
src/YSAI.Tool.Wpf/views/DB.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace YSAI.Tool.Wpf.views
+{
+    /// <summary>
+    /// DB.xaml 的交互逻辑
+    /// </summary>
+    public partial class DB : UserControl
+    {
+        public DB()
+        {
+            InitializeComponent();
+        }
+    }
+}