LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure with multiple selectors

Solved!
Go to solution

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

0 Kudos
Message 1 of 10
(2,210 Views)

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.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 10
(2,196 Views)

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…

 

  • Would it make sense to use a loop iterating over your "connection state" array to react on each boolean element individually?
  • Would it make sense to use the ArrayAND/ArrayOR functions on your boolean array?

(Can you attach your VI downconverted for LV2019?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(2,192 Views)

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

0 Kudos
Message 4 of 10
(2,185 Views)
Solution
Accepted by topic author Nico_W

Hi Nicolas,

 

something like this?

 

(I wired the references in reversed order to the BuildArray node: please wire it in the correct order…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 10
(2,174 Views)

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,

 

0 Kudos
Message 6 of 10
(2,129 Views)

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???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(2,122 Views)

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

Download All
0 Kudos
Message 8 of 10
(2,094 Views)

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.…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(2,086 Views)

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:

2023-10-24_16-09-41.png

2023-10-24_16-19-59.png

 

This is also described in the manual:

https://www.ni.com/docs/en-US/bundle/labview/page/creating-and-editing-user-defined-constants.html#:....

 

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,

 

0 Kudos
Message 10 of 10
(2,067 Views)