From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-28-2015 01:25 PM
I have an enum inside a dowhile loop. The loop uses shift reg to feed back the next state of the enum. Sometimes I want to stay in the current enum state (actually go back to it). I'm trying this "subvi" so that I can keep each enum increment or come back to the current state as a general vi.
Question: is it ok to use the type cast in this manner??
If a certain condition ( in my state) is met I increment the enum and goto the next state. If not, I stay in the current state ( don't increment the count).
Solved! Go to Solution.
07-28-2015 01:45 PM - edited 07-28-2015 01:49 PM
But you do not need to
The +1 and Select will return your enum
No need to type cast
Unless you have gone into the Object Properties and messed with the "Output Configurations"
But I now see that you are not passing in an enum "Current State"
07-28-2015 01:51 PM
Omar_II wrote:
No need to type cast
Unless you have gone into the Object Properties and messed with the "Output Configurations"
I think you missed the point of the OP wanting to make this a "generic" subVI, implying a reuse subVI. In my experience, making a reuse VI that acts on a enum just does not work out well. You will end up converting back and forth and weird things can happen when you try to increment past the largest value of your enum (direct adding will cause a rollover, casting from a number whose value is larger than the enum will allow will coerce to the last value).
I suggest just making this subVI a template and making copies from the template for the state machines you actually will use this on.
07-28-2015 01:53 PM
07-28-2015 01:57 PM
crossrulz wrote:In my experience, making a reuse VI that acts on a enum just does not work out well. You will end up converting back and forth and weird things can happen when you try to increment past the largest value of your enum (direct adding will cause a rollover, casting from a number whose value is larger than the enum will allow will coerce to the last value).
Also miss match between Enum U32, Enum U16 and Enum U8 does not work very well.
07-28-2015 02:40 PM
Clint,
To illustrate the point that Omar, Crossrulz, and Gerd are making, consider the following Snippet (if you drag this picture to a Block Diagram, it will become executable LabVIEW Code that you can run yourself).
Color is an Enum that I defined as "Red, Orange, ..., Violet". As you can see, within the While Loop I add the current value to the Rainbow Array, increment it to the next Color, and stop when I get the first color back again (meaning I've "wrapped around"). This idea will work with any Enum.
Bob Schor
07-29-2015 04:48 AM
Guess I should have provided more info..See below:
so my question is:
can I use type cast in this manner?? do I even need to? If I took the enum ( test1..test2..) and just added 1 to it would it cause problems??
It sounds like I shouldn't be doing what I'm asking from the replies I'm getting.
Thanks.
07-29-2015 04:53 AM
07-29-2015 05:05 AM
so my test1..test2 the way I have it ISN'T an enum??
07-29-2015 05:11 AM
there is a shipping example w LV2014.."State Machine Fundamentals.vi" I thought I did the same thing they did but they don't have the coercion dot and they made thier enum a type def...What am I doing wrong?? Or better yet how do I do what I'm doing correctly? ..get rid of the dot?