Change log system

This commit is contained in:
luosheng
2023-03-01 09:36:07 +08:00
parent 46222348be
commit a8c9fefbce
80 changed files with 2227 additions and 1921 deletions

View File

@@ -1,7 +1,7 @@
using System.Linq; using Opc.Ua;
using Opc.Ua;
using System;
using Opc.Ua.Client; using Opc.Ua.Client;
using System;
using System.Linq;
namespace Hylasoft.Opc.Ua namespace Hylasoft.Opc.Ua
{ {

View File

@@ -1,6 +1,4 @@
using System.Collections.Generic; namespace Hylasoft.Opc.Common
namespace Hylasoft.Opc.Common
{ {
/// <summary> /// <summary>
/// Base class representing a node on the OPC server /// Base class representing a node on the OPC server

View File

@@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hylasoft.Opc.Common namespace Hylasoft.Opc.Common
{ {

View File

@@ -1,5 +1,4 @@
using System; using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates;
using OpcUa = Opc.Ua; using OpcUa = Opc.Ua;
namespace Hylasoft.Opc.Ua namespace Hylasoft.Opc.Ua

226
Modbus.Net/.editorconfig Normal file
View File

@@ -0,0 +1,226 @@
# 如果要从更高级别的目录继承 .editorconfig 设置,请删除以下行
root = true
# c# 文件
[*.cs]
#### Core EditorConfig 选项 ####
# 缩进和间距
indent_size = 4
indent_style = space
tab_width = 4
# 新行首选项
end_of_line = crlf
insert_final_newline = false
#### .NET 编码约定 ####
# 组织 Using
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = false
file_header_template = unset
# this. 和 Me. 首选项
dotnet_style_qualification_for_event = false
dotnet_style_qualification_for_field = false
dotnet_style_qualification_for_method = false
dotnet_style_qualification_for_property = false
# 语言关键字与 bcl 类型首选项
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# 括号首选项
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
# 修饰符首选项
dotnet_style_require_accessibility_modifiers = for_non_interface_members
# 表达式级首选项
dotnet_style_coalesce_expression = true
dotnet_style_collection_initializer = true
dotnet_style_explicit_tuple_names = true
dotnet_style_namespace_match_folder = true
dotnet_style_null_propagation = true
dotnet_style_object_initializer = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_style_prefer_simplified_boolean_expressions = true
dotnet_style_prefer_simplified_interpolation = true
# 字段首选项
dotnet_style_readonly_field = true
# 参数首选项
dotnet_code_quality_unused_parameters = all
# 禁止显示首选项
dotnet_remove_unnecessary_suppression_exclusions = none
# 新行首选项
dotnet_style_allow_multiple_blank_lines_experimental = true
dotnet_style_allow_statement_immediately_after_block_experimental = true
#### c# 编码约定 ####
# var 首选项
csharp_style_var_elsewhere = false
csharp_style_var_for_built_in_types = false
csharp_style_var_when_type_is_apparent = false
# Expression-bodied 成员
csharp_style_expression_bodied_accessors = true
csharp_style_expression_bodied_constructors = false
csharp_style_expression_bodied_indexers = true
csharp_style_expression_bodied_lambdas = true
csharp_style_expression_bodied_local_functions = false
csharp_style_expression_bodied_methods = false
csharp_style_expression_bodied_operators = false
csharp_style_expression_bodied_properties = true
# 模式匹配首选项
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_extended_property_pattern = true
csharp_style_prefer_not_pattern = true
csharp_style_prefer_pattern_matching = true
csharp_style_prefer_switch_expression = true
# Null 检查首选项
csharp_style_conditional_delegate_call = true
# 修饰符首选项
csharp_prefer_static_local_function = true
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
csharp_style_prefer_readonly_struct = true
# 代码块首选项
csharp_prefer_braces = true
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = block_scoped
csharp_style_prefer_method_group_conversion = true
csharp_style_prefer_top_level_statements = true
# 表达式级首选项
csharp_prefer_simple_default_expression = true
csharp_style_deconstructed_variable_declaration = true
csharp_style_implicit_object_creation_when_type_is_apparent = true
csharp_style_inlined_variable_declaration = true
csharp_style_prefer_index_operator = true
csharp_style_prefer_local_over_anonymous_function = true
csharp_style_prefer_null_check_over_type_check = true
csharp_style_prefer_range_operator = true
csharp_style_prefer_tuple_swap = true
csharp_style_prefer_utf8_string_literals = true
csharp_style_throw_expression = true
csharp_style_unused_value_assignment_preference = discard_variable
csharp_style_unused_value_expression_statement_preference = discard_variable
# "using" 指令首选项
csharp_using_directive_placement = outside_namespace
# 新行首选项
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
csharp_style_allow_embedded_statements_on_same_line_experimental = true
#### C# 格式规则 ####
# 新行首选项
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
# 缩进首选项
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
# 空格键首选项
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# 包装首选项
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
#### 命名样式 ####
# 命名规则
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# 符号规范
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# 命名样式
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

View File

@@ -1,8 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Modbus.Net.Modbus.NA200H namespace Modbus.Net.Modbus.NA200H
{ {

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.Modbus.NA200H</AssemblyName> <AssemblyName>Modbus.Net.Modbus.NA200H</AssemblyName>
<RootNamespace>Modbus.Net.Modbus.NA200H</RootNamespace> <RootNamespace>Modbus.Net.Modbus.NA200H</RootNamespace>
<PackageId>Modbus.Net.Modbus.NA200H</PackageId> <PackageId>Modbus.Net.Modbus.NA200H</PackageId>
<Version>1.4.0</Version> <Version>1.4.0-beta03</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian Science Technology Co.,Ltd.</Company>
<Product>Modbus.Net.Modbus</Product> <Product>Modbus.Net.Modbus</Product>

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.Modbus</AssemblyName> <AssemblyName>Modbus.Net.Modbus</AssemblyName>
<RootNamespace>Modbus.Net.Modbus</RootNamespace> <RootNamespace>Modbus.Net.Modbus</RootNamespace>
<PackageId>Modbus.Net.Modbus</PackageId> <PackageId>Modbus.Net.Modbus</PackageId>
<Version>1.4.0</Version> <Version>1.4.0-beta03</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian Science Technology Co.,Ltd.</Company>
<Product>Modbus.Net.Modbus</Product> <Product>Modbus.Net.Modbus</Product>

View File

@@ -1,6 +1,6 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
namespace Modbus.Net.Modbus namespace Modbus.Net.Modbus
{ {
@@ -69,6 +69,8 @@ namespace Modbus.Net.Modbus
/// </summary> /// </summary>
public class ModbusUtility : BaseUtility, IUtilityMethodTime, IUtilityMethodWriteSingle public class ModbusUtility : BaseUtility, IUtilityMethodTime, IUtilityMethodWriteSingle
{ {
private static readonly ILogger<ModbusUtility> logger = LogProvider.CreateLogger<ModbusUtility>();
/// <summary> /// <summary>
/// Modbus协议类型 /// Modbus协议类型
/// </summary> /// </summary>
@@ -142,7 +144,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility: {ConnectionString} format error"); logger.LogError(e, $"ModbusUtility: {ConnectionString} format error");
return null; return null;
} }
} }
@@ -261,7 +263,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> GetTime: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> GetTime: {ConnectionString} error");
return DateTime.MinValue; return DateTime.MinValue;
} }
} }
@@ -283,7 +285,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> SetTime: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> SetTime: {ConnectionString} error");
return false; return false;
} }
} }
@@ -316,7 +318,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> GetDatas: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> GetDatas: {ConnectionString} error");
return null; return null;
} }
} }
@@ -340,7 +342,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> SetDatas: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> SetDatas: {ConnectionString} error");
return false; return false;
} }
} }
@@ -364,7 +366,7 @@ namespace Modbus.Net.Modbus
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> SetSingleDatas: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> SetSingleDatas: {ConnectionString} error");
return false; return false;
} }
} }

