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: 

Best way to manage global application data

Hello,

 

I'm looking for the best way to manage my global application data. I have a program containing about 70 application settings which are loaded from an ini file and organised as clusters and loose variables. I want to be able to use these settings across multiple vi's. The application settings can be modified during execution. Some vi's can change settings and these changes need to be visible accros all vi's.

 

What is the best way to manage this. Ideally, I would have one cluster or class containing all the application settings but since the sub vi's run independend, I can't wire them through. 

 

From what I've read so far, global variables ain't really well suited for this due to race conditions. The FGV might be a solution but it is not clear to me how to implement this for many variables. (One FGV or multiple FGV's, etc... Does anyone have a good example of this?)

 

Are there any other good solutions? Any advice is welcome!

 

Best regards,

Wouter

 

0 Kudos
Message 1 of 3
(2,158 Views)

Are you using the configuration VIs or do you have a roll your own system?

 

What I do is to read the configuration settings on startup. I use a FGV to store the settings and when they change I imediately save them back to disk. You can use one FGV that holds a cluster of all your settings. Also, global variables are perfect for this sort of thing. Just make sure that you update the settings through a VI that saves them to disk then updates the global. Globals (and locals) do not cause race conditions. Bad programming causes race conditions and a FGV will not prevent them. It is just very easy to run into them with variables.

 

You might want to look at a by reference class if classes are the way you want to go.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 3
(2,154 Views)

You can also create a singleton LVOOP object (maybe a few if you want to logically organize your settings). When you initialize the system you create the object and it uses a DVR internally to store your data. Since this is a singleton object you do not need to wire it through your code. Your subVIs simply call the appropriate methods and it will interact with the class data. A FGV is basically the same thing except that you only have a single VI so you are more limited with your inputs and outputs. A singleton object let's you refine the connector pains based on the methods and what they are doing.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 3
(2,141 Views)