LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

few General CVI Questions - How the compiler works

Solved!
Go to solution

 

Hi ,

 

I'm working with CVI 9.1 for more then a year during this time i'v noticed a few things, i would like you to help me understand them.

 

 

  1. Working with numerous C files:
  • When i'm writing a software that uses lets say 10 C files and 10 H file :  Main.c Main.h Panels.uir Panels.h File1.c File1.h and so on.... I'm implementing the function in the c file and writing it's deceleration in the h file , i'v noticed that some times i'm getting msgs from the compiler about conflicts , maybe there is a way that i don't know about just for CVI ?
  • Properly working with the UIR File for example lets take the files written above , if i have Panel - MAIN and Control LED1 and i want to do SetCtrlVal in the Main.c I can implement like this SetCtelVal(MAIN,MAIN_LED1,1); but when i'm going to to file1.c and trying to do so i'm getting the error message MAIN_LED1 is not a control value ( I'm including the Panels.h ) this problem happens to me a lot is there any solution ? or maybe i'm doing something wrong...
  • what is the best way to implement bollean var ( true false ) for the software ? is there a way to add this var always ?
  • inconsistent type decelerations : lets take Fmt function for example when i'm trying to use it in different files i'm getting inconsistent type decelerations warning with the names of the files....
  • general question : lets say i want to include <Daqmx.h> in my project and i want to use its functions in main.c and file1.c , i'm including  <Daqmx.h> in both files ? or there is a way to include it in one file only ?

2. Accessing buttons 

 

  • lets say i have to buttons and i'm pressing one after the button pressed i have a loop for 10 min , i want to create an abort button but i cant press any thing because the buttons are "locked" is there a way besides multi threading to implement this ?
Thank You

 

 

 

 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 1 of 3
(3,187 Views)
Solution
Accepted by topic author Kobi_K

Wow! A very huge set of questions!

Some fast answer.

 

  • Properly working with the UIR File for example lets take the files written above , if i have Panel - MAIN and Control LED1 and i want to do SetCtrlVal in the Main.c I can implement like this SetCtelVal(MAIN,MAIN_LED1,1); but when i'm going to to file1.c and trying to do so i'm getting the error message MAIN_LED1 is not a control value ( I'm including the Panels.h ) this problem happens to me a lot is there any solution ? or maybe i'm doing something wrong...
  • There is a basic error in your statement: the first parameter of SetCtrlVal ( ) must be the panel handle, that is the reference to the in-memory object that is created when you call LoadPanel ( ). Using the panel constant name is not correct: it may work if you're lucky and have the panel handle with the same value as its constant name, but it's definitely not the correct way to address controls on a panel. 

    Even though, I do not understand the error you are reporting: I would expect "the control is not the type expected by the function" or some error for inconsistent data type (like passing an int to a double control) or so...

    Please remember that every function that addresses objects on a panel must be aware of the panel handle, so either you pass it to the function as a parameter or store it in a global variable.

     

  • inconsistent type decelerations : lets take Fmt function for example when i'm trying to use it in different files i'm getting inconsistent type decelerations warning with the names of the files....
  • I normally let CVI take care of #including the necessary system files: when I use some function like Fmt in a source file and compile it CVI warns me to add the relevant include file, and it does it properly. Operating this way I never had problems with the Formatting and I/O Library functions. You could rebuild the include list by deleting all #includes in yous source files and compiling the project, this should fix the errors

     

  • general question : lets say i want to include <Daqmx.h> in my project and i want to use its functions in main.c and file1.c , i'm including  <Daqmx.h> in both files ? or there is a way to include it in one file only ?
  • You must include the files with function definitions in all source files that are using them. Or you can create a general include file with all includes in your project and include only this one in all of your source files

     

  • lets say i have to buttons and i'm pressing one after the button pressed i have a loop for 10 min , i want to create an abort button but i cant press any thing because the buttons are "locked" is there a way besides multi threading to implement this ?
  • This is a general rule that drives CVI environment: when executing a loop inside a function (either a control callback or another function) the system is not handling UI events, so your buttons appear locked. This can be solved by adding a repetitive call to ProcessSystemEvents ( ) inside your loop: this way all UI events are monitored and handled by the system.

    You must use this method with care: before entering the loop you should disable all controls that are not to be used during the function (normally only the Quit button must be left active) otherwise you could enter a situation in which other callbacks are executed during the loop that may interfere with it.

    In such a case, to avoid setting a callback in stop button and the use of a global variable I normally create a toggle Stop button and handle it this way:

     

    while (1) {

       ....

       ProcessStemsEvents ( );

       GetCtrlVal (panelHandle, PANEL_STOP, &stop);

       if (stop) {

          ... exit gracefully from the function

          break;

       }

    }

    This argument has been discussed several times in the forums: making a search for ProcessSystemEvents returns a large set of discussions that you may want to read

     

  • what is the best way to implement bollean var ( true false ) for the software ? is there a way to add this var always ?
  • CVI does not have a native boolean value. I normally use an int and test wether it is zero or not

     

  • When i'm writing a software that uses lets say 10 C files and 10 H file :  Main.c Main.h Panels.uir Panels.h File1.c File1.h and so on.... I'm implementing the function in the c file and writing it's deceleration in the h file , i'v noticed that some times i'm getting msgs from the compiler about conflicts , maybe there is a way that i don't know about just for CVI ?
  • I don't understand what you are describing: could you add some piece of code that enters this situation and report the exact message the compiler is warning?

     



    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?
    Message 2 of 3
    (3,168 Views)

    Thank you Roberto for you answers I know it was a big post 🙂 ,

     

    About my last question , I think i know the answer one of your previous  answers helped me understand...

     

    Thank you again for the quick answer.

     

    -----------------------------------------
    Kobi Kalif
    Software Engineer

    0 Kudos
    Message 3 of 3
    (3,143 Views)