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

Streams and Parameters

Highlighted
Newbie

Streams and Parameters

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.

Tags (1)
16 REPLIES 16

Streams and Parameters

Hi,

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

Any help would be appreciated. Thanks.

Streams and Parameters

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.


Streams and Parameters

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.

Streams and Parameters

While a database that historizes data would be preferable, it is certainly possible to do what you've described using a Stream. You can use a Timer-based Thing or Scheduler-based Thing to schedule an Event to fire at a particular interval and create a Subscription to the Event.

Streams and Parameters

Hi Adam,

Still trying to wrap my head around it. I've created a stream (TestDBStream) and have associated a data shape to it (TestDBShape), which contains all my field definitions that I want. I have also created a timer (TestDBTimer), keeping the defaults and configuration rate of 60 seconds.

Where I am stuck is at the event/subscription. Were you saying I can create an event/subscription on the Timer or should this be done on my database thing? In any case, I attempted to create an event (TestDBRetrieveValues) on the timer and was in the process of adding a subscription to fire the event (TestDBRetrieveValues), but I'm not sure what else needs to be done.

Looking at the subscription on the timer, I feel the source should be my database thing and I was looking at the "Add Stream Entry" script, but not sure if I was going down the right path or what needed to be configured to have the timer retrieve values from the database and store it into the stream.

Any help would be appreciated. Thanks.

Streams and Parameters

Victor,

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.

Streams and Parameters

Hi Adam,

Thanks for the guidance. I have a better understanding conceptually. I've created a subscription on the stream to have the source be the TestDBTimer. I understand that when the timer hits the interval, it should trigger my service on the stream.

The service I am to create on the Stream to retrieve the values from the database, do you have a tutorial on the configuration parameters or what snippets I am to use? I created a service and went to the Entities tab to find my Database Thing and added a service from it. So it added a snippet: var result = Things["TestConnectSQL"].RetrieveTestInfoData(); Testing it throws an error of invalid service name.

And within my Timer Subscription on the stream, how do I configure the snippet to call my service on the stream? I went to the Me tab and added in the service I created, which added in a snippet: var result = me.TestDBRetrieveService();

Sorry for all the questions, new to this and trying to test out the capabilities.

Streams and Parameters

Victor,

Make sure you have saved your RetrieveTestInfoData() Service and saved the Thing on which you created RetrieveTestInfoData(). Since Subscriptions execute asynchronously, you will not return anything from your Subscription. It would simply be – me.TestDBRetrieveService() – no need to assign the output (if any) to result.

Streams and Parameters

Hi Adam,

Thanks for the info, I'll look into doing what you mentioned and let you know.

Thanks!

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________