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.

SubscribeMultipleItems example vb.net

More
28 Dec 2010 15:18 #163 by support
Apologies - only now I have noticed that you have asked for VB.NET code, not C#. Here is the same thing in VB.NET:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    Dim argumentsList = New List(Of DAItemGroupArguments)()
    For Each control As Control In Me.Controls
        Dim itemId = TryCast(control.Tag, String)
        If itemId IsNot Nothing Then
            argumentsList.Add(New DAItemGroupArguments("", "OPCLabs.KitServer.2", itemId, 50, control))
        End If
    Next control
    Me.easyDAClient1.SubscribeMultipleItems(argumentsList.ToArray())
End Sub

Private Sub easyDAClient1_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs) Handles easyDAClient1.ItemChanged
    Dim textBox = TryCast(e.State, TextBox)
    If textBox IsNot Nothing AndAlso textBox.ReadOnly Then
        If e.Exception Is Nothing Then
            textBox.Text = e.Vtq.DisplayValue()
        Else
            textBox.Text = "** Error **"
        End If
    End If
End Sub

Private Sub writeButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles writeButton.Click
    Dim textBox As TextBox = Me.writeValueTextBox
    Me.easyDAClient1.WriteItemValue("", "OPCLabs.KitServer.2", CStr(textBox.Tag), textBox.Text)
End Sub

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

More
09 Dec 2010 13:10 #152 by support
Yes. You can have a look e.g. at following examples in the Bonus Pack:

HmiScreen
SubscribeToMany

For illustration, below is a relevant piece from HmiScreen example. It uses a "tag" string configured on form's controls as ItemID, and subscribes to every such item. It then reacts to item data changes and updates the controls with the new value.

I hope this helps.
Zbynek Zahradnik

private void Form1_Load(object sender, EventArgs e)
{
   var argumentsList = new List<DAItemGroupArguments>();
   foreach (Control control in this.Controls)
   {
      var itemId = control.Tag as string;
      if (itemId != null)
         argumentsList.Add(new DAItemGroupArguments("", "OPCLabs.KitServer.2", itemId, 50, control));
   }
   this.easyDAClient1.SubscribeMultipleItems(argumentsList.ToArray());
}

private void easyDAClient1_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
{
   var textBox = e.State as TextBox;
   if (textBox != null && textBox.ReadOnly)
   {
      if (e.Exception == null)
         textBox.Text = e.Vtq.DisplayValue();
      else
         textBox.Text = "** Error **";
   }
}

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

More
09 Dec 2010 12:57 #151 by hbl123
Is ther an example for the SubscribeMultipleItems function?

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

Moderators: support
Time to create page: 0.043 seconds