キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Calling .seq files from Python

解決済み
解決策を見る

You might be having issues with UIMessages. TestStand creates a hidden window in the thread that creates it and then posts Window messages to that window for each UIMessage that it sends. If that thread isn't processing messages that could lead to problems. WaitForExecution, processes messages by default, but once that completes, you won't be processing messages unless you do something extra. One way to work around this is to create a worker that that creates the engine, and have that process window messages the whole time your app is running. Alternatively you could manually pump messages after your execution completes and at other places that might generate UIMessages and see if that helps. I'm not sure exactly how to manually process Window Messages in python. In win32 code a message pump looks something like this:

 

        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

But there might be a high level python API which does this for you. .NET has an API, Application.DoEvents(), you might have something similar.

 

Hope this helps,

-Doug

メッセージ11/22
3,641件の閲覧回数

David, 

 

You are correct, I was able to reproduce the problem you mention and I actually noticed that it is not hanging on the statement you mention but it is hanging during teardown of the Python interpreter process. I do not know enough about win32com to determine exactly why this is happening, however, I can offer you some alternatives to solve your problem:

 

a) In order to shut down the engine correctly you really have to wait for UI messages as specified in Shutting Down The Engine, I am not exactly sure how to do this in win32com, but setting up a function pointer to handle the UI messages might fix your problems (it is possible that win32com is not correctly releasing all COM objects and is freezing during teardown because there are UI messages pending). 

 

b) Do not shut down the engine correctly, make the reference to the engine global and just keep around all the time: If you are only attempting to call a sequence then the engine will be destroyed during process teardown. This is bad programming but it might be good enough for your use case. I am attaching an example where this approach is executing a sequence twice.

 

c) Use the command line for the sequence editor to run a sequence in the sequence editor: You could use a command similar to 'seqedit.exe /run "C:\\MySequence.seq" "MainSequence" ', the sequence could then write a file or use IPC to communicate with the Python process and exit TestStand after execution.

 

d) Create a DLL that calls the sequence for you and handle all COM methods and references from the DLL (you could do this in LabVIEW, C++ or C#).

 

I hope this helps,

Francisco

メッセージ12/22
3,639件の閲覧回数

Thanks for the help guys, I'll look into those options.

0 件の賞賛
メッセージ13/22
3,633件の閲覧回数

*edit:

 

found the problem of my former post by myself..

CLA
0 件の賞賛
メッセージ14/22
3,424件の閲覧回数

Okay now I have a question -.-

 

depending the NewExecution() Function of Python with win32com. Is it possible to hand over some parameters to the sequence? With this or any other function? I couldn't find anything in the web about this NewExecution function 😕

 

Greetings,

Boing

CLA
0 件の賞賛
メッセージ15/22
3,408件の閲覧回数

The NewExecution function receives the sequence arguments as an optional parameter:

 

NewExecution Method
Syntax: Engine.NewExecution ( sequenceFileParam, sequenceNameParam, processModelParam, breakAtFirstStep, executionTypeMaskParam, [sequenceArgsParam], [editArgsParam], [InteractiveArgsParam])

 

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 

 

The Python libraries are just calling TestStand's COM API, if you want to play around with the calls and view their parameters you can just call them using the statement step in TestStand.

0 件の賞賛
メッセージ16/22
3,394件の閲覧回数

Hey flaborde,

 

first thanks for your reply and your information.

 

I played around with the function within TestStand in a Statement Expression, within LabView as an Automation Reference and Invoke Nodes and in Python itself were I want to be able to getting it done.

 

Everywhere I wasn't able to pass a correct Type for the "sequenceArgsParam" to see them within a sequence its variables like "Parameters.test".

 

Everytime I get the same errors.

The post-expression for the step 'Statement' could not be evaluated.
Error in call to TestStand API member 'IEngine.NewExecution'.
Specified value does not have the expected type.

 

Does nobody have a propper example what I have to write to this parameter in the NewExecution Function to be able to send data to the Parameters.test variable within an sequence??

 

Greetings,

Boing

CLA
0 件の賞賛
メッセージ17/22
3,383件の閲覧回数

I have not been able to find an existing example.  Maybe these two other forum posts could add insight to your problem:

 

NewExecution sequenceArgsParam

http://forums.ni.com/t5/NI-TestStand/NewExecution-sequenceArgsParam/td-p/2363606

 

Executing a sequence using new Execution method

http://forums.ni.com/t5/NI-TestStand/Executing-a-sequence-using-new-Execution-method/td-p/790765

 

0 件の賞賛
メッセージ18/22
3,366件の閲覧回数

The parameters are just a property object that you would create like any other property object by calling Engine.NewPropertyObject. 

 

PropertyObject sequenceOptions = mEngine.NewPropertyObject(PropertyValueTypes.PropValType_Container, false, "", PropertyOptions.PropOption_NoOptions);

sequenceOptions.SetValString("ParameterName", PropertyOptions.PropOption_InsertIfMissing, "My Value");

 

Hope this helps,

Francisco

0 件の賞賛
メッセージ19/22
3,363件の閲覧回数

Hey guys,

 

it worked with the SetValString Function :D. Awesome thank you 😉

CLA
0 件の賞賛
メッセージ20/22
3,356件の閲覧回数