06-29-2012 03:57 PM
Hi,
I created a wrapper for calling a dll from LabVIEW. My driver uses a lot of constants like:
#define Baud_Rate_192001001
#define Baud_Rate_96001002 etc.
How do I include this information in my driver so when I call a VI I do not have to use "hardcoded" numbers?
Thanks
CT
06-29-2012 05:00 PM
One approach I've seen in many NI-distributed VIs is a ring type definition. Rings are used because the values in them do not need to be sequential; the downside is that unlike an enumeration, a the items in a list aren't part of the data type, so they don't update when new items are added to the type definition. If the DLL header is stable and unlikely to change then this may be acceptable.
If you need flexibility to change the #define values, then you could create an enumerated type definition and a dedicated VI that uses that enum as an index into an array of output values. It's very slightly more work but much easier to change if the header changes.
07-26-2012 02:30 PM
But what if my constants are not 0,1,2 ...Is there a way to assign a number to a constant? It seems like there's no way to edit the "Digital Display" value.
thanks
07-26-2012 02:59 PM
Sorry, I think I figured it out. It needs to be a Text Ring and and enum type.
07-26-2012 05:21 PM
@Cimteker wrote:
Sorry, I think I figured it out. It needs to be a Text Ring and and enum type.
Why a text ring? Why not use Nathan's solution?
07-27-2012 06:30 AM
Text ring is the only structure where I can define (BAUD_RATE_500k, 0x10) pair. Enum type would only allow me consecutive numbers. I think this is what Nathan was suggesting.
07-27-2012 07:00 AM
You may want to consider voting for this idea: http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Adding-CONSTs-to-LabVIEW/idi-p/942213
07-27-2012 11:14 AM