View File

@@ -1,8 +1,8 @@
using System; using Hylasoft.Opc.Common;
using Hylasoft.Opc.Ua;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hylasoft.Opc.Common;
using Hylasoft.Opc.Ua;
namespace Modbus.Net.OPC namespace Modbus.Net.OPC
{ {

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.OPC</AssemblyName> <AssemblyName>Modbus.Net.OPC</AssemblyName>
<RootNamespace>Modbus.Net.OPC</RootNamespace> <RootNamespace>Modbus.Net.OPC</RootNamespace>
<PackageId>Modbus.Net.OPC</PackageId> <PackageId>Modbus.Net.OPC</PackageId>
<Version>1.4.0</Version> <Version>1.4.0-beta03</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian Science Technology Co.,Ltd.</Company>
<Product>Modbus.Net.OPC</Product> <Product>Modbus.Net.OPC</Product>

View File

@@ -1,11 +1,10 @@
using System; using Hylasoft.Opc.Common;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hylasoft.Opc.Common;
using Serilog;
namespace Modbus.Net.OPC namespace Modbus.Net.OPC
{ {
@@ -14,6 +13,8 @@ namespace Modbus.Net.OPC
/// </summary> /// </summary>
public abstract class OpcConnector : BaseConnector<OpcParamIn, OpcParamOut> public abstract class OpcConnector : BaseConnector<OpcParamIn, OpcParamOut>
{ {
private static readonly ILogger<OpcConnector> logger = LogProvider.CreateLogger<OpcConnector>();
/// <summary> /// <summary>
/// 是否正在连接 /// 是否正在连接
/// </summary> /// </summary>
@@ -61,12 +62,12 @@ namespace Modbus.Net.OPC
Client?.Dispose(); Client?.Dispose();
Client = null; Client = null;
_connect = false; _connect = false;
Log.Information("opc client {ConnectionToken} disconnected success", ConnectionToken); logger.LogInformation("opc client {ConnectionToken} disconnected success", ConnectionToken);
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "opc client {ConnectionToken} disconnected error", ConnectionToken); logger.LogError(ex, "opc client {ConnectionToken} disconnected error", ConnectionToken);
_connect = false; _connect = false;
return false; return false;
} }
@@ -108,7 +109,7 @@ namespace Modbus.Net.OPC
if (answerTag != null) if (answerTag != null)
{ {
var result = await Client.ReadAsync<object>(answerTag); var result = await Client.ReadAsync<object>(answerTag);
Log.Verbose($"Opc Machine {ConnectionToken} Read opc tag {answerTag} for value {result}"); logger.LogDebug($"Opc Machine {ConnectionToken} Read opc tag {answerTag} for value {result}");
return new OpcParamOut return new OpcParamOut
{ {
Success = true, Success = true,
@@ -134,11 +135,11 @@ namespace Modbus.Net.OPC
try try
{ {
await Client.WriteAsync(answerTag, value); await Client.WriteAsync(answerTag, value);
Log.Verbose($"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) catch (Exception e)
{ {
Log.Error(e, "opc client {ConnectionToken} write exception", ConnectionToken); logger.LogError(e, "opc client {ConnectionToken} write exception", ConnectionToken);
return new OpcParamOut return new OpcParamOut
{ {
Success = false Success = false
@@ -157,7 +158,7 @@ namespace Modbus.Net.OPC
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "opc client {ConnectionToken} read exception", ConnectionToken); logger.LogError(e, "opc client {ConnectionToken} read exception", ConnectionToken);
return new OpcParamOut return new OpcParamOut
{ {
Success = false, Success = false,
@@ -200,12 +201,12 @@ namespace Modbus.Net.OPC
{ {
await Client.Connect(); await Client.Connect();
_connect = true; _connect = true;
Log.Information("opc client {ConnectionToken} connect success", ConnectionToken); logger.LogInformation("opc client {ConnectionToken} connect success", ConnectionToken);
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "opc client {ConnectionToken} connected failed", ConnectionToken); logger.LogError(ex, "opc client {ConnectionToken} connected failed", ConnectionToken);
_connect = false; _connect = false;
return false; return false;
} }

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
namespace Modbus.Net.OPC namespace Modbus.Net.OPC
{ {

View File

@@ -1,6 +1,6 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
namespace Modbus.Net.OPC namespace Modbus.Net.OPC
{ {
@@ -11,6 +11,8 @@ namespace Modbus.Net.OPC
PipeUnit<OpcParamIn, OpcParamOut, IProtocolLinker<OpcParamIn, OpcParamOut>, PipeUnit<OpcParamIn, OpcParamOut, IProtocolLinker<OpcParamIn, OpcParamOut>,
ProtocolUnit<OpcParamIn, OpcParamOut>>> ProtocolUnit<OpcParamIn, OpcParamOut>>>
{ {
private static readonly ILogger<OpcUtility> logger = LogProvider.CreateLogger<OpcUtility>();
/// <summary> /// <summary>
/// 获取分隔符 /// 获取分隔符
/// </summary> /// </summary>
@@ -66,7 +68,7 @@ namespace Modbus.Net.OPC
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"OpcUtility -> GetDatas: {ConnectionString} error"); logger.LogError(e, $"OpcUtility -> GetDatas: {ConnectionString} error");
return null; return null;
} }
} }
@@ -92,7 +94,7 @@ namespace Modbus.Net.OPC
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"OpcUtility -> SetDatas: {ConnectionString} error"); logger.LogError(e, $"OpcUtility -> SetDatas: {ConnectionString} error");
return false; return false;
} }
} }

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Modbus.Net.Siemens namespace Modbus.Net.Siemens
{ {

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.Siemens</AssemblyName> <AssemblyName>Modbus.Net.Siemens</AssemblyName>
<RootNamespace>Modbus.Net.Siemens</RootNamespace> <RootNamespace>Modbus.Net.Siemens</RootNamespace>
<PackageId>Modbus.Net.Siemens</PackageId> <PackageId>Modbus.Net.Siemens</PackageId>
<Version>1.4.0</Version> <Version>1.4.0-beta03</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian Science Technology Co.,Ltd.</Company>
<Description>Modbus.Net Siemens Profinet Implementation</Description> <Description>Modbus.Net Siemens Profinet Implementation</Description>

View File

@@ -1,6 +1,6 @@
using System.Threading.Tasks; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Nito.AsyncEx; using Nito.AsyncEx;
using System.Threading.Tasks;
namespace Modbus.Net.Siemens namespace Modbus.Net.Siemens
{ {

View File

@@ -1,6 +1,6 @@
using System.Threading.Tasks; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Nito.AsyncEx; using Nito.AsyncEx;
using System.Threading.Tasks;
namespace Modbus.Net.Siemens namespace Modbus.Net.Siemens
{ {

View File

@@ -1,6 +1,6 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
namespace Modbus.Net.Siemens namespace Modbus.Net.Siemens
{ {
@@ -59,6 +59,8 @@ namespace Modbus.Net.Siemens
/// </summary> /// </summary>
public class SiemensUtility : BaseUtility public class SiemensUtility : BaseUtility
{ {
private static readonly ILogger<SiemensUtility> logger = LogProvider.CreateLogger<SiemensUtility>();
private readonly ushort _maxCalled; private readonly ushort _maxCalled;
private readonly ushort _maxCalling; private readonly ushort _maxCalling;
private readonly ushort _maxPdu; private readonly ushort _maxPdu;
@@ -173,7 +175,7 @@ namespace Modbus.Net.Siemens
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"SiemensUtility: {ConnectionString} format error"); logger.LogError(e, $"SiemensUtility: {ConnectionString} format error");
return null; return null;
} }
} }
@@ -254,7 +256,7 @@ namespace Modbus.Net.Siemens
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"SiemensUtility -> GetDatas: {ConnectionString} error"); logger.LogError(e, $"SiemensUtility -> GetDatas: {ConnectionString} error");
return null; return null;
} }
} }
@@ -285,7 +287,7 @@ namespace Modbus.Net.Siemens
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> SetDatas: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> SetDatas: {ConnectionString} error");
return false; return false;
} }
} }

View File

@@ -1,13 +1,15 @@
using System; using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using Nito.AsyncEx; using Nito.AsyncEx;
using Serilog; using System;
using System.Threading.Tasks;
namespace Modbus.Net namespace Modbus.Net
{ {
/// <inheritdoc /> /// <inheritdoc />
public abstract class BaseConnector : BaseConnector<byte[], byte[]> public abstract class BaseConnector : BaseConnector<byte[], byte[]>
{ {
private static readonly ILogger<BaseConnector> logger = LogProvider.CreateLogger<BaseConnector>();
/// <summary> /// <summary>
/// 发送锁 /// 发送锁
/// </summary> /// </summary>
@@ -71,12 +73,12 @@ namespace Modbus.Net
} }
Controller.ForceRemoveWaitingMessage(messageSendingdef); Controller.ForceRemoveWaitingMessage(messageSendingdef);
} }
Log.Information("Message is waiting in {0}. Cancel!", ConnectionToken); logger.LogInformation("Message is waiting in {0}. Cancel!", ConnectionToken);
return null; return null;
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Connector {0} Send Error.", ConnectionToken); logger.LogError(e, "Connector {0} Send Error.", ConnectionToken);
return null; return null;
} }
finally finally

View File

@@ -1,11 +1,11 @@
using System; using Microsoft.Extensions.Logging;
using Nito.AsyncEx;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO.Ports; using System.IO.Ports;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Nito.AsyncEx;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -25,6 +25,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class ComConnector : BaseConnector, IDisposable public class ComConnector : BaseConnector, IDisposable
{ {
private static readonly ILogger<ComConnector> logger = LogProvider.CreateLogger<ComConnector>();
/// <summary> /// <summary>
/// 波特率 /// 波特率
/// </summary> /// </summary>
@@ -124,7 +126,8 @@ namespace Modbus.Net
; ;
/// <inheritdoc /> /// <inheritdoc />
protected override IController Controller { protected override IController Controller
{
get get
{ {
if (Controllers.ContainsKey(_com)) if (Controllers.ContainsKey(_com))
@@ -265,13 +268,13 @@ namespace Modbus.Net
SerialPort.Close(); SerialPort.Close();
} }
SerialPort.Dispose(); SerialPort.Dispose();
Log.Information("Com interface {Com} Disposed", _com); logger.LogInformation("Com interface {Com} Disposed", _com);
Connectors[_com] = null; Connectors[_com] = null;
Connectors.Remove(_com); Connectors.Remove(_com);
ReceiveMsgThreadStop(); ReceiveMsgThreadStop();
} }
Linkers.Remove(_slave); Linkers.Remove(_slave);
Log.Information("Com connector {ConnectionToken} Removed", ConnectionToken); logger.LogInformation("Com connector {ConnectionToken} Removed", ConnectionToken);
} }
m_disposed = true; m_disposed = true;
} }
@@ -289,19 +292,19 @@ namespace Modbus.Net
private void RefreshSendCount() private void RefreshSendCount()
{ {
_sendCount++; _sendCount++;
Log.Verbose("Com client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount); logger.LogDebug("Com client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount);
} }
private void RefreshReceiveCount() private void RefreshReceiveCount()
{ {
_receiveCount++; _receiveCount++;
Log.Verbose("Com client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount); logger.LogDebug("Com client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount);
} }
private void RefreshErrorCount() private void RefreshErrorCount()
{ {
_errorCount++; _errorCount++;
Log.Verbose("Com client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount); logger.LogDebug("Com client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount);
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -353,13 +356,13 @@ namespace Modbus.Net
} }
} }
Log.Information("Com client {ConnectionToken} connect success", ConnectionToken); logger.LogInformation("Com client {ConnectionToken} connect success", ConnectionToken);
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Com client {ConnectionToken} connect error", ConnectionToken); logger.LogError(e, "Com client {ConnectionToken} connect error", ConnectionToken);
Dispose(); Dispose();
return false; return false;
} }
@@ -378,15 +381,15 @@ namespace Modbus.Net
try try
{ {
Dispose(); Dispose();
Log.Information("Com client {ConnectionToken} disconnect success", ConnectionToken); logger.LogInformation("Com client {ConnectionToken} disconnect success", ConnectionToken);
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Com client {ConnectionToken} disconnect error", ConnectionToken); logger.LogError(e, "Com client {ConnectionToken} disconnect error", ConnectionToken);
return false; return false;
} }
Log.Error(new Exception("Linkers or Connectors Dictionary not found"), logger.LogError(new Exception("Linkers or Connectors Dictionary not found"),
"Com client {ConnectionToken} disconnect error", ConnectionToken); "Com client {ConnectionToken} disconnect error", ConnectionToken);
return false; return false;
} }
@@ -420,7 +423,7 @@ namespace Modbus.Net
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Com client {ConnectionToken} open error", ConnectionToken); logger.LogError(err, "Com client {ConnectionToken} open error", ConnectionToken);
Dispose(); Dispose();
try try
{ {
@@ -428,7 +431,7 @@ namespace Modbus.Net
} }
catch (Exception err2) catch (Exception err2)
{ {
Log.Error(err2, "Com client {ConnectionToken} open error", ConnectionToken); logger.LogError(err2, "Com client {ConnectionToken} open error", ConnectionToken);
Dispose(); Dispose();
} }
} }
@@ -447,15 +450,15 @@ namespace Modbus.Net
{ {
try try
{ {
Log.Verbose("Com client {ConnectionToken} send msg length: {Length}", ConnectionToken, logger.LogDebug("Com client {ConnectionToken} send msg length: {Length}", ConnectionToken,
message.Length); message.Length);
Log.Verbose( logger.LogDebug(
$"Com client {ConnectionToken} send msg: {String.Concat(message.Select(p => " " + p.ToString("X2")))}"); $"Com client {ConnectionToken} send msg: {String.Concat(message.Select(p => " " + p.ToString("X2")))}");
await Task.Run(() => SerialPort.Write(message, 0, message.Length)); await Task.Run(() => SerialPort.Write(message, 0, message.Length));
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Com client {ConnectionToken} send msg error", ConnectionToken); logger.LogError(err, "Com client {ConnectionToken} send msg error", ConnectionToken);
Dispose(); Dispose();
} }
RefreshSendCount(); RefreshSendCount();
@@ -483,9 +486,9 @@ namespace Modbus.Net
var returnBytes = ReadMsg(); var returnBytes = ReadMsg();
if (returnBytes != null) if (returnBytes != null)
{ {
Log.Verbose("Com client {ConnectionToken} receive msg length: {Length}", ConnectionToken, logger.LogDebug("Com client {ConnectionToken} receive msg length: {Length}", ConnectionToken,
returnBytes.Length); returnBytes.Length);
Log.Verbose( logger.LogDebug(
$"Com client {ConnectionToken} receive msg: {String.Concat(returnBytes.Select(p => " " + p.ToString("X2")))}"); $"Com client {ConnectionToken} receive msg: {String.Concat(returnBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(returnBytes); var isMessageConfirmed = Controller.ConfirmMessage(returnBytes);
@@ -502,7 +505,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Com client {ConnectionToken} read msg error", ConnectionToken); logger.LogError(e, "Com client {ConnectionToken} read msg error", ConnectionToken);
} }
} }
} }
@@ -524,7 +527,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Com client {ConnectionToken} read error", ConnectionToken); logger.LogError(e, "Com client {ConnectionToken} read error", ConnectionToken);
RefreshErrorCount(); RefreshErrorCount();
Dispose(); Dispose();
return null; return null;

