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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to create a counter

tjason
1-Newbie

How to create a counter

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

7 REPLIES 7

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".

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

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?

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.

This should be a good method, thanks.

Do you mind to share me some information regarding the "Push Properties"? I tried to understand from the knowledgebase below, but i cant.

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS243895&art_lang=en&posno=1&q=getproperties&source=search

Hi Tan,

The clue it's on this part of the document ( you should be at least at TW 7.2 ):

Enabling Automatic Property Updates:

  • The Automatic Property Update functionality is provided as an option on the GetProperties service.
    • When the GetProperties service is selected in the Data Tab, the Service Properties panel (lower right) displays a checkbox labeled Automatically update values when able, which enables the auto-update functionality.
  • After a property update has been received, the GetProperties service's ServiceInvokeCompleted event is fired, allowing the mashup to perform any additional updates that may be required as a result of the change.
    • Note: The properties to be displayed on the Mashup should be bound from the GetProperties service

Thanks! Carles Coll

Top Tags