Skip to main content
Feb 17, 2020 11:19 AM UTC
Solved

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

Feb 17, 2020 2:55 PM UTC

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

3 replies

Feb 17, 2020 2:55 PM UTC

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

Feb 25, 2020 5:16 AM UTC

Hi Raluca..

 

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

Thank you very much.

 

Regards,

Prashant Pandarkar

Feb 24, 2020 4:11 PM UTC

Hi @ppandarkar-2_183531.

 

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