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
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
vtqResults(iItem).Vtq.Quality
Please Log in or Create an account to join the conversation.
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
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
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.
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.
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.
Please Log in or Create an account to join the conversation.
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
Please Log in or Create an account to join the conversation.
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.