NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence Variables

Is it possible to update the variables of an executing sequence?

Thanks.
0 Kudos
Message 1 of 10
(4,961 Views)
Hi Tim,

I guess you are talking about variables that you have defined in the Locals of a sequence.
You can do this by using the PropertySetVal method eg for a CVI use the TS_PropertySetValString() wrapper to update a string variable.

Hope this helps
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 10
(4,961 Views)
Hi Ray,

Thanks for answering. I figured that as much except, I'm not quite sure what to use as the TestStand handle for TS_PropertySetVal wrapper. Currently, I have been able to update the TS variables of a loaded sequence (using TS_EngineGetSeqFile wrapper to "load"), and using TS_SeqFileGetSequence to retrieve the handle of the sequence. However, when I execute the sequence (using TS_EngineNewExecution), updating the TS variables no longer seems to work.

Thanks,
Tim Phoa
0 Kudos
Message 3 of 10
(4,961 Views)
Hello Tim,

The TestStand handle you would use for the TS_PropertySetVal wrapper functions is a SequenceContext object, which only exists at runtime. If your code was being called by a TestStand step, you could have the current SequenceContext (ThisContext) passed to your code as an object reference.

However, from looking at your posting, it looks like you're doing something entirely different. I believe you're attempting to programmatically do the following with TestStand 3.0 (please let me know if my understanding is incorrect):

1) Load a sequence file.
2) Change the default values for TestStand variable(s) contained in the sequence file.
3) Execute the sequence file using the new values for the TestStand variables.

Based on t
his, there are several approaches you can consider:

1) Load the sequence file, modify the TestStand variables default values, save the modified sequence file to disk, then execute the sequence file. This approach would require that you have a TestStand development license on each machine that executes this code, since any software that creates or modifies TestStand sequence files is acting as a development system.

2) Alter your TestStand sequence file to use a Property Loader step, so it can modify the variable(s) values based on the contents of a properties file. You can programmatically create this properties file on-the-fly in CVI, so that when the sequence is executed it loads the values you have saved into the properties file.

3) If you're just executing your sequence file without using a process model, you can use the TS_EngineNewExecution method's sequenceArgsParam and pass PropertyObjects as parameters to your TestStand sequence.

I'd recommend approach number 2,
it's by far the easiest to implement. There are other approaches to doing this as well, but these are the first ones that come to my mind.

David Mc.
NI Applications Engineer
0 Kudos
Message 4 of 10
(4,961 Views)
Hi Tim,

Try having a look at the example in the folder C:\Program Files\National Instruments\TestStand 3.0\Examples\SequenceBuilderTool\C. This example is about cloning steps in a sequencefile from another sequencefile and I know that's not what you are doing. But it may help you with understanding getting the correct handles.

Although I agree with Dave about using the Property Loader to change your locals at runtime.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 5 of 10
(4,961 Views)
Hi Dave, Ray:

Thanks for the replies. But let me back up for a minute. What I would really like to do is improve the performance of running the TestStand sequence. I have TestStand dumping data into an Excel spreadsheet, which is part of the sequence.
I do have the initial writing of the TS variables working just fine (using TS_PropertySetVal) as stated before, except that when running over the TS Remote Engine, the performance is poor. I'm pretty sure this is due to constant opening/closing/saving of Excel. What I'd like to do is to turn the sequence into a pseudo-callback, running in essentially an infinite loop so that while executing, all I'd have to do is to modify the values of the TS variables and the sequence would b
ehave accordingly.

Thanks for your help.

Tim Phoa
0 Kudos
Message 6 of 10
(4,961 Views)
Hello Tim,

I'd have to understand your application better in order to make some suggestions. Could you post your code and sequence files, or can you write out a detailed pseudo-code listing?

David Mc.
NI Applications Engineer
0 Kudos
Message 7 of 10
(4,961 Views)
Hi Dave,

It's pretty simple really:

What I have now as a sequence:
1. Open Excel
2. Capture Data
3. Write to Excel
4. Save and Close Excel

The method and format of capturing data for Excel varies, and thus depends on the value of the TS variables. However, due to the size of the Excel template file I'm using, this process coupled with the fact that the sequence is often called a number of times consecutively, is rather slow.

What I'd like to do:
1. Open Excel
2. :MainLoop
3. :WaitingLoop //execution should stay in this loop until a "Capture Data" flag is set
4. Go to WaitingLoop while NOT Capturing Data
5. Capture Data
6. Write to Excel
7. Save Excel
8. Go to MainLoop while TestIsRunning (allows for
more capturing of data while Excel is open)
9. Close Excel

The reason for doing it this way is because Excel only allows the writing of data to an open spreadsheet while the sequence is running (the file becomes read-only after the sequence finishes its execution). I believe that by doing it this way, it would eliminate the constant opening and closing of the file and thus speed up execution.

Thanks,
Tim Phoa
0 Kudos
Message 8 of 10
(4,961 Views)
Hi Tim,

Attached is a TestStand 2.0.1 sequence file that demonstrates how I think you could do what you're talking about using a TestStand sequence, ActiveX steps which open/close Excel and write to a worksheet in a separate thread, and TestStand's "queue" functionality to send data between the main thread and the Excel thread.

You can read more about the "queue" functionality in the TestStand documentation.

David Mc.
NI Applications Engineer
0 Kudos
Message 9 of 10
(4,961 Views)
Thanks David. I'll give it a try.

Tim Phoa
0 Kudos
Message 10 of 10
(4,961 Views)