LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Diagram enable

Hello,

 

I was wondering if there is an option to only run a certain part of the code that is inside a block and disable everyting outside of the box. Sort of the opposite of the 'diagram disable'. I know I could put all the code except for what I want to test in a diagram disable, but it seems a bit devious.

 

Thank you

 

 

0 Kudos
Message 1 of 7
(2,953 Views)
Devious, no. Just the way it works. Why have a separate structure to enforce default behavior?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(2,947 Views)

copy/paste it into a new VI

0 Kudos
Message 3 of 7
(2,925 Views)

So here's what I do in that situation (indeed, my "usual approach" to using Diagram Disable (which I really appreciate when I need it).  Let's say that there's a moderately-sized piece of code that I want to "simplify" by removing isolated pieces, maybe "around the edges" as you seem to suggest.  I do the following (taking advantage of the "Case-like" structure of Diagram Disable:

  • Draw my Diagram Disable around the code I want to modify and test.  I get a box with "Disabled" containing my code, and "Enabled" being blank.
  • Right-click the edge of the Diagram Diable box and choose "Remove Empty Subdiagrams".  This gets rid of the blank "Enabled" case.
  • Right-click again and choose "Duplicate Subdiagram".  This creates another Disabled case with the same code.  If you had Controls or Indicators in the original Diagram Disable, you will (unfortunately) also create duplicates on the Front Panel.  I usually leave them there (they'll disappear when we clean up in a few more steps).
  • Once more, right-click and choose "Enable this Subdiagram".  This is the copy of the original (with possibly new controls/indicators that you'll subsequently discard) -- go ahead, make your test changes, and run the code.
  • When you are done, one more right-click to the edge, Delete this Subdiagram (your test case), leaving you with your Original code as the Disabled case.
  • Final right-click and Remove Diagram Disable Structure, to take you back to where you started.

This is the LabVIEW equivalent of "Having your Cake and Modifying/Testing It, Too".

 

Bob Schor

0 Kudos
Message 4 of 7
(2,920 Views)

@Allard171 wrote:

 

I was wondering if there is an option to only run a certain part of the code that is inside a block and disable everyting outside of the box. Sort of the opposite of the 'diagram disable'. I know I could put all the code except for what I want to test in a diagram disable, but it seems a bit devious.

 


The problem is with dataflow, because if you disable the wires going into your section, their values are not really defined. One possible workaround would be that it could be implemented if we enable the debugging tool "retain wire values". Now all wires going into the interesting section have defined values even if their upstream souce might be disabled. Unfortunately, you cannot easily change these values. You also still have serious problems if far parts of the code intereact (e.g. via local variables, queueus, etc.), so this still seem dangerous in general.

 

Have a look at this idea and its discussions. I think you are looking for something similar.

 

Of course in a well designed, modular LabVIEW program, there should be plenty of subVIs, and each is individually runnable and debuggable. Run the main program once with the interesting subVI front panel open and the subVI will now have typical values on all the controls that will remain unitl you close the project and you can run the subVI standalone with the last-seen data, but you can of course change the controls values at will to see what happens.

0 Kudos
Message 5 of 7
(2,896 Views)

@natasftw wrote:

copy/paste it into a new VI


Or, more quickly, select the relevant code and select Edit>>Create SubVI from the menus. You can then undo to go back. Of course, as already pointed out, it's likely you should have more subVIs, so maybe you should save the subVI rather than undo.


___________________
Try to take over the world!
Message 6 of 7
(2,871 Views)

@tst wrote:

@natasftw wrote:

copy/paste it into a new VI


Or, more quickly, select the relevant code and select Edit>>Create SubVI from the menus. You can then undo to go back. Of course, as already pointed out, it's likely you should have more subVIs, so maybe you should save the subVI rather than undo.


I was about to say something to this effect. Sub VI's are good, OPs predicament is a perfect explanation as to why you should create them. Create them. Sub VI's good. 😉

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(2,858 Views)