|
|
@@ -1,4 +1,6 @@
|
|
|
using System.Collections.Concurrent;
|
|
|
+using YSAI.Core.reflection;
|
|
|
+using YSAI.Core.script;
|
|
|
using YSAI.Log;
|
|
|
using YSAI.Model.data;
|
|
|
using YSAI.Model.@enum;
|
|
|
@@ -39,23 +41,105 @@ 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)
|
|
|
+for (int i = 0; i < strings.Count; i++)
|
|
|
{
|
|
|
- string[] str = item.Split(",");
|
|
|
+ string[] str = strings[i].Split(",");
|
|
|
string addressD = str[0].Replace("\"", "");
|
|
|
- address.AddressArray.Add(new AddressDetails()
|
|
|
+ if (i % 2 == 0)
|
|
|
{
|
|
|
- AddressName = $"ns=2;s=6022.6022.{addressD}",
|
|
|
- SN = Guid.NewGuid().ToString(),
|
|
|
+ address.AddressArray.Add(new AddressDetails()
|
|
|
+ {
|
|
|
+ AddressName = $"ns=2;s=6022.6022.{addressD}",
|
|
|
+ SN = Guid.NewGuid().ToString(),
|
|
|
|
|
|
- AddressRelayParam = new AddressRelay
|
|
|
+ AddressRelayParam = new AddressRelay
|
|
|
+ {
|
|
|
+ ISns = new List<string> { "YSAI.Mqtt.client.MqttClientOperate.mqtt1", "YSAI.Mqtt.client.MqttClientOperate.mqtt2" },
|
|
|
+ Topic = $"TEST/{addressD}"
|
|
|
+ },
|
|
|
+ AddressParseParam = new AddressParse
|
|
|
+ {
|
|
|
+ ParseType = ParseType.S,
|
|
|
+ ScriptBasics = new ScriptData.Basics()
|
|
|
+ {
|
|
|
+ ScriptCode = @"function Convert(addressname,value) { return '【这是调用脚本解析】传入的地址是:'+ addressname + '----传入的参数是:' + value; }",
|
|
|
+ ScriptFunction = "Convert",
|
|
|
+ ScriptType = ScriptData.ScriptType.JavaScript
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ address.AddressArray.Add(new AddressDetails()
|
|
|
{
|
|
|
- ISns = new List<string> { "YSAI.Mqtt.client.MqttClientOperate.mqtt1", "YSAI.Mqtt.client.MqttClientOperate.mqtt2" },
|
|
|
- Topic = $"TEST/{addressD}"
|
|
|
- }
|
|
|
- });
|
|
|
+ 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}"
|
|
|
+ },
|
|
|
+ AddressParseParam = new AddressParse
|
|
|
+ {
|
|
|
+ ParseType = ParseType.R,
|
|
|
+ ReflectionParseParam = new ReflectionParse()
|
|
|
+ {
|
|
|
+ ReflectionBasics = new ReflectionData.Basics
|
|
|
+ {
|
|
|
+ DllDatas = new List<ReflectionData.Basics.DllData>
|
|
|
+ {
|
|
|
+ new ReflectionData.Basics.DllData
|
|
|
+ {
|
|
|
+ DllPath="lib\\YSAI.Test.Dll.dll",
|
|
|
+ IsAbsolutePath=false,
|
|
|
+ NamespaceDatas=new List<ReflectionData.Basics.DllData.NamespaceData>
|
|
|
+ {
|
|
|
+ new ReflectionData.Basics.DllData.NamespaceData
|
|
|
+ {
|
|
|
+ Namespace="YSAI.Test.Dll",
|
|
|
+ ClassDatas=new List<ReflectionData.Basics.DllData.NamespaceData.ClassData>
|
|
|
+ {
|
|
|
+ new ReflectionData.Basics.DllData.NamespaceData.ClassData
|
|
|
+ {
|
|
|
+ ClassName="TestAll",
|
|
|
+ SN="YSAI.Test.Dll.TestAll[Instance]",
|
|
|
+ MethodDatas=new List<ReflectionData.Basics.DllData.NamespaceData.ClassData.MethodData>
|
|
|
+ {
|
|
|
+ new ReflectionData.Basics.DllData.NamespaceData.ClassData.MethodData
|
|
|
+ {
|
|
|
+ MethodName="R1",
|
|
|
+ SN="[R1]"
|
|
|
+ },
|
|
|
+ new ReflectionData.Basics.DllData.NamespaceData.ClassData.MethodData
|
|
|
+ {
|
|
|
+ MethodName="R2",
|
|
|
+ SN="[R2]"
|
|
|
+ },
|
|
|
+ new ReflectionData.Basics.DllData.NamespaceData.ClassData.MethodData
|
|
|
+ {
|
|
|
+ MethodName="R3",
|
|
|
+ SN="[R3]"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ RSn = "YSAI.Test.Dll.TestAll[Instance][R1]"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+File.WriteAllText("config\\config.json", address.ToJson().JsonFormatting());
|
|
|
+
|
|
|
OpcUaClientOperate opcUaClientOperate = OpcUaClientOperate.Instance(new OpcUaClientData.Basics
|
|
|
{
|
|
|
ServerUrl = "opc.tcp://192.168.2.220:49320",
|