05/20/2014
Hi All,
I am using OPC .NET Api in my application develped under .NET Framework.
The OPC server I am using is Simatic .NET V16.
The OPC communication works fine, tested with OPC Scout.
I can write tags through PLC with no problem using the Write method:
Opc.IdentifiedResult[] resultsW = ServerOPC.Write(itemsW);
But when I try to read the same tags.
Opc.Da.ItemValueResult[] resultS = ServerOPC.Read(items);
I have the exception :
E_FAIL
IOPCItemIO.Read
Any idea?
Thanks in advance.
05/30/2017
/// <summary> /// Begins an asynchronous read operation for a set of items. /// </summary> /// <param name="items">The set of items to read (must include the server handle).</param> /// <param name="requestHandle">An identifier for the request assigned by the caller.</param> /// <param name="callback">A delegate used to receive notifications when the request completes.</param> /// <param name="request">An object that contains the state of the request (used to cancel the request).</param> /// <returns>A set of results containing any errors encountered when the server validated the items.</returns> IdentifiedResult[] Read( Item[] items, object requestHandle, ReadCompleteEventHandler callback, out IRequest request);
05/20/2014
Thank you for your help Randy.
I am currently using groups to read the data.
Siemens has no explanation for this behavior…they say there is no difference between V14 and V16.
What I’ve been reading is that the IOPCItemIO interface is implemented in all DA3.0 OPC Servers, but apparently there is something wrong in Simatic .NET V16, or I am doing something wrong in my installation…
This error made me take a look to the documentation I found in the web and in it it said that it’s better to use groups in terms of efficiency.
For those that run into this error, I hope it helps.
This is what I am doing
//Create Group Opc.Da.Subscription GroupSync; // Group for Read PLC Tags Opc.Da.SubscriptionState GroupStateSync = new Opc.Da.SubscriptionState(); // Sync GroupStateSync.Name = "GroupSync"; GroupStateSync.Active = false; GroupSync = (Opc.Da.Subscription)ServerOPC.CreateSubscription(GroupStateSync);
//Define Items to Read
//Opc.Da.Item[] items = new Opc.Da.Item[Number of Items]
GroupSync.AddItems(items);
//Read items when
Opc.Da.ItemValueResult[] results = GroupSync.Read(GroupSync.Items);
1 Guest(s)