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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to create thing from Edge micro server ?

mpatel-21
12-Amethyst

How to create thing from Edge micro server ?

Hello Expert ,

I want to develop Edge micro server (Java) agents to remote thing with file transfer, I have multiple system who run this same agent but problem is same agent can't connect with single remote thing in thingworx using web socket , So if you know how can I connect multiple EMS agent in thingworx or every time if different agent run then create remote thing in thingworx.

If Thing is present in thingworx then directly connect otherwise create new thing in Thingworx.

Please let me know if any one have ans.

Thanks

ACCEPTED SOLUTION

Accepted Solutions

So if I understand you correctly  , rather than mapping a Virtual thing from Java SDK to a Remote Thing Created in Thingworx , You want Java SDK to be code din a way that it creates a Thing on Thingworx server Using specific template from Thingworx .

There are severals ways with which you can acheive this ,  I am giving you a rough idea , how I achived this (as some one asked similar question few days ago)

tep 1 Create a new Template named as "TemplateForCreatingThingsRemotely" from Remote Template.

Step 2  Add Service with Name "CreateThing"  with one input which would be name of  new Thing which will be created

Example Script :

var params = {

  name: NameOfThing /* STRING */,

  description: me.description /* STRING */,

  thingTemplateName: me.thingTemplate /* THINGTEMPLATENAME */,

  tags: me.tags /* TAGS */

};

// no return

Resources["EntityServices"].CreateThing(params);

Step 3 , Create a Thing Extending this newly created Template.

Step 4 Test the Service .

Now you need to call the service of first Thing which you have created from "TemplateForCreatingThingsRemotely"from Edge or Java SDK.

Please do let me know if you find this useful or if  you need further clarification or help on this.

View solution in original post

6 REPLIES 6

So if I understand you correctly  , rather than mapping a Virtual thing from Java SDK to a Remote Thing Created in Thingworx , You want Java SDK to be code din a way that it creates a Thing on Thingworx server Using specific template from Thingworx .

There are severals ways with which you can acheive this ,  I am giving you a rough idea , how I achived this (as some one asked similar question few days ago)

tep 1 Create a new Template named as "TemplateForCreatingThingsRemotely" from Remote Template.

Step 2  Add Service with Name "CreateThing"  with one input which would be name of  new Thing which will be created

Example Script :

var params = {

  name: NameOfThing /* STRING */,

  description: me.description /* STRING */,

  thingTemplateName: me.thingTemplate /* THINGTEMPLATENAME */,

  tags: me.tags /* TAGS */

};

// no return

Resources["EntityServices"].CreateThing(params);

Step 3 , Create a Thing Extending this newly created Template.

Step 4 Test the Service .

Now you need to call the service of first Thing which you have created from "TemplateForCreatingThingsRemotely"from Edge or Java SDK.

Please do let me know if you find this useful or if  you need further clarification or help on this.

Hi Ravi,

It is helpful to me for thingworx side but how can I use this for EMS side , Let you clear what is thought behind of this , Actually I want create a agent who can run many machine and same in thingworx using RemoteThing with file transfer and tunnel Thing create each thing for agent machine. So i need code in EMS side for create thing then after connect it RemoteThing with file transfer and tunnel.

I am not part of this partner communities so i can't access How can we programmatically create device template in our own application? this  link.

I sent a request to join this.


Thanks

No issues Mayank , if you are not able to access that .

There are numerous ways to achieve this.

Firstly , Once a Virtual Object from Java SDK is binded with Remote Thing on Thingworx server , all the properties can be pushed from Virtual object to Remote Thing on Thingworx , and you can put an alert against any such properties to call a service once certain specified condition is met. I mean you can call service depending on value of any property.

Secondly , You can invoke a service on Thing from Client application.

I am sending you a small documentation wherein an example code is given for service invoked from from Java SDK .

Mayank Patel​ You can also check this thread and may find it useful.

How can we programmatically create device template in our own application?

Mayank , you might like to have a look on the give below discussion :

Run a local service from SDK

This seems to be similar issues as requirement seems to be quite similar.

Do let me know me if you find this helpful.

Thanks Ravi I done my work

Announcements


Top Tags