How to define variable

What I’m trying to accomplish is to make a dashboard where stations on an assembly line are competing for the top spot. The stations with the highest Cycle Score(this is the accumulated value) stay on the top of the stack(used by the sorting method). If a station meets a 32 second cycle time, the script adds 1 (INCREMENT CYCLE SCORE) to the Cycle Score and this adds up over a shift. If the station goes over a the 32 second cycle time, the Cycle Score is DECREMENTED 1. The highest Cycle Score goes to the top. There is a gamifaction theme here because the operators are here all shift and have control over their cycle times so they can play if they want or not.

The red border happens when cycle time is not met.

Short gif…

This code shouldn’t be in the user interface. This code should run all the time in the gateway, presumably in a gateway timer event. If the UI is restarted, that workstation will lose all status.

1 Like

Why not historize the cycle times? Maybe I’m not following, but it looks like you are doing the heavy lifting in the PLC. Let the HMI do all of this work for you, it’s easier and better.

I recommend spending time doing IU, it will give you a good basis if you are staring off.

@pturmel thank you. That is a good call, I’m thinking about moving the script but I don’t see how to access component properties from the gateway…

For starters, how would I get this?


If this was a timer script, at what frequency would you suggest I run it?

@jlandwerlen I could historize, that might be where this going I’m not sure yet. The PLC tags I’m subsribed to have been there for years and I don’t have a lot of control over them, another department owns the logic.

Bidirectionally bind the components to tags (but not client tags). Memory tags would do. Then the gateway event script, reading those tags each time, will run whether a client is open at all, using the last value supplied in the UI. If multiple UIs are open for the same tags, changes in one will reflect in the others, and in the gateway event.

The key is that process logic belongs in PLCs or in the gateway, where the relevant code can execute all of the time.

User interfaces should not have process logic, unless there is a physical constraint tying a workstation to a process (pretty much only practical in Vision, yet).

Thanks working on it. I don’t see the bidirectional checkbox in cell binding.

Bind components, not cell binding.

To historize is a check box. If you are subscribing to PLC tags now, it’s a simple step.

I think you may want to start this thread over by starting from the beginning and really explain in detail what you are trying to accomplish. Then you will get the best help vs just asking how to do something that you think is the best way.


@pturmel I moved the script to the gateway after several changes and it is working great. Thank you for that.

@jlandwerlen thanks for ruining the fun. Just kidding after looking at my title “How to define variable”, it would appear I wandered around a bit.