NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Create FileGlobals variable without deleting of existing, using TestStand API from LabVIEW

Solved!
Go to solution

Dear NI community,

 

I create FileGlobals Variables as it is shown in the attachments. Variables are created, but at the same time, all existing if the file FileGlobals are deleted. Could anyone help, please, how can I insert variables, without affect on existing ones?

 

Thanks a lot in advance!

0 Kudos
Message 1 of 8
(5,118 Views)

What is your lookup string ("String") for the variable?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(5,114 Views)

String - is name of my variable, which I want to create.

0 Kudos
Message 3 of 8
(5,111 Views)

You did prepend the "FileGlobals." before the variable name itself, did you?

 

E.g. String  = FileGlobals.MyGlobal

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 8
(5,107 Views)

Actually, I've tried it with FileGlobals at the beginning, and without. 

In the first case, it puts created variables to container named "FileGlobals", and other FileGlobals vars are deleted.

In the second case, variables are created OK, but all others variables, existing ones, are deleted.

I have also concerns about usage of FileGlobalsDefaultValues reference - maybe, it causes problems? But I can not access FileGlobals reference from SequenceContext, while I'm not running sequence...

0 Kudos
Message 5 of 8
(5,105 Views)

Actually, my previous post is nonsense....

Using your approach within the sequence itself works for me to create the variable, but it doesn't show up in the execution itself (which is expected).

What i see from your code is that you didn't increment the change count of the file befor saving it.

 

I haven't checked without the sequence running, so here just a guess:

- Create a new variable

- Add this variable as InsertSubProperty to the FileGlobals

 

Norbert

 

PS: If my memory serves me correctly, this is something which is done in TS 2 class from NI as exercise.....

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 6 of 8
(5,101 Views)

You are updating the sequence file programatically. If the sequence file is already opened in Sequence Editor, it needs to be refreshed. Hence, as Norbert specified, you need to use SequenceFile.IncChangeCount() before saving the sequence file. KB contains details about using IncChangeCount API.

 

If you are creating/modifying value of a FileGlobal variable of a sequence file in execution, you need to use Execution.GetFileGlobals() and modify the run time copy of the FileGlobals.

 

Note: Irrespective of using IncChangeCount() solves your issue or not, it is always good practice to use InChangeCount() when you are programatically modifying and saving the sequence file.

 

- Shashidhar

Message 7 of 8
(5,092 Views)
Solution
Accepted by topic author kosist90

I was struggling with this issue all morning, and... I've realized, that this code doesn't delete variables from FileGlobals. Code for creation of sequences does it, which runs before this code... So, I've corrected that code - and it works now!

 

Thanks to everyone for help, I've found couple interesting things - I didn't know about this incrementation of file changes.

0 Kudos
Message 8 of 8
(5,086 Views)