From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

python call teststand engine

I use python and teststand engine to customize solution.But I have some questions about it. 1,code as below: tsEngine = win32com.client.Dispatch("TestStand.Engine.1") print "TestStand %s.%s ready" % (tsEngine.MajorVersion, tsEngine.MinorVersion) tsEngine.UIMessagePollingEnabled = True sequencePath = os.path.join(cwd, 'MySequence.seq') seqFile = tsEngine.GetSequenceFileEx(sequencePath) execution = tsEngine.NewExecution(seqFile, "MainSequence", seqFile, False, 0) execution.WaitForEndEx(60000) execution = None released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) seqFile = None #coreleased = tsEngine.ReleaseSequenceFileEx() tsEngine.ShutDown(True) tsEngine = None ## Execution freezes here 2,I need to use UImessage to get pass/fail result of "MySequence.seq".So the first step,I set "tsEngine.UIMessagePollingEnabled = True".But python print these error: Traceback (most recent call last): File "D:\TS_solution\CallTestStand.py", line 39, in released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) File "", line 3, in ReleaseSequenceFileEx pywintypes.com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3', (0, u'TSAPI', u"Unable to unload sequence file 'MySequence.seq' because it is in use, possibly because it is executing.", None, 0, -17213), None) 3,I comment "tsEngine.UIMessagePollingEnabled = True",then teststand pop-up warning windows,show as below: References to PropertyObjects were not released properly. Total number of objects: 53 Number of top-level objects: 13 Note: Some top-level objects may be included if they are referenced by an incorrectly released top-level object. For example, an unreleased SequenceContext object references a SequenceFile object. The following top-level objects were not released: Executions [1 object(s) not released] Type Definitions [2 object(s) not released] Type Definition #1: Name: CommonResults Type Definition #2: Name: Error PropertyObjects [6 object(s) not released] PropertyObject #1: Type: ActiveX Reference Value: Nothing PropertyObject #2: Type: ActiveX Reference Value: Nothing PropertyObject #3: Type: Obj PropertyObject #4: Type: Array of Containers PropertyObject #5: Type: Array of Containers PropertyObject #6: Type: Array of Containers And the following uncategorized objects: UIMessage (TEMessage) UIMessage (TEMessage) Report EditArgs 4,How can I call Teststand API--UImessage class through Python?
0 Kudos
Message 1 of 6
(5,760 Views)

Currently, your post is not readable.

 

You can use code tags to insert code into a post. Juck click the button with the "<>" symbol on it.

 

0 Kudos
Message 2 of 6
(5,707 Views)

I reedit my issue in my reply.Thanks very much for 

 

 

I use python and teststand engine to customize solution.But I have some questions about it.
1,code as below:

tsEngine = win32com.client.Dispatch("TestStand.Engine.1") 
print "TestStand %s.%s ready" % (tsEngine.MajorVersion, tsEngine.MinorVersion) 
tsEngine.UIMessagePollingEnabled = True 
sequencePath = os.path.join(cwd, 'MySequence.seq') 
seqFile = tsEngine.GetSequenceFileEx(sequencePath) 
execution = tsEngine.NewExecution(seqFile, "MainSequence", seqFile, False, 0) 
execution.WaitForEndEx(60000) 
execution = None 
released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) 
seqFile = None 
tsEngine.ShutDown(True) 
tsEngine = None ## Execution freezes here 

 

2,I need to use UImessage to get pass/fail result of "MySequence.seq".
So the first step,I set "tsEngine.UIMessagePollingEnabled = True".
But python print these error:

Traceback (most recent call last): File "D:\TS_solution\CallTestStand.py", 
line 39, in released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) File "", 
line 3, in ReleaseSequenceFileEx pywintypes.com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3', (0, u'TSAPI', u"Unable to unload sequence file 'MySequence.seq' because it is in use, possibly because it is executing.", None, 0, -17213), None)

3,I comment "tsEngine.UIMessagePollingEnabled = True",
then teststand pop-up warning windows,show as below:

