# Minute increment for production that accounts for break time

**URL:** <https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493>\
**Category:** Ignition\
**Created:** [October 29, 2019, 6:07pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493 "2019-10-29T18:07:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 29, 2019, 6:07pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/1 "2019-10-29T18:07:40Z")

</div>

I have a label that is showing number of employees at the line that can change by minute, and I have a timer that is set for the line leader to toggle when they are actively producing at the line as we have multiple break times etc. When they toggle that they are at the line producing that initiates a timer, and what I'm trying to get done is to have a "Total Employee Count" event that I'll use to average out the amount of employees on the line by minute for the entire day. I have this scripted on the actionPerformed on the timer itself:

> v = event.source.value  
> e = event.source.parent.getComponent('EmployeeNum').intValue  
> c = event.source.parent.getComponent('PPMHNum 4').floatValue  
> c = c+e

It's not working, but I don't know why. Could any of you fine people help me out? Thank you!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 29, 2019, 6:22pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/2 "2019-10-29T18:22:03Z")

</div>

I believe the issue is your variable `c` becomes a float value (which you can’t write to), rather than a handle to that component value you want to write to. Also, on closer inspection, you have curly quotes in there–at least on the forum post–which would be an issue if they’re in your script that way. Try making `c` a handle to the component and then reading/writing the component’s floatValue property like this (curly quotes also replaced with straight ones):

```python
v = event.source.value
e = event.source.parent.getComponent('EmployeeNum').intValue
c = event.source.parent.getComponent('PPMHNum 4')
c.floatValue += e

```

Note `v` is not used in this code–not sure if that’s intentional as I’m guessing this is just a snippet of your full code.

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 29, 2019, 6:31pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/3 "2019-10-29T18:31:19Z")

</div>

I've gotten frustrated at this point and honestly didn't realize I had even left V out - I was originally using

> if v == 60:  
> c=c+e

That didn't work so I tried to do it on the label itself, that didn't work, I've tried different variations as well and those don't seem to work either lol. I tried what you gave me and that didn't work either. I'm not getting error messages, it's just like it's ignoring my attempts at scripting.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 29, 2019, 6:43pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/4 "2019-10-29T18:43:00Z")

</div>

Maybe the script isn’t even being called. Can you share a screen clipping of your timer properties and your script configuration?

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 29, 2019, 6:45pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/5 "2019-10-29T18:45:36Z")

</div>

![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9d7298adc951cbed54201bd976cdd389c5747044.jpeg)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 29, 2019, 6:52pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/6 "2019-10-29T18:52:59Z")

</div>

If you want this to run every sixty seconds, try putting it in a propertyChange script something like this:

```python
# Run when value rolls over to zero (the next value after 59 is zero due to 60 bound).
if event.propertyName == 'value' and event.newValue == 0:
	# Read employee number value.
	e = event.source.parent.getComponent('EmployeeNum').intValue
	# Get handle c to component.
	c = event.source.parent.getComponent('PPMHNum 4')
	# Add e to c value.
	c.floatValue += e

```

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 29, 2019, 7:06pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/7 "2019-10-29T19:06:50Z")

</div>

It takes the script, no errors, but no increment change at all. It’s maddening lol!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 29, 2019, 7:13pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/8 "2019-10-29T19:13:41Z")

</div>

Yeah, that’s no fun. This script (similar idea, but without building the other components) on a new timer with default configuration works (tested just now):

```auto
if event.propertyName == 'value' and event.newValue == 0:
	e = 5
	c = event.source
	c.value += e

```

With timer `running` true, it results in a timer `value` that increments 1…9, and then repeats at 5…9.

So either your timer isn’t running, there’s something else breaking your script (like curly quotes?), or there’s something wrong in the component references after the equals sign following e and/or c. I’m not sure why you’re not seeing an error, unless the timer isn’t running.

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 29, 2019, 7:17pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/9 "2019-10-29T19:17:29Z")

</div>

So I created a new timer - Put this script on the propertyChange that you posted above and it increments 1-9, 1-9, 1-9.

 ![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/989b783ee0c5438fabca59e23a23b84b41b8ebe6.jpeg)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 29, 2019, 7:50pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/10 "2019-10-29T19:50:19Z")

</div>

Make sure you switch it to preview mode in Designer (scripts don’t run in design mode so it will run 0-9 repeatedly as if the script wasn’t there).

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [October 30, 2019, 2:07pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/11 "2019-10-30T14:07:49Z")

</div>

As a followup this is what finally worked:

> '# Run when value rolls over to zero (the next value after 59 is zero due to 60 bound).  
> if event.propertyName == 'value' and event.newValue == 0:  
> '# Read employee number value.  
> e = event.source.parent.getComponent('EmployeeNum').value  
> '# Add e to c value.  
> event.source.parent.getComponent('PPMHNum 4').intValue += e

I appreciate you dealing with this low understanding individual haha

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [October 30, 2019, 2:32pm UTC](https://forum.inductiveautomation.com/t/minute-increment-for-production-that-accounts-for-break-time/29493/12 "2019-10-30T14:32:07Z")

</div>

> [@dholt](#):
>
> I appreciate you dealing with this low understanding individual haha

We all have our moments 😄 Glad you've got it working!
