LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run time menu causing lag

So I'm trying to make a small VI to incorporate into a larger project

 

I have a custom runtime menu, options menu with sub catorgries of 1 and 2, when pressed these options are checked, when the user presses the run button depending on which options are checked it will generate some data for 1 or 2 or both and plot this data after this is done in the garph menu the user will be able to look at the plotted data for either plot or both together, if only one option is picked I would like the graph option plot 1 and 2 to not be visible 

 

however when an option is checked the program stalls and you cant pick the next option or press the buttons and I have absolutely no idea why, this is my first attempt at using menus and event sturctures hence Im not 100% sure of the possible issues here, thinking maybe it might have to do with the timeout of the event sturctures maybe not 

 

if anyone could give me some pointers on what Im doing wrong here it would be very much appreciated

0 Kudos
Message 1 of 4
(2,738 Views)

Also whe i try to take both arrays from one and 2 using a build array to plot both plots on the waveform graph i get a bad wired error which states the graph is 1D and im trying add 2D which is annoying because i know you can plot 2 plots of data to a graph using the build array.  If I use a seperate graph I can plot both, so im thinking it has something to do with the waveform graph local variable ive used 

 

also for the not being able to see the polt both option if both 1 and 2 are not checked i can use a delete menu item tool 

0 Kudos
Message 2 of 4
(2,727 Views)

A couple of things.

  • The classic Event Loop is a While Loop with a single Event Structure inside it.  The Event Structure has all of the Events as separate cases, including Menu Selection, Value Changed (used to detect Front Panel interactions), etc.  Your VI has at least three!!  [There was recently, meaning within the last week, probably, a response in the Forum to an Event question that referenced the article that discussed why "Only One Event Structure" was so important].
  • Typically, with Event structures, you have two parallel loops, one the Event Loop that decides what to do, and the other a State Machine or Queued Message Handler that handles the details of carrying out the Actions dictated by the Event Loop.  Again, there are clever ways to combine these two loops into a single loop (one is to use User Events, a slighly-more-advanced topic, to make the Event Structure handle Actions-as-Events, the other is to put the Action Engine in the Event Structure's Time-out Event).  Personally, I find using something like the Queued Message Handler and setting up a Producer/Consumer loop pair, with the Event Structure being (mainly) the Producer and the QMH being the Consumer, easier to follow and implement.
  • Never (what?  Never? ... well, Hardly Ever ...)(if that suggests a tune to you, give yourself 5 extra points) use a Stacked Sequence.  Having connecting wires going all over the place, not being able to see what is going on (because they are "buried" in overlapping Sequences), and not having "self-documenting labels" (like the Message Names in the Queued Message Handler, where a Case statement controls the various "Actions" or "States" or "Messages" (pick your metaphor) being processed) makes the logic that much more opaque.

I decided that I need to add 1000 words to this post, so here is a "Picture", a Snippet of an example Event Loop + Queued Message Handler.  Your code should fit easily into this structure (if you don't know about Queues, feel free to ask, or go on the Web and search ...).

Events + QMH.png

Bob Schor

0 Kudos
Message 3 of 4
(2,700 Views)

Thanks for the advice, after much comtemplation and study I got it to work Smiley Very Happy

0 Kudos
Message 4 of 4
(2,657 Views)