Concurrency parameter
-
Just taking a look at 1.13 release in CVS, I have seen that ModbusFactory.createRtuMaster and ModbusFactory.createAsciiMaster now requires an int "concurrency" parameter.
This parameter could be SerialMaster.SYNC_TRANSPORT, SerialMaster.SYNC_SLAVE or SerialMaster.SYNC_FUNCTION and modify the behaviour of SerialWaitingRoomKeyFactory.
What's the difference between those 3 values? -
This parameter tells Modbus4J at what concurrency level it needs to operate. This is for when you have multiple threads using the same modbus master to send requests. (Note that Modbus4J doesn't handle the multi-threading for you. You still need to do that yourself.)
For example, one thread may be sending requests to slave 1, and another to slave 2. You can send both requests at the same time and have each slave generate the response concurrently, which is more efficient then sending them serially. To do this, you should set your master concurrency level to SYNC_SLAVE.
Does this make sense?
-
Good improvement! :)
Looks like SYNC_FUNCTION syncs on slaveId and functionCode, so both must be different to send a concurrent request, and SYNC_TRANSPORT doesn't allow to send concurrent modbus requests, like before.
Please correct me if I'm wrong. -
You are correct.