From 050ed78c3b190bc1fc2dd514e64d83429ab9c6b7 Mon Sep 17 00:00:00 2001 From: luosheng Date: Mon, 29 May 2023 10:32:25 +0800 Subject: [PATCH] opc fix --- .../Modbus.Net.OPC/AddressFormaterOpc.cs | 2 +- .../Modbus.Net.OPC/AddressTranslatorOpc.cs | 2 +- Modbus.Net/Modbus.Net.OPC/ClientExtend.cs | 10 +++++----- .../Modbus.Net.OPC/Modbus.Net.OPC.csproj | 14 +++++++------- Modbus.Net/Modbus.Net.OPC/OpcConnector.cs | 18 +++++++++--------- Modbus.Net/Modbus.Net.OPC/OpcDaConnector.cs | 2 +- Modbus.Net/Modbus.Net.OPC/OpcDaProtocal.cs | 2 +- .../Modbus.Net.OPC/OpcDaProtocalLinker.cs | 4 +--- Modbus.Net/Modbus.Net.OPC/OpcMachine.cs | 4 ++-- Modbus.Net/Modbus.Net.OPC/OpcProtocol.cs | 2 +- Modbus.Net/Modbus.Net.OPC/OpcProtocolLinker.cs | 2 +- Modbus.Net/Modbus.Net.OPC/OpcUaConnector.cs | 4 ++-- Modbus.Net/Modbus.Net.OPC/OpcUaProtocol.cs | 2 +- .../Modbus.Net.OPC/OpcUaProtocolLinker.cs | 4 +--- Modbus.Net/Modbus.Net.OPC/OpcUtility.cs | 10 +++++----- Modbus.Net/Modbus.Net.sln | 2 +- 16 files changed, 40 insertions(+), 44 deletions(-) diff --git a/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs b/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs index 47d082a..045f999 100644 --- a/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs +++ b/Modbus.Net/Modbus.Net.OPC/AddressFormaterOpc.cs @@ -1,7 +1,7 @@ using System; using System.Linq; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc地址编码器 diff --git a/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs b/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs index 892b5c7..c9ef4a4 100644 --- a/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs +++ b/Modbus.Net/Modbus.Net.OPC/AddressTranslatorOpc.cs @@ -1,6 +1,6 @@ using System; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc地址解析器 diff --git a/Modbus.Net/Modbus.Net.OPC/ClientExtend.cs b/Modbus.Net/Modbus.Net.OPC/ClientExtend.cs index fa3e3e9..d68c1c2 100644 --- a/Modbus.Net/Modbus.Net.OPC/ClientExtend.cs +++ b/Modbus.Net/Modbus.Net.OPC/ClientExtend.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc Client Extend interface, Unified for DA and UA @@ -18,7 +18,7 @@ namespace Modbus.Net.OPC Node RootNodeBase { get; } /// - /// Connect the client to the OPC Server + /// Connect the client to the Opc Server /// void Connect(); @@ -30,11 +30,11 @@ namespace Modbus.Net.OPC /// The fully-qualified identifier of the tag. You can specify a subfolder by using a comma delimited name. /// E.g: the tag `foo.bar` reads the tag `bar` on the folder `foo` /// - /// The value retrieved from the OPC + /// The value retrieved from the Opc ReadEvent Read(string tag); /// - /// Write a value on the specified opc tag + /// Write a value on the specified Opc tag /// /// The type of tag to write on /// @@ -50,7 +50,7 @@ namespace Modbus.Net.OPC Task> ReadAsync(string tag); /// - /// Write a value on the specified opc tag asynchronously + /// Write a value on the specified Opc tag asynchronously /// Task WriteAsync(string tag, T item); diff --git a/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj b/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj index 6fc109c..93aefd7 100644 --- a/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj +++ b/Modbus.Net/Modbus.Net.OPC/Modbus.Net.OPC.csproj @@ -3,16 +3,16 @@ net462 10.0 - Modbus.Net.OPC - Modbus.Net.OPC - Modbus.Net.OPC + Modbus.Net.Opc + Modbus.Net.Opc + Modbus.Net.Opc 1.4.1 Chris L.(Luo Sheng) Hangzhou Delian Science Technology Co.,Ltd. - Modbus.Net.OPC - Modbus.Net OPC Implementation + Modbus.Net.Opc + Modbus.Net Opc Implementation Copyright 2023 Hangzhou Delian Science Technology Co.,Ltd. - https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.OPC + https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Opc https://github.com/parallelbgls/Modbus.Net git hardware communicate protocol modbus Delian @@ -26,7 +26,7 @@ - bin\Debug\Modbus.Net.OPC.xml + bin\Debug\Modbus.Net.Opc.xml diff --git a/Modbus.Net/Modbus.Net.OPC/OpcConnector.cs b/Modbus.Net/Modbus.Net.OPC/OpcConnector.cs index d762eb6..ac35e32 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcConnector.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcConnector.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc连接器 @@ -62,12 +62,12 @@ namespace Modbus.Net.OPC Client?.Dispose(); Client = null; _connect = false; - logger.LogInformation("opc client {ConnectionToken} disconnected success", ConnectionToken); + logger.LogInformation("Opc client {ConnectionToken} disconnected success", ConnectionToken); return true; } catch (Exception ex) { - logger.LogError(ex, "opc client {ConnectionToken} disconnected error", ConnectionToken); + logger.LogError(ex, "Opc client {ConnectionToken} disconnected error", ConnectionToken); _connect = false; return false; } @@ -109,7 +109,7 @@ namespace Modbus.Net.OPC if (answerTag != null) { var result = await Client.ReadAsync(answerTag); - logger.LogDebug($"Opc Machine {ConnectionToken} Read opc tag {answerTag} for value {result.Value}"); + logger.LogDebug($"Opc Machine {ConnectionToken} Read Opc tag {answerTag} for value {result.Value}"); return new OpcParamOut { Success = true, @@ -135,11 +135,11 @@ namespace Modbus.Net.OPC try { await Client.WriteAsync(answerTag, value); - logger.LogDebug($"Opc Machine {ConnectionToken} Write opc tag {answerTag} for value {value}"); + logger.LogDebug($"Opc Machine {ConnectionToken} Write Opc tag {answerTag} for value {value}"); } catch (Exception e) { - logger.LogError(e, "opc client {ConnectionToken} write exception", ConnectionToken); + logger.LogError(e, "Opc client {ConnectionToken} write exception", ConnectionToken); return new OpcParamOut { Success = false @@ -158,7 +158,7 @@ namespace Modbus.Net.OPC } catch (Exception e) { - logger.LogError(e, "opc client {ConnectionToken} read exception", ConnectionToken); + logger.LogError(e, "Opc client {ConnectionToken} read exception", ConnectionToken); return new OpcParamOut { Success = false, @@ -197,12 +197,12 @@ namespace Modbus.Net.OPC { Client.Connect(); _connect = true; - logger.LogInformation("opc client {ConnectionToken} connect success", ConnectionToken); + logger.LogInformation("Opc client {ConnectionToken} connect success", ConnectionToken); return true; } catch (Exception ex) { - logger.LogError(ex, "opc client {ConnectionToken} connected failed", ConnectionToken); + logger.LogError(ex, "Opc client {ConnectionToken} connected failed", ConnectionToken); _connect = false; return false; } diff --git a/Modbus.Net/Modbus.Net.OPC/OpcDaConnector.cs b/Modbus.Net/Modbus.Net.OPC/OpcDaConnector.cs index 4b30e81..12fa468 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcDaConnector.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcDaConnector.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc DA连接实现 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcDaProtocal.cs b/Modbus.Net/Modbus.Net.OPC/OpcDaProtocal.cs index f8bac5f..330b54f 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcDaProtocal.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcDaProtocal.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc Da协议 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcDaProtocalLinker.cs b/Modbus.Net/Modbus.Net.OPC/OpcDaProtocalLinker.cs index 9189a2e..caec5d4 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcDaProtocalLinker.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcDaProtocalLinker.cs @@ -1,6 +1,4 @@ - - -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc Da协议连接器 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcMachine.cs b/Modbus.Net/Modbus.Net.OPC/OpcMachine.cs index d83a929..3769471 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcMachine.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcMachine.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc设备 @@ -17,7 +17,7 @@ namespace Modbus.Net.OPC /// 连接地址 /// 需要读写的地址 /// 开启正则匹配 - protected OpcMachine(TKey id, OpcType connectionType, string connectionString, IEnumerable> getAddresses, bool isRegexOn = false) + public OpcMachine(TKey id, OpcType connectionType, string connectionString, IEnumerable> getAddresses, bool isRegexOn = false) : base(id, getAddresses, true) { BaseUtility = new OpcUtility(connectionType, connectionString, isRegexOn); diff --git a/Modbus.Net/Modbus.Net.OPC/OpcProtocol.cs b/Modbus.Net/Modbus.Net.OPC/OpcProtocol.cs index fdec28f..cea9f7b 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcProtocol.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcProtocol.cs @@ -1,4 +1,4 @@ -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc协议 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcProtocolLinker.cs b/Modbus.Net/Modbus.Net.OPC/OpcProtocolLinker.cs index 67abf73..dd1c778 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcProtocolLinker.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcProtocolLinker.cs @@ -1,7 +1,7 @@ using System.Text; using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc协议连接器 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcUaConnector.cs b/Modbus.Net/Modbus.Net.OPC/OpcUaConnector.cs index acae757..75ad592 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcUaConnector.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcUaConnector.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc UA连接实现 @@ -28,7 +28,7 @@ namespace Modbus.Net.OPC /// /// Opc UA服务地址 /// 是否开启正则匹配 - /// OPC UA实例 + /// Opc UA实例 public static OpcUaConnector Instance(string host, bool isRegexOn) { if (!_instances.ContainsKey(host)) diff --git a/Modbus.Net/Modbus.Net.OPC/OpcUaProtocol.cs b/Modbus.Net/Modbus.Net.OPC/OpcUaProtocol.cs index b18faca..3e9dbac 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcUaProtocol.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcUaProtocol.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc UA协议 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcUaProtocolLinker.cs b/Modbus.Net/Modbus.Net.OPC/OpcUaProtocolLinker.cs index 38ceef4..acb1632 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcUaProtocolLinker.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcUaProtocolLinker.cs @@ -1,6 +1,4 @@ -using System.Configuration; - -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc UA协议连接器 diff --git a/Modbus.Net/Modbus.Net.OPC/OpcUtility.cs b/Modbus.Net/Modbus.Net.OPC/OpcUtility.cs index 257f4f0..8712cef 100644 --- a/Modbus.Net/Modbus.Net.OPC/OpcUtility.cs +++ b/Modbus.Net/Modbus.Net.OPC/OpcUtility.cs @@ -2,7 +2,7 @@ using System; using System.Threading.Tasks; -namespace Modbus.Net.OPC +namespace Modbus.Net.Opc { /// /// Opc类型 @@ -12,11 +12,11 @@ namespace Modbus.Net.OPC /// /// DA连接 /// - Da=0, + Da = 0, /// /// UA连接 /// - Ua=1 + Ua = 1 } /// @@ -73,9 +73,9 @@ namespace Modbus.Net.OPC /// 是否开启正则匹配 public OpcUtility(int connectionType, string connectionString, bool isRegexOn = false) : base(0, 0) { - OpcType = (OpcType)connectionType; ConnectionString = connectionString; IsRegexOn = isRegexOn; + OpcType = (OpcType)connectionType; AddressTranslator = new AddressTranslatorOpc(); } @@ -87,9 +87,9 @@ namespace Modbus.Net.OPC /// 是否开启正则匹配 public OpcUtility(OpcType connectionType, string connectionString, bool isRegexOn = false) : base(0, 0) { - OpcType = connectionType; ConnectionString = connectionString; IsRegexOn = isRegexOn; + OpcType = connectionType; AddressTranslator = new AddressTranslatorOpc(); } diff --git a/Modbus.Net/Modbus.Net.sln b/Modbus.Net/Modbus.Net.sln index d15b9c9..dad642e 100644 --- a/Modbus.Net/Modbus.Net.sln +++ b/Modbus.Net/Modbus.Net.sln @@ -26,7 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modbus.Net.Modbus.NA200H", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnyType", "..\Samples\AnyType\AnyType.csproj", "{1857DA63-3335-428F-84D8-1FA4F8178643}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modbus.Net.OPC", "Modbus.Net.OPC\Modbus.Net.OPC.csproj", "{C854A379-C5EA-4CAC-9C5F-7291372D1D3F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modbus.Net.Opc", "Modbus.Net.OPC\Modbus.Net.Opc.csproj", "{C854A379-C5EA-4CAC-9C5F-7291372D1D3F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CrossLamp", "..\Samples\CrossLamp\CrossLamp.csproj", "{AA3A42D2-0502-41D3-929A-BAB729DF07D6}" EndProject