12-05-2013 09:22 AM
Probably the easiest way to pass data would be with a TestStand queue where you give it a name beginning with an '*' character so that it is shared across processes. See the API help for Engine.GetSyncManager() as a starting point. The sync manager API is also used by the synchronization step types (the queues created by them are one and the same).
-Doug
12-16-2013 02:24 PM
Is their a way to pass an object reference from TestStand to a python script? Has anybody had success using IronPython (basically as a .NET wrapper). I'm not sure how to pass a COM object via the command line. It'd be great if you can directly pass a reference, like ThisContext, to a python script but I can't find anybody tackling this on the forums.
01-02-2014 10:00 AM
I have not used IronPython; howerver, since it is only a .NET wrapper you can use COM Interop to communicate with TestStand. For more information on this, depending on your specific IronPython version see http://blogs.msdn.com/b/shrib/archive/2008/04/10/ole-automation-idispatch-support-in-ironpython.aspx
The name for the COM reference is "NationalInstruments.TestStand.Interop.API", the GUID can be found in the registry under HKEY_CLASSES_ROOT\CLSID (or HKEY_CLASSES_ROOT\Wow6432Node\CLSID in 64-bit systems), just search for the COM reference name.
11-27-2015 03:43 AM - edited 11-27-2015 03:44 AM
I have been trying to pass data to Teststand from python/pywin32 and the com interface.
I can connect to a running Teststand sequence which creates a queue "*GlobalQueue" and get a the created queue name, however i am unable to get data into the queue using the enqueue method.
Code
import win32api import win32com.client import pythoncom QUEUE_NAME = "*GlobalQueue" #Get Engine Reference. testStandEngine = win32com.client.Dispatch("TestStand.Engine.1") print ("TestStand Ver: ",str(testStandEngine.MajorVersion)+"."+str(testStandEngine.MinorVersion),"Ready") #sync with TS engine syncMgr = testStandEngine.GetSyncManager(QUEUE_NAME) queue = syncMgr.GetQueue(QUEUE_NAME) while queue == None: print("Unable to get queue:",QUEUE_NAME) queue = syncMgr.GetQueue(QUEUE_NAME) print("Found Queue:",queue.Name) # TS enqueue usage # http://zone.ni.com/reference/en-XX/help/370052G-01/tssuppref/reftopics/queue_enqueue_m/ # Queue.Enqueue ( atFront, full Q Option, newElementPropObj, byRef, timeoutInSeconds, sequenceContextObj, processMsgs, waitRes, enqueueRes) waitRes = -1 enqueueRes = -1 data = "test" seqContext = None #create queue object queueObject = testStandEngine.NewPropertyObject(1, False, "", 0) queueObject.SetValString("", 0, "Test"); print(queueObject.GetValString("",0)) #create sequence object. seqObject = testStandEngine.NewPropertyObject(5, False, "", 0) print(seqObject.GetTypeDefinition ("", 0)) queue.enqueue(False, 0, queueObject, False, 5, seqObject, True,waitRes,enqueueRes)
The error i get is an exception;
TestStand Ver: 14.0 Ready Found Queue: *GlobalQueue Test None Traceback (most recent call last): File "C:\ts\pyTS.py", line 48, in <module> queue.enqueue(False, 0, queueObject, False, 5, seqObject, True,waitRes,enqueueRes) File "<COMObject GetQueue>", line 2, in enqueue pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'TSSync', None, None, 0, -2147467261), None) >>>
I have tried using the OLEviewer and found the prototype.
Any help would be apprieciated.
Thanks in advance
Tim