View File

@@ -1,10 +1,10 @@
using System; using Microsoft.Extensions.Logging;
using Nito.AsyncEx;
using System;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Nito.AsyncEx;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -14,6 +14,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class TcpConnector : BaseConnector, IDisposable public class TcpConnector : BaseConnector, IDisposable
{ {
private static readonly ILogger<TcpConnector> logger = LogProvider.CreateLogger<TcpConnector>();
private readonly string _host; private readonly string _host;
private readonly int _port; private readonly int _port;
@@ -94,7 +96,7 @@ namespace Modbus.Net
{ {
CloseClientSocket(); CloseClientSocket();
_socketClient = null; _socketClient = null;
Log.Debug("Tcp client {ConnectionToken} Disposed", ConnectionToken); logger.LogDebug("Tcp client {ConnectionToken} Disposed", ConnectionToken);
} }
} }
@@ -134,16 +136,16 @@ namespace Modbus.Net
_taskCancel = false; _taskCancel = false;
Controller.SendStart(); Controller.SendStart();
ReceiveMsgThreadStart(); ReceiveMsgThreadStart();
Log.Information("Tcp client {ConnectionToken} connected", ConnectionToken); logger.LogInformation("Tcp client {ConnectionToken} connected", ConnectionToken);
return true; return true;
} }
Log.Error("Tcp client {ConnectionToken} connect failed.", ConnectionToken); logger.LogError("Tcp client {ConnectionToken} connect failed.", ConnectionToken);
Dispose(); Dispose();
return false; return false;
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Tcp client {ConnectionToken} connect exception", ConnectionToken); logger.LogError(err, "Tcp client {ConnectionToken} connect exception", ConnectionToken);
Dispose(); Dispose();
return false; return false;
} }
@@ -159,12 +161,12 @@ namespace Modbus.Net
try try
{ {
Dispose(); Dispose();
Log.Information("Tcp client {ConnectionToken} disconnected successfully", ConnectionToken); logger.LogInformation("Tcp client {ConnectionToken} disconnected successfully", ConnectionToken);
return true; return true;
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Tcp client {ConnectionToken} disconnected exception", ConnectionToken); logger.LogError(err, "Tcp client {ConnectionToken} disconnected exception", ConnectionToken);
return false; return false;
} }
finally finally
@@ -187,13 +189,13 @@ namespace Modbus.Net
RefreshSendCount(); RefreshSendCount();
Log.Verbose("Tcp client {ConnectionToken} send text len = {Length}", ConnectionToken, datagram.Length); logger.LogDebug("Tcp client {ConnectionToken} send text len = {Length}", ConnectionToken, datagram.Length);
Log.Verbose($"Tcp client {ConnectionToken} send: {String.Concat(datagram.Select(p => " " + p.ToString("X2")))}"); logger.LogDebug($"Tcp client {ConnectionToken} send: {String.Concat(datagram.Select(p => " " + p.ToString("X2")))}");
await stream.WriteAsync(datagram, 0, datagram.Length); await stream.WriteAsync(datagram, 0, datagram.Length);
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Tcp client {ConnectionToken} send exception", ConnectionToken); logger.LogError(err, "Tcp client {ConnectionToken} send exception", ConnectionToken);
Dispose(); Dispose();
} }
} }
@@ -229,9 +231,9 @@ namespace Modbus.Net
if (len > 0) if (len > 0)
{ {
byte[] receiveBytes = CheckReplyDatagram(len); byte[] receiveBytes = CheckReplyDatagram(len);
Log.Verbose("Tcp client {ConnectionToken} receive text len = {Length}", ConnectionToken, logger.LogDebug("Tcp client {ConnectionToken} receive text len = {Length}", ConnectionToken,
receiveBytes.Length); receiveBytes.Length);
Log.Verbose( logger.LogDebug(
$"Tcp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}"); $"Tcp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes); var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes);
foreach (var confirmed in isMessageConfirmed) foreach (var confirmed in isMessageConfirmed)
@@ -257,7 +259,7 @@ namespace Modbus.Net
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Tcp client {ConnectionToken} receive exception", ConnectionToken); logger.LogError(err, "Tcp client {ConnectionToken} receive exception", ConnectionToken);
//CloseClientSocket(); //CloseClientSocket();
} }
} }
@@ -280,19 +282,19 @@ namespace Modbus.Net
private void RefreshSendCount() private void RefreshSendCount()
{ {
_sendCount++; _sendCount++;
Log.Verbose("Tcp client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount); logger.LogDebug("Tcp client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount);
} }
private void RefreshReceiveCount() private void RefreshReceiveCount()
{ {
_receiveCount++; _receiveCount++;
Log.Verbose("Tcp client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount); logger.LogDebug("Tcp client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount);
} }
private void RefreshErrorCount() private void RefreshErrorCount()
{ {
_errorCount++; _errorCount++;
Log.Verbose("Tcp client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount); logger.LogDebug("Tcp client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount);
} }
private void CloseClientSocket() private void CloseClientSocket()
@@ -312,7 +314,7 @@ namespace Modbus.Net
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Tcp client {ConnectionToken} client close exception", ConnectionToken); logger.LogError(ex, "Tcp client {ConnectionToken} client close exception", ConnectionToken);
} }
} }
} }

