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.

Need help on WriteMultipleItems or WriteMultipleItemValues in VB.NET

More
28 Jul 2016 07:49 #4284 by Sandro@More

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

More
27 Jul 2016 14:54 #4277 by support
The code for subscription is OK in general.

Here is an example for WriteMultipleItemValues:
' This example shows how to write values into multiple items.
 
Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.OperationModel
 
Namespace _EasyDAClient
    Friend Class WriteMultipleItemValues
        Public Shared Sub Main()
            Dim easyDAClient = New EasyDAClient()
 
            Dim argumentsArray = New DAItemValueArguments() { _
                New DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 12345), _
                New DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_BOOL", True), _
                New DAItemValueArguments("", "OPCLabs.KitServer.2", "Simulation.Register_R4", 123.45) _
            }
 
            Dim resultsArray As OperationResult() = easyDAClient.WriteMultipleItemValues(argumentsArray)
 
            For i = 0 To resultsArray.Length - 1
                Debug.Assert(resultsArray(i) IsNot Nothing)
                Console.WriteLine("resultsArray[{0}].Succeeded: {1}", i, resultsArray(i).Succeeded)
            Next i
        End Sub
    End Class
End Namespace

Let me know if you need further help.

Best regards

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

More
27 Jul 2016 14:26 #4276 by Sandro@More
It would be great if you can show me how exactly to do this based on my code.
In your opinion the code I wrote for reading the tags is valid or there are others solutions ?


Thanks
Sandro

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

More
27 Jul 2016 14:20 #4275 by support
Calling WriteMultipleItemValues is similar to SubscribeMultipleItems, in that you need to prepare an array of argument objects upfront, and then make a single call. What exactly isn't clear about it?

If we provide an example with WriteMultipleItemValues (and talking to our simulation server, for verification), would that help ?

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

More
27 Jul 2016 13:38 - 27 Jul 2016 14:16 #4274 by Sandro@More
Hi guys,
I have not found any solution on my problem in the forum so please I need some help.
I wroted a VB.NET 2015 program that read from PLC (for debugging I use MATRIKONOPC Simulator) using SubscribeMultipleItems
and receiving data with the event EasyDAClient.ItemChanged and this works well (for the moment).
It's clear also how to write a single item but it is too slow to use this for my project.
What I need is a example on how to use WriteMultipleItems and WriteMultipleItemValues based on my program.

I want to send all the DTPWC_OPCItemIDs() with the relative tag value faster than possible.

Any idea ?

'..
sOPCServerNode = "127.0.0.1"
sOPCServerName = "Matrikon.OPC.Simulation.1"
sOPCAccessPath = "MorePlc.ENB.BACKPLANE.LOGIX5000"
' items to read from PLC
DFPWS_ItemCount = 5
DFPWS_OPCItemIDs(1) = sOPCAccessPath & "." & "PSF_WS_MORE_PLC_WDOG_CNT"
DFPWS_OPCItemIDs(2) = sOPCAccessPath & "." & "PSF_WS_PWRON"
DFPWS_OPCItemIDs(3) = sOPCAccessPath & "." & "PSF_WS_STA"
DFPWS_OPCItemIDs(4) = sOPCAccessPath & "." & "PSF_WS_ACT_BCK"
DFPWS_OPCItemIDs(5) = sOPCAccessPath & "." & "PSF_WS_ACT_HEAT"
'
' items to write from PLC
DFPWS_ItemCount = 3
DTPWC_OPCItemIDs(1) = sOPCAccessPath & "." & "PSF_WC_WDOG"
DTPWC_OPCItemIDs(2) = sOPCAccessPath & "." & "PSF_WC_SETP_TRIG"
DTPWC_OPCItemIDs(3) = sOPCAccessPath & "." & "PSF_WC_CNT_RST"
'
tbDFPWC_OPCItemIDs_1.Text = "0"
tbDFPWC_OPCItemIDs_2.Text = "0"
tbDFPWC_OPCItemIDs_3.Text = "0"
'..
EasyDAClient.UnsubscribeAllItems()
'
Dim DFPWS_TagList = New List(Of DAItemGroupArguments)()
For iDataFromPLC = 1 To DFPWS_ItemCount
    DFPWS_TagList.Add(New DAItemGroupArguments(sOPCServerNode, sOPCServerName,DFPWS_OPCItemIDs(iDataFromPLC), 100, ""))
Next
EasyDAClient.SubscribeMultipleItems(DFPWS_TagList.ToArray())
 
 
 
    Public Sub UpdateTags(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs) Handles EasyDAClient.ItemChanged
        Dim ItemValue
        Try
            If e.Vtq.Quality = 192 Then
                If e.Vtq Is Nothing Then ItemValue = "0" Else ItemValue = e.Vtq.DisplayValue()
                '
                Select Case e.Arguments.ItemDescriptor.ItemId
                    Case DFPWS_OPCItemIDs(1) : tbDFPWS_OPCItemIDs_1.Text = ItemValue
                    Case DFPWS_OPCItemIDs(2) : tbDFPWS_OPCItemIDs_2.Text = ItemValue
                    Case DFPWS_OPCItemIDs(3) : tbDFPWS_OPCItemIDs_3.Text = ItemValue
                    Case DFPWS_OPCItemIDs(4) : tbDFPWS_OPCItemIDs_4.Text = ItemValue
                    Case DFPWS_OPCItemIDs(5) : tbDFPWS_OPCItemIDs_5.Text = ItemValue
                End Select
            End If
        Catch
            DisplayException(e.Exception)
        End Try
    End Sub
 
 
    Private Sub btDFPWC_OPCItemIDs_1_Click(sender As Object, e As EventArgs) Handles btDFPWC_OPCItemIDs_1.Click
        EasyDAClient.WriteItemValue(sOPCServerNode, sOPCServerName, DTPWC_OPCItemIDs(1), tbDFPWC_OPCItemIDs_1.Text)
    End Sub
    Private Sub btDFPWC_OPCItemIDs_2_Click(sender As Object, e As EventArgs) Handles btDFPWC_OPCItemIDs_2.Click
        EasyDAClient.WriteItemValue(sOPCServerNode, sOPCServerName, DTPWC_OPCItemIDs(2), tbDFPWC_OPCItemIDs_2.Text)
    End Sub
    '..
Last edit: 27 Jul 2016 14:16 by support. Reason: code formatting

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

Moderators: support
Time to create page: 0.067 seconds