Professional OPC
Development Tools

logos

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.

UnsubscribeMultipleItems / UnsubscribeAllItems

More
14 Feb 2012 12:52 #769 by hedgehog
Thank you for quick answer!
I solve the problem with creating new easyDAClient - drag&drop from toolbox to Form1.cs[Design] (before I create easyDAClient inside the code in Form1.cs).
Now I can call UnsubscribeXXX function on Form1_FormClosing event.
Thanks a lot!!

Best regards

Please Log in or Create an account to join the conversation.

More
13 Feb 2012 18:00 #767 by support
Hello,
it does not look right that you keep an instance of EasyDAClient object in a local variable (easyDAClient1) only. That would be fine if you need it just there. If you, however, want to make operations on the same object somewhere else, such as in Form1_FormClosing, you need to store it somewhere, most likely as a field in the form object. Your code does not show it, but I suspect that you might be creating a new object when you call UnsubscribeXXXX, and that would explain why it doesn't work, because on a new object, there is nothing to unsubscribe from.
Let me know if this helped.
Best regards

Please Log in or Create an account to join the conversation.

More
13 Feb 2012 13:23 #766 by hedgehog
I use this code for subscribing multiple items:


private void Form1_Load(object sender, EventArgs e)
{
fn_SubscribeMultipleItems()
}



private void fn_SubscribeMultipleItems()
{


OpcLabs.EasyOpc.DataAccess.EasyDAClient easyDAClient1 = new OpcLabs.EasyOpc.DataAccess.EasyDAClient();


easyDAClient1.ItemChanged += new EventHandler<EasyDAItemChangedEventArgs>(easyDAClient1_ItemChanged);
OpcLabs.EasyOpc.DataAccess.DAItemGroupArguments[] opcGroup = new OpcLabs.EasyOpc.DataAccess.DAItemGroupArguments[Tags.Length];

short dataType = VarType.Empty;
for (int u = 0; u < Tag.Length; u++)
{
opcGroup2 = new OpcLabs.EasyOpc.DataAccess.DAItemGroupArguments(
Properties.Settings.Default.OPCmachineName,
Properties.Settings.Default.OPCserverClass,
Tag.TagID,
dataType,
Convert.ToInt32(Tag.UpdateRate),
float.Parse(Tag.DeadBand),
null);
}


easyDAClient1.SubscribeMultipleItems(opcGroup);
}

private void easyDAClient1_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
//insert statement
}

Now i want to unsubscribe items on Form closing.



private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
}
I try to use UnsubscribeMultipleItems() but I have problem with parameters.
I also try to use UnsubscribeAllItems() but it don't work.

I think there is problem with calling UnsubscribeAllItems() or UnsubscribeMultipleItems() in private void Form1_FormClosing.
If I call UnsubscribeAllItems() or UnsubscribeMultipleItems() in private void fn_SubscribeMultipleItems() after easyDAClient1.SubscribeMultipleItems(opcGroup) it work well...

Is there some solution for this problem?

Thanks & Best regards

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.047 seconds