NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Update locals subsequence in runtime

Hi, I need to update the values of the TS variable in runtime. I do not want change the static values of these variables and I do not want insert a step in each subsequence. I'd like insert a step into the setup of the main seq that load from a DB the correct values of all the variables. I can do it for FileGlobals and the Locals of the main seq. But I have some problem with the subsequence.

I tried in two different ways but the results are not exactly what I want.

1 way) Use the TS-SetPropertyValue using the following lookup string: RunState.SequenceFile.Data.Seq["nameSeq"].Locals.Name. It works but I am afraid it change the static copy of the sequence, because when the sequence ends the values of the variables do not came back to the default. I should close and re-open TS without save the sequence. I have the same problems also for ovewriting the newRunMode.

2 way) Use the following method/property: Engine->GetSequenceFileEx->GetSequence->Locals->SetValNumber (picture). Also in this way I change the static copy of the sequence. 

 

Thanks.

0 Kudos
Message 1 of 14
(4,606 Views)

Hi logatto

 

I am not sure I completely understand what you are trying to do, but think I get the idea.  Most of the changes you make to the SequenceContext are lost when the execution completes.  Unfotunately for you the SequenceFile and Globals objects are persistable.  You need to gain access your variables outside of the SequenceFile object.

 

For example you can access the local variables of the Sequence above a sub sequence using RunState.Caller.Locals.<your variable name> and the local variables of the top level sequence from a sub sequence using RunState.Root.Locals.<your variable name> (NOTE:  If you are running from a process model Root will be the model, if you are running from Run MainSequence Root will be the main sequence)

 

You should be able to access FileGlobals anywhere FileGlobals.<your variable name>.

 

Regards

 

Steve

0 Kudos
Message 2 of 14
(4,559 Views)

Hi, excuse the delay, but I was out of office. I attached a simply sequence where I try to explain better what I have to do.
In the setup of the main sequence there is an action that gets from a DataBase the values of the variables and overwrite them (for example the variables Locals_TEST into the SuqSeq).
The matter is that (I guess) I am overwriting the static copy of the sequence as I explained in the previous post.
Thanks a lot.

0 Kudos
Message 3 of 14
(4,499 Views)

Hi,

 

Steve's comment regarding FileGlobals is incorrect. Only the StationGlobals are persistable. If you what the FileGlobals values to be available after test execution then you have to update the Default value which is a different lookup string and not use FileGlobals.<variable_name>

 

I think the Default FileGlobals lookup string is "RunState.SequenceFile.Data.FileGlobalDefaults"

 

Regards
Ray Farmer
0 Kudos
Message 4 of 14
(4,482 Views)

Hi Guys

 

I think it depends on the level of persistence you are looking for.  I agree StationGlobals are pretty much as persistable as you can get.  But my understanding is that most of the changes you make to the SequenceContext are not persistable and are lost at the end of execution. Exceptions to this are persistable objects SequenceFile and Globals which retain there values after execution but are lost if the sequence is closed as logatto is seeing.

 

Regards

 

Steve

0 Kudos
Message 5 of 14
(4,474 Views)

Hi Steve,

 

Globals (ie StationGlobals) as you say do retain there value from run to run and when teststand is shut down the StationGlobals file is updated.

 

FileGlobals on the other hand don't and are lost at the end of the execution even on a Restart the runtime version is updated for the FileGlobalsDefaultValues. If you need to retain these values then they must be copied back in the FileGlobalsDefaultValues.

 

Also FileGlobals are only in scope for all sequences within a particular SequenceFile unless of course your are using the Parallel or Batch processes and have set the Sequence File property to Share FileGlobals.

 

 

Regards
Ray Farmer
0 Kudos
Message 6 of 14
(4,464 Views)

Good, but what about locals variables? How can I change the locals variable in sub sequence file from the main sequence? I am not able to do it with sequence context because I can not "see" the locals of subsequence. Using the "Engine" I had the problems I posted.

 

Any ideas?

 

Thanks a lot guys.

0 Kudos
Message 7 of 14
(4,443 Views)

Hi,

 

You can do this in a couple of ways,

Use the SequenceContext and specify the exact lookup string or get a reference to the Sequence of which the Locals are contained then get a reference to the locals using Sequence.Locals. Once you have this use the PropertyObject methods to get or set the values.

 

Hope this helps

 

 

 

Regards
Ray Farmer
0 Kudos
Message 8 of 14
(4,437 Views)

I know of no way to modify the run-time copy of sequence locals before executing the sequence. That's because TestStand doesn't create the run-time copy of the sequence until you start executing it.

 

You could try cloning the sequence file and then modifying and running the clone. That way you don't modify the original.

0 Kudos
Message 9 of 14
(4,422 Views)

...And I thought he just wanted to change the values before the sequence was called not before it had even started executing the test sequence... I thought it a bit strange, why didn't they just pass the new values in via the Parameters of the sequence....

 

 

Regards
Ray Farmer
0 Kudos
Message 10 of 14
(4,416 Views)