From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the default value of a variable in runtime

Solved!
Go to solution

Hi,

 

I have a TS sequence which through serial communication with a microcontroller sends the MCU its new IP address. The final octet is incremented for each new UUT. Example, the first one would be 192.168.0.10, the second 192.168.0.11, third one 192.168.0.12.

 

I have a solution for that. But what I want is for the default value of my variable, which I called FileGlobals.Octet, to be saved as the last one that was issued. I have it set to 10 now, and it works fine for running one batch, but if I close the program and reopen it the day after, it's back to 10, and I don't want that. In the example above, I want it the sequence file to be reopened and have the variable start at 12!

 

 

I have three solutions as far as I can tell.

 

1) I can use StationGlobals to store it. I want to avoid that so the program can be used elsewhere smoothly.

2) I can store the value in a text file and read it each run. That's a silly solution, but would work.

3) Most elegant: I need your help to find out how to change the default value of the variable in runtime.

 

TS2016, LV2017.

 

Any help much appreciated!

0 Kudos
Message 1 of 4
(2,530 Views)
Solution
Accepted by topic author DrOnline82

@DrOnline82 wrote:

2) I can store the value in a text file and read it each run. That's a silly solution, but would work.


That is not a silly solution at all.  That is how you would have to do it in a built application, so it only makes sense in this situation as well.


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
Message 2 of 4
(2,511 Views)

Using the shared flag could be a way to do this, but make sure you test and are fully aware of the impact of that flag before using it. It will cause the edit-time and runtime copies of your variable to be shared, which could give the persistence you're looking for, but it will also cause it to be shared with all other clones of the variable, such as between multiple executions in the batch or parallel model.

 

I'll second that the file option isn't such a bad idea... that's what the other options do to persist data (storing it in StationGlobals.ini, vs a custom file, vs the .seq file with the default value). This has the benefit of being an explicit step, so it's probably more obvious to someone looking at this code in the future.

 

Hope this helps!

Trent

https://www.linkedin.com/in/trentweaver
Message 3 of 4
(2,505 Views)

Thank you for your help. I might use the file solution then. It just felt to me to be inferior to using some runtime access to the variable's default value. You guys have a lot of experience with TS, are you not familiar with any such feature? Or is what I am asking for in fact what the flags are used for? I have never used that, but I'll check it. If I find it introduces any risk or unneccessary complexity I'll will probably go with the file solution. Keep it simple.

 

I'm using a sequencial model for this.

0 Kudos
Message 4 of 4
(2,501 Views)