cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

OPC UA server connection to Thingworx Composer

augmentor
12-Amethyst

OPC UA server connection to Thingworx Composer

Hello community,

 

For my current project, I need to implement a OPC UA server on top of  a Kuka robot and stream the process data to Thingworx composer. What would be the best way to implement this? Is there a OPC UA client implementation for Thingworx Composer that I could connect to the server? 

 

Thanks a lot for advise!

 

13 REPLIES 13

@augmentor : PTC has OPC UA client extension available at MarketPlace for the purpose.

that has documentation attached as well on its usage and installation. Kindly follow that

 

Thanks

Or you may use the OPC Aggregator (which features OPC-DA and OPC-UA clients) pointed out here https://developer.thingworx.com/resources/downloads/manufacturing-trial-editionand it's the replacement for the old OPC-DA agent and it may become the replacement to OPC-UA client on the marketplace too. OPC Aggregator it's based on Kepware which in theory it's the path to follow.

Thanks, I`ll try both solutions and see what works best!

augmentor
12-Amethyst
(To:rosharma)

Thanks for the information!

augmentor
12-Amethyst
(To:rosharma)

I followed the documentation, unfortunately I have some more questions. 

 

1. In the Documentation it says:

 

"Deploy ThingWorx OPC UA Client
1. Place the ThingWorx_OPC_UA_Client.jar
file and config.json file in a
folder on any server within the
OPC UA servernetwork."

 

This is a University project and I am using the Thwingworx platform etc. via the University network. Do I understand correctly, that I now need to find out where the server with Thingworx installation is located and place the .jar - and .json file there? 

 

2. Also from the documentation:

 

ThingWorx OPC UA Client Startup


"The ThingWorx OPC UA client can be started as a service or using the following command:
java –jar ThingWorx_OPC_UA_Client.jar
The config.json file must be present in the same folder. The parameter settings have to
reflect the overall environment setup.
The client has to be deployed in the same network of the OPC UA server and can be
operated on the ThingWorx server, the OPC UA server or any server in-between."

 

 

What is meant with "start OPC UA client as a service"? Can I start it this way just via the Composer platform? 

Also could I somehow deploy the OPC UA client just through my PC when I`m connected to the Thingworx server network?

 

 

Sorry if the questions are confusing, I hope you know what I`m trying to ask.

 

 

 

 

@augmentor : generally we do setup of ThingWorx and OPC UA servers locally on same system for connectivity.

on query1 : no need to place the files at ThingWorx server side.

 

you downloaded the extension from PTC MArketplace on your system- lets say in D drive

unzip files you shall be able to locate below files. make sure that  ThingWorx_OPC_UA_Client.jar   & config.json files - both should be there in one folder.( not required to be there at thingworx server)

 

on point 2: first import this OPCUAClientExtension_v2.1.zip on platform

then downlaod server as mentioned in document : Please download the ProSys OPC UA Simulation Server from here

execute this ProSys OPC UA server

 

make changes in config.json file like appkey and defining identifier in this column

"opcua_device" : {
"devices": [
{
"identifier": "opcua_device_001",

 

now run jar file ThingWorx_OPC_UA_Client.jar

from command prompt using command : java –jar ThingWorx_OPC_UA_Client.jar

 

augmentor
12-Amethyst
(To:rosharma)

Thanks a lot for the quick reply!

 

I downloaded and unzipped the File (now contains ThingWorx_OPC_UA_Client.jar, config.json and a folder OPCUAClientExtension_v2.1 with some .xml files) and tried to start it with cmd, but it seems that it can not find the config.json and logback.xml file.

 

thats my cmd return:

 

ch.qos.logback.core.joran.spi.JoranException: Could not open [logback.xml].
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:80)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:68)
at com.thingworx.opcua.client.OPCUAClient.main(OPCUAClient.java:39)
Caused by: java.io.FileNotFoundException: logback.xml (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:75)
... 2 more
java.io.FileNotFoundException: .\config.json (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at com.thingworx.opcua.client.config.JSONConfig.<clinit>(JSONConfig.java:62)
at com.thingworx.opcua.client.OPCUAClient.main(OPCUAClient.java:48)

 

I understand that it can not find logback.xml as it is not there (do I need to write that file?) but it should find config.json.. 

 

In the config file, how do I find the correct appkey?

 

Thanks!

keep the attached log file in same folder where OPC client jar and config file is placed.

for appkey you need to define 1 at ThingWorx Platform and use that in config.json file in below field

///////////////////////////////////////////////////////////

ws_connection": {
"host" : "localhost",
"port" : 80,
"app_key" : "f24a062f-8165-4082-ba0a-d322b4db3aee",

augmentor
12-Amethyst
(To:rosharma)

Thanks! I was now able to execute the .jar file but it seems that something is not working yet..

 

My steps were:

1. Create an OPC_UA thing with composer (with RemoteOPCUAEndpoint template).

2. Create an application key on the platform and paste the key to the config file.

3. Modify the config file as following:

////////////////////////////////////

"ws_connection": {
"host" : "10.xxx.xx.xx",    (this is the IP adress i use to access Composer via the Browser)
"port" : 8080,
"app_key" : "de2003fe-b3f4-430f-92a9-0ca556c058dd",
"thing_name" : "OPC_UA_Sim",   

////////////////////////////////////////////////////////

I did not change anything here: 

"opcua_endpoint_connection": {
"host" : "127.0.0.1", 
"port" : 53530,
"server_name" : "OPCUA/SimulationServer",

 

4. Start the SimulationServer

5. Execute the .jar

 

>>>> now no return values occure in the cmd line (would there be some returns if it woked?)

also when I go to Monitor >> Remote Things on the Platform, I see the Thing I created but with and (!) mark and I cannot see my opcua_device_001 in Unbound..

 

I`ll mark the solution once It works 

 

 

