LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set TestStand Station Model from CVI

Solved!
Go to solution
I need to programmatically set the TestStand Station Model from CVI.  Correct me if I'm wrong, but I think I need to use the function TS_StationOptionsSetStationModelSequenceFilePath.  Unfortunately, I cannot find any information about how to use this function on the NI website. This function has an input parameter "object handle".  Where do I get that object handle?  I have tried using the object handles returned from GetObjHandleFromActiveXCtrl and ApplicationMgrGetEngine, but I get the error 0x80004002 "No such interface supported" Thank you for your help.

 

0 Kudos
Message 1 of 7
(4,609 Views)

Christine,


I see what you mean, getting that ObjectHandle wasn't straight forward. I was able to obtain the Object Handle through using:

 

static MainPanel     gMainWindow;

 

     errChk( gMainWindow.panel = LoadPanelEx (0, "StationModel.uir", MAINPANEL, __CVIUserHInst));

     tsErrChk( TSUI_ApplicationMgrGetEngine(gMainWindow.applicationMgr, &errorInfo, &gMainWindow.engine));    

     TS_EngineDisplayOptionsDialog (gMainWindow.engine, NULL, "None", VFALSE, VFALSE, NULL);  

 

I was then able to use it in:

 

            TS_EngineDisplayOptionsDialog (gMainWindow.engine, NULL, "None", VFALSE, VFALSE, NULL); 

 

While TS_EngineDisplayOptionsDialog isn't exactly the same as  TS_StationOptionsSetStationModelSequenceFilePath, both of them take in the same Engine ObjectHandle. I made an example of my work and put it on the community example Manipulate TestStand Station Model Options from CVI. Check out the example and see if you can glean any useful information. If you have any questions, or run into any problems running the file please let me know. You may have to point it at a different tsuitl.fp file, if you're using a different version of TestStand .

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 2 of 7
(4,586 Views)

 

Thank you!  Your example was very helpful.

 

I am still having a couple of problems, though.  When I call TS_EngineDisplayOptionsDialog, it displays the Station Options popup but the options are grayed out (that is, not selectable).  I have tried setting the "read only" flag in the function call to both true and false, and in both cases the popup behaves the same way.  It seems as though something is read-only.  My TestExec.ini file is writable.  As a matter of fact, I made all files under the TestStand folder writable just to make sure I wasn't overlooking something.

 

I have another issue which may be related.  When I call TS_StationOptionsSetAllowOtherModels and TS_StationOptionsSetStationModelSequenceFilePath, I get the error 0x80004002 "No such interface supported".  I can't help but wonder if something is read-only or a setting is not properly set, preventing all of the mentioned function calls from working properly.

 

I am using TestStand 3.1, if that matters.

 

Thanks again!

0 Kudos
Message 3 of 7
(4,555 Views)

Christine,

 

Using a virtual machine I tried this using CVI 9.0 and TestStand 3.1, and I was able to use both  TS_StationOptionsSetAllowOtherModels and TS_EngineDisplayOptionsDialog. What version of CVI are you using? All options are allowed when i run this way. Maybe we should make a new thread about these errors, also some screenshots would be helpful. I noticed in my code i posted online, i accidentally required NIVision (which you don't need), but you also need to make sure that you are pointing it to the correct TestStand fp files in your project. When you open this simple user interface are you capeable of running a simple sequence file? Also when do you get these errors, is it durring runtime, or when you build?

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 4 of 7
(4,542 Views)
 

Using your sample code, displaying the Station Options (TS_EngineDisplayOptionsDialog) does work for me.  As you said previously, calling TS_StationOptionsSetStationModelSequenceFilePath should be very similar to calling TS_EngineDisplayOptionsDialog.  As an experiment, I added other steps to the callback in your example.  The first call is to use a station model (TS_StationOptionsSetUseStationModel).  The second call is to allow other station models (TS_StationOptionsSetAllowOtherModels).  The third call is to change the Station Model (TS_StationOptionsSetStationModelSequenceFilePath).  The snippet of code is below.

 

During runtime, the calls to the functions I added return the error 0x80004002 "No such interface supported".  When I press the "Change Station Model Options" button again and select the "Model" tab, the Station Model filename has not changed.  In case you are wondering, the Station Model specified in the function call really does exist.  I purposely used the full path to avoid confusion.

 

I am using CVI 8.5.1. 

 

You asked if I am using the correct TestStand fp file.  I am using C:\Program Files\National Instruments\TestStand 3.1\API\CVI\tsutil.fp.  I am able to build and run, so I assume it's correct.

 

Ultimately, I need to be to be able to set the Station Model before I make the call to start TestStand (TSUI_ApplicationMgrStart). 

 

Thanks again for your help!

 

 

int CVICALLBACK StationModelOptions (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  int status;
  char Buffer[1024];
  unsigned int Buffer_Size = 1024;

 

 switch (event)
 {
  case EVENT_COMMIT:
   TS_EngineDisplayOptionsDialog (gMainWindow.engine, NULL, "None", VFALSE, VFALSE, NULL);
        
         // set station options to use Station Models
         status = TS_StationOptionsSetUseStationModel (gMainWindow.engine, NULL, VTRUE);  
         if (status < 0)
         {
            CA_GetAutomationErrorString (status, Buffer, Buffer_Size);
         }
  
         // set station options to allow other Station Models
         status = TS_StationOptionsSetAllowOtherModels (gMainWindow.engine, NULL, VTRUE);  
         if (status < 0)
         {
            CA_GetAutomationErrorString (status, Buffer, Buffer_Size);
         }
  
         // change the Station Model
         status = TS_StationOptionsSetStationModelSequenceFilePath (
            gMainWindow.engine, NULL,
            "C:\\Program Files\\National Instruments\\TestStand 3.1\\Components\\NI\\Models\\TestStandModels\\ParallelModel.seq");
         if (status < 0)
         {
            CA_GetAutomationErrorString (status, Buffer, Buffer_Size);
         }

   break;
 }

 return 0;
}

0 Kudos
Message 5 of 7
(4,527 Views)
Solution
Accepted by topic author Christine

Thank you for all of your help.  I was able to find the solution:

 

In order to use the Station Option functions (TS_StationOptionsSetAllowOtherModels, TS_StationOptionsSetStationModelSequenceFilePath, etc) you must pass in the Station Options handle.  Get the handle to Station Options by calling TS_EngineGetStationOptions.

0 Kudos
Message 6 of 7
(4,504 Views)

Christine,

 

Looks like you beat me to the post, i was just going to mention I was able to generate a callback that sets the Station Model:

 

 

int CVICALLBACK SETSMOD (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
   
    char stModPath;
    char* getStationModelPath = &stModPath;
    HRESULT stat;
    HRESULT stat2;
    CAObjHandle StOptsHandle;
    switch (event)
    {
        case EVENT_COMMIT:
            TS_EngineGetStationOptions (gMainWindow.engine, NULL, &StOptsHandle);
            stat = TS_StationOptionsSetStationModelSequenceFilePath (StOptsHandle, NULL,
                                                                     "C:\\Program Files\\National Instruments\\TestStand 3.1\\Components\\NI\\Models\\TestStandModels\\ParallelModel.seq" )  ;
            stat2 = TS_StationOptionsGetStationModelSequenceFilePath (StOptsHandle, NULL, &getStationModelPath);
            break;
    }
    return 0;
}
 

Message Edited by Richard S. on 05-06-2009 12:42 PM
Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 7 of 7
(4,495 Views)