LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with a console application

Solved!
Go to solution

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

 

 

 

 

 

0 Kudos
Message 1 of 7
(3,720 Views)

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.

0 Kudos
Message 2 of 7
(3,706 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 7
(3,703 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 7
(3,699 Views)

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()?

0 Kudos
Message 5 of 7
(3,695 Views)
Solution
Accepted by topic author Fasching_K

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(3,678 Views)

Thank you for your help. To solve the problem I can use "Is Task Done" in combination with ProcessSystemEvents () . This works fine.

0 Kudos
Message 7 of 7
(3,674 Views)