09-14-2012 09:44 AM
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
09-14-2012 10:08 AM
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
09-14-2012 10:59 AM
Thanks for the help guys, I'll look into those options.
03-02-2015 09:16 AM - edited 03-02-2015 09:18 AM
*edit:
found the problem of my former post by myself..
03-03-2015 01:39 AM
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
03-03-2015 09:34 AM
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.
03-04-2015 02:31 AM
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
03-05-2015 11:03 AM
I have not been able to find an existing example. Maybe these two other forum posts could add insight to your problem:
NewExecuti
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
03-05-2015 11:19 AM
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
03-06-2015 01:23 AM
Hey guys,
it worked with the SetValString Function :D. Awesome thank you 😉