NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Read sequence ini file in first instance of pre uut callback

I want to read a sequence dependent .ini file when I open the sequence.  I had been intending to read the file during the first instance of the pre-uut callback, but I'm not sure how to tell the system which file to use.  Is there a way to get a fileglobal from the sequence into the preuutcallback (even though the preuutcallback is called BEFORE the main sequence)?
 
Is there a better way of doing this that I am not seeing because I have already latched onto the preuutcallback idea?
 
Thanks,
Sean
0 Kudos
Message 1 of 8
(4,153 Views)

Hey Sean,

Why not use the SequenceFileLoad callback?  It's an engine callback that gets called when the file is loaded into memory. 

By the way if you added the PreUUTCallback to your client sequence file then you should already have access to the sequence file globals.  FileGlobals.MyVariable.

Hopefully you aren't editing the PreUUTCallback sequence in your process model.  You should be overriding it from your client by adding it there.  Edit>>Sequence File Callbacks  Then add the ones that you want.

Hope that helps,

Message Edited by ~jiggawax~ on 10-18-2007 03:18 PM

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

Thank you for your response jigg. 

I am indeed modifying the process model, because I don't want to have to go through this for all of the individual sequences that will be written.  I want the default behavior to read the ini file for a given sequence. 

I hadn't thought about the SequenceFileLoadCallback.  That is probably a better place than the PreUUTCallback, but it still leaves me with the problem of extracting information from the FileGlobals of the individual test sequence (before that sequence occurs in the process model) to determine the path to the ini file for that sequence.

If you have any suggestions, please let me know.
Thanks,
-Sean

0 Kudos
Message 3 of 8
(4,089 Views)
Hey Sean,
 
Unfortunately, I think this is bad practice because what if the client sequence doesn't contain the FileGlobals needed?  However, it is possible.  Have you read this KB: http://digital.ni.com/public.nsf/allkb/F970E072B4B41EF786256E30007505B2?OpenDocument  It's an older KB so you'll have to modify some things for your version of TS.  If you have TS 4.0 you can call into the API without doing an activeX step.
 
If you are doing this then you should use preconditions on your steps to see if this variable exists or not.  Because if it doesn't you will get runtime errors. 
 
One more thing, if it must be in your process model then the best place would be the Process Setup Callback.  If it changes every loop then use the PreUUTLoopCallback.
 
Hope that helps some,
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 4 of 8
(4,078 Views)

One more thing- In TS 4.0 you can have templates.  So then you can just drag and drop into your new client sequences without having to redo it every time.  🙂

Talking about adding the ProcessSetupCallback to your client.  Or whatever callback you choose to change.

Message Edited by ~jiggawax~ on 10-19-2007 11:39 AM

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

Jiggawax,

Thank you for the reference.  It answers my initial question admirably.  Unfortunately, trying to pass an indeterminate amount of data from an ini read by my process model to my client has proven to be unpleasant.  I may have to implement this client side after all.  I tried to put it in the SequenceLoadCallback and update the file globals, but it appears to only update the globals for the duration of the SequenceLoadCallback?  Is there a way to have it update the globals for the duration of all executions until the sequence is exited?  I can do this in the PreUUTCallback using an IF statement to check for an empty array and filling it from the INI, but if tnere is a better way to do this then I would rather do it that way.  Smiley Happy

Thanks,
Sean

0 Kudos
Message 6 of 8
(4,036 Views)
Honestly, the best place is in the Process Setup Callback.  The reason that it's only happening for the duration of the Sequence File Load Callback is because you are only updating the runtime copy of those variables.  Once the file is loaded into memory the runtime copy is gone.  Then when you start a new execution it creates another runtime copy with the default File Globals.  Unless you wanted to save the changes as defaults in your Sequence File Load callback then you will need to do it after you start the execution.  The first callback to execute is the Process Setup Callback and was designed for situtations like yours where engineers need to set up variables or devices for their sequence.  You can definitely hard code it into the Process Model like you were doing with the KB I referenced or you can just have your developers override it from their client sequence. 
 
Also, if you want to modify the Process Model directly, you could add your own sequence call at whatever place you wanted and have that sequence only get called if the user has a certain variable set in their client sequence.  For instance in my client sequence I have a File Global that's a boolean called IncludeINI and it's set to true.  Then at some point in the process model you have a Sequence Call to a sequence that loads the ini file.  Then the precondition for the Sequence Call step would be that the PropertyExists() and that it's true.  Just another idea.
 
Hope that helps,
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 8
(4,034 Views)
Thanks for taking the time to help with this.
-Sean
0 Kudos
Message 8 of 8
(4,031 Views)