10-10-2016 04:11 AM - edited 10-10-2016 04:16 AM
Hello,
I have developed a application in LabWindows. Now I would like to link it with the console. I do know how I can call my *.exe Data and the files the program needs. When I start the program there is a problem. I generate a signal for example 10 seconds but in reality I generate only 550 ms. So the conclusion is, that the program ends before it really should end.
I have no idea where this behavior comes from. I tried to toggle the stop moment but the program didn't run in any of my breakpoints.
So I think I have a failure in the main menu. In the following you can see the test how I tried to run it. (Here I can toggle my program)
int main (int argc, char *argv[])
{
// **********************************************************************************
// Calls the interface
// **********************************************************************************
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((PanelHandle = LoadPanel (0, "AWG.uir", MainPanel)) < 0)
return -1;
argc = 2;
argv[1] = "test.uir";
if(argc == 1)
{
DisplayPanel(PanelHandle );
RunUserInterface ();
DiscardPanel(PanelHandle );
return 0;
}
else if(argc > 1)
{
// Load the file the program needs
if(RecallPanelState (PanelHandle , argv[1], 0) < 0)
MessagePopup("Error","File could not be loaded!");
// Gets a value that is important for the program
GetCtrlVal (PanelHandle , MainPanel_TREE, &g_Mode);
// Starts the program
ChooseMode(MainPanelHandle);
}
}
My courser runs into ChooseMode and the program starts. It runs to all funktion and I see the little part of the signal I described above.
Did I made a mistake when I wrote this part or is there a part absence for running my program correct?
Best regards
Solved! Go to Solution.
10-10-2016 05:00 AM - edited 10-10-2016 05:01 AM
Ok the problem is that my program ends to soon. My program runs through the code and at the end it closes the application. In this time it is not possible to generate a the whole signal because it has not enought time. (I have a background writing function, when the buffer is full it writes new samples in the buffer. So the program courser starts the task and also the background function. But that is the last line in my application and so it jumps back in the main function und closes the application instead of waiting until the background event has completly finished.)
Now the questions is. How can I tell my program it should not end at the moment it reaches the end of the application and waits that the whole signal was writen?
When I use my GUI I press the QUIT button to end the application.
10-10-2016 05:04 AM - edited 10-10-2016 05:05 AM
You should not manipulate argc and argv inside your program, these are input parameters passed to you by the OS.
The way your program is made up, it always looks for "test.uir" file (where you may or may not have MainPanel_TREE control) and never runs on the built-in UIR file. But in that special branch of the software you have no RunUserInterface, so after ChooseMode () terminates the program terminates as well.
10-10-2016 05:07 AM - edited 10-10-2016 05:07 AM
Fasching_K ha scritto:
When I use my GUI I press the QUIT button to end the application.
That's because the program is sitting on RunUserInterface () waiting for (user) events to process.
There is no equivalent in your "console" scenario.
10-10-2016 05:31 AM - edited 10-10-2016 05:39 AM
Yeah I used test.uir to have a better look at the program itself. I know that I should not manipulate them. Later I delete these lines and it get the informations only over the command line tool. The first part of the if instructions calls the gui from Labwindows.
The second part should call me a gui that I created before with some options over the command line tool.
Is there some option to wait at my program to be finished after ChooseMode()?
10-10-2016 08:06 AM
If you have a user interface, why not calling ProcessSystemEvents () ?
I imagine in the user interface you are displaying parameters and other elements the program is running on, as well as status value on what it's doing and bmaybe some progress bar or similar method to inform the user of the program activity. At program completion some function could call QuitUserInterface to close the program.
10-10-2016 08:43 AM
Thank you for your help. To solve the problem I can use "Is Task Done" in combination with ProcessSystemEvents () . This works fine.