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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Time Counter

mnaeem
15-Moonstone

Time Counter

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

ACCEPTED SOLUTION

Accepted Solutions
cmorfin
19-Tanzanite
(To:mnaeem)

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

View solution in original post

12 REPLIES 12
cmorfin
19-Tanzanite
(To:mnaeem)

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

mnaeem
15-Moonstone
(To:cmorfin)

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

 

 

mnaeem
15-Moonstone
(To:mnaeem)

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

cmorfin
19-Tanzanite
(To:mnaeem)

Hi @mnaeem 

 

I have attached a sample (Timer Thing + Mashup) I did that should make it easier to understand.

In my case all the properties are on the timer Thing, but you can easily have this on separate thing too.

 

Kind regards

Christophe

 

 

mnaeem
15-Moonstone
(To:cmorfin)

Thank you @cmorfin 

I was trying on ptc academic server https://ptcu-thingworx83-fundamentals.portal.ptc.io/Thingworx, where it is not working.

But on internal server where I have installed Thingworx works fine.

Best Regards,

Naeem

mnaeem
15-Moonstone
(To:cmorfin)

Hi @cmorfin ,

I was working on timer thing and I am experiencing that I'm not able to update two time properties in the same timer thing.

I need this kind of functionality for almost 33 signals.

Comment on this will be highly appreciated.

Thanks You!

 

 

cmorfin
19-Tanzanite
(To:mnaeem)

Hi @mnaeem 

 

I am not sure to understand.

If we take back the example I attached earlier, I simply add a new property time2 and update the checkON service with new lines to increment and reset time2 similar to time.

This works fine for me, both time and time2 are being updated.

Are you doing something different ?

 

Maybe you could attach your entities to have a closer look.

 

Thanks

Christophe

 

mnaeem
15-Moonstone
(To:cmorfin)

Thank you @cmorfin 

In attached file only time property is changing not the timeCopy property.

cmorfin
19-Tanzanite
(To:mnaeem)

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

mnaeem
15-Moonstone
(To:cmorfin)

Hi @cmorfin ,

In attachement you can find the exported thing that I'd like to use to update the timer of all properties.

In this not even a single service is working.

Thank You!

Naeem

cmorfin
19-Tanzanite
(To:mnaeem)

@mnaeem 

 

Yes this is the same issue as with the sample data, you need to create a subscription to the timer.

You can have a look at https://community.ptc.com/t5/IoT-Tech-Tips/Timers-and-Schedulers-Best-Practices/m-p/537812 for an example of creating a timer with subscription.

 

Christophe

 

mnaeem
15-Moonstone
(To:cmorfin)

Thank You @cmorfin ,

It was really helpful.

 

Best Regards,

Naeem

Announcements


Top Tags