LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create function panel?

Hi,
is there any easy way to creat functional panel from c and h file. I mean automated tool without manually typing in each function?
I have lots of functions and I want to make this process faster and error free. I already have c and h file.

Also, if this is not possible can someone please tell me where do I get "how to create functional panel" document?
Thanks.
Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 21
(5,758 Views)
If you have CVI 7.0 or later, there is a command in the source code window that might help you: open the header file that you want to generate the fp from, and then select Options>>Generate Function Tree.

You'll have to read the help carefully, since there you will probably have to add several tags to the header file in order to properly construct the fp file (there are inherent ambiguities in C prototypes that have to be resolved).

Hope this helps

Luis
NI
0 Kudos
Message 2 of 21
(5,711 Views)
Thanks a lot Luis. This is what I was looking for.

It worked as you explained. I opened h file and generate function tree.
So now my fp is automatically linked to my source code? I also tried to create source code from fp window and it did but it put CVICALL as qualifier.
For example: int CVICALL my_function (int port, int timeout)

If I keep my function like int __stdcall my_function (int port, int timeout) then is it ok? if not what is the standard function prototype?

I am not very familiar with standard type and c type.

Again, thank you very much for your help and please keep up the good work!

Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 3 of 21
(5,707 Views)
Hello Sheetal,

Your fp file will be automatically linked to your source code, if your source code has the same base name as your fp file and is in the same directory. You can verify this by right clicking on your instrument in the library tree, then selecting "Edit Instrument". From there, select "Attach and Edit Source", and your source code should appear. Also, if you generated your function nodes and specified the CVICALL qualifier, it should still work with your original source and header file. But for consistency, you might want to include the CVICALL qualifier in your source and header file.

Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 4 of 21
(5,684 Views)
Hi,

Is there any example code which explainds how to use different tags in h file to create fp? I am specially interested in enum and creating ring and slide control.

I tried but it give me an error.
Thanks for your help.
Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 5 of 21
(5,672 Views)
Hello Sheetal,

The easiest way to find out how you should declare an enum or slide control would be to create a function panel using one and then see how the generated function prototype looks. For instance if you create a slide control as an input parameter to one of your functions, the value will be returned as the data type you set in the Edit Slide Control window. In particular, you have options to set it to one of the intrinsic C data types, a meta data type, or user-defined data type. More information on these data types can be found in the CVI Help under Using LabWindows/CVI >> Instrument Drivers >> Instrument Driver Fundamentals >> Data Types.

Also, I would suggest taking a look at the "Instrument Driver Fundamentals" and "Building Instrument Drivers" topics under the Using LabWindows/CVI >> Instrument Drivers folder.

Hope that helps. If not, what specifically were you trying to do, and what errors were you getting.

Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 6 of 21
(5,655 Views)
Thanks for the reply.
I am trying to create fp from h file which has different tag according to help file. (Options»Generate Function Tree)
I want to use tags like /// SLD p1/enum,... and /// RNG p1/enum,...
and I am looking for an example h file which creates fp with ring and slide controls.

Currently I crash cvi everytime when I try to creat fp from h file.
Here my h file.

#include
#define CVIFUNC __stdcall
typedef enum
{
zero,
one,
two,
three,
}my;
/// SLD 2
int CVIFUNC my_function(int para1, my para2, int para3);

Thanks.
Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 7 of 21
(5,650 Views)
I have included cvidef.h which is not shown in my post above.
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 8 of 21
(5,646 Views)
I am strugling with "Tags in Header Files" section of attached file.
Any example would be helpful.
Please help.
Thanks.
Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 9 of 21
(5,620 Views)
Sheetal,

We've been looking into this crash, and we did find a bug in CVI that is responsible for the crash. The bug happens during the error handling for this operation. The reason there were errors is because you need to include the slide labels (in comment form) after each enum value. For example:

typedef enum
{
zero, // zero slide label
one, // one slide label
two, // two slide label
three, // three slide label
} my;

Also, notice that I added a space between the closing bracket and the typedef name "my". You need to have that space there to avoid the crash. This is a bug, which we will fix for the next version. We will also be making a change such that enums do not require label comments. If an enum value doesn't have a comment, it will just use the constant name as the label.

Sorry for the setback.

Luis
NI
0 Kudos
Message 10 of 21
(5,604 Views)