48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Modbus.Net.Modbus
|
|
{
|
|
public class ModbusRtuInUdpProtocol : ModbusProtocol
|
|
{
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="slaveAddress">从站号</param>
|
|
/// <param name="masterAddress">主站号</param>
|
|
public ModbusRtuInUdpProtocol(byte slaveAddress, byte masterAddress)
|
|
: this(ConfigurationManager.AppSettings["IP"], slaveAddress, masterAddress)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="ip">ip地址</param>
|
|
/// <param name="slaveAddress">从站号</param>
|
|
/// <param name="masterAddress">主站号</param>
|
|
public ModbusRtuInUdpProtocol(string ip, byte slaveAddress, byte masterAddress)
|
|
: base(slaveAddress, masterAddress)
|
|
{
|
|
ProtocolLinker = new ModbusRtuInUdpProtocolLinker(ip);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="ip">ip地址</param>
|
|
/// <param name="port">端口号</param>
|
|
/// <param name="slaveAddress">从站号</param>
|
|
/// <param name="masterAddress">主站号</param>
|
|
public ModbusRtuInUdpProtocol(string ip, int port, byte slaveAddress, byte masterAddress)
|
|
: base(slaveAddress, masterAddress)
|
|
{
|
|
ProtocolLinker = new ModbusRtuInUdpProtocolLinker(ip, port);
|
|
}
|
|
}
|
|
}
|