12-20-2024 07:59 AM - edited 12-20-2024 08:00 AM
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.
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?).
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).
Solved! Go to Solution.
12-20-2024 08:02 AM
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
12-20-2024 08:39 AM
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.
12-20-2024 08:44 AM
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.
12-20-2024 08:46 AM
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?
12-20-2024 08:46 AM
How old is this code? The SSS should be beyond your reach.
12-20-2024 08:50 AM
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.
12-20-2024 08:56 AM
@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.
12-20-2024 08:57 AM
I know it's ugly but this way it will work:
12-20-2024 08:59 AM
@michele.santucci wrote:
I know it's ugly but this way it will work:
Yes, that forces order. But it'd be easier to just wire it from the previous VI. 🙂