From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI_AppGetCVIState takes a long time

Solved!
Go to solution

I am using the CviServer function CVI_AppGetCVIState and find that if I get the state of a 2013 project it takes 500 times longer than getting the state of a 2012 or less project. As my software calls this function repeatedly it is completly messing things up for me. Can you help.

 

Gus

0 Kudos
Message 1 of 6
(3,939 Views)

Hello gusscott!

 

The symptom you are seeing with CVI 2013 is a known issue in CVI 2013. The issue has been fixed in the last CVI 2013 Patch f1, so we highly recommend you to perform this update. You should also consider using the improved version of this function, called GetCVIStateEx, which is intended to address this slowdown. You can track this bug fix with ID 425248, in the following KB document: http://digital.ni.com/public.nsf/allkb/B632593DECA1F0C986257BF600766F03 related to the CVI 2013 Patch f1.

 

Hope this helps!

0 Kudos
Message 2 of 6
(3,904 Views)

Hi jay_tee,

 

Thank you for your response. Recompiling the code in 2013 with the patch and using GetCVIStateEx certinly makes things faster but that is not the problem. The problem is that when the active app is a 2013 project (CVI_ActiveApp) the CVI_AppGetCVIState function call takes longer.

my code is compiled in 2012 and I really do not want to recompile my code in 2013 as i only have the demo version.

 

here is my test code.

 

int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)

    int CviAppHnd;
    enum CVIEnum_CVIExecutionState ExState,IntExState;
    long WaitingOnUserResponse=0;
    long CompiledLinked,IntCompiledLinked,RetVal;
    int t;
    HRESULT s;

    CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED);

    CVI_ActiveApp (NULL, 1, LOCALE_NEUTRAL, 0, &CviAppHnd);

 

    /*******************************************************************/
    /* call CVI_AppGetCVIState and display the time it takes to call */
    /*******************************************************************/
    t= clock();
    s=CVI_AppGetCVIState (CviAppHnd, NULL, &CompiledLinked, &ExState, &IntCompiledLinked, &IntExState,
    &WaitingOnUserResponse, &RetVal);
    FmtOut("time taken = %i status = %x\n", clock()-t),(int)s;


    CA_DiscardObjHandle(CviAppHnd);

    /********************************************/
    /* display results until user presses a key */
    /********************************************/
    do{ProcessSystemEvents();}while(!KeyHit());

    return 0;
}

 

when  the above code is compiled to an executable and run when a 2012 project is active and when a 2013 project is active, the difference can clearly be seen.

 

Gus

 

0 Kudos
Message 3 of 6
(3,895 Views)
Solution
Accepted by topic author gusscott

Hello gusscott!

 

In order to automate your CVI 2013 (Patch f1) through an application built with CVI 2012 (SP1), you have to use an ActiveX Controller from CVI 2013 into your CVI 2012 program and use GetCVIStateEx to improve your application's performance.

 

For example you can try the following:

  1. Open the CVI 2013 cvidemo program from <CVI2013>\samples\activex\cvi in CVI 2012.
  2. Make sure CVI 2013 is registred by your ActiveX Server present on your machine (e.g. start CVI 2013 as Administrator before running your program).
  3. Use GetCVIStateEx somewhere in the cvidemo application.
  4. Run the application from CVI 2012. It should perform faster, because you are now using GetCVIStateEx from your program compiled with CVI 2012.

Please let me know if this works for you!

Best regards!

0 Kudos
Message 4 of 6
(3,875 Views)

Hello Jay_tee

 

Thank you

 

 

Copying the CviSrv library from CVI 2013  and including it in my 2012 project worked just fine when I recompiled my code.

Although this would suggest that that all programs created with previous versions of CVI and using the CviSrv library will need to be recompiled for use with CVI 2013. However your help has been invaluable and I am now up and running again.

 

Regards Gus

0 Kudos
Message 5 of 6
(3,859 Views)

Wow, scott! I'm am very glad that it eventually worked out for you!

 

Best regards!

0 Kudos
Message 6 of 6
(3,844 Views)