LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Anyway to programmatically add a page to Tab Control during VI execution?


@JÞB wrote:

Brian, Lets stick to public stuff.  

 

OK I get the premise behind X nodes, I'm just not working in an environment 


What's not public about XControls?  Open LabVIEW and go File >> New... and pick XControl.  Been supported since LabVIEW 7.x or so.  Besides I wasn't suggesting making one, I was suggesting using one that has been developed and tested and comes with nice pretty demos.

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

@Hooovahh wrote:

@JÞB wrote:

Brian, Lets stick to public stuff.  

 

OK I get the premise behind X nodes, I'm just not working in an environment 


What's not public about XControls?  Open LabVIEW and go File >> New... and pick XControl.  Been supported since LabVIEW 7.x or so.  Besides I wasn't suggesting making one, I was suggesting using one that has been developed and tested and comes with nice pretty demos.


I read X-node.  I'm going to split this in the hopes that you show some snippets and explain more.  

 

Spoiler
I do learn more every day!

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 4
(2,568 Views)

You want me to teach you about XControls?  It's a pretty big topic, and somewhat not recommended just because it the behavior of XControls is sometimes not the same as a normal VI resulting in work arounds to get it to work the way you expect. 

 

http://www.ni.com/tutorial/3198/en/

http://www.ni.com/example/25048/en/

 

Basically it is a collection of VIs made into a library.  This library has a couple of special VIs called Ability VIs which get ran when specific actions occur.  At the moment the only ability VIs that can be made for an XControl are Data, State, Facade, Init, Uninit, and Convert State For Save.  All except the last 2 are required for all XControls.  It is like being able to make a control, and wrapping functionality into that control.  You know how at run time you can change a graphs like colors?  Or zoom in when it is running?  You could make an XControl that has similar functionality with custom right click menus based on the data being displayed which is wrapped up into a single control you drop on your front panel.

 

What this allows for you to do is create front panel objects that can behave differently in the edit, or runtime state.  The one I mentioned is by Saphir (VI box) is an XControl that allows for making an unlimited number of tabs at runtime, which can be pulled off as individual windows.  The included demo shows how to insert N instances of a VI that allows for dragging and dropping images into a VI and displaying them.  Here is the demo as I drop some of the LabVIEW glyphs and manipulate the windows.

 

https://www.screencast.com/t/6jijZ2xylRFw

 

Most of this is open, but a decent amount of it is password protected last I checked.  This XControl consists of a 2D picture control (which is the tabs part) and the bottom is just an empty subpanel that you can insert anything into.  Once installed the demo can be found in "<LabVIEW Install>\examples\SAPHIR\ViBox - XControls\XTab\PV_Main.vi"

 

Other fun XControl examples includes the Variant Probe which can display any data type, as a nested tree with coloring for the data.  It is pretty handy for viewing a variant which can be a payload to a generic messaging structure.  Just probe a variant wire, or drop it on a front panel and wire anything to it.

 

XNodes (which I wasn't talking about) have a common XInterface class as XControls and therefor share some functionality (like being in a library and having ability VIs).  But while XControls work on a front panel and work at runtime or edit time, XNodes (which aren't official and aren't supported and don't even think about making one unless you really want to experiment) work on the block diagram, and so are generally an edit time only feature.  I think there are some abilities that can be ran at runtime but you need the full IDE to see the block diagram so it generally isn't used for that.

 

Also here is a demo of the Variant Probe XControl as part of my XNode presentation.

Message 3 of 4
(2,481 Views)

To be more firm on the "not recommended" side:

I've never had good luck with xcontrols. Making them is easier than some people claim, but this just leads you into a false sense of security -- you feel confident...hey look I made this "advanced" tool work and it wasnt that hard...

 

The painful part to me is using xcontrols that ever need editing (swapping back and forth between edit and run mode) and how they lock any other libraries whose types you consume (lets say you want to make an xcontrol that magically displays "mylib.lvlib::mytype.ctl" with pretty indicators and graphs and stuff...well now mylib.lvlib is locked for editing...all the time).

 

For a while, I had issues with constant redraws making things really slow. I'm honestly not sure how this fixed it, but I changed all the ui events in the xcontrol to only maintain 1 instance of the event in the queue and that resolved a lot of my issues...probably 5-10x speedup.

 

I gave up on xcontrols for several years until I recently made a super fancy digital waveform graph that I thought I might need to reuse and so I did it as an xcontrol...such a horrific mistake. Now to open the project its in, I have to first open the xcontrol, break one of the controls, and then load the project. If the project tries to load and the xcontrol isn't broken, it crashes labview. I'm planning on reverting it to normal controls next week, but for now its super annoying.

Message 4 of 4
(2,467 Views)