References to PropertyObjects were not released properly. 
Total number of objects: 53 
Number of top-level objects: 13 
Note: Some top-level objects may be included if they are referenced by an incorrectly released top-level object. 
For example, an unreleased SequenceContext object references a SequenceFile object. 
The following top-level objects were not released: 
Executions [1 object(s) not released] 
Type Definitions [2 object(s) not released] 
Type Definition 
#1: Name: CommonResults Type Definition 
#2: Name: Error PropertyObjects 
[6 object(s) not released] PropertyObject 
#1: Type: ActiveX Reference Value: Nothing PropertyObject 
#2: Type: ActiveX Reference Value: Nothing PropertyObject 
#3: Type: Obj PropertyObject 
#4: Type: Array of Containers PropertyObject 
#5: Type: Array of Containers PropertyObject 
#6: Type: Array of Containers And the following uncategorized objects: 
UIMessage (TEMessage) 
UIMessage (TEMessage) 
Report 
EditArgs 


4,How can I call Teststand API--UImessage class through Python?

0 Kudos
Message 3 of 6
(5,592 Views)

I reedit my issue in my reply.Thanks very much for altenbach's remindding.


I use python and teststand engine to customize solution.But I have some questions about it.
1,code as below:

tsEngine = win32com.client.Dispatch("TestStand.Engine.1") 
print "TestStand %s.%s ready" % (tsEngine.MajorVersion, tsEngine.MinorVersion) 
tsEngine.UIMessagePollingEnabled = True 
sequencePath = os.path.join(cwd, 'MySequence.seq') 
seqFile = tsEngine.GetSequenceFileEx(sequencePath) 
execution = tsEngine.NewExecution(seqFile, "MainSequence", seqFile, False, 0) 
execution.WaitForEndEx(60000) 
execution = None 
released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) 
seqFile = None 
tsEngine.ShutDown(True) 
tsEngine = None ## Execution freezes here 


2,I need to use UImessage to get pass/fail result of "MySequence.seq".
So the first step,I set "tsEngine.UIMessagePollingEnabled = True".
But python print these error:

Traceback (most recent call last): File "D:\TS_solution\CallTestStand.py", 
line 39, in released = tsEngine.ReleaseSequenceFileEx(seqFile, 0x4) File "", 
line 3, in ReleaseSequenceFileEx pywintypes.com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3', (0, u'TSAPI', u"Unable to unload sequence file 'MySequence.seq' because it is in use, possibly because it is executing.", None, 0, -17213), None)


3,I comment "tsEngine.UIMessagePollingEnabled = True",
then teststand pop-up warning windows,show as below:

References to PropertyObjects were not released properly. 
Total number of objects: 53 
Number of top-level objects: 13 
Note: Some top-level objects may be included if they are referenced by an incorrectly released top-level object. 
For example, an unreleased SequenceContext object references a SequenceFile object. 
The following top-level objects were not released: 
Executions [1 object(s) not released] 
Type Definitions [2 object(s) not released] 
Type Definition 
#1: Name: CommonResults Type Definition 
#2: Name: Error PropertyObjects 
[6 object(s) not released] PropertyObject 
#1: Type: ActiveX Reference Value: Nothing PropertyObject 
#2: Type: ActiveX Reference Value: Nothing PropertyObject 
#3: Type: Obj PropertyObject 
#4: Type: Array of Containers PropertyObject 
#5: Type: Array of Containers PropertyObject 
#6: Type: Array of Containers And the following uncategorized objects: 
UIMessage (TEMessage) 
UIMessage (TEMessage) 
Report 
EditArgs

4,How can I call Teststand API--UImessage class through Python?

0 Kudos
Message 4 of 6
(5,592 Views)

Hi, have you find a solution for this issue?

I am currently facing the same problem.

0 Kudos
Message 5 of 6
(3,168 Views)

It's probably a bit late now but I had to create a handler for UI messages in python with the win32com module. So I'll share my solution in case it can help anyone...

 
All you need to do is call the "WithEvents" function of win32com.client like this : 
tsEngine = win32com.client.Dispatch('TestStand.Engine.1')
tsEngineEvent = win32com.client.WithEvents(tsEngine, EngineEventHandler)
EngineEventHandler being a class dedicated to the handling of the messages  : 
class EngineEventHandler:
    def OnUIMessageEvent(self, uiMsgEvent):
        ...
It could probably also work with the DispatchWithEvent function. 
 
Although technically this is more a win32com question than a Teststand API one. And I guess this is not exactly the place to ask this. 
 
 

 

0 Kudos
Message 6 of 6
(1,029 Views)