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
- General Issues, Building
- ItemChanged handler (after upgrade from 5.12)
ItemChanged handler (after upgrade from 5.12)
I suppose that you know that Microsoft support for .NET 4.0 and, in fact, also 4.5 and 4.5.1, has ended just yesterday. That effectively leaves only 3.5, and then 4.5.2 and higher, as supported frameworks.
Best regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Note that the example code is intentionally oversimplified. e.Vtq may be null in case of errors; your code should check e.Exception for non-nullness first.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
dataCache[e.ItemDescriptor.ItemId] = e.Vtq.Value;
Now ItemDescriptor is gone, so where might I find ItemId for this value?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
using OpcLabs.EasyOpc.DataAccess.OperationModel;
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
#region Example
// This example shows how subscribe to changes of multiple items, and unsubscribe from one of them.
using JetBrains.Annotations;
using OpcLabs.EasyOpc.DataAccess;
using System;
using System.Threading;
namespace DocExamples
{
namespace _EasyDAClient
{
class UnsubscribeItem
{
public static void Main()
{
using (var easyDAClient = new EasyDAClient())
{
easyDAClient.ItemChanged += easyDAClient_ItemChanged;
int[] handleArray = easyDAClient.SubscribeMultipleItems(
new[] {
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Simulation.Random", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Ramp (1 min)", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Trends.Sine (1 min)", 1000, null),
new DAItemGroupArguments("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 1000, null)
});
Console.WriteLine("Processing item changed events for 30 seconds...");
Thread.Sleep(30 * 1000);
Console.WriteLine("Unsubscribing from the first item...");
easyDAClient.UnsubscribeItem(handleArray[0]);
Console.WriteLine();
Console.WriteLine("Processing item changed events for 30 seconds...");
Thread.Sleep(30 * 1000);
}
}
// Item changed event handler
static void easyDAClient_ItemChanged([NotNull] object sender, [NotNull] EasyDAItemChangedEventArgs e)
{
Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq);
}
}
}
}
#endregion
// ReSharper restore InconsistentNaming
// ReSharper restore CheckNamespace
Note that it is 'static' only for the purpose of the sample code, in your app it probably won't be.
Best regards
Please Log in or Create an account to join the conversation.
Argument type 'method group' is not assignable to parameter type 'opcLabs.EasyOpc.DataAccess.OperationalModel.EasyDAItemChangedEventArgs'
How do you instantiate an event handler for ItemChanged?
Please Log in or Create an account to join the conversation.
I have not tested it, but can't you change
var itemChangedEventHandler = new EventHandler<EasyDAItemChangedEventArgs>(this.OPCItemChanged);
to
var itemChangedEventHandler = new EasyDAItemChangedEventHandler(this.OPCItemChanged);
Provided that OPCItemChanged has proper argument types, it should be possible to simply write
opc.ItemChanged += OPCItemChanged;
Best regards
Please Log in or Create an account to join the conversation.
opc = new EasyDAClient();
var itemChangedEventHandler = new EventHandler<EasyDAItemChangedEventArgs>(this.OPCItemChanged);
opc.ItemChanged += itemChangedEventHandler;
The EasyDAItemChangedArgs is no longer in OpcLabs.EasyOpc.DataAccess. EasyOpc.DataAccess.Generic has EasyDAItemChangedEventArgs<T> and EasyOpc.DataAccess.OperationModel has EasyDAItemChangedEventArgs. So I selected second one because we don't have a <T>, but then the last line will not work, not assignable. It says opc.ItemChanged is of type EasyOpc.DataAccess.EasyDAItemChangedEventHandler.
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-Classic in .NET
- General Issues, Building
- ItemChanged handler (after upgrade from 5.12)