Skip to main content
1-Visitor
August 22, 2014
Question

Streams and Parameters

  • August 22, 2014
  • 4 replies
  • 6128 views

Hi,

I have a few questions I'm hoping to get some help with:

  1. Playing around with streams and would like to know how to retrieve database values from a table and store it into a stream. I suspect I would need some form of Timer Service to constantly query for values. I would then use those values in a chart between certain time ranges.

2. How would I pass values to a contained mashup that is dynamically bound?

Thanks.

4 replies

victorgan1-VisitorAuthor
1-Visitor
August 25, 2014

Hi,

I'm still having trouble with these two questions. Are these possible to perform within ThingWorx?

Any help would be appreciated. Thanks.

5-Regular Member
August 26, 2014

Victor,

What is your reason for wanting to store this data into a Stream?

To answer your second question, you'll do the following:
  • Bind inputs to each Mashup Parameter.
  • Remove the Mashup you set in step 2 and repeat steps 2-4 for each Mashup.
  • Once you're done, remove the Mashup you set in step 2 and verify that the Mashup is still dynamically bound.
  • Setup Mashup Parameters for each Mashup you'll be displaying in the Contained Mashup widget.


victorgan1-VisitorAuthor
1-Visitor
August 26, 2014

Hi Adam,

Thanks, that worked for setting up parameters on a dynamically bound mashup.

For the stream, I want to set up a stream that queries and records values in a database at a set interval. In essence, if a database is not historizing the data points, be able to perform the historization within Thingworx. If there are other alternatives to the stream, please let me know.

1-Visitor
April 14, 2015

Hi Adam,

I have followed the steps mentioned by you.

TestDBTimer has it's own

Event

, Timer, which fires at the interval you set in the Configuration section. You'll want to create a

Subscription

 to this

Event

. Since you'll be storing this data in a

Stream

, I would create a

Subscription

 to the Timer's

Event

 on the

Stream

 and

 

a

Services

 on the

Stream

 (which you'll call from the

Subscription

) to retrieve values from the database and add a

Stream

 entry.

What is Add a Stream entry..?

How do I check the values in the stream?

When I call the Generic service "GetStreamData"  of Stream Thing, I get only the coloumn names and not the data.Please help.

 

5-Regular Member
April 14, 2015

Hi Raj,

Victor wanted to query a database at a set interval and store the results in a Stream. Adding a Stream entry refers to the Services available on Streams for adding data (e.g., AddStreamEntries, AddStreamEntry). After you've added entries to the Stream, you can query the data by using Services like QueryStreamEntriesWithData.

1-Visitor
April 15, 2015

Hi Adam,

Thanks for the comments. I have followed the below steps and still data is not picked up in stream.

  1. I have created a subscription on the stream to TestDBTimer event with time 60 secs, and snippet: me.TestDBRetrieveService()
  2. stream service TestDBRetrieveService() code snippet:  var result = Things ["TestConnectSQL"].RetrieveTestInfoData()

 

 I am expecting to receive the data from DB and to be added to stream. But the data from DB is not picked up in the stream.

Note: RetrieveTestInfoData()  is working properly and returning a row of DB data. 

1-Visitor
April 15, 2015

What does your actual code snippet look like that Adds the data to the Stream (besides the retrieval of your data)?

1-Visitor
April 15, 2015

Hi Adam & PaiC,

Thanks for pointing out. The stream is working now and picking up data. I want to remove all the entries in the Stream but  only  "DeleteStreamEntry" service is available. I am able to delete only one entry corresponding to streamEntryID.kindly let me know to remove all entries in the stream.

1-Visitor
January 26, 2016

That can be done with PurgeStreamEntries.​ You will be asked for the time interval from which all entries will be removed.