Skip to main content
1-Visitor
January 17, 2020
Solved

Time Counter

  • January 17, 2020
  • 1 reply
  • 6075 views

Hi,

I'd like to show timer increment every second on mashup, which is based on the property values 1 ON and 0 OFF. I'd like to start counting the time till property has value  (OFF) and the store it in database that I've already connected to my Thingworx.

Your help will be highly appreciated.

Thank You!

Naeem

Best answer by cmorfin

Hi @mnaeem 

 

Ok I see.

You have created a second service checkONCopy to update the timeCopy property.

This service needs to be called by the subscription to the timer otherwise it is never executed and therefore the property is not updated.

You can do this by selecting the tab Subscription and edit the timer subscription, just add a line 

me.CheckONCopy();

 

However, since both service will be executed at the same time, you could probably do everything inside the CheckON service itself by modifying it:

 

if (me.switch === true) {
me.time = me.time + 1;

me.timeCopy = me.timeCopy + 1;
}

 

hope this helps

Christophe

1 reply

19-Tanzanite
January 17, 2020

Hi @mnaeem 

 

One possible solution would be to have a timer thing set at 1 sec, with 2 services:

- one check the value of the on/off property and increment by 1 a time property if it is on

- one to set the value on/off from mashup and if off store the last value in database

 

In the mashup :

- a checkbox bound to the input parameter state of second service

- a led display that takes the value of time property

- an autorefresh set at 1 sec that refreshes the geproperty service to show in LED display

 

Hope this helps

Christophe

mnaeem1-VisitorAuthor
1-Visitor
January 17, 2020

Hi @cmorfin ,

Thank you for very clear explanations.

If I have understood well. I have created a thing with timer base template.

mnaeem_0-1579261288595.png

In this created a services which checks the value of the property created on another thing, if it is equal to 1 it updates the property timer created in Timer Thing.

mnaeem_1-1579261562310.png

 

 

mnaeem1-VisitorAuthor
1-Visitor
January 17, 2020

While changing property signal in Rilevatore_mnaeem

mnaeem_0-1579262023048.png

 

 

It is not updating timer property in Timer Thing.

mnaeem_1-1579261785136.png

 

I think there is something I didn't understand.

 

Thank You,

Naeem