-
Notifications
You must be signed in to change notification settings - Fork 136
4.5 二次封装协议的Api
parallelbgls edited this page Jun 29, 2017
·
1 revision
二次封装协议的Api,请使用Utility。
原因很简单:Utility中获取和设置数据的方法比较多,但是Machine只以byte的方式读写数据,而且已经做过了一次比较狠地封装,所以不建议在Machine上做扩展。
比如,如果你想实现一个Modbus的GetCoil方法,可以这样:
public bool GetCoil(int address)
{
var ans = _modbusUtility.GetDatas("0X " + address, 1);
int pos = 0, subpos = address;
return ValueHelper.GetInstance(Endian).GetBit(ans, ref pos, ref subpos) == 1;
}
Modbus.Net Hangzhou Delian Science Technology Co.,Ltd. © 2023
-
2 Specification of Modbus.Net main framework
- 2.1 Modbus.Net Architecture
- 2.2 Transmission Control Layer Controller
- 2.3 Transmission Link Layer Connector
- 2.4 Concrete Protocol Layer ProtocolLinker
- 2.5 Abstract Protocol Layer Protocol
- 2.6 Protocol Presentation Layer Utility
- 2.7 Device Application Layer Machine
- 2.8 Task Application Layer MachineJob
-
3 Using Modbus.Net to implement a protocol
- 3.1 Global Tools
- 3.2 Extends Protocol and ProtocolUnit according to protocol specification
- 3.3 Extends Connector to create a link method
- 3.4 Extends Machine and Utility, creating two apis
- 3.5 Extends API methods to Machine and Utility
- 3.6 Extends Formater, Translator and Combiner, Creating Encoding,Decoding,Combining methods for address
- 3.7 Extends Controller, to control message