LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make current control values of subvi default

Solved!
Go to solution

I have a vi that is used as subvi and whose front panel has got 4 tabbed pages and each tab has got controls now there are two things that I need

 

1.  The front panel of the subvi has OK and CANCEL buttons

     - OK button should make the current
     panel values the new default, so that next time the app is closed and
     reopened these new values will be in place.

     - CANCEL button will undo
     the changes and reset the controls back to the default state.

      I have tried using invoke node to set the current values to the default state but no luck

      I have attached the screen shot of the vi (done with online help) related to this pls have a look and tell me if it is correct and if not pls give a suggestion.

 

2.   After setting the values I want to write these values of subvi  into the microcontroller when I press the button on the main vi how can I do that ?…..I was successful in opening the front panel window of subvi from the main vi but how can I configure these values………

 

      Here I am attaching the screen shots of my VI pls check and tell me if my way of assigning controls to the tabbed window is correct and if not how can I do that ?

     

0 Kudos
Message 1 of 12
(7,667 Views)

Samantha,

 

"Make Current Values Default" method will work only when the VI is in Edit mode, NOT in Run mode. This is what the LV online help says, I think... Moreover, in Cancel event, you are just reinitializing the Cancel button's value to its default, NOT the variables of the VI itself.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 2 of 12
(7,640 Views)
Yeah.. See the attached screenshot. Smiley Happy
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 3 of 12
(7,638 Views)
But the VI Method, Reinit to Default is available in run-time also. Smiley Wink
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 4 of 12
(7,636 Views)
Solution
Accepted by samtha

Hi Samatha,

 

Good afternoon and I hope your well today.

 

Thanks for the post.

 

1. As parthabe has pointed out, you can't update the defaults for a VI at runtime, you can only set the front panel settings back to the default. If you wish to have this functionality, I would suggest using a config file (text file) where you can store all the control/indicator values. You could load these and update them. i.e. when you start your VI it will load the settings from the file, when the user clicks the ok (Save Config File) save to the file, and if they press cancel then just don't update the file.

 

Now I just had a quick look on the NI Community pages, and I found this example - which examples how I would do it:

 

Programmatically saving and loading values of all front panel controls

 

You should be able to adjust this example to meet your needs, if you wish to be able to update the defaults during runtime.  

 

2.  There are a few ways to pass data between top-level VIs and subVI. What methods have you tried? If you require your subVI to run in parallel with your top-level(main) VI then you may wish to consider calling the VI dynamically using VI Server. Using the VI Server methods you can update/read from controls/indicators using the Get/Set methods. If you simply want to call the VI, execute it and return to the main VI then you can use the connector pane of the subVI to wire data into and out of the subVI. Please let me know more details.

 

Hope this helps, 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 5 of 12
(7,628 Views)
thank you every one for the reply especially Mr.Hillman i will try and do the needful
0 Kudos
Message 6 of 12
(7,610 Views)

Hello,

 

has anybody an idea, why the example code linked above has problems with enums (see  example)?

 

transfererror

0 Kudos
Message 7 of 12
(7,267 Views)

Can you tell us what problems it is having with enums?

 

I don't think that is a very good example.  Having two event structures in the same while loop means the loop can't interate again until both event structures have executed.

0 Kudos
Message 8 of 12
(7,228 Views)

Hello,

 

when loading the saved configuration, I'm getting the following message:

 

Error 1 occurred at Invoke Node in Programmatically Save Control Values 86 _ to be debugged.vi

 

Possible reason(s):

LabVIEW:  An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
=========================
NI-488:  Command requires GPIB Controller to be Controller-In-Charge.

Method Name: Control Value:Set [Flattened] (Deprecated)

"Enum" type descriptor does not match

 

 

 

As you can see, there is a problem with the "Enum" type. Do you have any idea?

 

transfererror

 

 

P.S.: I only modified the above linked example. In my programs I don't use two structures in the same loop. But this is not the problem here.

0 Kudos
Message 9 of 12
(7,103 Views)
For LabVIEW 2009 you have to use a different method. I also corrected the example to use only one event structure which, as Ravens Fan noted, is the proper way to do it. See attached modification.
Message 10 of 12
(7,063 Views)