How to create a counter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
Solved! Go to Solution.
- Labels:
-
Troubleshooting
- Tags:
- timers
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
But one moment, why don't you just record starting time, and differentiate seconds between starting time and ending time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks! Carles Coll