PS: I tried the Application Key by trying to change the value of a property of my thing with the following adress command: http://10.128.xx.xx:8080/Thingworx/Things/OPC_UA_Sim/Properties/MyKey?method=put&appKey=de2003fe-b3f4-430f-92a9-0ca556c058dd&value=100

but it does just display the value but doesn`t change by doing this, I can only change it manually on the platform.. maybe this has nothing to do with it but just in case

@augmentor  : could you please mark one of the replies as solution to this post for the benefits of others as well

augmentor
12-Amethyst
(To:rosharma)

Thanks! I was now able to execute the .jar file but it seems that something is not working yet..

 

My steps were:

1. Create an OPC_UA thing with composer (with RemoteOPCUAEndpoint template).

2. Create an application key on the platform and paste the key to the config file.

3. Modify the config file as following:

////////////////////////////////////

"ws_connection": {
"host" : "10.xxx.xx.xx",    (this is the IP adress i use to access Composer via the Browser)
"port" : 8080,
"app_key" : "de2003fe-b3f4-430f-92a9-0ca556c058dd",
"thing_name" : "OPC_UA_Sim",   

////////////////////////////////////////////////////////

I did not change anything here: 

"opcua_endpoint_connection": {
"host" : "127.0.0.1", 
"port" : 53530,
"server_name" : "OPCUA/SimulationServer",

 

4. Start the SimulationServer

5. Execute the .jar

 

>>>> now no return values occure in the cmd line (would there be some returns if it woked?)

also when I go to Monitor >> Remote Things on the Platform, I see the Thing I created but with and (!) mark and I cannot see my opcua_device_001 in Unbound..

 

I`ll mark the solution once It works 

 

 

PS: I tried the Application Key by trying to change the value of a property of my thing with the following adress command: http://10.128.xx.xx:8080/Thingworx/Things/OPC_UA_Sim/Properties/MyKey?method=put&appKey=de2003fe-b3f4-430f-92a9-0ca556c058dd&value=100

but it does just display the value but doesn`t change by doing this, I can only change it manually on the platform.. maybe this has nothing to do with it but just in case

@augmentor i just checked configurations and it worked at my end.

attached is my config file and the folder structure from where i am running OPC UAclient jar (from cmd)

//////////////////////////////////////////////////////

{

"ws_connection": {
"host" : "localhost",
"port" : 8443,
"app_key" : "f3d6b317-e45e-4dc2-8d69-56c172665e7d",
"thing_name" : "*OPCUAEndpoint",
"encryption" : "ssl",
"ignore_ssl_errors" : true,
"connect_retry_interval" : 10000,
"connect_timeout" : 10000,
"auto_scan_mode" : true,
"scan_rate" : 50,
},

"opcua_endpoint_connection": {
"host" : "127.0.0.1",
"port" : 53530,
"server_name" : "OPCUA/SimulationServer",
"security_mode" : "none",
"request_timeout" : 60000,
"identity_provider" : "anonymous"
}

"opcua_device" : {
"devices": [
{
"identifier": "opcua_device_001",
"auto_scan_mode": true,
"scan_rate": 100,
"dataItems" : [
{
"name" : "Counter",
"baseType" : "INTEGER",
"identifier" : "Counter1",
"namespaceIndex" : 5,
"isReadOnly" : false
},
{
"name" : "RandomDouble",
"baseType" : "NUMBER",
"identifier" : "Random1",
"namespaceIndex" : 5,
"isReadOnly" : false
},
{
"name" : "MyString",
"baseType" : "STRING",
"identifier" : "StringDataItem",
"namespaceIndex" : 3,
"isReadOnly" : false
},
{
"name" : "MyBoolean",
"baseType" : "BOOLEAN",
"identifier" : "BooleanDataItem",
"namespaceIndex" : 3,
"isReadOnly" : false
},
{
"name" : "MyDT",
"baseType" : "DATETIME",
"identifier" : "DateTimeDataItem",
"namespaceIndex" : 3,
"isReadOnly" : false
},

{
"name" : "MyText",
"baseType" : "TEXT",
"identifier" : "StringDataItem",
"namespaceIndex" : 3,
"isReadOnly" : false
}
]
}


]
}
}

augmentor
12-Amethyst
(To:rosharma)

Thanks a lot for trying!

 

Unfortunately I still couldn't connect, so I tried the application key tutorial: https://learningconnector.ptc.com/content/tut-4348/what-is-an-application-key

 

I tried this (once with and without the port): http://10.128.54.64/Thingworx/Things/Key_Debug/Properties/MyAppKey?method=put&appKey=bfb2ab7a-38e6-4db5-b398-a256fac7d8cc&vaule=100

 

It seems that there is some kind of connectivity problem because I can not change the value like in the video. 

Could it be that this also causes the problem with the OPC UA connection?

 

Kind regards

Top Tags