View File

@@ -1,10 +1,10 @@
using System; using Microsoft.Extensions.Logging;
using Nito.AsyncEx;
using System;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Nito.AsyncEx;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -13,6 +13,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class UdpConnector : BaseConnector, IDisposable public class UdpConnector : BaseConnector, IDisposable
{ {
private static readonly ILogger<UdpConnector> logger = LogProvider.CreateLogger<UdpConnector>();
private readonly string _host; private readonly string _host;
private readonly int _port; private readonly int _port;
@@ -81,7 +83,7 @@ namespace Modbus.Net
{ {
CloseClientSocket(); CloseClientSocket();
_socketClient = null; _socketClient = null;
Log.Debug("Udp client {ConnectionToken} Disposed", ConnectionToken); logger.LogDebug("Udp client {ConnectionToken} Disposed", ConnectionToken);
} }
} }
@@ -116,17 +118,17 @@ namespace Modbus.Net
_taskCancel = false; _taskCancel = false;
Controller.SendStart(); Controller.SendStart();
ReceiveMsgThreadStart(); ReceiveMsgThreadStart();
Log.Information("Udp client {ConnectionToken} connected", ConnectionToken); logger.LogInformation("Udp client {ConnectionToken} connected", ConnectionToken);
return true; return true;
} }
Log.Error("Udp client {ConnectionToken} connect failed.", ConnectionToken); logger.LogError("Udp client {ConnectionToken} connect failed.", ConnectionToken);
Dispose(); Dispose();
return false; return false;
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Udp client {ConnectionToken} connect exception", ConnectionToken); logger.LogError(err, "Udp client {ConnectionToken} connect exception", ConnectionToken);
Dispose(); Dispose();
return false; return false;
} }
@@ -142,12 +144,12 @@ namespace Modbus.Net
try try
{ {
Dispose(); Dispose();
Log.Information("Udp client {ConnectionToken} disconnected successfully", ConnectionToken); logger.LogInformation("Udp client {ConnectionToken} disconnected successfully", ConnectionToken);
return true; return true;
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Udp client {ConnectionToken} disconnected exception", ConnectionToken); logger.LogError(err, "Udp client {ConnectionToken} disconnected exception", ConnectionToken);
return false; return false;
} }
finally finally
@@ -168,13 +170,13 @@ namespace Modbus.Net
RefreshSendCount(); RefreshSendCount();
Log.Verbose("Udp client {ConnectionToken} send text len = {Length}", ConnectionToken, datagram.Length); logger.LogDebug("Udp client {ConnectionToken} send text len = {Length}", ConnectionToken, datagram.Length);
Log.Verbose($"Udp client {ConnectionToken} send: {String.Concat(datagram.Select(p => " " + p.ToString("X2")))}"); logger.LogDebug($"Udp client {ConnectionToken} send: {String.Concat(datagram.Select(p => " " + p.ToString("X2")))}");
await _socketClient.SendAsync(datagram, datagram.Length); await _socketClient.SendAsync(datagram, datagram.Length);
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Udp client {ConnectionToken} send exception", ConnectionToken); logger.LogError(err, "Udp client {ConnectionToken} send exception", ConnectionToken);
Dispose(); Dispose();
} }
} }
@@ -210,9 +212,9 @@ namespace Modbus.Net
{ {
if (receive.Buffer.Clone() is byte[] receiveBytes) if (receive.Buffer.Clone() is byte[] receiveBytes)
{ {
Log.Verbose("Udp client {ConnectionToken} receive text len = {Length}", ConnectionToken, logger.LogDebug("Udp client {ConnectionToken} receive text len = {Length}", ConnectionToken,
receiveBytes.Length); receiveBytes.Length);
Log.Verbose( logger.LogDebug(
$"Udp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}"); $"Udp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes); var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes);
foreach (var confirmed in isMessageConfirmed) foreach (var confirmed in isMessageConfirmed)
@@ -239,7 +241,7 @@ namespace Modbus.Net
} }
catch (Exception err) catch (Exception err)
{ {
Log.Error(err, "Udp client {ConnectionToken} receive exception", ConnectionToken); logger.LogError(err, "Udp client {ConnectionToken} receive exception", ConnectionToken);
//CloseClientSocket(); //CloseClientSocket();
} }
} }
@@ -247,19 +249,19 @@ namespace Modbus.Net
private void RefreshSendCount() private void RefreshSendCount()
{ {
_sendCount++; _sendCount++;
Log.Verbose("Udp client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount); logger.LogDebug("Udp client {ConnectionToken} send count: {SendCount}", ConnectionToken, _sendCount);
} }
private void RefreshReceiveCount() private void RefreshReceiveCount()
{ {
_receiveCount++; _receiveCount++;
Log.Verbose("Udp client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount); logger.LogDebug("Udp client {ConnectionToken} receive count: {SendCount}", ConnectionToken, _receiveCount);
} }
private void RefreshErrorCount() private void RefreshErrorCount()
{ {
_errorCount++; _errorCount++;
Log.Verbose("Udp client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount); logger.LogDebug("Udp client {ConnectionToken} error count: {ErrorCount}", ConnectionToken, _errorCount);
} }
private void CloseClientSocket() private void CloseClientSocket()
@@ -280,7 +282,7 @@ namespace Modbus.Net
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex, "Udp client {ConnectionToken} client close exception", ConnectionToken); logger.LogError(ex, "Udp client {ConnectionToken} client close exception", ConnectionToken);
} }
} }
} }

