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.

Read multiple OPC tags

More
17 Nov 2015 08:51 #3681 by support
Replied by support on topic Read multiple OPC tags
I am not sure if I understand the question. Please clarify. Maybe you are trying to say that
vtqResults(iItem).ToString()

displays more information than you need, and that you just want specific pieces of it.
In such case, you need to use specific properties of the vtqResults(iItem), which is an instance of DAVtqResult (see www.opclabs.com/files/onlinedocs/QuickOpc/Latest/Reference/Q...71b-fcd5-0ca4-65e51c165889.htm ). For example, you can extract
vtqResults(iItem).Vtq.Value
or
vtqResults(iItem).Vtq.Quality
Best regards

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

More
16 Nov 2015 20:40 - 17 Nov 2015 08:45 #3677 by pvs
Replied by pvs on topic Read multiple OPC tags
I succeeded to read multiple tags from the OPC server in my application.
Based on your comments I was able to quickly disconnect.
I can visualize in a tekstbox the contents of the results from reading multiple tags.
See piece of code below.
However for each tag I get all the tag information (value, status, type, etc.)
I found the method:
ReadMulitpleItemValues.
What lines should I modify or add to get the values and the status?
Dim vtqResults() As DAVtqResult = EasyDAClient1.ReadMultipleItems(serverName, itemDescriptors)
 
        TextBox1.Text = ""
        ' Count successful results (totalling to previous value)
        For iItem As Integer = 0 To ItemsInGroup - 1
            Debug.Assert(vtqResults(iItem) IsNot Nothing)
            If vtqResults(iItem).Succeeded Then
                successCount = successCount + 1
                TextBox1.Text = TextBox1.Text + " " + vtqResults(iItem).ToString()
 
            End If
        Next iItem
Last edit: 17 Nov 2015 08:45 by support. Reason: code formatting

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

More
16 Nov 2015 18:27 #3676 by pvs
Replied by pvs on topic Read multiple OPC tags
Thanks. Clear. I will ix it.

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

More
16 Nov 2015 16:33 #3675 by support
Replied by support on topic Read multiple OPC tags
The method (in fact, all our methods that take one of their arguments as an array of objects) require that all elements are not null. If you get the error message indicating that they are not all null, then you need to fix it on your side; it is a general (or VB.NET specific) programming task that in itself has nothing to do with QuickOPC.

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

More
16 Nov 2015 15:55 #3674 by pvs
Replied by pvs on topic Read multiple OPC tags
When I explicitely define the size of the item-descriptor array

Public itemDescriptors(0 To 4) As DAItemDescriptor

The error disappears. Can you explain this for me?
Apparently the size of the item-descriptor array is unknown in the timer-loop. Could it be that the size remains local for the form-Load?

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

More
16 Nov 2015 15:31 #3673 by pvs
Replied by pvs on topic Read multiple OPC tags
I moved back the filling of the item-descriptors to the form_load.
Now I have the following error message.
I do not understand the meaning.

System.ArgumentException was unhandled
HResult=-2147024809
Message=Precondition failed: (itemDescriptorArray == null) || Contract.ForAll(itemDescriptorArray, elem => elem != null) Null element in itemDescriptorArray.
Parameter name: Null element in itemDescriptorArray.
ParamName=Null element in itemDescriptorArray.
Source=OpcLabs.EasyOpcClassicInternal
StackTrace:
at System.Diagnostics.Contracts.__ContractsRuntime.Requires[TException](Boolean condition, String msg, String conditionTxt)
at OpcLabs.EasyOpc.DataAccess.IEasyDAClientExtension.ReadMultipleItems(IEasyDAClient easyDAClient, ServerDescriptor serverDescriptor, DAItemDescriptor[] itemDescriptorArray)
at QuickOPC_Test1.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\VB2013Projects\QuickOPC_Test1\QuickOPC_Test1\QuickOPC_Test1\Form1.vb:line 51
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at QuickOPC_Test1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

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

More
16 Nov 2015 15:21 #3672 by pvs
Replied by pvs on topic Read multiple OPC tags
I followed your suggestion.
I moved the single read to the Form_load and enabled the timer after that read. In this way I am sure the connection to the OPC-server is made.
I still have the same error message.
Then I moved the filling of the item-descriptors to the Timer-loop. This made the error message disappear. However I want to fill the descriptors only once. Could it have to do with the size of the item-descriptor array?

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

More
16 Nov 2015 10:28 #3671 by pvs
Replied by pvs on topic Read multiple OPC tags
Thank you. I will give it a try and keep you informed.

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

More
16 Nov 2015 09:33 - 16 Nov 2015 09:33 #3669 by support
Replied by support on topic Read multiple OPC tags
The problem is described in the exception itself. You are passing in a null reference in the itemDescriptorArray argument to the ReadMultipleItems method.

From looking at your code, it is likely that the timer fires before the code in Form_Load, which can explain it. You must make sure you first initialize your itemDescriptors() array, and only then start the timer.

Best regards
Last edit: 16 Nov 2015 09:33 by support. Reason: typo corr.

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

More
16 Nov 2015 08:54 #3667 by pvs
Replied by pvs on topic Read multiple OPC tags
I received the following exception message:


System.ArgumentNullException was unhandled
HResult=-2147467261
Message=Precondition failed: value != null itemDescriptorArray
Parameter name: itemDescriptorArray
ParamName=itemDescriptorArray
Source=OpcLabs.EasyOpcClassicInternal
StackTrace:
at System.Diagnostics.Contracts.__ContractsRuntime.Requires[TException](Boolean condition, String msg, String conditionTxt)
at OpcLabs.EasyOpc.DataAccess.IEasyDAClientExtension.ReadMultipleItems(IEasyDAClient easyDAClient, ServerDescriptor serverDescriptor, DAItemDescriptor[] itemDescriptorArray)
at QuickOPC_Test1.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\VB2013Projects\QuickOPC_Test1\QuickOPC_Test1\QuickOPC_Test1\Form1.vb:line 48
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at QuickOPC_Test1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

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

Moderators: support
Time to create page: 0.068 seconds