NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing TestStand Variables using Application Manager

I am working with an Operator Interface written in LabWindows/CVI 7.1.  I need this program to be able to access station globals and local variables in TestStand 3.1.  This Operator Interface was originally written for TestStand 2 and uses the older functions like TS_NewEngine, TS_EngineSetProperty, TS_PropertyGetValString, etc.  This has caused some problems when I try to use these functions with TestStand 3.1.  I can run the code fine in the debugger, but my executable just quits as soon as it encounters one of these older testStand functions (I can't tell which one).  I have been trying to incorportate the Application Manager, Sequence File View Manager, and Execution View Manager into the existing code without altering the GUI's appearence (keeping with the standard LabWindows text boxes and not using ActiveX controls).  I cannot figure out how to access variables in testStand using the Managers.  Here is the code I am using so far:
 
//Define Panel Handles and ActiveX Control Handles
typedef struct
 {
 //panel handles
 int              m_pnMain;
 int              m_pnExecute;
 
 // ActiveX control handles:
 CAObjHandle applicationMgr;     // invisible control, manages Startup/Shutdown, and other application functions
 CAObjHandle sequenceFileViewMgr;   // invisible control, manages a SequenceView control that displays loaded sequence files
 CAObjHandle executionViewMgr;    // invisible control, manages a SequenceView control that displays executing sequences
 CAObjHandle m_oEngine;
 } ApplicationWindow;
 
static ApplicationWindow gMainWindow; // this application only has one window
   // load the panels for the main window from the .UIR file
   errChk( gMainWindow.m_pnMain = LoadPanelEx (0, "Symtx Operator Console.uir", PN_MAIN, __CVIUserHInst));
   errChk( gMainWindow.m_pnExecute = LoadPanelEx (gMainWindow.m_pnMain, "Symtx Operator Console.uir", PN_EXECUTE, __CVIUserHInst));
   // prepare to use the TestStand ActiveX controls
   errChk( GetActiveXControlHandles());
   tsErrChk( TSUI_ApplicationMgrGetApplicationWillExitOnStart(gMainWindow.applicationMgr, &errorInfo, &appWillExitOnStart));
   if (!appWillExitOnStart)
   {
    // show a splash screen while starting up
    errChk( splashPanel = LoadPanelEx(0, "Symtx Operator Console.uir", SPLASH, __CVIUserHInst));
       errChk( InstallPopup(splashPanel));
   }
   // make TS engine conveniently accessible
   tsErrChk( TSUI_ApplicationMgrGetEngine(gMainWindow.applicationMgr, &errorInfo, &gMainWindow.m_oEngine)); 
 
The code shown above works fine.  I tried to add the following lines to access the station globals:
 
   // Get station globals
   m_oGlobals = gMainWindow.m_oEngine.NewPropertyObject( 3, False, "", 0); 
   m_oGlobals = gMainWindow.m_oEngine.Globals;
and got the following error when I compiled:
 
  290, 39   Left operand of . has incompatible type 'CAObjHandle'.
which referred to
m_oGlobals = gMainWindow.m_oEngine.NewPropertyObject( 3, False, "", 0); 
 
If anyone can help I'd greatly appreciate it.
0 Kudos
Message 1 of 2
(3,388 Views)
Hi there,

The reason the code for TestStand globals does not work is because CVI does not support using the TestStand API in this way.  This can be a little confusing because in the help it lists using these methods and functions to access the properties you were looking for, however, in CVI you still have to use the TS_ functions to access different properties.  Usually it is TS_objectToOperateOn.  For example TS_Engine will always be getting properties or executing methods of the engine.  I have put some code below that should accomplish the same thing you were looking to do.  Hope this helps out!

    int error = 0;
    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;
    CAObjHandle myGlobals;

    //Get the globals from the engine
    tsErrChk (TS_EngineGetGlobals (myEngine, &errorInfo, &myGlobals)); 
   
    //Store the last user name into a local string
    tsErrChk (TS_PropertyGetValString(myGlobals, &errorInfo, "TS.LastUserName", 0, &lastUserName));

Error: 
    // FREE RESOURCES
    if (lastUserName != NULL)
         CA_FreeMemory(lastUserName);

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if (error < 0)
        {
         *errorOccurred = TRUE;
   
        // OPTIONALLY SET THE ERROR CODE AND STRING
         *errorCode = error;
         strcpy(errorMsg, errMsg);
        }   
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,355 Views)