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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure interferes with the other cases in while loop

Solved!
Go to solution

I made a VI that saves a setup in a config file and the user can load that setup next time he opens the application. However, I recently put some event structures to other parts of the application, and they seem to interfere with the save and load options. When I delete the event structures, the saving and loading work again, so what can be the problem??
I am attaching the VI but its very large

0 Kudos
Message 1 of 14
(3,191 Views)

Hi dilge,

 

even though I cannot open your VI due to its LabVIEW version I can recommend to NOT use more than one event structure per VI!

And additionally I recommend NOT to hide event structure in cases…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(3,178 Views)

could you back save for 2016?

File -> Save for Previous Version

 

my guess without seeing the code is, that you have a blocking element, probably the event structure, which shouldn't be side-by-side in a loop with a case-structure.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 14
(3,177 Views)

There is WAAAAYYY too much going on in that VI.  (Try making some subVI's)  I couldn't really search around it or see what its overall architecture is.   I did come across one event structure.

 

Read this Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help

 

Event structures by default set cases that lock the front panel until the event case is complete, but if the architecture of the code doesn't allow the program to flow to that event structure to handle it, you will lock up your VI cold.

 

In general, you shouldn't have multiple event structures in your VI.  You can, but you really need to know what you are doing.

0 Kudos
Message 4 of 14
(3,175 Views)

I uploaded for previous versions,

 

thanks for helping!

0 Kudos
Message 5 of 14
(3,172 Views)

Hi dilge,

 

your block diagram has a size of 20146×2300 pixels: this is about 20× the size of a FullHD screen.

This is way TOO BIG!

 

As recommended before: clean up your VI! Use subVIs! Apply a "programming pattern" in your VI!

 

And: NO, DON'T CREATE AN EVENT STRUCTURE IN NEARLY EVERY CASE OF YOUR BIG CASE STRUCTURE!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 14
(3,166 Views)

It is very rare for a tab control terminal to be connected to a case structure.  Tab controls don't really "control" anything.  They are more of a friendly user interface tool that allow the programmer to organize controls and indicators on the front panel into pages.

 

You need to re-architect your program so:

1. There is only 1 event structure.

2.  It is not buried in case structures.  It should be near the top level of the VI in a while loop.

3.  Does not contain long running code inside any give event case.

4.  Your VI is able to get back to the event structure in a timely manner to handle any events that have been triggered.

Message 7 of 14
(3,159 Views)

hi dilge,

you have the perfect example, why design patterns exist and fields like software engineering, i am sorry to say.

heed the advice of gerdw and ravensfan.

to help you get started, you might want to read this http://www.ni.com/newsletter/51735/en/ (labview best practice).

 

the key to maintainability is simplicity, modularity and don't-repeat-yourself.

try to find parts of your code that you use often and abstract them into one sub-vi,

then use this subvi instead.

try to grok the data flow paradigm of labview and use it. (e.g. explain yourself, why error terminals exist for most VIs)

 

sorry we can not help you with your specific problem more,

but you should make your (coding-)life easier by taking the time to structure your code more.

 

regards, and don't be shy to come back with more questions

 

 EDIT:

i found it very helpful starting with labview to google for terms like "labview best practice" and "labview design pattern".

 

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 8 of 14
(3,145 Views)

I tried to simplify the VI as much as I could. I also tried to disable locking front panel for each event. And I have only one event structure which is placed in the while loop now.

 

I am using the tab control both for the user and for myself, so I can organize better in the case itself. However, you dont really need to look at the tab control case as it has nothing to do with my problem but the other saving,loading cases are the ones that do not work.

 

I really appreciate the feedback you have given me,

 

Thanks.

0 Kudos
Message 9 of 14
(3,099 Views)
Solution
Accepted by topic author dilge

your while-loop should only have one event structure in it.

all your case-structures that are beside it shouldn't be there.

use the controls you have as input for the case-structures as an event,

which then triggers the computation or whatever.

 

get rid of all the sequence structures! use the wires, only when there is no way to use a wire for the data flow (like the tick counter) wrap only it with a sequence ...

 

as was said before, don't have long running code inside the event structure.

use producer-consumer pattern for example to separate long running tasks from your UI loop.

(learn about queues or user events)

 

the case-structures besides you event-structure are almost surely the cause for the locked front panel.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 10 of 14
(3,075 Views)