@@ -33,7 +33,8 @@ public string Name
33
33
}
34
34
35
35
string _port = "COM1" ;
36
- public string ServerName
36
+ [ Category ( "串口设置" ) , Description ( "串口号" ) ]
37
+ public string PortName
37
38
{
38
39
get { return _port ; }
39
40
set { _port = value ; }
@@ -48,6 +49,7 @@ public bool IsClosed
48
49
}
49
50
50
51
private int _timeOut = 3000 ;
52
+ [ Category ( "串口设置" ) , Description ( "通迅超时时间" ) ]
51
53
public int TimeOut
52
54
{
53
55
get { return _timeOut ; }
@@ -56,7 +58,7 @@ public int TimeOut
56
58
57
59
58
60
private int _baudRate = 9600 ;
59
- [ Description ( "波特率" ) ]
61
+ [ Category ( "串口设置" ) , Description ( "波特率" ) ]
60
62
public int BaudRate
61
63
{
62
64
get { return _baudRate ; }
@@ -65,23 +67,23 @@ public int BaudRate
65
67
// private SerialPort _serialPort;
66
68
67
69
private int _dataBits = 8 ;
68
- [ Description ( "数据位" ) ]
70
+ [ Category ( "串口设置" ) , Description ( "数据位" ) ]
69
71
public int DataBits
70
72
{
71
73
get { return _dataBits ; }
72
74
set { _dataBits = value ; }
73
75
}
74
76
private StopBits _stopBits = StopBits . One ;
75
- [ Description ( "停止位" ) ]
77
+ [ Category ( "串口设置" ) , Description ( "停止位" ) ]
76
78
public StopBits StopBits
77
79
{
78
80
get { return _stopBits ; }
79
81
set { _stopBits = value ; }
80
82
}
81
83
82
84
private Parity _parity = Parity . None ;
83
- [ Description ( "奇偶校验" ) ]
84
- public Parity parity
85
+ [ Category ( "串口设置" ) , Description ( "奇偶校验" ) ]
86
+ public Parity Parity
85
87
{
86
88
get { return _parity ; }
87
89
set { _parity = value ; }
@@ -270,6 +272,12 @@ public int PDU
270
272
所以PDU应为: 253字节 */
271
273
get { return 0xFD ; } //0xFD 十进制为253
272
274
}
275
+ private string _serverName = "unknown" ;
276
+ public string ServerName
277
+ {
278
+ get { return _serverName ; }
279
+ set { _serverName = value ; }
280
+ }
273
281
274
282
public DeviceAddress GetDeviceAddress ( string address )
275
283
{
@@ -321,7 +329,7 @@ public DeviceAddress GetDeviceAddress(string address)
321
329
dv . Start = int . Parse ( address . Substring ( 1 ) ) ;
322
330
dv . Start -- ;
323
331
dv . Bit -- ;
324
- dv . ByteOrder = ByteOrder . Network ;
332
+ dv . ByteOrder = ByteOrder . BigEndian ;
325
333
}
326
334
break ;
327
335
case '3' :
@@ -337,7 +345,7 @@ public DeviceAddress GetDeviceAddress(string address)
337
345
dv . Start = int . Parse ( address . Substring ( 1 ) ) ;
338
346
dv . Start -- ;
339
347
dv . Bit -- ;
340
- dv . ByteOrder = ByteOrder . Network ;
348
+ dv . ByteOrder = ByteOrder . BigEndian ;
341
349
}
342
350
break ;
343
351
}
@@ -544,7 +552,6 @@ public void Dispose()
544
552
#endregion
545
553
}
546
554
547
-
548
555
public sealed class Modbus
549
556
{
550
557
public const byte fctReadCoil = 1 ;
0 commit comments