LV 2010 (yes, 2010), Win Vista.
I have a DISPLAY UPDATE event, occurring at 2 Hz.
The event carries an array of values, one for each channel.
Four CHANNEL SELECTORS drive an ARRAY INDEX operation.
The four selected channels are shown separately on numeric indicators, then combined on to a waveform chart.
The little subVIs are there to produce a NaN for charting if the channel selector is -1 (none).
Currently they are changed to output a "123.0" value, for debugging purposes.
The HELP says that the ARRAY INDEX will produce a default 0 if the input index is outside the bounds of the array.
Yet, under certain circumstances (see JING at http://screencast.com/t/0kO0GDhlo0E), the "CHART VALUE" indicators fail to update.
In that video, I set the indicators to values of 1, 2, 3, 4 before starting the program.
I DO NOT set the DEFAULT, just enter those numbers into the panel indicators.
The two which have selected channels are updated seemingly normally. The other two, which are left at NONE (-1) do not update.
I would expect them to show a zero, or SOMETHING, but the "3" and "4" never change.
This code is called, as evidenced by the chart advancing, but the values do not change.
If I change the channel to a live channel, then back to NONE, it will return to 0. That's expected.
But why doesn't it update at first?
If I swap the channel selectors around, the problem swaps with it. Any selector set on NONE has the corresponding indicator unchanged from the starting value.
ABOUT THE CODE:
This is a REENTRANT VI, inserted into a SUBPANEL.
Here's the insertion code:
The idea is that each control on the page is a subpanel, each will receive an instance of this one VI.
For each subpanel, I open a new re-entrant ref to this VI (it's set to be reentrant), and insert that ref into the subpanel.
I set a couple of control values, and start it running.
1... If I change OPTIONS = 8 to OPTIONS = 0 in the above, the problem goes away. Everything works as expected.
2... The N=1 in the above, is simply to limit the number of instances, for debugging purposes.
3... I get no errors at any time.
4... I've tried with and without a wire to the TYPE SPECIFIER VI REFNUM input of OPEN VI REFERENCE. No change.
A search on this topic brings up some 2008 issues with LV 8.0, and a suggestion there to use a VIT as the item inserted had no effect here.
So, why does the indicator NOT update if the index is -1, at first? It's as if the code is not there.
And why does making it non-reentrant fix it?
(I have to have it reentrant so I can have multiple instances).
Blog for (mostly LabVIEW) programmers: Tips And Tricks
Solved! Go to Solution.
I see your using a flat sequence structure, try moving the index control outside of the flat sequence structure. Its my wild guess. You probably don't need the sequence structure anyhow or maybe your using it to save realestate? Avoid sequence structure they are not data dependant, they're great for initialization and finalization. I'm sure you've heard this already...
At this point wild guesses are appreciated. But changing it as per your guess doesn't help, nor would I expect it to.
The sequence is to save real estate, the next frame has 20 controls and 20 indicators to manage, no sense in putting all that on the same level as this chart for the sake of dogma.
More KEY FACTS:
5... the window is FLOATING, though it doesn't change anything if it's NORMAL.
6... Removing the outer TAB structure changes nothing.
7... The chart is on top of an inner TAB structure, perhaps that affects things (Tabs have influenced behavior negatively before)...
I don't know how to probe that in the real situation.
If I put a probe there, it doesn't tell me anything, because it's a re-entrant copy that's actually running: the probe is on the original VI which isn't.
If I make it non-reentrant, the problem goes away.
8... Moving the indicators OFF the tab page does nothing different.
9... another page of the inner tab has more text indicators (20) instead of a chart. (see pic below). That page shows the same behavior. Any selector inditialized to -1 fails to update until it is first set to an active channel.
10... It doesn't matter if the selector values are converted to I32 or not (not that I would expect it to).
11.. The selectors are given a STRINGS & VALUES property of ["< None >", -1] by the init code, or ["Speed", 2} or ["Torque", 3] or something if the channel is found in the settings file. When you click on it, I populated the menu with all channels and all indexes. Wonder if there's something wonky with that.
I would expect the index controls to be initialized at start up. Set programmatically (for debugging) before the reentrant VI fires. You mentioned you only set index 0 and 1, 3 and 4 are null? A break point on the reentrant and then highlight should give some clues to the problem.
Hint, go to the original VI from thr project window, probes there will persist on spawns
You mentioned you only set index 0 and 1, 3 and 4 are null?
No, I set all four when the VI starts. In this case 0 and 1 were set to active channels (values >= 0), 2 and 3 were set to <None> (index = -1).
go to the original VI from thr project window, probes there will persist on spawns
I put the VI into the project.
I opened it via the project window.
I put probes where I wanted.
I ran the program.
The probes all say "Not executed"
I know the code is executed because I put a N=N+1 display indicator on the panel (not shown above), and that runs at 2 Hz.
But the probes show nothing.
Hmmm. A fault elsewhere (device lockup) caused the data array to be empty. When that happens ALL FOUR indicators show the original 1,2,3,4 values that I put in the indicators. The updates are still happening, the N=N+1 is still rolling, but the indicators do not change.
That's in spite of the fact that some of the selectors are set to positive numbers.
Looks like any array index out of bounds (not just -1) causes the indicator to ignore the value.
I didn't know that was possible; the help says it won't happen, but there it is in front of me.