LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reusable custom controls/indicator groups and associated code

Hi all,

 

here is my problem, simplified for the sake of this discussion: I have an application with a VI that acquires data real time and copy them to a global variable. There are a number of other VIs that use this global variable for different purposes. One of them is a panel with four (but could be more) identical groups of chart+controls. Each of these "groups" is comprised of:

  • a list selector to chose from a predetermined list which combination/function of the 4 input variables to plot (eg. v1, v2, v3, v4, v1-v2, v3-v4, (v1+v2)/2...)
  • a button to select if the variable should be calibrated (according to predetermined coefficients) before being used in the various combinations/function
  • a chart
  • the underlying code that "accepts" the four values, transform them according to the selection in the list and button, and then sends the result to the chart to be plotted

What I am looking for is a way of "encapsulating" controls, indicators and associated code in a single "object" so as to be able to:

  • easily and quickly add one of such groups to any VI (not only that one), by somehow "referencing" one main instance of this "object"
  • having all the instances update when I update the main object (for example adding an additional choice to the list selector)

Ideally, what I'm looking for is an "object" that I can add to the front panel of the VI (where it would show, for every instance, one chart, one list selector and one button), and shows up as a block with 4 inputs in the code. And, I'd like to be able to add as many instances I want, all independent in the data the manage and display, but all a copy of the same "object".

 

It seemed at first a fairly natural and common need, but I realized that I don't know how to do it (probably because I don't have a complete enough overview of the various possibilities available in LV), and my searches have been so far more confusing than conclusive. I don't need step by step instructions, but an informed opinion on what is the most efficient path to follow from someone with a broader view of the labview infrastructure than I have...

 

Thanks

 

Giacomo

0 Kudos
Message 1 of 23
(3,057 Views)

Hi giacomo,

 

whenever you want something scalable in terms of duplicating existing items you should think of an ARRAY.

Whenever you want different things (like boolean, listbox, chart) grouped together you should think of a CLUSTER.

 

Combine both and you get an array of cluster…

 

When you want to encapsulate this even more you should learn to use LVOOP!

Best regards,
GerdW


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

It also sounds like an XControl could be what you're looking for.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 23
(3,039 Views)

Yup sounds like an XControl.  Be aware that XControls could use some polish, and at times working with them feels like an incomplete implementation.  I try to avoid making them because of this, but I've seen some really well done XControls that I use all the time.

0 Kudos
Message 4 of 23
(3,011 Views)

@GerdW wrote:

Hi giacomo,

 

whenever you want something scalable in terms of duplicating existing items you should think of an ARRAY.

Whenever you want different things (like boolean, listbox, chart) grouped together you should think of a CLUSTER.

 

Combine both and you get an array of cluster…

 

When you want to encapsulate this even more you should learn to use LVOOP!



Thanks for the answer, but it doesn't quite get to the point (or I don't see it).

 

Array and clusters do not include code. They can simplify it as you can make an iteration instead of copying the same snippet of code many times, but it's still not what I was looking for.

 

