Skip to main content
15-Moonstone
February 17, 2020
Solved

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

  • February 17, 2020
  • 2 replies
  • 1898 views

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

Best answer by raluca_edu

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

2 replies

17-Peridot
February 17, 2020

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

15-Moonstone
February 25, 2020

Hi Raluca..

 

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

Thank you very much.

 

Regards,

Prashant Pandarkar

Support
February 24, 2020

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