I have 10 tags, they are set with values acquired using following:
while(true)
{
List<int> addresses = new List<int> {40001,40002,40003,40004,40005,40006,40007,40008,40009,40010};
Dictionary<string, Tuple<DateTime, int> values = new Dictionary<string, Tuple<DateTime, int>();
ModbusTcpCom mtc = new ModbusTcpCom();
mtc.IPAddress = "127.0.0.1";
mtc.TcpipPort = (ushort)502;
foreach(var addr in addresses)
{
var value = mtc.Read(addr.ToString());
values.add(addr.ToString(), new Tuple<DateTime, int>(DateTime.Now(), int.Parse(value));
}
}
With the above code, each tag gets updated only after about 5 seconds, as if like each read is taking roughly 500ms.
So please let me know, what is the inherent round trip time for Read() and how to mimimize it ?
How to make it thread-safe, because what I found was, running the above loop iterations in their own threads, causes Read() to go in error?