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
Something like this (not tested in compiler) should work:* Put Quality into a INT variable
int quality = (int)(DAVtqPtr->Quality->NumericalValue);
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 .* split Timestamp into a struct with date and time
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.* Then I would like to create as Case based on the datatype.
Best regards
Please Log in or Create an account to join the conversation.
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.
_DAVtqResultPtr DAVtqResultPtr(ResultArray[0]);
_DAVtqPtr DAVtqPtr(DAVtqResultPtr->Vtq);
Convert_SZSTR_to_S7STRING(DAVtqPtr->ToString, opcValue);
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.
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.
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.
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
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I guess one of the reasoins is that I'm quite new to c++
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
Please Log in or Create an account to join the conversation.
Is it now possible to build our examples ?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.