資源簡介
國外牛人編寫的C#modbus協議解析,適合于下位機PLC等。方便您的快速開發
代碼片段和文件信息
/****************************************************************************
?
?Modbus?-?Free?.NET?Modbus?Library
?
?Author??:?Simone?Assunti
?License?:?Freeware?open?source
*****************************************************************************/
using?System;
using?System.Collections;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.IO;
using?System.IO.Ports;
using?System.Net;
using?System.Net.Sockets;
using?System.Threading;
using?System.Reflection;
using?System.Diagnostics;
namespace?OilField
{
????#region?Custom?Events?Args
????///?
????///?Event?args?for?remote?endpoint?connection
????///?
????public?sealed?class?ModbusTCPUDPClientConnectedEventArgs?:?EventArgs
????{
????????#region?Global?Variables
????????///?
????????///?Remote?endpoint
????????///?
????????IPEndPoint?remote_ep;
????????#endregion
????????#region?Parameters
????????///?
????????///?Remote?EndPoint
????????///?
????????public?IPEndPoint?RemoteEndPoint
????????{
????????????get?{?return?remote_ep;?}
????????}
????????#endregion
????????#region?Constructor
????????///?
????????///?Constructor
????????///?
????????///?Remote?EndPoint
????????public?ModbusTCPUDPClientConnectedEventArgs(IPEndPoint?remote_ep)
????????{
????????????this.remote_ep?=?remote_ep;
????????}
????????#endregion
????}
????#endregion
????#region?Enumerations
????///?
????///?Connection?types
????///?
????public?enum?ConnectionType
????{
????????///?
????????///?Modbus?serial?RTU
????????///?
????????SERIAL_RTU?=?0
????????///?
????????///?Modbus?serial?ASCII
????????///?
????????SERIAL_ASCII?=?1
????????///?
????????///?Modbus?TCP/IP
????????///?
????????TCP_IP?=?2
????????///?
????????///?Modbus?UDP
????????///?
????????UDP_IP?=?3
????}
????///?
????///?Type?of?modbus?serial
????///?
????public?enum?ModbusSerialType
????{
????????///?
????????///?Modbus?RTU
????????///?
????????RTU?=?0
????????///?
????????///?Modbus?ASCII
????????///?
????????ASCII?=?1
????}
????///?
????///?Type?of?device
????///?
????public?enum?DeviceType
????{
????????///?
????????///?Modbus?master
????????///?
????????MASTER?=?0
????????///?
????????///?Modbus?slave
????????///?
????????SLAVE?=?1
????}
????///?
????///?Tabelle?del?database?modbus
????///?
????public?enum?ModbusDBTables
????{
????????DISCRETE_INPUTS_REGISTERS?=?0
????????COIL_REGISTERS?=?1
????????INPUT_REGISTERS?=?2
????????HOLDING_REGISTERS?=?3
????}
????///?
????///?Modbus?calling?codes
????///?
????enum
評論
共有 條評論