There is a way to do stop and start the who modubus plugin, a connection, or even down to the level of the function.
there is a modbus control register "mbcntl/command" which accepts the following syntax:
START | STOP | RESTART
START | STOP | RESTART <device connection> e.g. P1_ToolChanger
START | STOP | RESTART <device connection/function> e.g. P1_ToolChanger/function1
Not only is the register called command, it is also of the command register type. You use mc.mcRegSendCommand()
local hReg, rc response
hreg, rc = mc.mcRegGetHandle(inst, "mbcntl/command")
response, rc = mc.mcRegSendCommand(hReg, "STOP P1_ToolChanger")
Please check the return codes. I left them out for brevity. The response variable has the response from the modbus plugin as to the result of the operation. It the device or functions didn't exist, you would be notified in that response variable.
As to the delay. All of the device connections are run sequentially IF they meet their poll interval. The modbus library that we use isn't multi-threaded, unfortunately. If the tool changer device is taking too long, it will impact others, unfortunately. You can try and streamline the calls by using the write/read multiple functions if your device supports them. I'm not sure why some devices are so slow and don't play well with others. I'll see if there is a way to mitigate that somehow but at the moment, I can't think of anything other than what I suggested with the multiple read/write functions and your idea of starting and stopping device connections.
Steve