> Indeed the sequential mapping (offset + enum * multiplier) is a special
> case. Sometimes that works, but for communication (as originally described)
> you should expect sparse non-sequential mappings. Instruments or libraries
> frequently use some bit-pattern or bit-position to represent a setting.
> Rather than wire up a numeric constant "42" it makes sense to present an
> enumerated set of possible choices.
>
....
> So no, I disagree. This does need re-engineering because it makes
> communication unnecessarily difficult. At lower levels the enumerated values
> are going to be sparse, non-sequential bit-patterns. Is there any reason to
> prevent the programmer from representing them directly just like in C?
>
There is a bit of a philosophical difference in how these things should
be exposed to the user/programmer. LV has the more pure form of
enumeration, more like the pascal language. C on the otherhand has
defines and enums that allow just about anything. Which is correct?
Again, it is a matter of philosophy.
The philosophy that LV prefers is to use nice numbers in the interface
to the driver software and hide the specific bit patterns and numbers
inside the driver SW. Unfortunately, this isn't universal, even NI
driver SW will sometimes expose odd bit patterns and such. But, it is
possible and recommended that you not scatter the constants throughout
your program, and instead isolate the constants in as few locations as
possible.
For instance, if you are communicating to a DLL, ideally, you do not
drop DLL nodes throughout your program and again and again configure
them to call into the functions that the DLL exposes. Instead, each
time you need to call a specific function in the DLL, make a small
wrapper subVI with the configured DLL node, and exposing the parameters
which you want to be able to change and using constants for others.
This is also the best place to smooth over the odd bit patterns and give
them a strict enumeration type. Then throughout your application, use
the nicer wrapper subVI with its nicer types, its icon, description, its
debugging abilities, etc.
As mentioned in another posting, the capability to do arbitrarily valued
rings or enumerations will likely show up in LV in future releases, but
this technique of wrapping external interfaces to give them a nicer and
more reusable LV interface is still a useful tool to avoid spreading
interface specifics throughout your code.
Greg McKaskle