How do I use timer.value in expression tag

I want to use the Value of Timer in an expression to work out the work rate of a machine during a shift. I have created the Timer property and binded the Running property to the machine state. I now want to use the value of the timer as part of an expression tag to work out the work rate ie.

work done/(timer.value/3600)

I’ve tried component scripting, but my python is on at novice level, im sure im missing something simple it cant be this difficult

The expression would look more like:

{Root Container.Numeric Text Field.intValue}/({Root Container.Timer.value}/3600)

You can pick tags and property through the buttons on the right hand side of the expression builder.

Here is a window you can import that will illustrate:
test_JCRateTest_2015-11-05_0735.proj (7.36 KB)

thank you for the reply jordan, but for some reason I only seem to be able to add tags in to my expression not property bindings

if i type the expression in it doesnt work

Ah! Sorry. I misread your post. Tags don’t really know what project a component it in. That’s why it won’t work.

Just so I’m clear (and trying not to give you bad information again!), where are the timer value and part counter coming from?

timer value is taken directly from the component, so as you said Root Container.Timer.value, if i could get that value in to a memory tag then i could work with it

the count is coming from and OPC tag that is then written to a memory tag as an accumulative counter


You can use this on the propertyChange Event to move the timer value to a tag:

if event.propertyName == 'value': system.tag.write('pathToTag',event.newValue)
The first line verifies that we are only paying attention to the value changed event.
The second line writes the value to a tag.

Hope this helps!

Computing system-wide tags from a component on a window is a recipe for disaster/frustration. Depending on how important the computation is :slight_smile:
If this calculation is critical, just put it in the system’s PLC.
If it needs to be close at all times, no matter what clients are running and what windows are open, you just need to compute it in the gateway. Given a “Running” boolean tag and a “Reset” boolean tag, the following pair of tags will get you what you need. Presumably, you’ll reset at the end of the shift.
Snapshot tag:if({[~]Reset}, now(), if({[~]Running}, forceQuality({[~]Snapshot}, 192), dateArithmetic(now(), -{[~]Uptime}, "second")))Uptime tag:if({[~]Reset}, 0, if({[~]Running}, dateDiff({[~]Snapshot}, now(0), "second"), forceQuality({[~]Uptime}, 192)))The accuracy of the result depends on the scan rate and how often Running changes, but it’ll be pretty close.

Oh, yeah: The Snapshot tag is a datetime, and the Uptime tag is a Float8.