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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if Ring contains specific int value

Solved!
Go to solution

Hi there,

I'am looking for a way to determine if an Int value exists within a ring tpedef .

As usual there is no simple way to do simple things with labview. Sorry for the sarcasm...

Does anybody knows of vi or process to find out my int value is defined in the ring lists?

Thanks in advance.

Eric

 

0 Kudos
Message 1 of 7
(2,550 Views)
Solution
Accepted by topic author Ericg67

@Ericg67 wrote:

As usual there is no simple way to do simple things with labview. Sorry for the sarcasm...

 


Guess that depends on what you call simple...

Value in Ring.png

 

The hidden scripting property would make it even easier:

Value in Ring (brown node).png

 

Keep in mind that the strings and values are not part of the ring's data type. The ring's data type is simply an U16, the strings and values are properties! So making it a type def won't update the strings and values of all type def instances.

 

In short, making a ring a type def seems pretty redundant to me...

Message 2 of 7
(2,535 Views)

Menu rings have a property called "Strings And Values[]".  You can search values within that array of clusters to find the values that are already defined.

Message 3 of 7
(2,534 Views)

Hi wiebe ,

Thank you for your answer.

So what i meant with " simple way" was an equivalent to "Enum.IsDefined" in C# ..... Not requiring the user to reacreate a whole loop or checks from the scratch. As ring and enum are used widely enough in labview, one would think that such a function is already available.

Basicaly, the Ring in our application is used as an array of commands IDs for a communication interface, in order to avoid having to deal with hex data directly. We use ring as enum doesn't allow for non-consecutive/custom values without having to define /disable all the values not used between 0 and your max value.

When a command comes in, we basically need to check if that a command ID is an authorised/ existing one within our ring definition. That's where an existance check is useful to either accept or discard the command.

 

I'll give your scripting answer a go and see how it works.

Thanks

 

0 Kudos
Message 4 of 7
(2,452 Views)

Hi Eric,

 


@Ericg67 wrote:

Not requiring the user to reacreate a whole loop or checks from the scratch. As ring and enum are used widely enough in labview, one would think that such a function is already available.

Basicaly, the Ring in our application is used as an array of commands IDs for a communication interface, in order to avoid having to deal with hex data directly.


In your case the ring is filled with values either once manually at VI edit time or with each VI run programmatically at runtime. In both cases you know the available IDs (aka integer values) and can implement that check loop easily…

 

(THINK DATAFLOW: there is a data source (of your integer values) and you want to check user input against that data source.)

Best regards,
GerdW


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

wiebe@CARYA wrote:

Keep in mind that the strings and values are not part of the ring's data type. The ring's data type is simply an U16, the strings and values are properties! So making it a type def won't update the strings and values of all type def instances.

 

In short, making a ring a type def seems pretty redundant to me...


Yes, but ... if you make a Strict typedef of a ring, then changes to strings and values in the strict typedef will propagate to the instances that are controls/indicators; but will not propagate to instances that are constants ...

unless:

  1. You have "EnableStrictTypedefConstantConfiguration=True" in your labview.ini file; and
  2. Every time you drop an instance of the typedef on a block diagram, you right-click and select "Act as Strict Typedef Constant".

std.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 7
(2,434 Views)

@Ericg67 wrote:

 

So what i meant with " simple way" was an equivalent to "Enum.IsDefined" in C# .....



But an enum is not the same as a ring at all. A ring's values are subject to change at run-time, not so for an enum. There is most likely a way to get an enum check up and running so that it is constant-folded in LabVIEW which will, for all intents and purposes, achieve what you want.

Message 7 of 7
(2,431 Views)