Professional OPC
Development Tools

logos

How to Decode the DAVtq ?

More
07 Nov 2014 20:21 #2504 by pgilbert
Replied by pgilbert on topic How to Decode the DAVtq ?
What is odd is that I can ask for the available properties by doing:

'OPCClient.VAQ' ⎕wi 'properties'
children class clsid data def description errorcode errormessage events instance interface links methods modified modifystop name obj opened pending progid properties self state suppress version xQuality xTimestamp xValue

So xQuality, xTimestamp and xValue should be available to interrogate but it is not working. I never used before the greater than sign '>' (as suggested in the documentation to resolve ambiguous call to a property), usually if it appears in the list of properties it is working.

I will continue my readings and experimentations.

Thanks for your help

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

More
07 Nov 2014 19:23 #2503 by support
Replied by support on topic How to Decode the DAVtq ?
OK, but you are quite lucky that in this particular case the information can be extracted from DisplayValue() or ToString(). With other objects (not sure if you are going to need them), this will not always be the case.

What about the hint contained in the error message:

use ">", "<", or "@" to request proper invocation

Use are using ">" - what are the others for?

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

More
07 Nov 2014 19:14 #2502 by pgilbert
Replied by pgilbert on topic How to Decode the DAVtq ?
I will work with the methods and that should do it. I must say for the benefits of APL2000 that I don't have an up-to-date version and I suppose that the latest version is working correctly with the properties also.

Thanks again for your help.

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

More
07 Nov 2014 19:02 #2501 by support
Replied by support on topic How to Decode the DAVtq ?
DisplayValue, HasValue, and ToString are actually methods (with no arguments), while the others (Value, Timestamp, Quality) are properties. This may be differentiating factor (or, it can be due to their data type, but I think it is less likely).

This is how the IDAVtq is actually declared in our code:
/// <summary>Holds data value, timestamp and quality, abbreviated sometimes as VTQ. This is a common combination in OPC,
/// e.g. returned when an OPC item is read.</summary>
/// \incpart{Example (JScript),IEasyDAClient.ReadItem.Main.js,//+++,//---}
/// \incpart{Example (VBScript),IEasyDAClient.ReadItem.Main.vbs,Rem+++,Rem---}
[
	object,
	uuid(7C486189-8B81-4902-83E0-8F695F6786FB),	// IID changed for V5.0
	dual,
	oleautomation,
	nonextensible,
	helpstring("Holds data value, timestamp and quality, abbreviated sometimes as VTQ"),
	pointer_default(unique)
]
interface IDAVtq : IDispatch
{
	/// <summary>Gets or sets the data value.</summary>
	[propget, id(1), helpstring("Gets or sets the data value")] 
	HRESULT Value([out, retval] VARIANT *pVal);
	//[propput, id(1), helpstring("property Value")] HRESULT Value([in] VARIANT newVal);
 
	/// <summary>Gets or sets the timestamp.</summary>
	[propget, id(2), helpstring("Gets or sets the timestamp")] 
	HRESULT Timestamp([out, retval] DATE *pVal);
	//[propput, id(2), helpstring("property Timestamp")] HRESULT Timestamp([in] DATE newVal);
 
	/// <summary>Gets or sets the quality.</summary>
	[propget, id(3), helpstring("Gets or sets the quality")] 
	HRESULT Quality([out, retval] LONG *pVal);
	//[propput, id(3), helpstring("property Quality")] HRESULT Quality([in] LONG newVal);
 
	/// <summary>Formats the data value for display.</summary>
	/// <param name="pvarResult">Receives the return value.</param>
	/// <returns>Returns the formatted data value.</returns>
	/// <remarks>Returns empty string when the quality is bad. The current data value can be a null reference.</remarks>
	[id(101), helpstring("Formats the data value for display")] 
	HRESULT DisplayValue([out, retval] VARIANT* pvarResult);
 
	/// <summary>Returns whether the <see cref="Value"/> contains valid data.</summary>
	/// <param name="pvarResult">Receives the return value.</param>
	/// <returns>Returns True when the <see cref="Quality"/> is not Bad.</returns>
	[id(102), helpstring("Returns whether the Value contains valid data")] 
	HRESULT HasValue([out, retval] VARIANT* pvarResult);
 
	/// <summary>Returns a string that represents the current <see cref="DAVtq"/>.</summary>
	/// <param name="pvarResult">Receives the return value.</param>
	/// <returns>A string representation of the current value, timestamp and quality.</returns>
	/// <remarks>
	/// <para>When the quality is bad, the returned string contains just the timestamp and quality. Otherwise, the
	/// returned string contains also the data value, and its type.</para>
	/// </remarks>
	/// \incpart{Example (JScript),IEasyDAClient.ReadItem.Main.js,//+++,//---}
	/// \incpart{Example (VBScript),IEasyDAClient.ReadItem.Main.vbs,Rem+++,Rem---}
	[id(103), helpstring("Returns a string that represents the current DAVtq")] 
	HRESULT ToString([out, retval] VARIANT* pvarResult);
};

