Sfoglia il codice sorgente

现在倍福参数包解析,更新参数

Shun 2 anni fa
parent
commit
5e6bf5a19f

+ 27 - 0
src/YSAI.DAQ/YSAI.Beckhoff.Pack/Program.cs

@@ -0,0 +1,27 @@
+using YSAI.Unility;
+
+namespace YSAI.Beckhoff.Pack
+{
+    internal class Program
+    {
+        static void Main(string[] args)
+        {
+            string FileDirectory = string.Empty;
+            string[] paths = AppDomain.CurrentDomain.BaseDirectory.Split('\\');
+            for (int i = 0; i < paths.Length - 5; i++)
+            {
+                FileDirectory += $"{paths[i]}//";
+            }
+            FileDirectory += "YSAI.Manage//param";
+            string Name = "YSAI.Beckhoff";
+            string ParamFile = $"{FileDirectory}//{Name}.Param.json";
+            string ParamDetailsFile = $"{FileDirectory}//{Name}.ParamDetails.json";
+            if (!Directory.Exists(FileDirectory))
+            {
+                Directory.CreateDirectory(FileDirectory);
+            }
+            FileTool.StringToFile(ParamFile, new BeckhoffData.Basics().ToJson().JsonFormatting());
+            FileTool.StringToFile(ParamDetailsFile, ReflexTool.GetClassAllPropertyData<BeckhoffData.Basics>().ToJson().JsonFormatting());
+        }
+    }
+}

File diff suppressed because it is too large
+ 18 - 0
src/YSAI.DAQ/YSAI.Beckhoff.Pack/YSAI.Beckhoff.Pack.csproj


+ 9 - 2
src/YSAI.DAQ/YSAI.DAQ.sln

