10-27-2009 02:26 AM
Dear AI S,
Thanks. What you have suggested, it is working fine.
But in second question, working with DLL. Still i do not understand how to run complete CVI panel like EXE. When i tried to Configure Library call in LabVIEW, i couldn't find main function in function list. How to run RunUserInterface ()?
As i understand, DLL is good if i want to use CVI function. But i want to use "main" function.
--Vishnu
10-27-2009 10:35 AM
Vishnu:
You typically would not call RunUserInterface() directly from your calling program (LabView in your case). Put RunUserInterface() in a wrapper function, export that wrapper function in your CVI DLL and call that function from LabView. To export a function, put its prototype in a .h file and add that file to the export list as follows: in the CVI project window, go to Build >> Target Settings, then in the box labeled Exports, click Change, and select the appropriate .h file.
Look at two examples that shipped with CVI 6.0:
samples\dll\gui\guidll.prj
samples\dll\gui\useguidll.prj
10-28-2009 05:51 AM
Dear AI S,
I tried with DLL. I can run CVI panel but can't close CVI panel using CVI function.
In my CVI application there is "quit" function. This function execute when QUIT Button on CVI panel pressed.
If i am using .exe to open CVI panel, i can close CVI panel by pressing QUIT button on CVI panel.
But if i am opening CVI panel by DLL function i can not close CVI panel by pressing QUIT button on CVI panel as well as by using "quit" function in LabVIEW programming.
I am using Event structure for start CVI run and quit panel.
--Vishnu
10-29-2009 10:10 AM - edited 10-29-2009 10:19 AM
Vishnu:
The attached example program demonstrates one way of letting LabVIEW call a CVI DLL with its own GUI and then let LabView go about its other business. It includes the CVI 6.0 DLL project as well as a LabView 7.0 VI to call the DLL.
The trick is to use GetUserEvent, not RunUserInterface. I started from the guidll sample program that ships with CVI and modified it to user GetUserInterface.
There are two problems using RunUserInterface in a DLL called by LabView. LabView's automatic multi-threading treats DLL calls as synchronous, so it doesn't multi-thread DLL calls. The VI will stop and wait for the DLL call to return. But RunUserInterface won't return until QuitUserInterface gets called. But LabView can't call QuitUserInterface because it's waiting for RunUserInterface to return.
GetUserInterface gives you the option for whether or not to wait for an event. If you call it like this:
GetUserEvent (0, &usedPanel, &usedControl);
then it won't wait. If there is a commit event, it will act on it and then return. If there is no event, it will just return without waiting. So you need to call GetUserInterface repeatedly (typically in a loop) to respond to any user action on the CVI DLL UI.
In your CVI DLL project, you now need to export 3 functions: 1: run the DLL UI; 2: check for user events; 3: quit the DLL UI. This project is set up to export functions listed in guidll.h. To match the calling convention in the LabView VI, the prototype for each exported function should be prefixed with int __stdcall. For example:
int __stdcall RunDLLUI (void);
If you need to pass data back and forth between LabView and CVI, you can create the functions to do that, and put their prototypes in guidll.h to export them.
In this sample, you can close the CVI UI either from CVI or from LabView. Depending on your application, you may not want to allow the user to close the CVI UI using a Quit button on that UI. You may want LabView to have sole control over when the CVI DLL UI is closed.
The CVI project is set up to launch the LabView VI and debug the DLL. You can also run it directly from LabView.
The readme.txt file included has some additional details.
10-29-2009 08:11 PM
10-30-2009 02:33 AM
Dear AI S,
Thanks for help.
--Vishnu
11-10-2009 12:42 AM
Dear AI S,
Thanks for help and example. Still i need your help. If i close CVI panel with Quit button on CVI panel i am not able to give this status to LV. With "CheckForUserEvents" i can run CVI and LV parallel but i want to pass some data from CVI panel to LV.
(1) Button pressed on CVI panel
(2) value of Numeric node or Numeric box....
etc..
Please help me to do pass information from CVI to LV.
Thank you very much
--Vishnu
11-10-2009 05:30 PM
Vishnu:
In this app, LabView is in charge, so the CVI DLL won't send anything to LabView on its own: LabView has to ask for it.
For LabView to read the state of buttons or numerics on the CVI UI, you just have to expose some functions that read and return those values.
For the finished app, I would make the Quit button invisible on the CVI UI, so LabView must close it.
I updated my earlier example to read some CVI control values and generate some errors.
11-11-2009 10:46 PM
Thank you very much for helping me.
--Vishnu