I develop a Java application in Flexy, is there a function that detects the change of a variable? like ‘ONCHANGE’ in Basic. I want to start processing when the variable value (float) changes.
You’ll want to implement the event tag value listener
Here’s a good example from the docs we have available
The type of my tag “level = Analog Input” is float, as you know, an analog input is not very stable: decimals will change with each refresh of the inputs / outputs. I have to launch a process each time the value change, so I risk starting the process several times per second! my questions:
1- How often is the analogs inputs are refreshed? 1 time per second? 1 time per millisecond? Or other?
2- Can I ignore the decimals from the 2nd, for example for a value = 25.1256, I only keep 25.12 and ignore the rest of the decimals? Does the “MyTagValueListnner” function allow you to perform some sort of filtration? (like a dead band).
3- If I use the ‘MyTagValueListnner’ function to start my process without considering the speed of change of the value of my variable, do you think that should not create a problem?
I’m not as familiar with the Java side of this as I am with the BASIC side. But I’ll see what I can find for a solution.
- We sample analog inputs at a rate of 4 samples per second
- If it’s analog then this function will likely be running pretty constantly. We might be able to get around this with a little bit of a hack so we don’t need to do as much coding. You could get around this by making an internal MEM tag that is an integer. You can set the int tag to be equal to the analog tag and then just do the onchange for the internal MEM tag.
- Depending on how much you plan on doing with this function, if you have it running 4 times per second that could potentially cause some problems if you choose to do this using the analog tag
Topic closed due to inactivity.