From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-09-2018 10:06 AM
Hello guys!
I have a matrix indicator OUTSIDE of an event structure, like so:
My problem is, that it shows the result of the for loops only, so the result of the last step.
If I bring the indicator inside, I can see every step, like so:
But the matrix indicator must be outside, because other events are using it.
My question is:
- how can I transfer each step outside so every step will be visible instead of only the last one?
(or alternatively)
- is it possible to have two copies of the same indicator that are pointing to the same frontpanel element?
Solved! Go to Solution.
05-09-2018 10:11 AM
You can use an action engine and have it in many different places. You would write to it in the loop and read it where ever you needed the data.
You can also use a local variable but you need to be careful with the use of local variables.
05-09-2018 10:26 AM
You don't need any of the inner loops or local variables. Keep the matrix data in a shift registers. Then just keep track of the indices in one shift register (one counting through the total number of elements, using Q&R to get the row/column at each iteration) of the outer loop and increment the values and modify the array in the timeout case set for a 100ms timeout. Also keep the current timeout value in a shift register and Once all values have been shown, reset the timeout back to -1 (infinite). Decide what to do if an event is triggered while it is still processing a current event (e.g. ignore and finish the new scenario, do the new thing instead, etc.).
This also has many advantages because it does not trap the code inside lengthy events during which nothing else can be processed by the event structure.
05-09-2018 10:43 AM
05-09-2018 12:23 PM
Just some pointers nobody asked for...
I'd hope the update of the matrix in the loop is only required for debugging? It would be a bit weird, and not recommended to put a wait in the inner loop of a for loop, except for debugging. If that's the case, you might as well try to use a probe instead of the indicator. You can combine it with a breakpoint, and remove the wait.
If it's a mockup\simulation of a process that takes a long time, you might outsource the calculation to an async process (producer\consumer, dynamic VI, etc.). It's considered good practice to do time consuming things outside the event structure, so it stays responsive. It's perfectly ok if the GUI can be locked during processing though...
Modifying your code to facilitate debugging has as downside that it's easy to forget to remove\put back the code when done debugging.
All's acceptable during experimental phase.
05-10-2018 03:22 AM
Thank you, that is what I needed!
05-10-2018 05:05 AM
But my original idea was, that this "scan" function stays in that "scan" event. Now everything is in the timeout event, I don't really like this. I would like that timeout event to stay clean as possible, and scan event handle this. How should I modify it?
05-10-2018 09:47 AM - edited 05-10-2018 10:33 AM
@THunter wrote:
But my original idea was, that this "scan" function stays in that "scan" event. Now everything is in the timeout event, I don't really like this. I would like that timeout event to stay clean as possible, and scan event handle this. How should I modify it?
No, event structures are for immediately dealing with something rapidly and going back to listening to new events. They are primarily for dealing with user interactions and should not be used for massive, lengthy processing. Trapping the code inside event frames for extended times is very bad architecture. If you don't want to use the timeout event, you need to create a parallel consumer loop, for example. While the long event frame is executing, the front panel is either locked (by default) or continues to accept user input. Since the code cannot process any event during that time because of dataflow, any user interaction will queue up events without user feedback and these will execute once the event structure is ready again.
05-11-2018 04:11 AM
Allright, thanks for the explanation!