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.

C++ #include problem

More
18 Aug 2016 06:48 #4302 by support
Replied by support on topic C++ #include problem
I understand, but unfortunately this is beyond the scope of our support. I would at least try to give some hints:

* Put Quality into a INT variable

Something like this (not tested in compiler) should work:
int quality = (int)(DAVtqPtr->Quality->NumericalValue);

* split Timestamp into a struct with date and time

Use functions designed for the DATE type, see e.g. msdn.microsoft.com/en-us/library/82ab7w69.aspx or better, ATL/MFC wrappers around that type, e.g. msdn.microsoft.com/en-us/library/38wh24td.aspx or msdn.microsoft.com/en-us/library/a1z81fxe.aspx .

* Then I would like to create as Case based on the datatype.

The VARIANT (and its wrappers) contains a 'VARTYPE vt' field that can be used for that. See e.g. msdn.microsoft.com/en-us/library/windows/desktop/ms221627(v=vs.85).aspx . The VARTYPE has constants such VT_I4 that can be used for the switch/case statement.

Best regards
The following user(s) said Thank You: olab

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

More
18 Aug 2016 06:37 #4301 by olab
Replied by olab on topic C++ #include problem
Thank you for your help so far, but I think I must ask again.

I would like to handle the result as follows:
* Put Quality into a INT variable
* split Timestamp into a struct with date and time
* Then I would like to create as Case based on the datatype.

If datatype Double then move into a double variable.
If datatype Bool then move into a bool variable.
If datatype Int then move into a int variable.

This i probaly easy stuff.... For those who know c++, but I unfortunately, don't...

Can you please provided me some information or samples here??


Kind regards.

O

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

More
16 Aug 2016 11:29 #4300 by support
Replied by support on topic C++ #include problem
You currently have following lines in your code:
_DAVtqResultPtr DAVtqResultPtr(ResultArray[0]);
_DAVtqPtr DAVtqPtr(DAVtqResultPtr->Vtq);
 
Convert_SZSTR_to_S7STRING(DAVtqPtr->ToString, opcValue);
In other words, you are extracting the Vtq property into _DAVtqPtr, and then calling its ToString.

The three pieces of information you are asking about are available as properties on the _DAVtqPtr, e.g.:
DAVtqPtr->Value
DAVtqPtr->Quality
DAVtqPtr->Timestamp

As to their types, Value is a VARIANT (use can use _variant_t), Quality is a _DAQuality object (from which you can extract its numerical value using its NumericalValue property, which is a long), and Timestamp is a DATE.

I hope this helps

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

More
15 Aug 2016 18:14 #4299 by olab
Replied by olab on topic C++ #include problem
Thank you for yoru response,

My project is based on one of opclab's examples. Based on this my project returns the result probably from an array presented as a long string.

Can you tell me how to put each value into separate variables:
-Value
-TimeStamp
-Quality

Kind regards

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

More
15 Aug 2016 15:20 #4298 by support
Replied by support on topic C++ #include problem
I am glad it works. The read squiggles come from IntelliSense. Whenever there is no actual compiler error, but IntelliSense does indicates an error in this way, you should either ignore it, or report it to Microsoft.

I can only express my opinions to the part of code that actually calls the OPC operations. This is fine as it is now (with one item), but I can see it was planned to support multiple items. When you get to do so, make sure you keep using the ReadMultipleItems and give it an array with the arguments for all the items. This would be fast. Do not call the ReadMultipleItems in a loop, if you know the items upfront - that would be slow.

Best regards

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

More
15 Aug 2016 10:56 #4297 by olab
Replied by olab on topic C++ #include problem
Greetings,

Thinks is starting to work here now. I think I got confused by a lot of curled red lines under my code. Don't know why this is happening. It happens even in your example projects in VS2013 Pro.

Well, as long as my code is working everybody is happy (I think).

Attached project is using the Simatic ODK to setup a connection between a S7-1500 soft plc and an opc server (S7 as client).

The project is not finished yet but I wonder: Will this code work efficient or is there a better way to do it?

Ola

File Attachment:

File Name: HIASFronEnd.zip
File Size:24,287 KB
Attachments:

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

More
03 Aug 2016 20:35 #4290 by support
Replied by support on topic C++ #include problem
Zip your project and upload the file with your forum post. I will have a look at it but only after August 14th when I am back in office.

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

More
02 Aug 2016 11:01 - 02 Aug 2016 11:01 #4287 by olab
Replied by olab on topic C++ #include problem
Sorry but I'm comletly stuck here.
I guess one of the reasoins is that I'm quite new to c++ :huh:

My final goal is to create a c++ dll project that make use op an opc connection as client.
I use Siemens' odk template for this.

As I mentioned earlier I tried to set references to the opclabs libraries. This gives me Runtime Errer R6033 when testing.

I have also tried using #import "libid:xxxxxx" but this gives me an error saying Error cannot open source file....

Even your sample project QuicOpcComCppExamples is giving me this error.

I'm currently using v 5.35 of the toolkit now.

I'm getting desperate here....


Ola
Last edit: 02 Aug 2016 11:01 by olab.

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

More
27 Jul 2016 17:18 #4283 by support
Replied by support on topic C++ #include problem
Which steps have you taken and what does not work and how?
Is it now possible to build our examples ?

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

More
27 Jul 2016 16:51 #4282 by olab
Replied by olab on topic C++ #include problem
I've upgraded to Visual Studio 2013 Professional now but it still won't work....

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

Moderators: support
Time to create page: 0.062 seconds