LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating multiple of the same typedef to default values?

Solved!
Go to solution

I have a panel of 4 (with possibly more to come) type-def controls that I would like to figure out how to reset to their default values when the program begins to run. With the hope being to keep things tidy, are there any other options when trying to reset the controls within these type-defs? Or do I literally have to create a Return to Default invoke node for each and every contorl?

 

Thanks

 

typeDefs.png

0 Kudos
Message 1 of 7
(3,518 Views)
Solution
Accepted by rkmadse

Create an array of references to the controls. Put the Invoke Node inside a for loop and autoindex over the array. Then you only need to add a reference to the array when you add a control to the panel.

 

Lynn

 

 

Message 2 of 7
(3,509 Views)

I know it's a silly request, but I have now created an array of references. When initializing to default, the previous axis values stay. Is there a way to reset these for appearance sake? I'd like the top two graphs to look like the bottom two when restarting the application.

 

typeDefs.png

0 Kudos
Message 3 of 7
(3,495 Views)

Graph axes are not values of the control so they will not be affected by the Default Values method. You can set the axes by property nodes. It has been a while since I worked with those properties.. Some properties behave differently if Autoscaling is on or off and there may be other interactions between various properties.

 

Lynn

Message 4 of 7
(3,482 Views)

Am I correct that (a) you have a TypeDef with Connection, Measurement, Last Value, etc. and a Graph in a Cluster, and you have a 2 by 2 array of these Clusters on your Front Panel?  If so, when you start your Program, get one Cluster set the way you want (if the defaults don't change, save the Cluster with the Defaults already set, then you won't have to do any work here).  You can then simply Initialize Array with that "Initial Cluster" and wire that to your 2 x 2 Front Panel indicator.  I made a Demo Cluster (too bad you didn't attach your TypeDef -- I could have used that) consisting of an XY Graph, a Numeric, and a Boolean.  Here I illustrate initializing the 2 x 2 Array with the Numeric initialized to 5 and the Boolean to True. I dropped the TypeDef as a Constant, set the initial values "by hand" (as I mentioned, setting them in the TypeDef saves this step), and initialize my FP array.  This also clears the graphs (I think), but does not reset all of the Scales -- not sure how to get the RefNums to the Graphs (unless you also save them in the Cluster and "hide" them).  Note that "Array" is the array of the 4 Front Panel clusters.

 

Init FP.png

Bob Schor

 

 

Message 5 of 7
(3,446 Views)

Am I correct that (a) you have a TypeDef with Connection, Measurement, Last Value, etc. and a Graph in a Cluster, and you have a 2 by 2 array of these Clusters on your Front Panel?  If so, when you start your Program, get one Cluster set the way you want (if the defaults don't change, save the Cluster with the Defaults already set, then you won't have to do any work here).  You can then simply Initialize Array with that "Initial Cluster" and wire that to your 2 x 2 Front Panel indicator.  I made a Demo Cluster (too bad you didn't attach your TypeDef -- I could have used that) consisting of an XY Graph, a Numeric, and a Boolean.  Here I illustrate initializing the 2 x 2 Array with the Numeric initialized to 5 and the Boolean to True. I dropped the TypeDef as a Constant, set the initial values "by hand" (as I mentioned, setting them in the TypeDef saves this step), and initialize my FP array.  This also clears the graphs (I think), but does not reset all of the Scales -- not sure how to get the RefNums to the Graphs (unless you also save them in the Cluster and "hide" them).  Note that "Array" is the array of the 4 Front Panel clusters.

 

Well, I had a Snippet in here that showed this process, but I'm somewhere with poor connectivity and I can't get it to "Reply" with the Snippet attached ...

 

Bob Schor

 

 

0 Kudos
Message 6 of 7
(3,438 Views)

Broadly speaking, when you have repeating elements in programming, it's a good sign that you should probably find a way to create one place which holds all the logic and then dynamically create copies of it.

 

In your case, here are a number of options:

 

  1. Hold all the logic in subVIs and give the VIs references to the controls.
  2. Create an XControl which will have all the functionality.
  3. Use subpanels and open N copies of a reentrant VI and put them in the subpanels.

Each of these options has its pros and cons, but of the three, I would suggest you go with the third, which will certainly reset everything (since you get a new copy of the VI each time you run it). You will need to communicate with each copy, which you can do through any number of means (like a queue or a user event). If you want somewhere to start, you can try looking up information about the Actor Framework, or JKI SMO, which are somewhat easier to understand.


___________________
Try to take over the world!
Message 7 of 7
(3,409 Views)