Besides, it looks like you cannot include charts in either clusters and/or arrays... (at least, it doesn't seem to work for me).

0 Kudos
Message 5 of 23
(2,991 Views)

Jim, Hooovahh,

 

I had a look at XCOntrols and indeed it looks like they might be what I am looking for, although they seem to be overly compicated...not that I want "quick and easy" at all cost, but it looks like the amount of work to create an XControl is hardly less than that of creating a few copies of my idicators/controls/code. I'm sure there are powerful application and customization of Xcontrols that are worth the effort, but I'm not sure this is my case (or rather, I'm quiete sure it is not! 🙂 ).

I was hoping that there would be a simpler way of reusing groups of indicator/controls and code. Something like a subVI that can have multiple istances and whose front panel you can include in the main VI. However, I haven't found such solution yet...

 

Thanks anyhow. Maybe I'll try to build an XControl after all, and I'll find out that is not such a big effort...

 

Giacomo

 

 

0 Kudos
Message 6 of 23
(2,988 Views)

@giacomociani wrote:

I was hoping that there would be a simpler way of reusing groups of indicator/controls and code. Something like a subVI that can have multiple istances and whose front panel you can include in the main VI. However, I haven't found such solution yet...


That is sounding more like a subpanel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 23
(2,982 Views)

Hi all again. Sorry for the long silence. I was tied up in other stuff.

 

Anyhow, a subpanel only allows me to run one instance of the VI, doesn't it? I mean, I can't have 4 "independent copies" of my subVI running in as many supanels, unless a make physical copies of the subVI file... is that not correct?

 

 

Since I haven't found any better solution yet, as an acceptable (to me) compromise between result and effort, here is what I have done:

 

  • I have created a subVI that has 6 controls (inputs):
    • 4 numerical controls for the input signals
    • 1 boolean control to decide if to calibrate them or not
    • 1 menu ring control to select the combination I want
  • the VI has one indicator (output), that is the calculated combination of signal, to be plotted
  • Then I inserted 4 instances of the subvi in the main vi, and for each of them I have created corresponding controls in the main VI using the "create->control" command on the input terminals. Then I have wired the output to four chart indicators.

This are the two main advantages:

  • the logic that does the combination/calibrations of the signals is contained in the subVI, so it doesn't clutter the main VI and can be updated on all 4 instances at once by just modifying the subVI
  • the menu ring controls in the main VI are populated with the right values (inherited from the subVI) when I create them

This come pretty close to the "easy to program/easy to maintain" solution I was looking for. However, I still have a couple of issues (actually, I have found a solution for both, but they don't seem very elegant to me):

  1. if I modify the subVI and add a new option to the ring menu, the corresponding controls in the main VI are not updated automatically. Right now I solved this way:
    • I modified the subVI to output also the strings corresponding to the values in the ring menu
    • I run the subVI once when I start the main VI, read the output and use it to programatically modify the entries in the 4 ring menus of the main VI
  2. the values that the subVI uses to calibrate the signals are read from a global variable, and the "read" operation happens inside the subVI. Unfortunately, it looks like those values are only read once: if they change while the main VI is running, the subVIs don't seem to notice it and continue to output the result as if the calibration was not changed. My solution for this (that I haven't implemented yet) would be to add another 4 controls to the subVI for the calibration values, and move the "read" operation of the global variable to the main VI, wiring then the value to the controls on the subVI. Again, doesn't seem very elegant.

Any suggestion for 1 and 2? Or even on a different way of implementing the whole thing?

 

I'm attachin a couple fo screnshot to make the whole thing clearer.

 

Thanks

 

Giacomo

0 Kudos
Message 8 of 23
(2,843 Views)

If the sub vi is re-entrant pre-allocate clones you can load any number of clones into seperate sub-panels or even launch them floating all over your screen.

 

Look into the shipping examples for "Start Asynchronous call" read the help (it isn't really an easy read) the help search term you want to key on is "Clone Pool"

 

 


"Should be" isn't "Is" -Jay
Message 9 of 23
(2,833 Views)

@giacomociani wrote:

Hi all,

 

here is my problem, simplified for the sake of this discussion: I have an application with a VI that acquires data real time and copy them to a global variable. There are a number of other VIs that use this global variable for different purposes. One of them is a panel with four (but could be more) identical groups of chart+controls. Each of these "groups" is comprised of:

  • a list selector to chose from a predetermined list which combination/function of the 4 input variables to plot (eg. v1, v2, v3, v4, v1-v2, v3-v4, (v1+v2)/2...)
  • a button to select if the variable should be calibrated (according to predetermined coefficients) before being used in the various combinations/function
  • a chart
  • the underlying code that "accepts" the four values, transform them according to the selection in the list and button, and then sends the result to the chart to be plotted

What I am looking for is a way of "encapsulating" controls, indicators and associated code in a single "object" so as to be able to:

  • easily and quickly add one of such groups to any VI (not only that one), by somehow "referencing" one main instance of this "object"
  • having all the instances update when I update the main object (for example adding an additional choice to the list selector)

Ideally, what I'm looking for is an "object" that I can add to the front panel of the VI (where it would show, for every instance, one chart, one list selector and one button), and shows up as a block with 4 inputs in the code. And, I'd like to be able to add as many instances I want, all independent in the data the manage and display, but all a copy of the same "object".

 

It seemed at first a fairly natural and common need, but I realized that I don't know how to do it (probably because I don't have a complete enough overview of the various possibilities available in LV), and my searches have been so far more confusing than conclusive. I don't need step by step instructions, but an informed opinion on what is the most efficient path to follow from someone with a broader view of the labview infrastructure than I have...

 

Thanks

 

Giacomo


Is it critical that the VIs that read the global get fresh data?  I use globals only for write once/read many because I'm afraid of the possibility of race conditions where the data can be read before the global is updated.  Or maybe I incorrectly assume that your real time reading was being performed more than once?

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.
0 Kudos
Message 10 of 23
(2,823 Views)