Minute increment for production that accounts for break time

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!

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):

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.

1 Like

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.

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

1 Like

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

# 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
1 Like

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

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):

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.

1 Like

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.

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

1 Like

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

1 Like

We all have our moments :smile: Glad you’ve got it working!

1 Like