View File

@@ -1,8 +1,8 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -11,6 +11,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class FifoController : BaseController public class FifoController : BaseController
{ {
private static readonly ILogger<FifoController> logger = LogProvider.CreateLogger<FifoController>();
private MessageWaitingDef _currentSendingPos; private MessageWaitingDef _currentSendingPos;
private bool _taskCancel = false; private bool _taskCancel = false;
@@ -94,7 +96,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "Controller throws exception"); logger.LogError(e, "Controller throws exception");
} }
} }

View File

@@ -1,6 +1,6 @@
using Quartz.Listener; using Microsoft.Extensions.Logging;
using Quartz; using Quartz;
using Serilog; using Quartz.Listener;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -12,6 +12,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class JobChainingJobListenerWithDataMap : JobListenerSupport public class JobChainingJobListenerWithDataMap : JobListenerSupport
{ {
private static readonly ILogger<JobChainingJobListenerWithDataMap> logger = LogProvider.CreateLogger<JobChainingJobListenerWithDataMap>();
/// <summary> /// <summary>
/// JobChaningJobListener with DataMap passing from parent job to next job /// JobChaningJobListener with DataMap passing from parent job to next job
/// </summary> /// </summary>
@@ -58,7 +60,7 @@ namespace Modbus.Net
return; return;
} }
Log.Information("Job '{JobKey}' will now chain to Job '{Job}'", context.JobDetail.Key, sj); logger.LogInformation("Job '{JobKey}' will now chain to Job '{Job}'", context.JobDetail.Key, sj);
try try
{ {
@@ -78,7 +80,7 @@ namespace Modbus.Net
} }
catch (SchedulerException se) catch (SchedulerException se)
{ {
Log.Error(se, "Error encountered during chaining to Job '{Job}'", sj); logger.LogError(se, "Error encountered during chaining to Job '{Job}'", sj);
} }
} }
#nullable disable #nullable disable

