From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use FGV as a Settings PoP-Up Window which Main.vi can get values from during runtime

Solved!
Go to solution

Hello Everybody,

I haven´t found anything which could help me with my Problem. Let me explain it to you.

 

I´m creating a bigger Program with a lot of  Serial Devices and i want to store all the device Information in an .ini File and load an save them at start and end of the Program-execution from the File to my Settings.vi. This Vi was planned as a FGV. The saving and reading to this FGV works fine, but i also wanna be able to change Settings during runtime(mainvi) by showing the frontpanel of my subvi and changing the ctrl.values in my Subvi and then in my main.vi call the subvi by dropping it in the block diagram and then just wire an indicator to the Outputs.

 

The Problem with my attached Vis, is that when the Pop Up happens i wether can t Change controls or the values from my .ini file are not loaded into the Frontpanel. I have 2 different and not working approaches to this attached in a little example.

 

The Vis are created with Labview 2015

 

0 Kudos
Message 1 of 12
(3,665 Views)

Sorry, but you should really get rid of this huge flat sequence structure. If I see a block diagram with an Event structure inside of a flat sequence structure, I can be almost always sure there are other serious problems with the VI.

Some other parts in the code also do not make too much sense to me, like an empty Timeout case, etc...

 

I really recommend to refactor the code, and use a proper State Machine (get rid of that sequence structure!). If you have access to the online Core 1-2 teaching material, I recommend to go through it.

 

Edit: some more things:

  • you should use a LV project (you did not share the SerialMotorCluster typdef cluster neither)
  • Your main BD is way too huge!
  • Your "ReadConfigFile" and "writeConfigFile" VIs are crazy! At least you could have used a FOR loop, and not repeat the ini function >30 times! Actually are you aware that you can save and read clusters to/from ini files? It would seriously simplify these two config file VIs. Read more here: http://digital.ni.com/public.nsf/allkb/FE4052AADA227B5686256F490036462F and here: https://www.mooregoodideas.com/readwrite-anything-vis/
  • "Settings_PoPUP.vi": what are you doing here with that 10 msec timeout? Why do you need it??
  • Why do you need to call VIs dynamically? What is the purpose?

Edit2: also read more about config files, and specially about cluster mutations (for example if you change your typedef, and wanna update the new cluster with an old config file):

https://forums.ni.com/t5/LabVIEW/Intialise-cluster-controls/m-p/3298337/highlight/true#M964632

about mutation: https://forums.ni.com/t5/LabVIEW/Saving-application-state-for-later-resume/m-p/3225945/highlight/tru...

0 Kudos
Message 2 of 12
(3,635 Views)

This is the "OpenG Variant Configuration File palette", You will find them very useful! You can install it via the VIPM:

 

openG_cluster_ini.png

0 Kudos
Message 3 of 12
(3,623 Views)

hi Blokk,

Thanks for the advices. Ist my first Approach using ini files so any Help is useful.

 

The Idea with the Timeout was to pass the Input to the Output when no ctrls are changed.

And i don t get why i should use a State Machine here. This is a small Part of my Main Programm and the Main.vi a State Machine and one Event is Calling the Settings Pop up but this Event doesn´t work because i don´t know how i Need to call the Vi when i want the Vi on the one Hand to work as a FGV where i can get data from in my Main (without opening FrontPanel)  and on the other Hand change this data on the Frontpanel of the Settings.vi (here i want to open FP)  and next time when i just "read" the vi i want the new Data at my Output and that isn´t working. So i need to call this Vi one time with opening Frontpanel and all other times just static and reading/writing to the ctrls of this Vi.

 

i´ll add the Motor.ctrl

0 Kudos
Message 4 of 12
(3,588 Views)

Modularity. Your problem is that you try to include multiple functionality in one single subVI.

Just use a FGV to Read/Write data operations, so only for storage. No need to show the front panel to the user. By the way, that timeout still does not make sense (maybe you do not understand data flow principle 100% yet?). If you have shift registers, the data is always there when you call the subVI. Actually you do not need an Event Structure in an FGV. An FGV should be purely used for data storage. It can have other things too, like actions on the data, those are the so called "Action Engines". Read more about action engines here from Ben:

https://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/td-p/503801

 

Use a separate modal VI for pop-up window, where the user can modify the content of the above FGV (Read/Write modes of the FGV).

 

edit: so you can use the FGV inside the pop-up VI. Beside, you do not need to use dynamic VI calls...

Message 5 of 12
(3,586 Views)

OK Thank u very much. I´ll use ur advices to modify my Vi and then post it again 🙂 I know there is a lot of nonsense in my code and im glad when someone tells me how to fix em 🙂 This makes sense to use like 2 Vis one for saving one for manipulating.

I was thinking of using a FGV for Settings because in my old Program this the Controls were in my main vi and i wanted to save Memory and i thought with using a subvi and just call it when i need the Config Data wld help me saving Memory and I thought using an Event Structure here wld be better because it only writes this specific changed value in the Cluster. When i remove the Event i have polling in my PoP-Up haven´t i?!

 

Maybe you know something about that to. I hoped to improve Performance with this Vi and i thought calling a Vi dynamically wld do that because i just load it when i need it or did i get this wrong too ?!

0 Kudos
Message 6 of 12
(3,581 Views)
Solution
Accepted by topic author Kai_!
  1. Do not worry that you write non sense code, that is the way to improve 🙂 Important is that you read lots of code in the forum, willing to learn and get advice from others, and also take as much tutorials as possible (do you have access to the Core 1-2 online training? It is very useful!)
  2. Do not worry about memory usage. In your case it is totally irrelevant memory-wise either calling your VIs dynamically or from the block diagram. Dynamic VI calls are advanced topics! First get a solid knowledge in the basics, then you can play with more advanced things like dynamically called modules, etc.
  3. "When i remove the Event i have polling in my PoP-Up haven´t i?!" No, I said do not use Event Structure in the FGV. An FGV should be as simple as possible, and execute immediately! So of course you need to use an Event Structure in your pop-up VI!  Do you know the template called "User Interface Event Handler"?: useerinteferafce.png

 

 

ps.: here is a simple example of an FGV (the enum should be a typdef, and the Number In/out can be a typdef cluster):

 

SET.png

GET.png

 

 

0 Kudos
Message 7 of 12
(3,571 Views)

@Kai_! wrote:

Maybe you know something about that to. I hoped to improve Performance with this Vi and i thought calling a Vi dynamically wld do that because i just load it when i need it or did i get this wrong too ?!


Yup. The only reasons to use dynamically loaded VI's is to spawn them off as a separate thread (VI server/Asynch call) and dynamic coding/functions ('overloading', if you have several VI's with the same connector pane). The marginally slower start (load) of the program is probably better than (repeated?) loading of a VI during runtime and adds complexity and makes it harder to debug.

 

As for your original question, my inherited projects use AE's frequently, and the Main setup typically has cases for showing the front panel and changing values. AE's used like this can be seen as OOP lite (but without any code and data protection). I agree the split design is better, but this works well enough.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 12
(3,570 Views)

Ok again Thanks a lot 4 the advices blokk and yamaeda. I will try the split design as soon as possible and when i can confirm that it works i´ll post my final design here and mark ur post as solution but it´ll take me a week or so because i´ve urgent things to do b4.

 

 

0 Kudos
Message 9 of 12
(3,541 Views)

And please read.

A Plea for Full Words

0 Kudos
Message 10 of 12
(3,532 Views)