LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pause a vi programmatically (with many loops and cases)

Solved!
Go to solution

@jwscs wrote:

take what GerdW said to heart

 

and a queue and an event structure don't make it a producer-consumer-design-pattern, although it uses both of them.

 

you also have to decouple your measurements from your presentation


I do take that on board.

I thought I was decoupling by having the plotting in a separate loop.

0 Kudos
Message 11 of 25
(1,298 Views)

@ASH2020 wrote:


I thought I was decoupling by having the plotting in a separate loop.


it should be the other way around 😉 (because for displaying you consume)


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 12 of 25
(1,296 Views)

@cbutcher wrote:

Some quick comments along the lines of those already posted:

  • You can use SubVIs even if you don't know if they're finished/going to be changed. You can always delete them later. If you really want, you can right click on a SubVI and choose to "Replace with SubVI Contents", which will basically copy-paste it out for you (this is almost the inverse of Create SubVI on the Edit menu).
  • Reflex 1 and 2 are almost but not quite the same case. It seems to me that you're changing only the stimulus choice between two different wires. You can make one Event Structure case handle both by going to the edit window for the structure, choosing to Add Event, and selecting the second. Then you can use a Select node with the two inputs, and compare the CtrlRef available on the left edge of the Event Structure to get a boolean allowing you to choose between the two at the Select node (compare equality to a reference for one of the buttons).
  • Here is the link for the Producer/Consumer design. This might be useful, but maybe you already read it.
  • Here is the link for the State Machine tutorial. This might require too much overhauling to be the best way forward at present, I'd say once you modularise with some SubVIs it will be easier to see what you want to do.

Thank you for the comments.

I had not tried to make sub vis of the main data collection loops because they have so many inputs, the icon pattern seemed to be very complicated, with about 6 inputs.

Not sure I really understand about combining Reflex1 and Reflex2 because they may have different inputs selected on the front panel, Reflex1 may be 105dB and Reflex2 may be 110dB

Thanks for the links, I will definitely look at the State Machine tutorial. It's unfortunately like jumping on a moving bike. When you're thrown in at the deep end, the job is so urgent that you can't stop long enough to learn the right way to do things, even though that is the most efficient way long term.

0 Kudos
Message 13 of 25
(1,293 Views)

regarding the too-many-terminals problem:

use clusters, bundle all the data and have the cluster-type as your input-/output-terminals


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

@jwscs wrote:

regarding the too-many-terminals problem:

use clusters, bundle all the data and have the cluster-type as your input-/output-terminals


I did try that but then often, just one of the cluster elements needs to be different according to front panel inputs.

0 Kudos
Message 15 of 25
(1,283 Views)

you could

- define the common properties in one cluster

- define other clusters/variables for the differing properties and create an extra terminal for them

 

or add a variant data holder in the 1st cluster, which you then have to cast to the correct type inside the subvi


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 16 of 25
(1,280 Views)

@jwscs wrote:

you could

- define the common properties in one cluster

- define other clusters/variables for the differing properties and create an extra terminal for them

 

or add a variant data holder in the 1st cluster, which you then have to cast to the correct type inside the subvi


That's good, thanks. I didn't know about variant data holders.

 

0 Kudos
Message 17 of 25
(1,273 Views)

IMHO there is really no excuse for "messiness".  What messiness does in the beginning is make you hopelessly lost as the project grows.  I've had plenty of projects grow from engineering tool to full production applications, and neatness is the only thing that saves you from drowning in your own spittle.

 

What really helps here is to plan for scalability from the moment you place your first node on the block diagram.  Don't let anyone deter you from this.  If you allow for growth, you don't end up with an unmanageable mess later.

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 18 of 25
(1,269 Views)

It might be worth noting that when you end up with a bunch of clusters and accessing one element here and one element there, a class object might be what you want.

 

With an object, you can place these data elements in the private data of the class and the method VIs can unbundle and bundle the class wire (use By Name) as needed.

 

This can really help to clear up busy block diagrams into manageable, 32x32 pixel blocks.


GCentral
0 Kudos
Message 19 of 25
(1,259 Views)

I wonder if anyone could explain this. I have taken all your advice and cleaned up my code considerably, also got rid of some of the redundancy.

However, I am at my wits end trying to work out why I can't stop my inner loop with a button. I have now removed my loop and put the simplest random number example in to try and debug it, but it still doesn't work. If I cut and paste the inner while loop into a new vi the button works and stops the loop. However, the stop button doesn't have any effect when the loop is running inside the event structure. Any ideas why?

Screen Shot 2017-07-15 at 12.56.15.png

0 Kudos
Message 20 of 25
(1,242 Views)