I have a counter that increments the tag "Counter" one by one, and a valueChange function associated to the same tag that performs a series of actions (although they do not come to the case, I will mention them anyway). The problem is that, while the counter increments, the valueChange script is not executed at any time.
Prints are never going to be viewable. Use system.util.getLogger | Ignition User Manual , log your statements. I would also log your limitcount and currentValue.value just to be sure you are getting what you expected. Check your gateway logs after trying it again to see what logs come through.
Not that you can't do this on a tag's valueChange event either but there is a lot of info on the forum why it is preferential to create a Gateway Tag Change vent and then monitor the appropriate tag(s), instead of making the valueChanged on the tag directly. Though I don't see this being your issue right now.
They're viewable you just have to know where to look.
This point can not be overstated here. This script, particularly with the number of blocking calls, is inappropriate as a tag valueChanged event script.
All of that being said, I see nothing syntactically incorrect about this script, which leads me to what information leads you to believe the script isn't executing?
What I am trying to do is that after certain seconds, if the value of controlValue has not changed, then I assign the value of oldValue. However, this is not happening, so I am placing the print every time a condition is met to debug the code.
If in this case I have a gateway timer event that is triggered when I click on the button, it is then when I activate the counter with a limit of 110 seconds. What I try to do is the following: if, after 110 seconds, the current value (currentValue.value) is greater or equal to the limit of the counter (limit_counter) and the value of the control (controlValue) is different from the value of the indicator (indicatorValue), then I write the previous value (oldValue) in the tag that communicates with the RTU. Previously, I already get both the oldValue and the newValue in the button.
what I am looking for, is that if within 110 seconds, the required value (1 or 2) does not arrive, then we send again the value in which it was before, for example. 1 enable 2 disable, if I want to disable it and in the course of 110 seconds, I do not receive a response from the RTU/PLC then I return to the previous state which is the 1.
I still don't understand what this control system is trying to do.
Instead of creating Max_Counter,
Create a memory tag of type DateTime. Call it timeoutStart or similar. Update this at the start of the timeout period.
Create an expression tag timeout of type Boolean. Set the expression to now() - {[timeoutStart]} > 110000
Use the tag change event to call a gateway script when this changes. The first line should check if it has turned false and return. Otherwise do what has to be done.