LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Failed global variable update?

Solved!
Go to solution

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).

 

0 Kudos
Message 1 of 24
(231 Views)

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

0 Kudos
Message 2 of 24
(226 Views)

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
0 Kudos
Message 3 of 24
(210 Views)

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.

0 Kudos
Message 4 of 24
(205 Views)

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?

0 Kudos
Message 5 of 24
(201 Views)

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.
0 Kudos
Message 6 of 24
(200 Views)

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.

0 Kudos
Message 7 of 24
(196 Views)

@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
0 Kudos
Message 8 of 24
(181 Views)
Solution
Accepted by topic author michele.santucci

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

 

michelesantucci_0-1734706591647.png

 

0 Kudos
Message 9 of 24
(180 Views)

@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
0 Kudos
Message 10 of 24
(178 Views)