70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace XP.Hardware.PLC.Configs
|
||
{
|
||
/// <summary>
|
||
/// PLC 类型枚举 | PLC Type Enumeration
|
||
/// </summary>
|
||
public enum PlcType
|
||
{
|
||
/// <summary>
|
||
/// S7-200Smart 系列 | S7-200Smart series
|
||
/// </summary>
|
||
S200Smart,
|
||
|
||
/// <summary>
|
||
/// S7-300 系列 | S7-300 series
|
||
/// </summary>
|
||
S300,
|
||
|
||
/// <summary>
|
||
/// S7-400 系列 | S7-400 series
|
||
/// </summary>
|
||
S400,
|
||
|
||
/// <summary>
|
||
/// S7-1200 系列 | S7-1200 series
|
||
/// </summary>
|
||
S1200,
|
||
|
||
/// <summary>
|
||
/// S7-1500 系列 | S7-1500 series
|
||
/// </summary>
|
||
S1500
|
||
}
|
||
|
||
public class PlcConfig
|
||
{
|
||
// 连接配置
|
||
public string IpAddress { get; set; } = "127.0.0.1";
|
||
public int Port { get; set; } = 502;
|
||
public short Rack { get; set; } = 0;
|
||
public short Slot { get; set; } = 1;
|
||
|
||
/// <summary>
|
||
/// PLC 型号类型 | PLC model type
|
||
/// </summary>
|
||
public PlcType PlcType { get; set; } = PlcType.S1200;
|
||
|
||
// 读取配置 | Read configuration
|
||
public string ReadDbBlock { get; set; } = "DB1";
|
||
public int ReadStartAddress { get; set; } = 0;
|
||
public int ReadLength { get; set; } = 100; // 字节长度
|
||
|
||
/// <summary>
|
||
/// 批量读取周期(ms)| Bulk read interval (ms)
|
||
/// </summary>
|
||
public int BulkReadIntervalMs { get; set; } = 100;
|
||
|
||
// 超时与重试
|
||
public int ConnectTimeoutMs { get; set; } = 3000;
|
||
public int ReadTimeoutMs { get; set; } = 3000;
|
||
public int WriteTimeoutMs { get; set; } = 3000;
|
||
public bool bReConnect { get; set; } = false;
|
||
}
|
||
}
|