ModbusTCP

所属分类:通讯编程
开发工具:C#
文件大小:20KB
下载次数:0
上传日期:2021-11-24 14:39:26
上 传 者sh-1993
说明:  Modbus主模拟器
(A Modbus Master simulator)

文件列表:
Modbus.Master.Simulator (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator.sln (1150, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Clients (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Clients\ModbusMasterClient.cs (16402, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Common (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Common\ConsoleHelper.cs (1123, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Interfaces (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Interfaces\IAppSettingsProvider.cs (317, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Interfaces\IInputArgumentParser.cs (452, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Interfaces\IModbusMasterClient.cs (1929, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Modbus.Master.Simulator.csproj (1029, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\ModbusMasterSim.cs (22437, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Parsers (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Parsers\InputArgumentParser.cs (3712, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Parsers\ParseResult.cs (376, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Program.cs (1588, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Providers (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Providers\AppSettingsProvider.cs (3019, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Types (0, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\Types\ModbusMasterOptions.cs (351, 2021-11-24)
Modbus.Master.Simulator\Modbus.Master.Simulator\appsettings.json (214, 2021-11-24)

## ModbusTCP.MasterSim ModbusTCP.MasterSim is a Modbus TCP master simulator built on the NModbus library. It supports all the standard read/write functionality, as well as reading and writing 32-bit floats and 16-bit strings. - [Getting started](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#getting-started) - [AppSettings.json ](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#appsettingsjson-) - [SlaveIPAddress ](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#slaveipaddress-) - [SlaveTcpPort ](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#slavetcpport-) - [SlaveId ](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#slaveid-) - [MaxRetryCount](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#maxretrycount) - [RetryInterval](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#retryinterval) - [SendTimeout](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#sendtimeout) - [ReceiveTimeout](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#receivetimeout) - [MODBUS Commands](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#modbus-commands) - [Read a range of coils](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-coils) - [Write to a single coil](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#write-to-a-single-coil) - [Write to a range of coils](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#write-to-a-range-of-coils) - [Read a range of discrete inputs](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-discrete-inputs) - [Read a range of input registers](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-input-registers) - [Read a range of input registers as bits](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-input-registers-as-bits) - [Read a range of input registers as 32-bit floats](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-input-registers-as-32-bit-floats) - [Read a range of holding registers](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-holding-registers) - [Read a range of holding registers as bits](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-holding-registers-as-bits) - [Read a range of holding registers as 32-bit floats](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#read-a-range-of-holding-registers-as-32-bit-floats) - [Write to a range of holding registers](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#write-to-a-range-of-holding-registers) - [Client Commands](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#client-commands) - [Connect to slave](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#connect-to-slave) - [Reconnect to slave](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#reconnect-to-slave) - [Set/change slave ID](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#setchange-slave-id) - [Set/change slave IP-address](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#setchange-slave-ip-address) - [Set/change slave TCP port](https://github.com/KevinBrueland/ModbusTCP.MasterSim/blob/master/#setchange-slave-tcp-port) # # # Getting started To get started with the ModbusTCP master simulator, clone the repository and build the project. # AppSettings.json The appsettings.json config file has application settings that can be set in order to autoconnect to a slave. If these values arent present in the appsettings.json file, you can still manually connect to a slave with the 'Connect' command. ## SlaveIPAddress The IP-address of the slave you wish to connect to. **Example:** 127.0.0.1 --- --- ## SlaveTcpPort The TCP port of the slave you wish to connect to. **Example:** 502 --- --- ## SlaveId The slaveId you wish to send commands to. **Example:** 1 --- --- ## MaxRetryCount Max number of retries when attempting to establish a connection to the slave. Value in ms. **Example:** 5000 --- --- ## RetryInterval Time between each retry attempt. Value in ms. **Example:** 5000 --- --- ## SendTimeout Send time before timing out. Value in ms. **Example:** 5000 --- --- ## ReceiveTimeout Receive time before timing out. Value in ms. **Example:** 5000 --- --- # MODBUS Commands ## Read a range of coils **Command:** READ COILS **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** coil values starting from **--startaddress** **Example** READ COILS --startaddress 1 --numbertoread 10 # # ## Write to a single coil **Command:** WRITE COIL **Arguments:** --address (uint16) --value (bool) **Description** Writes the **--value** to the **--address** **Example** WRITE COIL --address 1 --value true # # ## Write to a range of coils **Command:** WRITE COILS **Arguments:** --startaddress (uint16) --values (comma separated string of bool) **Description** Writes the **--values** to coil addresses starting at **--startingaddress** and increments address by one for each value. **Example** WRITE COILS --startaddress 1 --value true,true,false,true # # ## Read a range of discrete inputs **Command:** READ DISCRETES **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** discrete input values starting from **--startaddress** **Example** READ DISCRETES --startaddress 10001 --numbertoread 10 # # ## Read a range of input registers **Command:** READ INPUTREGS **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** input register values starting from **--startaddress** **Example** READ INPUTREGS --startaddress 30001 --numbertoread 5 # # ## Read a range of input registers as bits **Command:** READ INPUTREGSB **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** input register values starting from **--startaddress** and displays the individual bit values. **Example** READ INPUTREGSB --startaddress 30001 --numbertoread 5 # # ## Read a range of input registers as 32-bit floats **Command:** READ INPUTREGSF **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** input register pairs starting from **--startaddress** and displays the value as 32-bit floats. NOTE: Register values in Modbus are 16 bit unsigned values, so a 32-bit float consists of two consecutive Uint16 register address values converted to a 32-bit float. **Example** READ INPUTREGSF --startaddress 30001 --numbertoread 3 # # ## Read a range of holding registers **Command:** READ HOLDREGS **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** holding register values starting from **--startaddress**. **Example** READ HOLDREGS --startaddress 40001 --numbertoread 5 # # ## Read a range of holding registers as bits **Command:** READ HOLDREGSB **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** holding register values starting from **--startaddress** and displays the individual bit values. **Example** READ HOLDREGSB --startaddress 40001 --numbertoread 5 # # ## Read a range of holding registers as 32-bit floats **Command:** READ HOLDREGSF **Arguments:** --startaddress (uint16) --numbertoread (uint16) **Description** Reads **--numbertoread** holding register pairs starting from **--startaddress** and displays the values as 32-bit floats. NOTE: Register values in Modbus are 16 bit unsigned values, so a 32-bit float consists of two consecutive Uint16 register address values converted to a 32-bit float. **Example** READ HOLDREGSF --startaddress 40001 --numbertoread 3 # # ## Write to a range of holding registers **Command:** WRITE HOLDREGS **Arguments:** --startaddress (uint16) --values (see description) **Description** Writes the **--values** to holding register addresses starting at **--startingaddress** and increments address by one for each value. The **--values** argument expects a comma-separated list of one of the following: 1. 16-bit unsigned values 2. 16-bit bitstrings (LSB->MSB) 3. 32-bit floats Note that you cannot mix types for a single write. The comma-separated values must consist of the same type. **Example** WRITE HOLDREGS --startaddress 40001 --values 1234,20543,51534 WRITE HOLDREGS --startaddress 40001 --values 1001000000001100,0001011000110000 WRITE HOLDREGS --startaddress 40001 --values 32.1235,654.2534,99.33452 # # # Client Commands ## Connect to slave **Command:** CONNECT **Arguments:** --ipaddress (ip-address in format x.x.x.x) --port (int) --slaveid (byte) **Description** Connects to a slave with the provided ip, port and slaveid. **Example** CONNECT --ipaddress 127.0.0.1 --port 502 --slaveid 1 # # ## Reconnect to slave **Command:** RECONNECT **Arguments:** N/A **Description** Reconnects to the last connected slave **Example** RECONNECT # # ## Set/change slave ID **Command:** SET SLAVEID **Arguments:** --slaveid (byte) **Description** Sets the slave ID the client sends commands to. **Example** SET SLAVEID --slaveid 1 # # ## Set/change slave IP-address **Command:** SET IPADDRESS **Arguments:** --ipaddress (ip-address in format x.x.x.x) **Description** Sets the IP-address of the slave the client connects to. This will force any current connection to be closed and will then attempt to reconnect to the new IP-address with the existing TCP port. **Example** SET IPADDRESS --ipaddress 127.0.0.1 # # ## Set/change slave TCP port **Command:** SET PORT **Arguments:** --port (int) **Description** Sets the TCP port of the slave the client connects to. This will force any current connection to be closed and will then attempt to reconnect to the new TCP port with the existing IP-address. **Example** SET PORT --port 502

近期下载者

相关文件


收藏者