View File

@@ -3,7 +3,6 @@ using Quartz.Impl;
using Quartz.Impl.Matchers; using Quartz.Impl.Matchers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection.PortableExecutable;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Modbus.Net namespace Modbus.Net

View File

@@ -0,0 +1,43 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
namespace Modbus.Net
{
/// <summary>
///
/// </summary>
public static class LogProvider
{
private static ILoggerFactory _loggerFactory = null;
/// <summary>
/// Sets the current log provider based on logger factory.
/// </summary>
/// <param name="loggerFactory">The logger factory.</param>
public static void SetLogProvider(ILoggerFactory loggerFactory)
{
_loggerFactory = loggerFactory;
}
/// <summary>
///
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public static ILogger CreateLogger(string category) => _loggerFactory != null ? _loggerFactory.CreateLogger(category) : NullLogger.Instance;
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static ILogger<T> CreateLogger<T>() => _loggerFactory != null ? _loggerFactory.CreateLogger<T>() : NullLogger<T>.Instance;
#if DIAGNOSTICS_SOURCE
internal static class Cached
{
internal static readonly System.Lazy<System.Diagnostics.DiagnosticListener> Default =
new(() => new System.Diagnostics.DiagnosticListener(DiagnosticHeaders.DefaultListenerName));
}
#endif
}
}

View File

