2017-05-11 update 1 move setting files to App.config
This commit is contained in:
13
Modbus.Net/Modbus.Net.Core/App.config
Normal file
13
Modbus.Net/Modbus.Net.Core/App.config
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="COM" value="COM1"/>
|
||||||
|
<add key="FBoxOpcDaHost" value="opcda://localhost/FBoxOpcServer"/>
|
||||||
|
<add key="IP" value="192.168.1.1"/>
|
||||||
|
<add key="IPConnectionTimeout" value="5000"/>
|
||||||
|
<add key="ModbusPort" value="502"/>
|
||||||
|
<add key="OpcDaHost" value="opcda://localhost/..."/>
|
||||||
|
<add key="OpcUaHost" value="opc.tcp://localhost/..."/>
|
||||||
|
<add key="SiemensPort" value="102"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
||||||
18
Modbus.Net/Modbus.Net.Core/ConfigurationManager.cs
Normal file
18
Modbus.Net/Modbus.Net.Core/ConfigurationManager.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace Modbus.Net
|
||||||
|
{
|
||||||
|
public static class ConfigurationManager
|
||||||
|
{
|
||||||
|
private static IConfigurationBuilder builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.AddXmlFile("App.config");
|
||||||
|
|
||||||
|
private static IConfigurationRoot Configuration => builder.Build();
|
||||||
|
|
||||||
|
public static IConfigurationSection AppSettings => Configuration.GetSection("AppSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,23 +51,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="1.1.2" />
|
||||||
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
|
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
|
||||||
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
|
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="..\src\Base.Common\ConfigurationManager.Designer.cs" Link="ConfigurationManager.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="..\src\Base.Common\ConfigurationManager.resx" Link="ConfigurationManager.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -27,4 +27,8 @@
|
|||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Modbus.Net.Modbus
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Modbus.Net.Modbus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modbus/Ascii码协议
|
/// Modbus/Ascii码协议
|
||||||
@@ -6,7 +8,7 @@
|
|||||||
public class ModbusAsciiProtocal : ModbusProtocal
|
public class ModbusAsciiProtocal : ModbusProtocal
|
||||||
{
|
{
|
||||||
public ModbusAsciiProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
public ModbusAsciiProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
||||||
: this(ConfigurationManager.COM, slaveAddress, masterAddress, endian)
|
: this(ConfigurationManager.AppSettings["COM"], slaveAddress, masterAddress, endian)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Modbus.Net.Modbus
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Modbus.Net.Modbus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modbus/Rtu协议
|
/// Modbus/Rtu协议
|
||||||
@@ -6,7 +8,7 @@
|
|||||||
public class ModbusRtuProtocal : ModbusProtocal
|
public class ModbusRtuProtocal : ModbusProtocal
|
||||||
{
|
{
|
||||||
public ModbusRtuProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
public ModbusRtuProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
||||||
: this(ConfigurationManager.COM, slaveAddress, masterAddress, endian)
|
: this(ConfigurationManager.AppSettings["COM"], slaveAddress, masterAddress, endian)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Modbus.Net.Modbus
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Modbus.Net.Modbus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modbus/Tcp协议
|
/// Modbus/Tcp协议
|
||||||
@@ -6,7 +8,7 @@
|
|||||||
public class ModbusTcpProtocal : ModbusProtocal
|
public class ModbusTcpProtocal : ModbusProtocal
|
||||||
{
|
{
|
||||||
public ModbusTcpProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
public ModbusTcpProtocal(byte slaveAddress, byte masterAddress, Endian endian)
|
||||||
: this(ConfigurationManager.IP, slaveAddress, masterAddress, endian)
|
: this(ConfigurationManager.AppSettings["IP"], slaveAddress, masterAddress, endian)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
namespace Modbus.Net.Modbus
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace Modbus.Net.Modbus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modbus/Tcp协议连接器
|
/// Modbus/Tcp协议连接器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ModbusTcpProtocalLinker : TcpProtocalLinker
|
public class ModbusTcpProtocalLinker : TcpProtocalLinker
|
||||||
{
|
{
|
||||||
public ModbusTcpProtocalLinker(string ip) : base(ip, int.Parse(ConfigurationManager.ModbusPort))
|
public ModbusTcpProtocalLinker(string ip) : base(ip, int.Parse(ConfigurationManager.AppSettings["ModbusPort"]))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -13,7 +14,7 @@ namespace Modbus.Net.OPC.FBox
|
|||||||
public string LinkerName { get; set; }
|
public string LinkerName { get; set; }
|
||||||
|
|
||||||
public FBoxOpcDaMachine(string localSequence, string linkerName,
|
public FBoxOpcDaMachine(string localSequence, string linkerName,
|
||||||
IEnumerable<AddressUnit> getAddresses, bool keepConnect) : base(ConfigurationManager.FBoxOpcDaHost, getAddresses, keepConnect)
|
IEnumerable<AddressUnit> getAddresses, bool keepConnect) : base(ConfigurationManager.AppSettings["FBoxOpcDaHost"], getAddresses, keepConnect)
|
||||||
{
|
{
|
||||||
LocalSequence = localSequence;
|
LocalSequence = localSequence;
|
||||||
LinkerName = linkerName;
|
LinkerName = linkerName;
|
||||||
|
|||||||
@@ -24,11 +24,17 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="H.Opc" Version="0.8.1" />
|
<PackageReference Include="H.Opc" Version="0.9.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.Configuration">
|
||||||
|
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Configuration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text;
|
using System.Configuration;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Modbus.Net.OPC
|
namespace Modbus.Net.OPC
|
||||||
{
|
{
|
||||||
@@ -7,7 +8,7 @@ namespace Modbus.Net.OPC
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpcDaProtocalLinker : OpcProtocalLinker
|
public class OpcDaProtocalLinker : OpcProtocalLinker
|
||||||
{
|
{
|
||||||
public OpcDaProtocalLinker() : this(ConfigurationManager.OpcDaHost)
|
public OpcDaProtocalLinker() : this(ConfigurationManager.AppSettings["OpcDaHost"])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -11,7 +12,7 @@ namespace Modbus.Net.OPC
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class OpcUaProtocalLinker : OpcProtocalLinker
|
public class OpcUaProtocalLinker : OpcProtocalLinker
|
||||||
{
|
{
|
||||||
public OpcUaProtocalLinker() : this(ConfigurationManager.OpcUaHost)
|
public OpcUaProtocalLinker() : this(ConfigurationManager.AppSettings["OpcUaHost"])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,5 +25,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.Configuration">
|
||||||
|
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Configuration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Configuration;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Modbus.Net.Siemens
|
namespace Modbus.Net.Siemens
|
||||||
{
|
{
|
||||||
@@ -10,7 +11,7 @@ namespace Modbus.Net.Siemens
|
|||||||
private readonly string _com;
|
private readonly string _com;
|
||||||
|
|
||||||
public SiemensPpiProtocal(byte slaveAddress, byte masterAddress)
|
public SiemensPpiProtocal(byte slaveAddress, byte masterAddress)
|
||||||
: this(ConfigurationManager.COM, slaveAddress, masterAddress)
|
: this(ConfigurationManager.AppSettings["COM"], slaveAddress, masterAddress)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Configuration;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Modbus.Net.Siemens
|
namespace Modbus.Net.Siemens
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ namespace Modbus.Net.Siemens
|
|||||||
private int _connectTryCount;
|
private int _connectTryCount;
|
||||||
|
|
||||||
public SiemensTcpProtocal(byte tdpuSize, ushort tsapSrc, ushort tsapDst, ushort maxCalling, ushort maxCalled,
|
public SiemensTcpProtocal(byte tdpuSize, ushort tsapSrc, ushort tsapDst, ushort maxCalling, ushort maxCalled,
|
||||||
ushort maxPdu) : this(tdpuSize, tsapSrc, tsapDst, maxCalling, maxCalled, maxPdu, ConfigurationManager.IP)
|
ushort maxPdu) : this(tdpuSize, tsapSrc, tsapDst, maxCalling, maxCalled, maxPdu, ConfigurationManager.AppSettings["IP"])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
namespace Modbus.Net.Siemens
|
namespace Modbus.Net.Siemens
|
||||||
{
|
{
|
||||||
@@ -8,7 +9,7 @@ namespace Modbus.Net.Siemens
|
|||||||
public class SiemensTcpProtocalLinker : TcpProtocalLinker
|
public class SiemensTcpProtocalLinker : TcpProtocalLinker
|
||||||
{
|
{
|
||||||
public SiemensTcpProtocalLinker(string ip)
|
public SiemensTcpProtocalLinker(string ip)
|
||||||
: base(ip, int.Parse(ConfigurationManager.SiemensPort))
|
: base(ip, int.Parse(ConfigurationManager.AppSettings["SiemensPort"]))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
Modbus.Net/Modbus.Net/App.config
Normal file
14
Modbus.Net/Modbus.Net/App.config
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="COM" value="COM1"/>
|
||||||
|
<add key="FBoxOpcDaHost" value="opcda://localhost/FBoxOpcServer"/>
|
||||||
|
<add key="IP" value="192.168.1.1"/>
|
||||||
|
<add key="ComConnectionTimeout" value="3000"/>
|
||||||
|
<add key="IPConnectionTimeout" value="5000"/>
|
||||||
|
<add key="ModbusPort" value="502"/>
|
||||||
|
<add key="OpcDaHost" value="opcda://localhost/..."/>
|
||||||
|
<add key="OpcUaHost" value="opc.tcp://localhost/..."/>
|
||||||
|
<add key="SiemensPort" value="102"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO.Ports;
|
using System.Configuration;
|
||||||
|
using System.IO.Ports;
|
||||||
|
|
||||||
namespace Modbus.Net
|
namespace Modbus.Net
|
||||||
{
|
{
|
||||||
@@ -15,7 +16,7 @@ namespace Modbus.Net
|
|||||||
/// <param name="stopBits">停止位</param>
|
/// <param name="stopBits">停止位</param>
|
||||||
/// <param name="dataBits">数据位</param>
|
/// <param name="dataBits">数据位</param>
|
||||||
protected ComProtocalLinker(int baudRate, Parity parity, StopBits stopBits, int dataBits)
|
protected ComProtocalLinker(int baudRate, Parity parity, StopBits stopBits, int dataBits)
|
||||||
: this(ConfigurationManager.COM, baudRate, parity, stopBits, dataBits)
|
: this(ConfigurationManager.AppSettings["COM"], baudRate, parity, stopBits, dataBits)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ namespace Modbus.Net
|
|||||||
protected ComProtocalLinker(string com, int baudRate, Parity parity, StopBits stopBits, int dataBits)
|
protected ComProtocalLinker(string com, int baudRate, Parity parity, StopBits stopBits, int dataBits)
|
||||||
{
|
{
|
||||||
//初始化连对象
|
//初始化连对象
|
||||||
BaseConnector = new ComConnector(com, baudRate, parity, stopBits, dataBits, 30000);
|
BaseConnector = new ComConnector(com, baudRate, parity, stopBits, dataBits, int.Parse(ConfigurationManager.AppSettings["ComConnectionTimeout"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,18 +50,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\src\Base.Common\ConfigurationManager.Designer.cs" Link="ConfigurationManager.Designer.cs">
|
<Reference Include="System.Configuration">
|
||||||
<DesignTime>True</DesignTime>
|
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Configuration.dll</HintPath>
|
||||||
<AutoGen>True</AutoGen>
|
</Reference>
|
||||||
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="..\src\Base.Common\ConfigurationManager.resx" Link="ConfigurationManager.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// 此代码由工具生成。
|
|
||||||
// 运行时版本:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|
||||||
// 重新生成代码,这些更改将会丢失。
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Modbus.Net {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
|
||||||
/// </summary>
|
|
||||||
// 此类是由 StronglyTypedResourceBuilder
|
|
||||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
|
||||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
|
||||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
public class ConfigurationManager {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal ConfigurationManager() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Modbus.Net.ConfigurationManager", typeof(ConfigurationManager).GetTypeInfo().Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 使用此强类型资源类,为所有资源查找
|
|
||||||
/// 重写当前线程的 CurrentUICulture 属性。
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
public static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 COM1 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string COM {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("COM", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 opcda://localhost/FBoxOpcServer 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string FBoxOpcDaHost {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("FBoxOpcDaHost", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 192.168.1.1 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string IP {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("IP", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 5000 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string IPConnectionTimeout {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("IPConnectionTimeout", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 502 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string ModbusPort {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("ModbusPort", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 opcda://localhost/... 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string OpcDaHost {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("OpcDaHost", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 opc.tcp://localhost/... 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string OpcUaHost {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("OpcUaHost", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找类似 102 的本地化字符串。
|
|
||||||
/// </summary>
|
|
||||||
public static string SiemensPort {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("SiemensPort", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<data name="COM" xml:space="preserve">
|
|
||||||
<value>COM1</value>
|
|
||||||
</data>
|
|
||||||
<data name="FBoxOpcDaHost" xml:space="preserve">
|
|
||||||
<value>opcda://localhost/FBoxOpcServer</value>
|
|
||||||
</data>
|
|
||||||
<data name="IP" xml:space="preserve">
|
|
||||||
<value>192.168.1.1</value>
|
|
||||||
</data>
|
|
||||||
<data name="IPConnectionTimeout" xml:space="preserve">
|
|
||||||
<value>5000</value>
|
|
||||||
</data>
|
|
||||||
<data name="ModbusPort" xml:space="preserve">
|
|
||||||
<value>502</value>
|
|
||||||
</data>
|
|
||||||
<data name="OpcDaHost" xml:space="preserve">
|
|
||||||
<value>opcda://localhost/...</value>
|
|
||||||
</data>
|
|
||||||
<data name="OpcUaHost" xml:space="preserve">
|
|
||||||
<value>opc.tcp://localhost/...</value>
|
|
||||||
</data>
|
|
||||||
<data name="SiemensPort" xml:space="preserve">
|
|
||||||
<value>102</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
namespace Modbus.Net
|
#if NET40||NET45||NET451||NET452||NET46||NET461||NET462||NET47
|
||||||
|
using System.Configuration;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Modbus.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tcp连接对象
|
/// Tcp连接对象
|
||||||
@@ -8,7 +12,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造器
|
/// 构造器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected TcpProtocalLinker() : this(ConfigurationManager.IP, int.Parse(ConfigurationManager.ModbusPort))
|
protected TcpProtocalLinker() : this(ConfigurationManager.AppSettings["IP"], int.Parse(ConfigurationManager.AppSettings["ModbusPort"]))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +24,7 @@
|
|||||||
protected TcpProtocalLinker(string ip, int port)
|
protected TcpProtocalLinker(string ip, int port)
|
||||||
{
|
{
|
||||||
//初始化连接对象
|
//初始化连接对象
|
||||||
BaseConnector = new TcpConnector(ip, port, int.Parse(ConfigurationManager.IPConnectionTimeout));
|
BaseConnector = new TcpConnector(ip, port, int.Parse(ConfigurationManager.AppSettings["IPConnectionTimeout"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user