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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to create thingworx app to change properties value by random number with timer?

ppandarkar-2
15-Moonstone

How to create thingworx app to change properties value by random number with timer?

Hi,

I want to create a things which properties should get change in some interval of time e.g. 30second with random number. So pls can you suggest how to do this.

 

I have created thing template and things but unable to link and configure timer.

 

So pls can you suggest how to do this, mainly i am facing issue to configure timer thing which will run in 30sec and change properties value.

 

Regards,

Prashant Pandarkar

ACCEPTED SOLUTION

Accepted Solutions

Hi,

 

Create a thing, choose its template "Timer", insert "Run as User" the user you want to run; Update rate: 30000; check Enabled checkbox.

Go to Subscriptions of Timer, create new, choose event = Timer.

 

I have used the following code: 

Things["mything"].prop1 = Math.floor(Math.random() * 10);
logger.warn("Value: " +Things["test_timer"].prop1);

 

Then Save.

 

my thing = a thing different than the timer;

prop1 = number property;

 

Every 30 sec, the prop1 is updated and the value is written in Script.log

 

Hope it helps,

Raluca Edu

View solution in original post

3 REPLIES 3

Hi,

 

Create a thing, choose its template "Timer", insert "Run as User" the user you want to run; Update rate: 30000; check Enabled checkbox.

Go to Subscriptions of Timer, create new, choose event = Timer.

 

I have used the following code: 

Things["mything"].prop1 = Math.floor(Math.random() * 10);
logger.warn("Value: " +Things["test_timer"].prop1);

 

Then Save.

 

my thing = a thing different than the timer;

prop1 = number property;

 

Every 30 sec, the prop1 is updated and the value is written in Script.log

 

Hope it helps,

Raluca Edu

Hi Raluca..

 

Thanks for your comment. The given solution seems to be working for me.

Thank you very much.

 

Regards,

Prashant Pandarkar

slangley
23-Emerald II
(To:ppandarkar-2)

Hi @ppandarkar-2.

 

If the response provided by Raluca answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Announcements


Top Tags