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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Dynamically create datastream

aziliotto
4-Participant

Dynamically create datastream

Hi, i need to create dynamically datastream,

i found the snippet code to create a things "runtime". Now i need to create datastreams in a snippet but i can't find documentation on snippet search and on the net. could you please help me ? thanks

1 ACCEPTED SOLUTION

Accepted Solutions
aziliotto
4-Participant
(To:aziliotto)

This is the code for create datastream from snippets, it is the same for a generic object. I was searching for something specialized in stream but a stream is a thing so this code works for me!

var thingName = "RunTimeCreatedDataStream";

var thingDescription = "this is a custom description for "+thingName;

var tagThing = 'MyParent:stream';

var params = {  

     name: thingName /* STRING */,  

     description: thingDescription /* STRING */,  

     thingTemplateName: "Stream" /* THINGTEMPLATENAME */,

     tags: tagThing /* TAGS */

};

//create data stream

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

//assign data shape to datastream

Things[nomeThing].SetDataShape({name:"PersonalShapeName"})

// enable thing and restart

Things[nomeThing].EnableThing();

Things[nomeThing].RestartThing();

View solution in original post

1 REPLY 1
aziliotto
4-Participant
(To:aziliotto)

This is the code for create datastream from snippets, it is the same for a generic object. I was searching for something specialized in stream but a stream is a thing so this code works for me!

var thingName = "RunTimeCreatedDataStream";

var thingDescription = "this is a custom description for "+thingName;

var tagThing = 'MyParent:stream';

var params = {  

     name: thingName /* STRING */,  

     description: thingDescription /* STRING */,  

     thingTemplateName: "Stream" /* THINGTEMPLATENAME */,

     tags: tagThing /* TAGS */

};

//create data stream

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

//assign data shape to datastream

Things[nomeThing].SetDataShape({name:"PersonalShapeName"})

// enable thing and restart

Things[nomeThing].EnableThing();

Things[nomeThing].RestartThing();

Top Tags