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.
- Forum
- Discussions
- Feature Requests & Product Improvement Ideas
- Testing OPC read/write with trial version - VisualFoxPro
Testing OPC read/write with trial version - VisualFoxPro
There are several OPC UA servers (free/free trial) that run on PC and provide simulated data. For experiments such as whether you can read, write and browse, that should be enough. For example:
- prosysopc.com/products/opc-ua-simulation-server
- www.ptc.com/en/products/kepware/kepserverex (with simulation driver)
These you need to install on a PC and run. Without installing anything at all, you can connect to the OPC UA Sample server that we run on the Web - its endpoint is listed in all our code examples.
Best regards
Please Log in or Create an account to join the conversation.
Well, I pretty understand all your advice and practice.
However, what I'm trying to achieve now is to simulate a sample server without have an PLC ready at the moment and in order to read/write and make tests in there.
I was able to test the code for reading (from your FoxPro sample at the address "nsu=http://opcfoundation.org/UA/;i=15183") but that's not a real one, as you said too it's not what I should be doing.
Is there any way to simulate a PLCserver with a kind or real use case? Do you have any reference/address?
I thought that OPCExpert tool or QuickOPC were enough to simulate a PLC but I can't a ready solution until now.
My objective mid-term is to integrate with a real machine (which I didn't have the data yet but I know needs OPCUA) and for this reason, I woul like before to simulate on my own and where the client will share the specs, I'll be ready to test it.
Thanks for any support, very appreciated.
Best regards
Please Log in or Create an account to join the conversation.
And, I am puzzled by what your experiments with the first part are. You are trying to do things that make little sense to me.
- Creating nodes from the client: Although such feature theoretically exists in the specs, no server I am aware of implements it. The nodes in normal servers are controlled by the server, not from the client. They are given by server configuration, or come from underlying systems. Why do you think you need to create a node?
- Working with nodes that exist for internal workings of the OPC UA standard, but have nothing to do with actual application logic. All nodes you have mentioned fall into this category. As I already wrote, it is unlikely that you will need such nodes for any real usage. If you are in UaExpert, you are probably finding such nodes under Root -> Objects -> Server. Do not look there. The useful nodes will be under Root -> Objects -> <something different>.
- The fact that the "system" nodes show you that they are writable in their WriteMask attribute (I think that is what you were referring to) might be a bug in the server. In reality they won't be writable anyway, and if they were, writing to them would either be ignored by the server or will corrupt the server state; certainly nothing useful can come out of it.
The server should have application-related nodes. For example, it might be controlling a temperature of a room, so there would be objects for that, and in them there will be node for a temperature setpoint. So that's where you would be allowed to write to. If you are tasked with some problem to solve, whoever specifies the task should tell you what the client is actually expected to do. Or are you just playing with some "empty" server to get an idea of how things work? And trying to find a node where you can write to?
Best regards
Please Log in or Create an account to join the conversation.
I tried to create a node called 'pippo' with ns=3; s=pippo and tried to write in a value from the UI of OPCExpert.
This is the error I got:
ErrorCode: ffffffff - OPC Expert could not establish a proper connection with OPC Expert UA Server (opc.tcp://vm-sviluppo:57888/opcexpert).
The error code was "0xFFFFFFFF"
Please Log in or Create an account to join the conversation.
I'm getting interesting hints from the topic and the PHP sample. My main doubt is about the node choice. You told me that the node I'm trying to write in is a standard one and so should be impossible to write in there.. Btw I'm also check that 1. The writable value in the properties of this node is 'true' 2. Could I theoretically write a value in the node which are already there? In my example I tried to write a value in the 'Namespace URI' property of the Namespace opcfoundation.org/UA.
Sorry if the question is pretty basic for you.... I feel I just need to understand better.
For example, I could write a value in 'ServerArray' writable=true and Datatype ? System.String[] (1 elements) i=2254?
Or do I need to create some new nodes?
Then I'll restart and getting the right syntax for foxpro.
If that's not clear, is there a chance you may assist me in the first testing phase?
Thanking you again, best regards
GiacoF
Please Log in or Create an account to join the conversation.
The write is fully supported by the trial license, so this is not the reason (as everything else, it works first 30 minutes each time the process is run, then it gives errors - but different from yours).
I do not know where you took the "WriteValueEx" method name you mentioned from - we do not have such method in our API. It is then understandable if it gave error 0x80020006 (DISP_E_UNKNOWNNAME), "Unknown name". The available methods are here: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...pcUA~EasyUAClient_members.html .
Similarly, error 0x8002000e (DISP_E_BADPARAMCOUNT), "Invalid number of parameters." would be expected if you have used the statement you had in your original post (but not in this second post):
oWriteResult = oClient.WriteValue("opc.tcp://vm-sviluppo:57888/opcexpert", cWriteItemID, cValueToWrite, "String")
This leaves me wondering, what is the actual behavior or the error your getting with the new code you posted? On the basic level, the syntax appears right.
While we do not have much examples for Visual FoxPro currently, as it is relatively rare, you can learn a lot from how it is done in other COM-based tools. For example, opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...rite%20a%20single%20value.html show the basic code for writing, and looking at PHP, VB6, or VBScript code can be good guidance. If we bump into something that you will be truly unable to write the code for, I will take it over and attempt to provide the necessary example.
But, I am seeing an additional problem there too. The node you are reading and writing is a standard OPC UA node, "i=15183", corresponds to BrowseResult_Encoding_DefaultJson . This is a low level node, unlikely to be used in any real user program (for writing, but also reading and subscriptions are unlikely&useless). I doubt that it is the one you truly want to work with. And, it certainly is not writable, so even if all the syntax is correct, the WriteValue call would still fail. What is it that you are trying to achieve with the WriteValue?
Best regards
Please Log in or Create an account to join the conversation.
I'm trying out the OPC library for integrating with an industrial machine. I use VisualFoxPro as a language with the trial version and for testing purposes, with the prospect of purchasing the full license.
During my tests, I managed to connect to my own virtual machine using the 'easyuaclientform' example present in the folder of the examples proposed by you and verifying the nodes on the other side with the OPCExpert tool.
I can easily acquire the data of the nodes in reading but, I don't know why, I have difficulty trying to write some value on some node (I think due to syntax problems or in my practices).
I tried different methods like 'WriteValue' or 'WriteValueEx', integrating them in your example. However I always get errors 0x8002000e or 0x80020006.
After various attempts, I suspect that something is wrong in the configuration, or that the free version doesn't allow me to work in writing...
I would like to make sure I can both read and write to a node of an OPC server to continue the tests and purchase the license...
I'm here to ask for help precisely because I would like to understand the functioning of the processes... for example, how could I modify your example so that I can write to an OPC node?
What is the best way to do a basic test?
Based on the code I share, does this seem right as an approach?
I put '00000' as a port number for sample purpose (to keep it private) and I got the error in runtime after the orange line.
Thanks for any help and support
GiacoF
DECLARE INTEGER GetTickCount IN kernel32
THISFORM.OutputEdit.Value = ""
* Instantiate the client object.
oClient = CREATEOBJECT("OpcLabs.EasyOpc.UA.EasyUAClient")
* In order to use event pull, you must set a non-zero queue capacity upfront.
oClient.PullDataChangeNotificationQueueCapacity = 1000
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Subscribing..." + CHR(13) + CHR(10)
* Specify the OPC server item you want to subscribe to
cSubscriptionItemID = "i=15183"
oSubscription = oClient.SubscribeDataChange("opc.tcp://vm-sviluppo:00000/opcexpert", "nsu=http://opcfoundation.org/UA/;i=15183", 1000)
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Processing data change notification events for 1 minute..." + CHR(13) + CHR(10)
EndTick = GetTickCount() + 60000
DO WHILE GetTickCount() < EndTick
oEventArgs = oClient.PullDataChangeNotification(2*1000)
IF NOT ISNULL(oEventArgs)
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + oEventArgs.DisplayString + CHR(13) + CHR(10)
ENDIF
ENDDO
* Writing to OPC server after connection
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Writing to OPC server..." + CHR(13) + CHR(10)
* Specify the OPC server item you want to read
cReadItemID = "i=15183"
* Read the current value of the array node
oReadResult = oClient.ReadValue("opc.tcp://vm-sviluppo:57888/opcexpert", cReadItemID)
IF oReadResult.Succeeded
LOCAL aCurrentValue
aCurrentValue = oReadResult.Value
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Current value of the array node: " + CHR(13) + CHR(10)
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + STRTRAN(aCurrentValue, ",", CHR(13) + CHR(10)) + CHR(13) + CHR(10)
* Append the new value to the array
cNewValue = "New Value"
AADD(aCurrentValue, cNewValue)
* Write the updated array value back to the OPC server
oWriteResult = oClient.WriteValue("opc.tcp://vm-sviluppo:000000/opcexpert", cReadItemID, aCurrentValue)
IF oWriteResult.Succeeded
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Write succeeded." + CHR(13) + CHR(10)
ELSE
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Write failed: " + oWriteResult.Exception + CHR(13) + CHR(10)
ENDIF
ELSE
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Read failed: " + oReadResult.Exception + CHR(13) + CHR(10)
ENDIF
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Unsubscribing..." + CHR(13) + CHR(10)
oSubscription.Unsubscribe()
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Finished." + CHR(13) + CHR(10)
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- Feature Requests & Product Improvement Ideas
- Testing OPC read/write with trial version - VisualFoxPro