@@ -1,8 +1,8 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -80,6 +80,8 @@ namespace Modbus.Net
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TUnitKey : IEquatable<TUnitKey> where TUnitKey : IEquatable<TUnitKey>
{ {
private static readonly ILogger<BaseMachine<TKey, TUnitKey>> logger = LogProvider.CreateLogger<BaseMachine<TKey, TUnitKey>>();
private readonly int _maxErrorCount = 3; private readonly int _maxErrorCount = 3;
/// <summary> /// <summary>
@@ -302,7 +304,7 @@ namespace Modbus.Net
catch (Exception e) catch (Exception e)
{ {
ErrorCount++; ErrorCount++;
Log.Error(e, $"BaseMachine -> GetDatas, Id:{Id} Connection:{ConnectionToken} key {key} existing. ErrorCount {ErrorCount}."); logger.LogError(e, $"BaseMachine -> GetDatas, Id:{Id} Connection:{ConnectionToken} key {key} existing. ErrorCount {ErrorCount}.");
if (ErrorCount >= _maxErrorCount) if (ErrorCount >= _maxErrorCount)
Disconnect(); Disconnect();
@@ -321,7 +323,7 @@ namespace Modbus.Net
catch (Exception e) catch (Exception e)
{ {
ErrorCount++; ErrorCount++;
Log.Error(e, $"BaseMachine -> GetDatas, Id:{Id} Connection:{ConnectionToken} error. ErrorCount {ErrorCount}."); logger.LogError(e, $"BaseMachine -> GetDatas, Id:{Id} Connection:{ConnectionToken} error. ErrorCount {ErrorCount}.");
if (ErrorCount >= _maxErrorCount) if (ErrorCount >= _maxErrorCount)
Disconnect(); Disconnect();
@@ -399,13 +401,13 @@ namespace Modbus.Net
//地址为空报错 //地址为空报错
if (address == null) if (address == null)
{ {
Log.Error($"Machine {ConnectionToken} Address {value.Key} doesn't exist."); logger.LogError($"Machine {ConnectionToken} Address {value.Key} doesn't exist.");
continue; continue;
} }
//不能写报错 //不能写报错
if (!address.CanWrite) if (!address.CanWrite)
{ {
Log.Error($"Machine {ConnectionToken} Address {value.Key} cannot write."); logger.LogError($"Machine {ConnectionToken} Address {value.Key} cannot write.");
continue; continue;
} }
addresses.Add(address); addresses.Add(address);
@@ -521,7 +523,7 @@ namespace Modbus.Net
catch (Exception e) catch (Exception e)
{ {
ErrorCount++; ErrorCount++;
Log.Error(e, $"BaseMachine -> SetDatas, Id:{Id} Connection:{ConnectionToken} error. ErrorCount {ErrorCount}."); logger.LogError(e, $"BaseMachine -> SetDatas, Id:{Id} Connection:{ConnectionToken} error. ErrorCount {ErrorCount}.");
if (ErrorCount >= _maxErrorCount) if (ErrorCount >= _maxErrorCount)
Disconnect(); Disconnect();
@@ -619,7 +621,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"BaseMachine -> GetAddressUnitById Id:{Id} ConnectionToken:{ConnectionToken} addressUnitId:{addressUnitId} Repeated"); logger.LogError(e, $"BaseMachine -> GetAddressUnitById Id:{Id} ConnectionToken:{ConnectionToken} addressUnitId:{addressUnitId} Repeated");
return null; return null;
} }
} }

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net</AssemblyName> <AssemblyName>Modbus.Net</AssemblyName>
<RootNamespace>Modbus.Net</RootNamespace> <RootNamespace>Modbus.Net</RootNamespace>
<PackageId>Modbus.Net</PackageId> <PackageId>Modbus.Net</PackageId>
<Version>1.4.0</Version> <Version>1.4.0-beta03</Version>
<Product>Modbus.Net</Product> <Product>Modbus.Net</Product>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian Science Technology Co.,Ltd.</Company>
@@ -28,10 +28,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" /> <PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="Quartz" Version="3.6.0" /> <PackageReference Include="Quartz" Version="3.6.2" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" /> <PackageReference Include="System.IO.Ports" Version="7.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup> </ItemGroup>

View File

@@ -1,8 +1,8 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
/// <summary> /// <summary>
/// 端格式 /// 端格式
@@ -47,6 +47,8 @@ namespace Modbus.Net
where TProtocolUnit : class, IProtocolFormatting<TParamIn, TParamOut> where TParamOut : class where TProtocolUnit : class, IProtocolFormatting<TParamIn, TParamOut> where TParamOut : class
where TPipeUnit : PipeUnit<TParamIn, TParamOut, IProtocolLinker<TParamIn, TParamOut>, TProtocolUnit> where TPipeUnit : PipeUnit<TParamIn, TParamOut, IProtocolLinker<TParamIn, TParamOut>, TProtocolUnit>
{ {
private static readonly ILogger<BaseUtility<TParamIn, TParamOut, TProtocolUnit, TPipeUnit>> logger = LogProvider.CreateLogger<BaseUtility<TParamIn, TParamOut, TProtocolUnit, TPipeUnit>>();
/// <summary> /// <summary>
/// 协议收发主体 /// 协议收发主体
/// </summary> /// </summary>
@@ -128,7 +130,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> GetDatas: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> GetDatas: {ConnectionString} error");
return null; return null;
} }
} }
@@ -164,7 +166,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> GetDatas Generic: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> GetDatas Generic: {ConnectionString} error");
return null; return null;
} }
} }
@@ -205,7 +207,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, $"ModbusUtility -> GetDatas pair: {ConnectionString} error"); logger.LogError(e, $"ModbusUtility -> GetDatas pair: {ConnectionString} error");
return null; return null;
} }
} }

View File

@@ -1,9 +1,9 @@
using System; using Microsoft.Extensions.Logging;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -12,6 +12,8 @@ namespace Modbus.Net
/// </summary> /// </summary>
public class ValueHelper public class ValueHelper
{ {
private static readonly ILogger<ValueHelper> logger = LogProvider.CreateLogger<ValueHelper>();
/// <summary> /// <summary>
/// 兼容数据类型对应的字节长度 /// 兼容数据类型对应的字节长度
/// </summary> /// </summary>
@@ -714,7 +716,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "ValueHelper -> ByteArrayToObjectArray error"); logger.LogError(e, "ValueHelper -> ByteArrayToObjectArray error");
count = contents.Length; count = contents.Length;
} }
} }
@@ -822,7 +824,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "ValueHelper -> SetValue set value failed"); logger.LogError(e, "ValueHelper -> SetValue set value failed");
return false; return false;
} }
} }
@@ -871,7 +873,7 @@ namespace Modbus.Net
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error(e, "ValueHelper -> SetBit set bit failed"); logger.LogError(e, "ValueHelper -> SetBit set bit failed");
return false; return false;
} }
} }

View File

