NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

When are dynamically created variables flushed in the sequential process model?

Solved!
Go to solution

I have a sequence in TestStand 2014 in which I dynamically create and populate many FileGlobal variables within the Setup section of my main sequence.  I do this by using the TestStand API to read in data from an Excel file (the data primarily consists of setpoints, limits, etc.).  The methodology itself works flawlessy.

 

However, there are differences in behavior when using the two execution entry points of the Sequential Process Model.  When using the "Single Pass" execution entry point, there is no problem in testing one DUT after another.  However, when using the "Test UUTs" execution entry point, I encounter the following error after completing DUT1 and proceeding to test DUT2:

An error occurred calling 'InsertSubProperty' in 'PropertyObject' of 'NI TestStand 2014 API'.

The item name 'VariableName' is invalid because it is already in use.

 

I interpret this error message to mean that the variable that I'm trying to dynamically create on DUT2's run is already present from DUT1's run.  I have a couple questions around this:

1. At what point in the Sequential Process Model are dynamically created variables flushed, such that a subsequent run using "Single Pass" is starting with a clean slate?

2. Is there a callback I can override such that the variables get flushed after each DUT run, allowing me to dynamically create the variables on every DUT when running using "Test UUTs"?

3. Better yet, is there a TestStand counter I can query to determine if I've already run DUT1 when using "Test UUTs", such that DUT2 uses the variables that were dynamically created on DUT1's run?

0 Kudos
Message 1 of 9
(4,431 Views)

How are you inserting the FileGlobals?

 

Let's assume you do something like this:

FileGlobals.NewSubProperty("Foo", PropValType_String, False, "", 0x0)

Use 0x4 instead of 0x0 as the property option.

From the TestStand Help:

  • PropOption_DoNothingIfExists–(Value: 0x4) Use this option with the SetVal methods of the PropertyObject class to avoid setting the value of a property that already exists. Usually, you use this option in combination with the PropOption_InsertIfMissing option.
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 2 of 9
(4,407 Views)

Actually I noticed you are using the InsertSubProperty.  You can use the same 0x4 as your second argument.

 

Also, to answer you questions regarding when a file gets released from memory.  As far as I understand it, and someone can correct me if I'm wrong, you essentially have 3 copies of your sequence file. 

  1. Disk Copy
  2. Edit Time Copy
  3. Execution Copy

The Disk Copy is the one on your hard drive.  The Edit Time Copy gets created once you open the file in the seq editor or UI.  It is now in RAM.  The Execution Copy occurs when you kick off an execution.  Basically the Process Model grabs the Edit Time Copy and creates the Execution Copy.  It is this Execution Copy that you are adding the FileGlobals to.  The Execution Copy hangs around until the Execution is completed.  In the case of Test UUTs your execution doesn't complete until you are done looping and the process model stops executing.  Your process model will continue using the Execution Copy until it completes. 

 

I haven't looked into it so I don't think it's possible, but I don't know if there is a way to "reset" the Execution Copy to the Edit Copy.  I highly doubt it.

 

Hopefully this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 3 of 9
(4,405 Views)

jigg,

 

I thought for sure your recommendation was going to knock this one out, as I had previously just been using the default flag for the property option.  However, using 0x4 (PropOption_DoNothingIfExists) or 0x5 (PropOption_DoNothingIfExists and PropOption_InsertIfMissing) still results in the same error.  Is there something else I could be overlooking?

 

Thanks!

0 Kudos
Message 4 of 9
(4,288 Views)

Can you post the exact expression you are using to insert it?  That way I can replicate it.  Because the 2 ways I tried above work fine for me.

 

Also, what version of TestStand are you using.

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 5 of 9
(4,272 Views)

I'm using TestStand 2014SP1.

 

I'm actually using an Action step with the ActiveX/COM adapter; the settings are as follows:

Screenshot.jpg

 

I did a comparison of functionality by instead using a Statement step with the following expression:

Parameters.Dynamic_Variables.InsertSubProperty("",5,0,Locals.Excel_refs.PropertyObject_ref)

 

The run on DUT1 ran fine, but the next run on DUT2 resulted in the same error.  If it matters at all, let me add that from my MainSequence there are 2 levels of subsequence call (MainSequence file > Subsequence file 1 > Subsequence file 2) before the "problem" step is reached (this is why you see "parameters" above, because this gets passed back up the chain to the MainSequence, where it eventually becomes a FileGlobal of the MainSequence sequence file).  Is it possible this is where my problem is?

0 Kudos
Message 6 of 9
(4,256 Views)
Solution
Accepted by awooster

Or you could just use the PropertyExists Function as a precondition.

 

PropertyExists("Locals.Foo")

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
Message 7 of 9
(4,249 Views)

jigg,

 

I appreciate the suggestion of using the PropertyExists function.  For the way I've got things implemented (i.e. the multiple layers of subsequence call mentioned previously), this appears to be working for me.  I'm using this function in the top level sequence to control if I even enter the dynamic variable creation routines in the first place.

 

I really like this solution because now when running as "Test UUTs" the dynamic variables are created on DUT(1) and then this step is skipped on DUT(N+1).  Yay for test time reduction!

 

 

0 Kudos
Message 8 of 9
(4,226 Views)

Glad it works for you!!! Smiley Very Happy

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 9 of 9
(4,222 Views)