12-15-2014 03:35 AM
hello,
I have a sub VI that receives a reference to a boolean input.
I need this reference to monitor the state of the boolean input throughout the operation of the sub VI.
The input is a stop button. The VI is supposed to frequently check the state of the stop button and in case of it being true, stops its actions.
I set the class of the refnum to be boolean, like so (your language may differ):
In order to get the value from the reference, I right click on it -> create -> property node -> value.
This is the way I was taught to get properties from things.
It creates one of those smaller property node blocks.
This value however is not usable. When I try to connect it to a logical OR, LV complains about the types being incompatible.
Aparently a boolean (reference) cannot be compared to a boolean.
That doesn't make any sense to me.
Could somebody please explain it?
Why is there a difference?
There was another option available:
right click on the reference -> create -> property for Boolean(strict) class -> value.
This creates a regular property node block, with a usable boolean value.
This value is preset to show the correct properties.
Do I still have to wire the reference input of this property node?
Or is this "connected" to the reference the same way as the other "wireless" node?
Please see image below that shows both described ways to retrieve the value:
thank you for your help
Solved! Go to Solution.
12-15-2014 03:52 AM - edited 12-15-2014 03:54 AM
Hi max,
your property node type "A" is not made for a boolean control, it seems to represent a reference as value.
Edit: you created a property node for your reference control. The "value" of that reference control will be of type "reference" - no matter what the reference should point to! You need to connect by wire a generic property node from the functions palette to your reference control!
When you want to use "generic" property nodes: right-click your boolean control and "create->reference". For that reference you can create a control to obtain a suitable reference control!
12-15-2014 04:23 AM
Thanks Gerd,
I assumed that the A node property would implicitely dereference the pointer, so to speak. But it doesn't.
While figuring this out, I noticed that there's an entry in the right click menu of the reference input: "add datatype", that can be ticked or not.
Adding the datatype adds a red star to the reference input in the front panel.
It also turns the type of the property node from variant into boolean.
So I can specify a class, add a datatype and also can create a typedefinition.
I come from other programming languages where these 3 things all seem to be one thing: the type of a variable.
Why are there those 3 seemingly redundant ways in LV to specify the type, or at least something that I think is something similar to what I know as a type of a variable.
This is very confusing.
12-15-2014 04:28 AM - edited 12-15-2014 04:29 AM
Hi max,
Adding the datatype adds a red star to the reference input in the front panel.
Adding the datatype make the reference "strict" (as is noted in the context help window!). You can have a reference to an unspecified boolean control. But you can make it a special reference to a very specific boolean control by setting the datatype!
Background: There can be differences between boolean controls. The can have different appearance in the FP, but they also can have different behaviour. Most prominent case of "different behaviour" is the switching mode of a boolean control…
So in summary: you can have more generic references and more specific ones. You need to choose the correct ones depending on their purpose!
12-15-2014 04:33 AM
@max_ wrote:
Thanks Gerd,
I assumed that the A node property would implicitely dereference the pointer, so to speak. But it doesn't.
While figuring this out, I noticed that there's an entry in the right click menu of the reference input: "add datatype", that can be ticked or not.
Adding the datatype adds a red star to the reference input in the front panel.
It also turns the type of the property node from variant into boolean.
So I can specify a class, add a datatype and also can create a typedefinition.
I come from other programming languages where these 3 things all seem to be one thing: the type of a variable.
Why are there those 3 seemingly redundant ways in LV to specify the type, or at least something that I think is something similar to what I know as a type of a variable.
This is very confusing.
It'll come to you, but they're not the same. First of all, the boolean control isn't a variable, it's a front panel object which you in this case access through its reference (whether or not that is a good design/solution is another matter). The wire is the variable.
The typedef is simply a saved "struct" so you can easily use the same thing everywhere and propagate changes you want to do. This is especially useful for clusters, and to some degree Strict typedefs for coherent look.
/Y
12-15-2014 04:55 AM
And this is what I don't quite understand.
There already is a notion of more or less "strictness" by choosing a class. Depending on where the class is in the inheritance chain, the more or less specific are the available options.
So why aren't there more specialised classes subclassing Boolean to choose from?
12-15-2014 05:00 AM - edited 12-15-2014 05:01 AM
Hi max,
see it this way: "strict" is related to a very specific control on your FP. When you change properties of that control (like the switching mode of a boolean button) the control changes and also the strict reference need to change. Therefor you need to set it to strict afterwards…
Try this:
Create a generic "element" reference on your FP. Then drop any other control of your FP on that reference control!
What happens? By dropping that very specific control on your reference it becomes a strict reference of this very type of control…
12-15-2014 05:31 AM
Thanks again Gerd for trying to help me understand this.
I understand what it does, but not why. In a few other programming languages one specifies the strictness of a type by exactly that: the type, there's no need for a "hey you, type over there! yes, you - be strict!".
But I came to terms with it. I settled on "this makes no sense to me, but I have to deal with it the way it is".
Thank you for your effort.
12-15-2014 05:35 AM
Hi max,
again: when you select a boolean element from the right-click menu of the reference (as you have shown in your first message) you select only a generic boolean control, thus the reference is non-strict. By pointing to a specific boolean control you make the reference strict as it now keeps track of the very specific properties of that boolean control.
A "boolean control" is more than just a bit of information! Maybe that's the difference to your "few other languages"…
12-15-2014 08:18 AM
@max_ wrote:
I understand what it does, but not why. In a few other programming languages one specifies the strictness of a type by exactly that: the type, there's no need for a "hey you, type over there! yes, you - be strict!".
The type has no strictness, it's a boolean. The front panel control has strictness, just like you have some 213 properties for each and every visual control in .net. (rough estimation) 😉
/Y