cancel
Showing results for 
Search instead for 
Did you mean: 

Failed global variable update?

SOLVED
Solved!

Failed global variable update?

Message contains an image

Hallo,

 

I think I'm having a problem with global variables.

I have a big number of global variables defined into parameters.vi.

Among these parameters I have BOARDS_PATH, this variable is the folder where I have to look for some xml files.

BOARDS_PATH value is changed by Load_Config.vi that reads values from .ini file and set BOARDS_PATH variable

(among the others).

BOARDS_PATH is used by Get_Boards.vi to create an array (Boards) of values I will use to look for specific board profile.

 

This's the main vi section where Load_Config and Get_Boards are called.

 

michelesantucci_0-1734700871851.png

Load_Config.vi do something like this, the stacked sequence is repeated for each possibile entry in the .ini

file (there's a better solution?).

michelesantucci_1-1734700960259.png

 

If I debug the main vi global values are correctly set BOARDS_PATH is consistent.

 

If I run the main vi without debugging it or if I compile it and run the binary then BOARDS_PATH is left at the default value (without any visible error).

 

23 REPLIES 23

Rif.: Failed global variable update?

BTW the ini file is something like this:

 

[general]
ProjectPath = "C:\Program Files (x86)\IDS\MAN_TEST_UI"
ReportTemplatePath = "C:\Program Files (x86)\IDS\MAN_TEST_UI\data\report_templates"
BoardsPath = "C:\Program Files (x86)\IDS\MAN_TEST_UI\data\boards"

 

[MAN_PAIPL]
SACableAtt = 0

 

[GPIB]
GPIB_E3649A = 10

Yamaeda
Proven Zealot

Re: Failed global variable update?

Welcome to Race Conditions.

In this case, the easy solution is to send out the path as an indicator and wire it directly to the next function.

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

Qestit Systems
Certified-LabVIEW-Developer

Re: Failed global variable update?

I got this but it's a workaround that could work for this case only.

I have something like 100 initialization parameters loaded from .ini files to manage and I cannot think to use this approach each time.

Re: Failed global variable update?

how can this code being subject to a Race condition?

Load Config and Get Boards are run sequentially .. if they are not how can Error in -> Error out be kept consistent?

billko
Proven Zealot

Re: Failed global variable update?

How old is this code?  The SSS should be beyond your reach.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
drjdpowell
Trusted Enthusiast

Re: Failed global variable update?

You need to execute your load config before reading any of the Global Variables.  In your screenshot, you have written code to read the global variable first.  Put a sequence structure around the Read, with an input error wire to enforce the execution order.   Remember, LabVIEW code does not necessarily execute left to right.

Yamaeda
Proven Zealot

Re: Failed global variable update?


@michele.santucci wrote:

how can this code being subject to a Race condition?

Load Config and Get Boards are run sequentially .. if they are not how can Error in -> Error out be kept consistent?


The Global is read before it's written since you have nothing that forces order.

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

Qestit Systems
Certified-LabVIEW-Developer
Solution

Re: Failed global variable update?

Message contains an image

I know it's ugly but this way it will work:

 

michelesantucci_0-1734706591647.png

 

Yamaeda
Proven Zealot

Re: Failed global variable update?

Message contains an image

@michele.santucci wrote:

I know it's ugly but this way it will work:

 

michelesantucci_0-1734706591647.png

 


Yes, that forces order. But it'd be easier to just wire it from the previous VI.

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

Qestit Systems
Certified-LabVIEW-Developer