@@ -97,9 +97,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Netty", "YSAI.Netty\YS
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Netty.Pack", "YSAI.Netty.Pack\YSAI.Netty.Pack.csproj", "{B2100081-54BC-4500-80D9-2A5B1CBCFD1B}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YSAI.Beckhoff", "YSAI.Beckhoff\YSAI.Beckhoff.csproj", "{B4932E85-54ED-4F1D-8773-184E3A0ADD62}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Beckhoff", "YSAI.Beckhoff\YSAI.Beckhoff.csproj", "{B4932E85-54ED-4F1D-8773-184E3A0ADD62}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YSAI.Mitsubishi", "YSAI.Mitsubishi\YSAI.Mitsubishi.csproj", "{DA9765D1-568D-48CE-A723-D7F10534FA22}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YSAI.Mitsubishi", "YSAI.Mitsubishi\YSAI.Mitsubishi.csproj", "{DA9765D1-568D-48CE-A723-D7F10534FA22}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YSAI.Beckhoff.Pack", "YSAI.Beckhoff.Pack\YSAI.Beckhoff.Pack.csproj", "{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -267,6 +269,10 @@ Global
 		{DA9765D1-568D-48CE-A723-D7F10534FA22}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{DA9765D1-568D-48CE-A723-D7F10534FA22}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{DA9765D1-568D-48CE-A723-D7F10534FA22}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -316,6 +322,7 @@ Global
 		{B2100081-54BC-4500-80D9-2A5B1CBCFD1B} = {1EBA4FD7-DF52-49A0-8AA4-9E61ABC614F5}
 		{B4932E85-54ED-4F1D-8773-184E3A0ADD62} = {0A264424-1AD7-49FA-B813-D96498066479}
 		{DA9765D1-568D-48CE-A723-D7F10534FA22} = {0A264424-1AD7-49FA-B813-D96498066479}
+		{BDFA0BDC-5645-4A7F-B063-0E162EABB7EF} = {1EBA4FD7-DF52-49A0-8AA4-9E61ABC614F5}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {5D5D3927-6714-40C0-84EA-44C5BA4C5E87}

+ 7 - 0
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Beckhoff.Param.json

@@ -0,0 +1,7 @@
+{
+    "SN": "283913ab356440808910b219c08138ad",
+    "AmsNetID": "192.168.66.130.1.1",
+    "Port": 851,
+    "TaskNumber": 5,
+    "TaskHandleInterval": 100
+}

+ 37 - 0
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Beckhoff.ParamDetails.json

@@ -0,0 +1,37 @@
+[
+    {
+        "Name": "SN",
+        "Describe": "唯一标识符",
+        "ParamType": "String",
+        "EnumArray": null,
+        "ObjArray": null
+    },
+    {
+        "Name": "AmsNetID",
+        "Describe": "设备的网络ID",
+        "ParamType": "String",
+        "EnumArray": null,
+        "ObjArray": null
+    },
+    {
+        "Name": "Port",
+        "Describe": "端口",
+        "ParamType": "Int32",
+        "EnumArray": null,
+        "ObjArray": null
+    },
+    {
+        "Name": "TaskNumber",
+        "Describe": "任务数量",
+        "ParamType": "Int32",
+        "EnumArray": null,
+        "ObjArray": null
+    },
+    {
+        "Name": "TaskHandleInterval",
+        "Describe": "任务处理间隔(毫秒)",
+        "ParamType": "Int32",
+        "EnumArray": null,
+        "ObjArray": null
+    }
+]

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Can.Param.json

@@ -1,10 +1,10 @@
 {
-    "SN": "629781c0a98148e498073c1860e7b127",
+    "SN": "b2c26336fdd04d54a169c73ab9fde693",
     "BaudRate": 0,
     "CanChannel": 0,
     "HandleInterval": 1000,
     "ChangeOut": true,
     "AllOut": false,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.DB.Param.json

@@ -1,10 +1,10 @@
 {
-    "SN": "0ed4181bae394d58868f1f90b92e86c7",
+    "SN": "2cb869601cec4ee1b18de3c92c6ee44a",
     "ConnectStr": null,
     "DBType": "SqlServer",
     "HandleInterval": 1000,
     "ChangeOut": true,
     "AllOut": false,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 1 - 1
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Kafka.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "72025abc9645440aa94732ddb78f9ebd",
+    "SN": "555bac07ec2e4dafbde3fc604032225c",
     "BootstrapServers": null,
     "WaitTime": 1000,
     "SecurityProtocol": "Plaintext",

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Modbus.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "21a7391887ab4aaab870419d6778a7e6",
+    "SN": "a8ad02ee398d4093a9143ea53deddc0e",
     "SlaveAddress": 1,
     "ProtocolType": "Tcp",
     "ReadTimeOut": 2000,
@@ -18,5 +18,5 @@
     "ChangeOut": true,
     "AllOut": false,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 1 - 1
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Mqtt.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "7df78ec405c74f66b79da8aeb12b96ab",
+    "SN": "0ba8c3109be046e18f9b212c90cf8702",
     "Ip": null,
     "Port": 0,
     "UserName": null,

+ 1 - 1
src/YSAI.DAQ/YSAI.Manage/param/YSAI.Netty.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "0024d74c44134930a2d3efaf6e322b9d",
+    "SN": "4f9f68f7a76a4df8a2fa08c53fa72ce5",
     "Host": null,
     "Port": 0,
     "SslFilePath": null,

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.OpcDa.Param.json

@@ -1,8 +1,8 @@
 {
-    "SN": "0092823c06124af6a9f8752117c1dd7b",
+    "SN": "0d0df0d01d9b4992a44cfb666389bd71",
     "SName": "Knight.OPC.Server.Demo",
     "ApiVerType": "COM_DA_30",
     "UpdateRate": 100,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.OpcDaHttp.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "6c35858df58849b79c8d91510e1ff7cf",
+    "SN": "8b043a71ed964b2a9bfbcdd4fbc9ab9b",
     "Ip": "127.0.0.1",
     "Port": 6688,
     "Key": null,
@@ -8,5 +8,5 @@
     "ChangeOut": true,
     "AllOut": false,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 3 - 3
src/YSAI.DAQ/YSAI.Manage/param/YSAI.OpcUa.Param.json

@@ -1,14 +1,14 @@
 {
-    "SN": "aeed4e2737e841dcac6e20d3b21766eb",
+    "SN": "dbb72ce84d9e4118a08fde68eddd54f4",
     "UserName": null,
     "Password": null,
     "Cer": null,
     "SecreKey": null,
     "ServerUrl": null,
-    "CustomName": "996F7E606AB449B39FC8C6383B039325",
+    "CustomName": "73E9D2982FFC43C6A4E69F2A40FEF735",
     "Timeout": 5000,
     "SamplingInterval": 100,
     "PublishingInterval": 1000,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 1 - 1
src/YSAI.DAQ/YSAI.Manage/param/YSAI.RabbitMQ.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "61f5355dc72f48e2ae917f8f18e7f2d9",
+    "SN": "65ebe69644ea42a8b42e0d7aaa2562c6",
     "ExChangeName": null,
     "HostName": null,
     "Port": 0,

+ 2 - 2
src/YSAI.DAQ/YSAI.Manage/param/YSAI.S7.Param.json

@@ -1,5 +1,5 @@
 {
-    "SN": "a201b4c4c5d1430387fc364b65302424",
+    "SN": "36961fd967384da196ee8df251f72175",
     "Ip": null,
     "Port": 0,
     "S7CpuType": "S7200",
@@ -9,5 +9,5 @@
     "ChangeOut": true,
     "AllOut": false,
     "TaskNumber": 5,
-    "TaskHandleInterval": 1000
+    "TaskHandleInterval": 100
 }

+ 6 - 1
src/YSAI.DAQ/YSAI.Pack.Param/Program.cs

@@ -1,5 +1,6 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
+using YSAI.Beckhoff;
 using YSAI.Can;
 using YSAI.DB;
 using YSAI.Kafka;
@@ -40,8 +41,9 @@ namespace YSAI.Pack.Param
             BodyHandler body9 = new BodyHandler { Body = new RabbitMQData.Basics(), FileName = "RabbitMQ.json", Namespace = "YSAI.RabbitMQ.RabbitMQOperate" };
             BodyHandler body10 = new BodyHandler { Body = new S7ClientData.Basics(), FileName = "S7.json", Namespace = "YSAI.S7.client.S7ClientOperate" };
             BodyHandler body11 = new BodyHandler { Body = new NettyClientData.Basics(), FileName = "Netty.json", Namespace = "YSAI.Netty.client.NettyClientOperate" };
+            BodyHandler body12 = new BodyHandler { Body = new BeckhoffData.Basics(), FileName = "Beckhoff.json", Namespace = "YSAI.Beckhoff.BeckhoffOperate" };
 
-            List<BodyHandler> bodys = new List<BodyHandler> { body1, body2, body3, body4, body5, body6, body7, body8, body9, body10,body11 };
+            List<BodyHandler> bodys = new List<BodyHandler> { body1, body2, body3, body4, body5, body6, body7, body8, body9, body10,body11,body12 };
 
             foreach (var item in bodys)
             {
@@ -85,6 +87,9 @@ namespace YSAI.Pack.Param
                     case "NettyClientData.Basics":
                         libInstanceParams = ReflexTool.GetClassAllPropertyData<NettyClientData.Basics>();
                         break;
+                    case "BeckhoffData.Basics":
+                        libInstanceParams = ReflexTool.GetClassAllPropertyData<BeckhoffData.Basics>();
+                        break;
                 }
                 if (message.Equals("Modbus"))
                 {

+ 1 - 0
src/YSAI.DAQ/YSAI.Pack.Param/YSAI.Pack.Param.csproj

@@ -8,6 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <ProjectReference Include="..\YSAI.Beckhoff\YSAI.Beckhoff.csproj" />
     <ProjectReference Include="..\YSAI.Can\YSAI.Can.csproj" />
     <ProjectReference Include="..\YSAI.DB\YSAI.DB.csproj" />
     <ProjectReference Include="..\YSAI.Kafka\YSAI.Kafka.csproj" />

+ 73 - 0
src/YSAI.DAQ/YSAI.Pack/Beckhoff.json

@@ -0,0 +1,73 @@
+{
+    "Code": "Beckhoff",
+    "Name": "Beckhoff",
+    "Description": "Beckhoff",
+    "Subset": [
+        {
+            "Name": "Beckhoff",
+            "Description": "Beckhoff",
+            "Propertie": [
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "唯一标识符",
+                    "PropertyName": "SN",
+                    "Value": null,
+                    "IsShow": true,
+                    "IsMust": false,
+                    "Options": null
+                },
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "设备的网络ID",
+                    "PropertyName": "AmsNetID",
+                    "Value": null,
+                    "IsShow": true,
+                    "IsMust": false,
+                    "Options": null
+                },
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "端口",
+                    "PropertyName": "Port",
+                    "Value": null,
+                    "IsShow": true,
+                    "IsMust": false,
+                    "Options": null
+                },
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "任务数量",
+                    "PropertyName": "TaskNumber",
+                    "Value": null,
+                    "IsShow": true,
+                    "IsMust": false,
+                    "Options": null
+                },
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "任务处理间隔(毫秒)",
+                    "PropertyName": "TaskHandleInterval",
+                    "Value": null,
+                    "IsShow": true,
+                    "IsMust": false,
+                    "Options": null
+                },
+                {
+                    "DataCate": "text",
+                    "Default": null,
+                    "Description": "实现类名",
+                    "PropertyName": "ServiceName",
+                    "Value": "YSAI.Beckhoff.BeckhoffOperate",
+                    "IsShow": false,
+                    "IsMust": false,
+                    "Options": null
+                }
+            ]
+        }
+    ]
+}

+ 75 - 42
src/YSAI.DAQ/YSAI.Test.All/Program.cs

@@ -440,51 +440,84 @@
 
 
 
-//using System.Collections.Concurrent;
-//using YSAI.Core.data;
-//using YSAI.Log;
-//using YSAI.Opc.ua.client;
-//using YSAI.Unility;
-
+using System.Collections.Concurrent;
+using YSAI.Core.data;
+using YSAI.Log;
+using YSAI.Opc.ua.client;
+using YSAI.Unility;
+
+/// <summary>
+/// 读取Csv,返回行集合
+/// </summary>
+/// <param name="path"></param>
+/// <param name="hasTitle"></param>
+/// <returns></returns>
+ List<string> ReadCsv(string path, bool hasTitle)
+{
+    if (!File.Exists(path))
+        return new List<string>();
+
+    var lines = File.ReadAllLines(path).ToList();
+    if (hasTitle)
+    {
+        lines.RemoveAt(0);
+    }
+    return lines;
+}
 
 //Address address = JsonTool.StringToJsonEntity<Address>(FileTool.FileToString("C:\\Users\\Shun\\Desktop\\[6032]Node_Address 202310120854271486.json"));
 
-
-//OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
-//{
-//    ServerUrl = "opc.tcp://127.0.0.1:8866/Opc.Ua.Service",
-//    Password = "ysai",
-//    UserName = "ysai",
-//    CustomName = "YSAI 性能测试",
-//});
-//Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
-//opcUaClientOperate.OnEvent += OpcUaClientOperate_OnEvent;
-
-//while (true)
-//{
-//    Console.ReadLine();
-//    OperateResult operateResult = opcUaClientOperate.Subscribe(address);
-//    Console.WriteLine(operateResult.ToJson().JsonFormatting());
-//}
-
-//void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
-//{
-//    switch (e.RType)
-//    {
-//        case YSAI.Core.@enum.ResultType.KeyValue:
-//            ConcurrentDictionary<string, AddressValue> pairs = e.RData as ConcurrentDictionary<string, AddressValue>;
-//            foreach (var item in pairs)
-//            {
-//                String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
-
-//                LogHelper.Verbose(str);
-//            }
-//            break;
-//        default:
-//            Console.WriteLine(e.Message);
-//            break;
-//    }
-//}
+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)
+{
+    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()
+    });
+}
+
+ OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
+{
+    ServerUrl = "opc.tcp://192.168.2.220:49320",
+    CustomName = "YSAI 性能测试",
+    TaskNumber=10,
+    TaskHandleInterval=1
+});
+Console.WriteLine(opcUaClientOperate.On().ToJson().JsonFormatting());
+opcUaClientOperate.OnEvent += OpcUaClientOperate_OnEvent;
+
+while (true)
+{
+    Console.ReadLine();
+    OperateResult operateResult = opcUaClientOperate.Subscribe(address);
+    Console.WriteLine(operateResult.ToJson().JsonFormatting());
+}
+
+void OpcUaClientOperate_OnEvent(object? sender, EventResult e)
+{
+    switch (e.RType)
+    {
+        case YSAI.Core.@enum.ResultType.KeyValue:
+            ConcurrentDictionary<string, AddressValue> pairs = e.RData as ConcurrentDictionary<string, AddressValue>;
+            foreach (var item in pairs)
+            {
+                String str = String.Format("{0,-100}{1,-100}", item.Key, item.Value.Value);
+
+                LogHelper.Verbose(str);
+            }
+            break;
+        default:
+            Console.WriteLine(e.Message);
+            break;
+    }
+}