02-07-2011 01:21 AM
Hi,
What do you term a "run"?
The way I saw it is that in your program, call it Prog, you run it, do stuff, and then quit (where quitting closes everything). In this case, put the initialize at the beginning of Prog, the terminate in the "quit" area, and there should be no problem. This means that in your compiled exe (that I assume closes everything when it quits) everything should work fine.
It is true that this method does not work in the development environment because you don't actually quit. I do not know of a method that works in the development environment, but I assume that you want to build an exe at the end, no? Try compiling and checking with the exe of your program.
Thanks,
Danielle
02-07-2011 10:44 AM
I see, yeah, I do want to call the dll in development environment for multiple times, not just run and quit everything; then open everything and run again. I want to run VI, stop, run VI again
02-07-2011 04:34 PM
I have a question, it may be dumb, how can I pass my array data from labview to EXE? I know I can do it easily with the dll. I follow this guide: http://digital.ni.com/public.nsf/allkb/5CF9526FF069EA8E862564C400579DBA, but it still doesn't tell me how to interact with labview data, especially numeric type
02-08-2011 03:11 AM
In that case, you can create two quit events, one for quitting everything and closing, and one for stopping without quitting (for example, q and ctrl+q). In one case call the terminate (before closing) and in the other don't. Then you can start and stop. Just remeber to terminate before closing everything!
I didn't really understand the second question, and the link is broken. Could you clarify?
Thanks,
Danielle
02-08-2011 12:26 PM
Oh, thanks for your answer, that works well for me. My second question is I know using the EXE will not have this "run once" issue, but I don't know how to pass my data into the .exe as the input arguments. Any idea like how to wire a array data to an .exe file in Labview? DLL is very convenient, u can directly wire the labview data to the "call shared library function".
02-09-2011 05:41 AM
Hi,
I think that there might be a basic misunderstanding here of what compilation means. The act of compiling doesn't change the functionality of your program - if it used a dll before it will use it now as well.
Add a while loop or event loop to your code, and have a simple GUI where the user inputs the values he wants and presses "Go" (or OK, or whatever). Write it so that the event of "Go" will be to pass the user parameters to the DLL.
There are design patterns using Event loop, you can use this as a basis.
Or, I still didn't understand your question, and you need to clarify more, sorry...
Thanks,
Danielle
02-09-2011 02:41 PM
I enclosed my .exe wrapper VI. In this VI, I call the myemhmm2.exe in the labview environment. I have two data input array Data_x and Data_t. My question is how can I pass them to the myemhmm2.exe as the input argument?
I use a very stupid method, first I write them into a file through "write to spreadsheet.vi" Then I build in a data file loader in the myemhmm2.exe. It can load the data through the file. Then after calculation it write the results data to a file called "tempsave". Then Labview read the data through the "tempsave" file to the 2D array output. I feel this may not the be the most effcient way to pass the input and output because it reqires the file I/O. Any idea for improvement on passing data? Because in dll, we can pass data directly.
02-10-2011 10:08 AM
It kinda seems like there might be a misunderstanding about what Danielle was saying about using an exe (at least from my point of view). I understood that to mean creating an exe out of your program and running it completely independently from the LabVIEW development environment. Just take your program and compile it to an EXE, and stop using LabVIEW. It seems like you've taken a different approach, and created an EXE just out of a part of your program. You've then modified your program to call the EXE. Unfortunately, there aren't a lot of good ways to communicate between LabVIEW and an independent exe that I know of, so your approach is totally reasonable. You can use command line arguments when you call the exe to point it to a file. Another idea would be to set your exe up as a TCP/IP server, and then talk to it through a TCP/IP connection. You could stream information back and forth that way without involving the filesystem, but it's a little more complicated.
Anyway, I kinda like your approach because I never thought of doing it that way, but you must have a pretty good reason to want to work from the development environment (maybe the code is constantly changing and it's easier to debug without compiling in between...?). I've had luck working as previously described, i.e., just calling initialize and terminate once per LabVIEW session.
If it works, stick with it.
Chris
07-25-2013 04:39 PM
I know this is a pretty outdated post, but I still hope you would see my question.
I am currently having the same error you encountered at one point :
Error 1 error C2371: 'char16_t' : redefinition; different basic types.
I did not get how you overcame it. You downgraded your VC? To which version? After that, the error is simply gone? Many many thanks.
07-28-2013 01:33 AM
Hi,
this error means that you have the datatype char16_t defined in two different places. I don't think downgrading is the solution. First, check that you are including the correct libraries of matlab in the correct places (usually includes are in .h files). Second, search for the definition of char16_t, see where it also shows up. Most likely you are including the library from two parallel files.
Thanks,
Danielle