LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Use CVI project in LabView

Hello
I have written an large application in CVI that communicate over parallel port with a frondend. Now I want to implement this CVI project in LabView to use automatic measurement. For that I have to send date from LabView to that CVI project and get data back to LabView. What is the best way to do that? Is there a way to run CVICALLBACK functions directly from LabView so I didn't have to change a lot in this CVI project.
0 Kudos
Message 1 of 3
(3,427 Views)
One of the easiest ways to have LabView control a CVI project is to make the CVI project a DLL. In LabView, you can then use the Call Library Function to call any function that you have exported from CVI.
CVI ships with several DLL examples. Look at those to understand the structure.
Instead of a main() function, you'll have a DllMain(). But you don't export that function or call it directly: it gets called automatically when you call another function. Typically, just leave the stuff in DllMain that CVI adds to it: don't move your main() stuff there. I will typically put the main() stuff (LoadPanelEx, DisplayPanel, etc.) in an init function then export the init function.
For projects that I will optionally want to use the user interface, I pass a parameter to the init function and set a global g_Use_CVI_UI. I check g_Use_CVI_UI before loading and displaying panels or interacting with controls. To run the program stand-alone, I create a simple exe project (in the same CVI workspace) which just calls the init function from the DLL with the use_CVI_UI parameter set true. Then the DLL takes over.
If you're using any of the user interface panels, etc., you built in CVI, use LoadPanelEx instead of LoadPanel.
Rather than trying to call a CVI callback from LabView, I would create a function in CVI that does the real work for the callback, then call that function from the callback function and export that function from the DLL.
Look at the DLL sample projects that ship with CVI.
Look here and here for some additional info on DLL and exported functions.
Message 2 of 3
(3,418 Views)
I made a DLL. But after start the GUI with RunUserInterface (); I didn't get access to the GUI controls until I close the GUI. Did that mean I didn't start the UI ?
In LabView I could open the GUI but nothing happen. The only way to close the CVI GUI are to close LabView? I call first the GUI init function and the I call a function that set a value. I didn't use a RunUserInterface call.

I'm sure I make a logical error but I didn't see it.
0 Kudos
Message 3 of 3
(3,389 Views)