- Posts: 42
- Thank you received: 4
Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- Reading, Writing, Subscriptions, Property Access
- Xmlserver and EasyDAClient.SharedInstance.SubscribeItem
Xmlserver and EasyDAClient.SharedInstance.SubscribeItem
- goosvanbeek
- Topic Author
- Offline
- Platinum Member
Best regards,
Goos van Beek.
Please Log in or Create an account to join the conversation.
A complete functional example can look like this:
// This example shows how subscribe to changes of a single item in an OPC XML-DA server and display the value of the item
// with each change, using a callback method specified using lambda expression.
using System.Diagnostics;
using OpcLabs.EasyOpc.DataAccess;
using System;
using System.Threading;
namespace DocExamples
{
namespace _EasyDAClient
{
partial class SubscribeItem
{
public static void CallbackLambdaXml()
{
// Instantiate the client object
var client = new EasyDAClient();
Console.WriteLine("Subscribing...");
// The callback is a lambda expression the displays the value
client.SubscribeItem(
"http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx",
"Dynamic/Analog Types/Int",
1000,
(sender, eventArgs) =>
{
Debug.Assert(eventArgs != null);
if (eventArgs.Exception != null)
Console.WriteLine(eventArgs.Exception.ToString());
else
{
Debug.Assert(eventArgs.Vtq != null);
Console.WriteLine(eventArgs.Vtq.ToString());
}
},
state: null);
Console.WriteLine("Processing item changed events for 10 seconds...");
Thread.Sleep(10 * 1000);
Console.WriteLine("Unsubscribing...");
client.UnsubscribeAllItems();
Console.WriteLine("Waiting for 2 seconds...");
Thread.Sleep(2 * 1000);
}
}
}
}
Please Log in or Create an account to join the conversation.
- goosvanbeek
- Topic Author
- Offline
- Platinum Member
- Posts: 42
- Thank you received: 4
The code you suggested unfortunately doesn't work at my side.
www.opclabs.com/products/quickopc/opc-specifications/opc-xml-da
// The callback is a lambda expression that displays the value
EasyDAClient.SharedInstance.SubscribeItem(
"http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", 1000,
(_, args) => Console.WriteLine(args.Vtq.Value));
Method 'SubscribeItem' has 5 parameter(s) but is invoked with 4 argument(s)
https://www.screencast.com/t/vX1gCILPv
Regards,
Goos van Beek
Please Log in or Create an account to join the conversation.
- goosvanbeek
- Topic Author
- Offline
- Platinum Member
- Posts: 42
- Thank you received: 4
I will test this later today and I expect no problems with it anymore.
Best regards,
Goos van Beek
Please Log in or Create an account to join the conversation.
Compare your code carefully with e.g. www.opclabs.com/products/quickopc/opc-specifications/opc-xml-da .
In addition, note that the callback code is simplified for the purpose of making the example short. Your actual code should check the Exception property before accessing Vtq. See:
opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...AttributeData%20property).html
and
opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...r%20UAAttributeData.Value.html
Best regards
Please Log in or Create an account to join the conversation.
- goosvanbeek
- Topic Author
- Offline
- Platinum Member
- Posts: 42
- Thank you received: 4
This is the stacktrace:
" bij SharedInstanceTest.Program.<>c.<Main>b__0_0(Object _, EasyDAItemChangedEventArgs eventArgs) in C:\\KUKA\\DEV\\SharedInstanceTest\\SharedInstanceTest\\Program.cs:regel 16\r\n bij OpcLabs.BaseLib.Widgets.NotifyingWidget.<>c__DisplayClass45_0`1.<CallbackAction>b__0()\r\n bij OpcLabs.BaseLib.Widgets.NotifyingWidget.SafeCallback(String name, Action action)"
See also the image links below (unfortunately in dutch)
https://www.screencast.com/t/NttWKjg4Ht
https://www.screencast.com/t/hi8cSzCtqeb
Regards,
Goos.
Please Log in or Create an account to join the conversation.
Is eventArgs.Exception null? If it is not, what is the exception it contains?
Best regards
Please Log in or Create an account to join the conversation.
- goosvanbeek
- Topic Author
- Offline
- Platinum Member
- Posts: 42
- Thank you received: 4
I'm trying use EasyDAClient.SharedInstance.SubscribeItem on a xml server. I can subscribe my items, but the vtq returns null. Am I doing something wrong or isn't it possible to use an shared instance subscrubtion with a (KUKA)xml server
?
Using SharedInstances with an local OPCDA server works fine.
EasyDAClient.SharedInstance.SubscribeItem(
"", "http://172.31.1.145:8081/DA", "RobotMSG.messageinfo", 1000,
(_, eventArgs)=>Console.WriteLine(eventArgs.Vtq.Value));
Best regards,
Goos van Beek
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- Reading, Writing, Subscriptions, Property Access
- Xmlserver and EasyDAClient.SharedInstance.SubscribeItem