NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling .seq files from Python

Solved!
Go to solution

I am trying to use Python to call a .seq file, wait until the sequence is done, then resume the Python script.  I have gotten everything to work it seems however my problem is when I perform the  Engine.NewExecution it doesn't seem to run the sequence file and WaitForEndEx times out. (The time for my sequence file is about 50 seconds.)

 

What am I doing wrong?

 

Python code: 

testStandEngine = win32com.client.Dispatch("TestStand.Engine.1")
sequenceFileObject = testStandEngine.GetSequenceFileEx("C:\\...\\SIL Version .13\\Teststand Primitives\\ShutDown Target.seq")
testStandExecution = testStandEngine.NewExecution(sequenceFileObject, "MainSequence", sequenceFileObject, False,0)
testStandExecution.WaitForEndEx(60000)

0 Kudos
Message 1 of 22
(8,105 Views)

Hello hobbs1,

It looks like you are on the right track. The only thing that I noticed was that you are passing in the same sequence file as the third parameter of NewExecution. Here is the help for the function:

 

Parameters

sequenceFileParam As SequenceFile

[In] Pass the SequenceFile object that contains the sequence to execute. If the execution uses a process model, pass the client SequenceFile object.

sequenceNameParam As String

[In] Pass the name of the sequence or Process Model entry point to execute.

processModelParam As SequenceFile

[In] Pass the process model SequenceFile object if you want to execute a Process Model entry point. Otherwise, a NULL object reference in LabVIEW, 0 in LabWindows/CVI, or the Nothing keyword in Visual Basic, pass a NULL dispatch pointer in Microsoft Foundation Classes.

breakAtFirstStep As Boolean

[In] Pass True to suspend execution before executing the first step.

executionTypeMaskParam As Long

[In] Pass 0 for the default behavior or pass one or more ExecutionTypeMask constants. Use the bitwise-OR operator to pass multiple constants.

sequenceArgsParam As Variant

[In] [Optional] Pass a PropertyObject object that contains the arguments to the sequence you want to execute. Each subproperty of the PropertyObject object represents a parameter to the sequence. The subproperties must appear in the same order as the sequence parameters.

 

 

The third paratmer is the process model sequence file object.

 

Take a look at this post to see how it was done in C#.

Jacob R. | Applications Engineer | National Instruments

0 Kudos
Message 2 of 22
(8,069 Views)

Thank you for the response, I was able to make some progress I think using the C code. However I have the same issue I had originally.

 

I was able to update my Python code to the current attachment however I have the same result.

 

 

0 Kudos
Message 3 of 22
(8,044 Views)

Why are you passing seqFileModel[0] for the process model parameter? It doesn't look like it's an array. Is your sequence running at all? You could add messagepopups to it to see.

 

-Doug

0 Kudos
Message 4 of 22
(8,029 Views)

Thanks for posting Doug, 

 

I am passing  seqFileModel[0] because when I execute line 

 

seqFileModel = seqFile.GetModelSequenceFile()

 

seqFileModel becomes a tuple the first item is a <COMObject GetModelSequenceFile> the second item is a string with the file path. So in order to perform the action GetSequenceByName(strEntryPoint) I perform it on the <COMObject GetModelSequenceFile> object.

 

My sequence is running, my engine is running because I can call methonds on my engine object (engine.AbortAll/ShutDown/GetUser/ect..) and I have tested that messagepopups work like you have recomended.

 

- David

0 Kudos
Message 5 of 22
(8,024 Views)

I was able to create a LabView VI that runs a sequence file by calling the TestStand APIs. I must be missing something, what does this file do that my Python does not?

2. Is the TestStand Engine in the VI the same engine that I am using when I call win32com.client.Dispatch("TestStand.Engine.1")?

3. If above is true then how do I create an Automation Refnum object within my Python enviroment?

0 Kudos
Message 6 of 22
(8,003 Views)

@hobbs1 wrote:

I was able to create a LabView VI that runs a sequence file by calling the TestStand APIs. I must be missing something, what does this file do that my Python does not?

2. Is the TestStand Engine in the VI the same engine that I am using when I call win32com.client.Dispatch("TestStand.Engine.1")?

3. If above is true then how do I create an Automation Refnum object within my Python enviroment?


It looks equivalent to what you are doing in python other than that it is not using a process model. You might try passing null for the process model parameter in python and see what happens, or doing the full thing including the process model in the vi and see if that works.

 

An Automation Refnum is a labview specific thing for holding COM references. Using it in Python doesn't really make sense in this context, so I'm not sure what you are getting at.

 

I do not know for sure if win32com.client.Dispatch is the best way to create the engine or might be having some negative affect. I am not familiar with python or this API. If your execution is successfully running, the wait step just isn't ever returning, then that likely isn't the problem.

 

-Doug

 

0 Kudos
Message 7 of 22
(7,979 Views)
Solution
Accepted by topic author hobbs1

hobbs,

 

I am able to call a sequence file and get the behavior you are expecting with the files I am attaching.

 

The code is basically the same code that you have and I only added some extra logic to figure out the sequence file path automatically (to be able to zip the file so that you could run it) and I removed the client sequence file parameter just so that I could see if the sequence was running without the process models mattering. 

 

I built and run with Python 2.7.1 using win32com from February 7 2012 (I was not able to figure out where they store the version)

 

Hope this helps,

Francisco

Message 8 of 22
(7,971 Views)

Francisco,

 

Thank you very much, this works well now. It seemed my issue lies somewhere within the directories that are being specified. 

 

-David

0 Kudos
Message 9 of 22
(7,959 Views)

I am running into a problem now where I cannot run another seq (even the same one) after running the first time. I tried adding code to release the sequencefile, release the execution and seqFile objects, and shutdown the engine. The weird thing is that it doesnt seem to be shutting down the engine because when I try and set the tsEngine = None Python tries to execute it and seems to be stuck. Any thoughts on this?

 

 

execution = None
tsEngine.ReleaseSequenceFileEx(seqFile, 0x4)
seqFile = None
tsEngine.ShutDown(True)
tsEngine = None  ## Execution freezes here

0 Kudos
Message 10 of 22
(7,957 Views)