Isn't there a separate, different syntax in your language to access the properties?

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

More
07 Nov 2014 16:12 #2500 by pgilbert
Replied by pgilbert on topic How to Decode the DAVtq ?
OK we are going somewhere now, if I do the following in APL2000:

'OPCClient' ⎕WI 'XReadItem > .VAQ' '' 'OPCLabs.KitServer.2' 'Demo.Ramp'

The following 3 methods are working:

'OPCClient.VAQ' ⎕wi 'XHasValue'
1
'OPCClient.VAQ' ⎕wi 'XDisplayValue'
-2.6082706451416
'OPCClient.VAQ' ⎕wi 'XToString'
-2.6082706451416 {VARTYPE(5)} @07-Nov-14 10:59:24 AM; OPCQUALITY(192)

However the following 3 properties are not working:

'OPCClient.VAQ' ⎕wi 'xValue'
⎕WI ACTION ERROR: Ambiguous invocation: use ">", "<", or "@" to request proper invocation

'OPCClient.VAQ' ⎕wi 'xValue >'
2
'OPCClient.VAQ' ⎕wi 'xTimestamp >'
4
'OPCClient.VAQ' ⎕wi 'xQuality >'
3

The XDisplayValue is returning the proper value but in characters. It is easy to convert it to a numerical value but would prefer to use the xValue property. Any idea that could help ?

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

More
07 Nov 2014 12:39 - 07 Nov 2014 12:39 #2497 by support
Replied by support on topic How to Decode the DAVtq ?
Actually, I was wrong, ReadItem returns a DAVtq directly (not a DAVtqResult) - see www.opclabs.com/files/onlinedocs/QuickOpc/Latest/Reference/Q...7ced255037b75bba1a633562457010 , but this does not affect the principle of the problem.

I think the issue may come from the fact that in the interface, the result is typed as a generic VARIANT, and not IDAVtq. This is intentional, because some tools (namely, VBScript) cannot work with anything else. In addition, many tools use late-binding, meaning that you can take the returned object, specify a property on it, and it will see that the VARIANT contains IDispatch and it will use the type library/IDispatch to figure it all out.

Yours may be one of the tools that do not do this, and in these cases it is necessary to have some language construct that specifies that the returned value, while declared as VARIANT, is supposed to actually contain an IDAVtq pointer. Not knowing your language, I cannot currently tell how this is done. Is there any documentation describing the COM interoperability aspects of the language that I can look at?

Best regards
Last edit: 07 Nov 2014 12:39 by support.

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

More
07 Nov 2014 12:28 #2496 by pgilbert
Replied by pgilbert on topic How to Decode the DAVtq ?
I think that ReadItem is returning a pointer to a DAVtqResult object in my case. Is there any methods that would accept this pointer ? In the negative is there other method(s) that will return the value and quality of a tag similarly to ReadItem.

Thanks in advance.

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

More
07 Nov 2014 07:14 #2492 by support
Replied by support on topic How to Decode the DAVtq ?
No, ReadItem returns a DAVtqResult object ( www.opclabs.com/files/onlinedocs/QuickOpc/Latest/Reference/QuickOpcCom/a00261.html ) which has properties likes Exception, or Vtq. In case of no exception, the Vtq further contains a DAVtq object ( www.opclabs.com/files/onlinedocs/QuickOpc/Latest/Reference/QuickOpcCom/a00119.html ) which has properties like Value, Timestamp, Quality. You can verify this e.g. using the VBScript code samples that are right on the Web pages I linked to (and are also included with the product installation).

If you are not seeing these objects, but a number instead, I think there is something done wrong on the consuming side of things.

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

More
06 Nov 2014 21:23 #2491 by pgilbert
While using OPCLabs.EasyDAClient.5.2 I am able to get the tag value on an OPC server using ReadItemValue. To get some speed we would like to use instead ReadItem like it is recommended in the documentation. However the item that is returned while using ReadItem (we are using APL2000 as our programming language) is a positive number (just a number, no properties, no methods).

Question 1: Is this number the numerical representation of the DAVtq ?
Question 2: In the affirmative how to 'decode' this numeric DAVtq to obtain the Value, Time and Quality ?

Thanks in advance.

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

Moderators: support
Time to create page: 0.213 seconds

      

 Recommend this on Google