LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using "to more specific class"

So I have a whole bunch of controls/indicators that I plan to use in my program.  I am going to have a seperate VI that loads all the default settings and user preferences during a "splash-type" screen before the user can use it.  So what I am trying to do is find an easy way to get all of my references organized and also make it easy to add more.

 

What I initially tried to do was make a cluster type def. with all the reference types that I plan to put on my front panel so far - then I referenced my Main.vi without opening the front panel and grabbed all the control references, but there are generic and I tried to typecast them to the strict classes that I want to use.  The snippet below shows what I tried.  I also included what my type def. is as well in case that might help. Some of them work and some of them don't.  Why will it not work? And what solutions are there available to do what I want?  Or something even better?

 

Thanks in advance.

 

classes.png

 

untitled.png

0 Kudos
Message 1 of 5
(2,855 Views)

What do you need all the references for? Why do you need to convert them? It'll default to a Control-ref, and only if you need a property specific to a certain type (as Strings[] of a Enum) do you need to convert to a more specific class.

 

Control references are mainly used for "remote control" of controls and indicators, so what's the goal?

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 5
(2,845 Views)

Please be more specific than "Some of them work and some of them don't." What do you mean by "work"? Which ones? What types of controls? In what way do they not work? What error or behavior occurs?

 

For loading settings, I like to use a VI that programmatically gets a reference to front panel elements, and uses their name and type to read the right settings. There are lots of variations on this idea. I'm attaching a read/write pair I'm using in one application now. It doesn't handle every data type, only the ones the application needs. It expects to be passed a reference to a page of a tab control, which you could easily replace with a reference to a front panel. I'm not completely sure if it helps you, though - is this close to what you're trying to do?

0 Kudos
Message 3 of 5
(2,844 Views)

@Yamaeda wrote:

What do you need all the references for? Why do you need to convert them? It'll default to a Control-ref, and only if you need a property specific to a certain type (as Strings[] of a Enum) do you need to convert to a more specific class.

 

Control references are mainly used for "remote control" of controls and indicators, so what's the goal?

 

/Y


The goal is to have an "initialize" VI to reset controls/indicators and/or set them to user preferences via values from a config file.  Maybe there is a better way to do this sort of process - I'm not sure.  This is the first application I've had decent reasons to use a config file (although not required - I want to get used to using one).

 

 


nathand wrote:

Please be more specific than "Some of them work and some of them don't." What do you mean by "work"? Which ones? What types of controls? In what way do they not work? What error or behavior occurs?

 

For loading settings, I like to use a VI that programmatically gets a reference to front panel elements, and uses their name and type to read the right settings. There are lots of variations on this idea. I'm attaching a read/write pair I'm using in one application now. It doesn't handle every data type, only the ones the application needs. It expects to be passed a reference to a page of a tab control, which you could easily replace with a reference to a front panel. I'm not completely sure if it helps you, though - is this close to what you're trying to do?


 

What I mean by "some work and some don't" is that when I use highlight execution some say "OK" and others give me error code 1057 - which is saying it cannot be cast to that type.  Why wouldn't it be able to cast to a more specific type regardless of what it is?

 

And those VI's are quite similar to some of the things I am trying to do.  At the very least I they may have helped me see something from a new angle and hopefully I can come up with something that works for me.

 

I guess some of my questions have less to do with my specific problem and more to do with how this "to more specific class" VI works and what it's proper use and limitations are.

0 Kudos
Message 4 of 5
(2,804 Views)

OpenG has a VI called Write Panel to INI, and Read Panel from INI.  It will take a front panel and all of it's controls and save them to a human readable INI file.  Then run the Read VI and it will set the control values to that in the INI file.  It is under the Variant Configuration File package.

0 Kudos
Message 5 of 5
(2,794 Views)