LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

List of constants in separate file

I have a project with multiple VIs, there's a bunch of constants (some can change often, some are more permanent). I am wondering if there's an efficient and robust way of compiling all those constants in one place and have all my VIs read from that place.

0 Kudos
Message 1 of 6
(953 Views)

Yeah, you can create an ini file with multiple sections (grouped logically) and create an LV2 that loads this ini file at the start of the application and read from this LV2 throughout your application.

 

Some even prefer an XML if you've complex structured data, but you're talking about constants which I would assume as scalar values that easily fit into ini file structure.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 6
(941 Views)

I think the cryptic term "LV2" actually means a "LabVIEW 2 style global" (aka "functional global"), but since you need more functionality, an "action engine" is probably a better word. Are you familiar with those?

On "first call?" it would read the ini file, populate the data structures (e.g. held as cluster in a globally initialized feedback node), and return them. On later calls, it would just return the values. There should be modes to update individual values programmatically. There should also be a mode to write the current values back to the ini file. etc.

 


@jmerham wrote:

I have a project with multiple VIs, there's a bunch of constants (some can change often, some are more permanent). I am wondering if there's an efficient and robust way of compiling all those constants in one place and have all my VIs read from that place.


You probably need to be more specific, for example of something changes often, it is not really constant. 😄

 

Can the values change during the run or only between runs? What part of the program is responsible for the value changes? Should the final values be written do disk so the next session starts with the final values of  the previous session? Are there good default values in case the ini file cannot be found?

 

so. many. questions!

0 Kudos
Message 3 of 6
(893 Views)

Thanks, @altenback for clarifying the LV2 term, yes, I meant an FGV (aka LV2) based Action Engine to maintain the data loaded from the config file.

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000015BjzSAE&l=en-US

https://labviewwiki.org/wiki/Functional_global_variable

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 6
(871 Views)

I'd be tempted to just use the simple Global Variable.  All of the "constants" can be stored in a simple global VI.  But these are not good for when you are performing actions on the data (read-modify-write) as that will create all kinds of race conditions.

 

Some references for things to consider:

A Look At Race Conditions

Are Global Variables Truly Evil? 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(842 Views)

I meant @altenbach, I have to be careful while replying late at night.

 


@santo_13 wrote:

Thanks, @altenback for clarifying the LV2 term, yes, I meant an FGV (aka LV2) based Action Engine to maintain the data loaded from the config file.

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000015BjzSAE&l=en-US

https://labviewwiki.org/wiki/Functional_global_variable

 


 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 6
(823 Views)