Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - vikrant

Pages: [1]
1
Support Questions / ModbusTcpCom does not recover from ComFail error
« on: July 03, 2014, 02:31:39 AM »
If the slave-master communication breaks (e.g. slave died, or slave comm cable removed), ModbusTcpCom does not recover from ComFail error.

I could not find a way to retry communication. Upon comm error, I made a retry loop that again instantiate ModbusTcpCom with the slave, but this goes in error stating that another socket is already open, so I tried to Dispose() this object and re-instantiated, but still communication does not come alive.

I have to kill the exe and then start it to make the comm healthy again.

If anyone has a solution, please let me know.

Thanks.

2
Support Questions / What is the round trip time for Modbus Read ?
« on: July 03, 2014, 02:28:05 AM »
I have 10 tags, they are set with values acquired using following:
Code: [Select]
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?

3
Support Questions / Getting NULL by OPCComm's ReadAny function
« on: September 25, 2013, 02:16:34 AM »
I had earlier used the OPCDAAutoDll to create an OPC client in VB.NET and it worked. I was trying out OPCComm lately, I could create OPCComm without any error but, ReadAny function returned null on any OPC tag ItemID I provide as Address argument.

I am now confused, while using the OPCDAAutoDll I was using the OPC ItemID as tag name, so should ItemID or Address of OPC Tag for OPCComm ReadAny's address arg?

Do we also have to provide the GroupName, or no or any group name will do ??

Look at the pseudo code as follows: I'm using Kepware's Demo OPC server for testing.

Code: [Select]
                OPCComm opcComm = new OPCComm();
                opcComm.OPCServer = "Kepware.KEPServerEX.V5";
                //opcComm.OPCGroup = "Device1.Channel1";

                while (true)
                {
                    foreach (var tag in device.Tags)
                    {
                        try
                        {
                            var data = opcComm.ReadAny("Channel1.Device1.Tag1");
                            tag.UpdateData(new Data { Timestamp = DateTime.Now, Value = data, Quality = "Good" });
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Error reading " + tag.Name + " for device " + device.Name +
                            ". Details: " + ex.Message + " Stack-trace: " + ex.StackTrace);
                        }
                    }     
                }

Pages: [1]