11-17-2017 08:08 AM
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
Solved! Go to Solution.
11-17-2017 09:37 AM - edited 11-17-2017 10:02 AM
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:
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...
11-17-2017 10:11 AM
This is the "OpenG Variant Configuration File palette", You will find them very useful! You can install it via the VIPM:
11-20-2017 02:21 AM
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
11-20-2017 02:40 AM - edited 11-20-2017 02:41 AM
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...
11-20-2017 02:47 AM - edited 11-20-2017 02:52 AM
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 ?!
11-20-2017 03:17 AM
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):
11-20-2017 03:20 AM
@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
11-22-2017 10:21 AM
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.
11-22-2017 10:58 AM
And please read.