11-08-2016 01:12 PM
With a cluster, I can use the "Controls[]" property node to get a reference for any control in the cluter and then write to that value by using an additional "value" property node.
Is there a way to do a simialr thing with an array?
I have tride using the "IndexVals" property node, but if I change any of the other array elements through the front panel while the code is running it breaks.
Basically I want to programatically change the value of one element but still be able to change the values of of other elements on the front panel.
11-08-2016 01:30 PM
There is no need to do it the way you describe, rethink what you really is trying to achive.
You could for instance keep the array in a shift register in a while loop.
Have a event structure with a short timeout inside the while loop. Make changes to the array in the timeout case and display the array. Catch user interaction with the array in the event structure and read back the array to your shift register.
Or something to that effect, depending on your needs.
11-08-2016 04:22 PM
Replace Array Subset will modify the vaue or values of an array that you specify by the index inputs. No need for property nodes unless you need to modify a control - and you should be very careful if doing that to avoid a poor user experience.
Lynn
11-08-2016 05:05 PM - edited 11-08-2016 05:07 PM
To update a array control, even if only a single value changes, requires the entire array to be written (e.g. via a local variable). This is not a big deal, because I assume that the array is pretty small (else it would not make sense to have it as a control!) Just rewrite all the other values to what they already are. (Updating all array elements using a local variable is probably orders of magitude more efficient that updating a cluster element via a reference and property node.)
Maybe you should describe in more details what you are actually trying to achieve. Controls are typically used for user input, so programatically changing them often leads to poor user experience, e.g. if the code is fighting with the operator for control of a value.
Can you explain your usage case, maybe attach a simplified version of the code?
11-08-2016 07:44 PM - edited 11-08-2016 07:47 PM
So I have tried this many ways with the array and am having the same issue each way I try it. This is my latest attempt.
If you run the VI I have attached you will see the basic operation I am expecting. As the line scrolls through the array of bools, they turn off momentarily (to indicate they have been "read") then they are returned to their previous value. I want to be able to change any other array element at any time. I don’t care if the one where the line is (that I am actively controlling) misbehaves if the user tries to change it while its actively being modified by the program.
The issue I am having Is that for whatever reason sometimes if I modify another array bit while the program is changing another, it either fails to turn off the one being prgramatically changed, or worse fails to turn it back on.
I am guessing there is some sort of race condition happening but I can’t see where.
(I quickly and repeatedly toggle one bit to occasionally see the undesired behavior)
If I hit a button while it is in another event, it should still trigger when it comes out of that event right? The events queue up correct?
I don't see this behavior if I use a cluster and modify the values by reference. I want to avoid this for several reasons including the efficiency penalty that altenbach mentioned.
Thanks for your help.
11-08-2016 10:48 PM
The things here are not 100% clear to me (yet), it is still very early 🙂 Neither I understand why you need this kind of "animation". However, I would point out some possible problems when you use Event structure:
11-09-2016 12:40 AM
OK, here's a quick draft how you could do it (LabVIEW 2013). Notice that this is now done with much less code. (no event structure, no hidden controls, a single case structure, not even a shift register. A single local variable, pleasant dataflow, easy to debug, etc.)
See if it can give you some ideas. It would be easy to modify for the exact desired behavior, just try it!
11-09-2016 10:04 AM
Thanks for your replies. Your VI is actually very similar to some of my earlier attempts (although I filter out the blinking on that happens when a false is "scaned" through).
Many of the other things added in my other VI were attempts to prevent the issue I have seen where for some reason a bit that was false does not return to true after being momentairily set false and anoter bit is changed at the same time.
Again this is seen if I rapidly click a bit as it is scanning through (the bit where the scan line is goes false and stays false when clicking a different bit).
I still have this problem on your vi as well.
I can't figure out why.
11-09-2016 11:04 AM
@teshurtz wrote:Again this is seen if I rapidly click a bit as it is scanning through (the bit where the scan line is goes false and stays false when clicking a different bit).
I still have this problem on your vi as well.
I can't figure out why.
For simplicity, my code just inverts the currest state, so if you want something different, it would be trivial to do. If you click the boolean during the time it is changed, it gets inverted to the opposite it was just changed. What else would you expect as correct behavior?
The problem is that you overload the information content of the array, having to hold both the values and temporary opposite values in a single boolean. All you probably need is another shift register holding state information.
11-09-2016 11:29 AM
sorry I tried to be clear but I guess I wasn't. It is not the element I am clicking that behaves incorrectly. It is the one that being prgramatically changed. E.G. if all bits are high and I am toggling bit 17, as it scans through bit 5 and sets it false. then for whatever reason it does dot get set high (on the "30" case).
This was what I was trying to fix by adding events and such. I am perfectly OK with the bit behaving erratically if I click it when the line is on top of it, but I don't want bit 3 to change funny if I am modifying bit 15.
Does that make sence?