@@ -1,9 +1,4 @@
using System; namespace AnyType.Models
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace AnyType.Models
{ {
public class TaskViewModel public class TaskViewModel
{ {

View File

@@ -1,9 +1,4 @@
using System; public enum LightLamp { Red, Yellow, Green }
using System.Collections.Generic;
using System.Linq;
using System.Web;
public enum LightLamp{Red,Yellow,Green}
namespace CrossLampControl.WebApi.Models namespace CrossLampControl.WebApi.Models
{ {
public class Lamp public class Lamp

View File

@@ -0,0 +1,30 @@
using Quartz.Logging;
namespace MachineJob
{
// simple log provider to get something to the console
public class ConsoleLogProvider : ILogProvider
{
public Logger GetLogger(string name)
{
return (level, func, exception, parameters) =>
{
if (level >= Quartz.Logging.LogLevel.Info && func != null)
{
Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] [" + level + "] " + func(), parameters);
}
return true;
};
}
public IDisposable OpenNestedContext(string message)
{
throw new NotImplementedException();
}
public IDisposable OpenMappedContext(string key, object value, bool destructure = false)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;

View File

@@ -15,6 +15,9 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,5 +1,4 @@
using System; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable

View File

@@ -1,10 +1,31 @@
using MachineJob;
using MachineJob.Service; using MachineJob.Service;
using Serilog;
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Console()
.CreateLogger();
var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
Quartz.Logging.LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());
Modbus.Net.LogProvider.SetLogProvider(loggerFactory);
IHost host = Host.CreateDefaultBuilder(args) IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services => .ConfigureServices(services =>
{ {
services.AddHostedService<Worker>(); services.AddHostedService<Worker>();
services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(Log.Logger, true));
}) })
.Build(); .Build();
await host.RunAsync(); await host.RunAsync();

View File

@@ -30,7 +30,6 @@ namespace MachineJob.Service
new AddressUnit() { Area = "4X", Address = 10, DataType = typeof(short), Id = "10", Name = "Test10" } new AddressUnit() { Area = "4X", Address = 10, DataType = typeof(short), Id = "10", Name = "Test10" }
}; };
/*
List<AddressUnit> _addresses2 = new List<AddressUnit> List<AddressUnit> _addresses2 = new List<AddressUnit>
{ {
new AddressUnit() { Area = "DB1", Address = 0, DataType = typeof(short), Id = "1", Name = "Test1" }, new AddressUnit() { Area = "DB1", Address = 0, DataType = typeof(short), Id = "1", Name = "Test1" },
@@ -44,28 +43,30 @@ namespace MachineJob.Service
new AddressUnit() { Area = "DB1", Address = 16, DataType = typeof(short), Id = "9", Name = "Test9" }, new AddressUnit() { Area = "DB1", Address = 16, DataType = typeof(short), Id = "9", Name = "Test9" },
new AddressUnit() { Area = "DB1", Address = 18, DataType = typeof(short), Id = "10", Name = "Test10" } new AddressUnit() { Area = "DB1", Address = 18, DataType = typeof(short), Id = "10", Name = "Test10" }
}; };
*/
IMachine<string> machine = new ModbusMachine<string, string>("ModbusMachine1", ModbusType.Tcp, "192.168.0.161", _addresses, true, 1, 2, Endian.BigEndianLsb);
//IMachine<string> machine2 = new SiemensMachine<string, string>("SiemensMachine1", SiemensType.Tcp, "192.168.0.161", SiemensMachineModel.S7_1200, _addresses2, true, 1, 2);
await MachineJobSchedulerCreator.CreateScheduler("Trigger1", -1, 5).Result.From(machine.Id, machine, MachineDataType.Name).Result.Query(machine.Id + ".ConsoleQuery", QueryConsole).Result.To(machine.Id + ".To", machine).Result.Deal(machine.Id+".Deal", OnSuccess, OnFailure).Result.Run(); IMachine<string> machine = new ModbusMachine<string, string>("ModbusMachine1", ModbusType.Tcp, "192.168.0.161", _addresses, true, 1, 2, Endian.BigEndianLsb);
//await MachineJobSchedulerCreator.CreateScheduler("Trigger2", -1, 5).Result.From(machine2.Id, machine2, MachineDataType.Name).Result.Query(machine2.Id + ".ConsoleQuery", QueryConsole).Result.To(machine2.Id + ".To", machine2).Result.Deal(machine2.Id + ".Deal", OnSuccess, OnFailure).Result.Run(); IMachine<string> machine2 = new SiemensMachine<string, string>("SiemensMachine1", SiemensType.Tcp, "192.168.0.161", SiemensMachineModel.S7_1200, _addresses2, true, 1, 2);
await MachineJobSchedulerCreator.CreateScheduler("Trigger1", -1, 10).Result.From(machine.Id, machine, MachineDataType.Name).Result.Query(machine.Id + ".ConsoleQuery", QueryConsole).Result.To(machine.Id + ".To", machine).Result.Deal(machine.Id + ".Deal", OnSuccess, OnFailure).Result.Run();
Thread.Sleep(5000);
await MachineJobSchedulerCreator.CreateScheduler("Trigger2", -1, 10).Result.From(machine2.Id, machine2, MachineDataType.Name).Result.Query(machine2.Id + ".ConsoleQuery", QueryConsole).Result.To(machine2.Id + ".To", machine2).Result.Deal(machine2.Id + ".Deal", OnSuccess, OnFailure).Result.Run();
} }
public override async Task StopAsync(CancellationToken cancellationToken) public override async Task StopAsync(CancellationToken cancellationToken)
{ {
await MachineJobSchedulerCreator.CancelJob("Trigger1"); await MachineJobSchedulerCreator.CancelJob("Trigger1");
await MachineJobSchedulerCreator.CancelJob("Trigger2");
} }
public Task OnSuccess(string machineId) public Task OnSuccess(string machineId)
{ {
Console.WriteLine("Machine {0} set success", machineId); _logger.LogInformation("Machine {0} set success", machineId);
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task OnFailure(string machineId) public Task OnFailure(string machineId)
{ {
Console.WriteLine("Machine {0} set failure", machineId); _logger.LogError("Machine {0} set failure", machineId);
return Task.CompletedTask; return Task.CompletedTask;
} }
@@ -74,7 +75,7 @@ namespace MachineJob.Service
var values = dataReturnDef.ReturnValues; var values = dataReturnDef.ReturnValues;
foreach (var value in values) foreach (var value in values)
{ {
Console.WriteLine(dataReturnDef.MachineId + " " + value.Key + " " + value.Value.DeviceValue); _logger.LogInformation(dataReturnDef.MachineId + " " + value.Key + " " + value.Value.DeviceValue);
} }
try try

View File

@@ -1,9 +1,12 @@
{ {
"Logging": { "Serilog": {
"LogLevel": { "MinimumLevel": {
"Default": "Information", "Default": "Information",
"Override": {
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information"
} }
}
}, },
"ConnectionStrings": { "ConnectionStrings": {
"DatabaseWriteConnectionString": "Server=localhost; User ID=root; Password=123456; Database=modbusnettest;" "DatabaseWriteConnectionString": "Server=localhost; User ID=root; Password=123456; Database=modbusnettest;"

View File

@@ -1,9 +1,4 @@
using System; namespace TripleAdd.Models
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TripleAdd.Models
{ {
public class TripleAddViewModel public class TripleAddViewModel
{ {

View File

@@ -6,7 +6,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,11 +1,18 @@
using System; using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using Modbus.Net; using Modbus.Net;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
using Serilog; using Serilog;
using System;
using System.Collections.Generic;
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console()
.CreateLogger();
Log.Logger = new LoggerConfiguration().MinimumLevel.Verbose().WriteTo.Console().CreateLogger(); var loggerFactory = new LoggerFactory()
.AddSerilog(Log.Logger);
LogProvider.SetLogProvider(loggerFactory);
ModbusMachine<int, string> machine = new ModbusMachine<int, string>(1, ModbusType.Rtu, "COM1", ModbusMachine<int, string> machine = new ModbusMachine<int, string>(1, ModbusType.Rtu, "COM1",
new List<AddressUnit>() new List<AddressUnit>()

View File

@@ -1,7 +1,4 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
using Modbus.Net.Siemens; using Modbus.Net.Siemens;

View File

@@ -1,9 +1,4 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
namespace Modbus.Net.Tests namespace Modbus.Net.Tests

View File

@@ -1,10 +1,6 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
using System.Reflection;
namespace Modbus.Net.Tests namespace Modbus.Net.Tests
{ {

View File

@@ -1,8 +1,4 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
namespace Modbus.Net.Tests namespace Modbus.Net.Tests

View File

@@ -1,7 +1,4 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus; using Modbus.Net.Modbus;
namespace Modbus.Net.Tests namespace Modbus.Net.Tests

View File

@@ -1,8 +1,4 @@
using System; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Modbus.Net.Modbus;
using Modbus.Net.Siemens; using Modbus.Net.Siemens;
namespace Modbus.Net.Tests namespace Modbus.Net.Tests