Skip to main content
1-Visitor
January 16, 2017
Solved

How to create a counter

  • January 16, 2017
  • 7 replies
  • 5781 views

Hi All,

I'm new in Thingworx, i facing a problem below:

I want to create a Thing/Services that contain the information below

1. Input parameter named "machine_Run", base type "Boolean"

2. A variable named "total_Qty", is integer/long

3. With the condition machine_Run = 1, "total_Qty" will keep on increase (total_Qty = total_Qty +1; every sec +1 if possible)

4. When machine_Run changed from 1 to 0, will insert a single record into SQL (DateTime and total_Qty)

5. Is it possible to make the Thing/Services to run in background?

Best answer by CarlesColl

Then if it's for live update, you should go with the timer.

To present the data, use "Push Properties" on the mashup this way the quantity will update live with data from the server, no Pull needed.

7 replies

1-Visitor
January 16, 2017

You can create a Timer thing which triggers every Second and does the total_Qty+1 execution. But take care, TW it's not a real time system then timer events can or can't be executed "on time".

1-Visitor
January 16, 2017

But one moment, why don't you just record starting time, and differentiate seconds between starting time and ending time?

tjason1-VisitorAuthor
1-Visitor
January 16, 2017

Carles Coll. Thanks for your suggestion.

It is a good idea on create a timer thing and trigger total_Qty + 1 execution.

Agree, this TW is not a real time system.

I just want to develop a demo system to my client.

While the machine is running, the production count will increase. And the production count will stop if the machine is stopped.

Do you have better idea on how to present it in TW?