10-24-2023 05:16 AM
Hi all,
As a part of the connection state of a producer/consumer queued state machine, I need to use a case structure with multiple selector inputs. I read some subjects on the forum, but the purpose here is a little bit different, as we have a set of retry connection buttons that should be enabled if the corresponding "device connected" Booleans are false (non mutually exclusive case).
I tried to make an array of the device connection states, then convert it to a number, but then I will have to detail all the possible cases in the case structure...
Isn't there any other method, more elegant? I am also thinking about an enum which would contain all the true cases, but the way to achieve it is not clear to me.
Thanks for your help and kind regards,
Nicolas Winandy
Solved! Go to Solution.
10-24-2023 05:42 AM
Firstly not able to access your code, till using LV20, Saving to previous versions will be easy for most of the forum users to access.
I recommend to use Enum with Multiple State options and use SELECT function to decide based on devices connected.
10-24-2023 05:44 AM
Hi Nico,
@Nico_W wrote:
I tried to make an array of the device connection states, then convert it to a number, but then I will have to detail all the possible cases in the case structure...
Read the help for the case structure to learn about the selector options for strings and (integer) numeric selector values!
You can easily define ranges for cases…
(Can you attach your VI downconverted for LV2019?)
10-24-2023 06:02 AM
Hi Gerd and Palanivel,
Thanks a lot for your swift answer.
Here is the VI saved in the version 19.
Indeed, I will dig into a for loop getting all the true cases, but then I am wondering how to increment the disabled property label.
Kind regards,
Nicolas
10-24-2023 06:24 AM - edited 10-24-2023 06:26 AM
10-24-2023 07:37 AM
Hi GerdW,
Thanks a lot. I do not know how I did not think about it before. It appeared the select function only admit numeric values, so I inserted a case structure to choose between them.
Any idea why there is a type conversion on my build array function, please?
Best regards,
10-24-2023 08:18 AM - edited 10-24-2023 08:20 AM
Hi Nico,
@Nico_W wrote:
Any idea why there is a type conversion on my build array function, please?
Because you are using different types of boolean buttons! (type definitions, switching behaviour…)
@Nico_W wrote:
It appeared the select function only admit numeric values, so I inserted a case structure to choose between them.
No, the Select function takes any kind of input data as you can see from my image!
Just wire the needed datatype to one of the T/F inputs…
Btw. using orange DBL constants is very wrong when you want to select a case later on.
And using the select function like you did is pure Rube-Goldberg! First you convert a boolean input to (orange DBL) 0/1 values just to select a case in a case structure - d'oh…
More Rube-Goldberg: why are there 5 NOT functions before the other BuildArray node? Why not place just one NOT on the array wire after the BuildArray???
10-24-2023 08:47 AM
Hi GerdW,
Sorry for the obvious noob errors and thanks for your time.
I switched to this topology because I had some conversion type when I inserted enum constants from the functions palette to connect the inputs of my select function (see 2023-10-24_15-38-06.png).
Digging into this, it looks like LV inserts a 16bits constant and they must be converted before being used in the select function.
I achieved to get the right type by creating a constant on the input of the disabled property node and copying it to the right place, but I do not really figure out the difference.
Thank you also to have noticed the NOT issue, which I have corrected right away.
Best regards,
Nicolas
10-24-2023 08:55 AM
Hi Nico,
more "noob":
To create the correct constant you right-click the "disabled" property and "Create"->"Constant".
Then wire this constant to the Select node…
You should have learned to create constants from function inputs in the basic LabVIEW lessons. Did you notice the Learning resources offered at the top of the LabVIEW board?
@Nico_W wrote:
I achieved to get the right type by creating a constant on the input of the disabled property node and copying it to the right place, but I do not really figure out the difference.
Type definitions, correct datatype, etc.…
10-24-2023 09:22 AM
Hi GerdW,
@GerdW a écrit :
You should have learned to create constants from function inputs in the basic LabVIEW lessons.
Yes, I followed the Core 1, and as far as I remember, this way of doing it is documented:
This is also described in the manual:
As you emphasized, the select function primarily creates DBL constant, so this is the way I found to circumvent the issue.
But, apparently not the good one... but I am glad to learn if you know a better method.
Best regards,