LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a Generic Cluster to a VI

Solved!
Go to solution

I was wondering how you create a VI that can take any cluster or data item as a control?  For example the "Write to Binary File", "Data" input takes any data type.  How do you do this in your own VIs?

 

Thanks.

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 1 of 10
(3,252 Views)
Solution
Accepted by topic author ChristopherPovey

Christopher,

 

the mentioned VIs are polymorphic.

You might be interested in this white paper.

 

Please note the following passage:

Do not use variants in place of polymorphic VIs in situations where data types can be determined at design time. Polymorphic VIs yield cleaner, faster code and require less runtime error checking.

 

So your question can be 'solved' by one of the following options:

- Polymorphic VIs

- Variant

- Flatten/unflatten to/from string

- ...

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 10
(3,247 Views)

For that purpose you can have Variant as a control that can take any data type.  But in many case it will not give the expected result so you can create a polymorphic vi with the predefined data type.

-----

The best solution is the one you find it by yourself
Message 3 of 10
(3,243 Views)

The problem I was thinking about was:

 

I have a GUI front end with a number of panels and each panel contains a number of different controls.  As part of each "panel" there is a save and load button.  When these are selected, the values of the controls on that panel are saved to disc or loaded from disc (via a single generic "Save Data" VI and a single generic "Load Data" VI ).  In this case the Generic "Save Data" and "Load Data" VI's would need to be designed with no concept of the input data control or output indicator until it was used.  The VI's would also contain a marker to associate a file with a panel so that the data from an incorrectly selected file would not trash a panel.

 

I'll have a look into Polymophic and Varient VI's...

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 4 of 10
(3,236 Views)

For this we generally create a cluster and bundle all the control values into that cluster and write it as a single element to a data log, binary or xml file and while starting retrive the data by reading the file and load it to the controls.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 10
(3,231 Views)

Christopher,

 

this sounds more like using VI server within your "save" and "load" functions.

You would simply pass the reference to the cluster to those VIs. Within the VIs, you would do something like this:

VI Server Flexibility.PNG

Of course, this is only a scetch of the functionality, without handling files and actual access to data.

 

Norbert

 

 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 10
(3,225 Views)

@P Anand wrote:

For this we generally create a cluster and bundle all the control values into that cluster and write it as a single element to a data log, binary or xml file and while starting retrive the data by reading the file and load it to the controls.


I might not want to save all the control values.  Say I had 8 panels (each with their own Save button) with different controls on it.  I might want to only save the contents of panels 2 and 6 for example but not the others...

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 7 of 10
(3,218 Views)

@Norbert_B wrote:

Christopher,

 

this sounds more like using VI server within your "save" and "load" functions.

You would simply pass the reference to the cluster to those VIs. Within the VIs, you would do something like this:

VI Server Flexibility.PNG

Of course, this is only a scetch of the functionality, without handling files and actual access to data.

 

Norbert

 

 


So the "generic" Save VI could have a Cluster Refnum input which would accept any cluster of controls.  Sound good.  As I say this was just a curiosity about passing any types to a VI.  The example was what I thought off the top of my head (based on the “Write Binary File” VI).

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 8 of 10
(3,215 Views)

Christopher,

 

i think, you now got some good points to start with an think about the requirements vs. implementation. Now it is your task to collect some experience by creating small examples/"proof of concepts" in order to define the solution you are going to use.

Have fun with playing around 😉

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 9 of 10
(3,211 Views)

Since this thread has drifted from its original and is now entertaining the option of working via control references you may want to review this Nugget I wrote on how to exploit control references.

 

It starts out with the simple ideas, moves through some more advanced ideas and eventually ties it all together with tricks to handle arrays of cluster os arrays ... using a recursive approach.

 

So...

 

Look that thread over and stop reading when the topic get hairy.

 

have fun,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 10
(3,197 Views)