LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get mechanical action of boolean programmatically

Solved!
Go to solution
Is there any way to get or set the mechanical action of a boolean programmaticaly. At least if I could only read the actual state of the mechanical action at runtime I would be very happy.
0 Kudos
Message 1 of 13
(4,687 Views)

Well this is not a full answer but,

If you use a property node and attempt to read the "value" of a latch action boolean, it will return an error.

The ClassName property will say boolean it the control is a boolean.

So if you pass an array of control references into a For loop and read the ClassName FIRST and then attempt to read the value you should be able to at least figure out which controls are booleans and which of those are latch action.

I took a quick look a the type descriptor and it apears that a new boolean from the palette will have the first byte equal to 12 and copied boolean have 14 in the first byte.

Now how to decide which type of latch action....

Can't help you there.

Ben


Ben Rayner
Certified LabVIEW Developer
www.DSAutomation.com


For the record: This approach was inspired by the save all control function originally devloped by Jean-Pierre and is available via OpenG. I am not blaming him if this does not work! I am only trying to give credit where credit is due.

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 13
(4,687 Views)
Hi Nitrof,

In regards to setting/reading the mechanical action of a Boolean programmatically, there is no way of doing that �directly� using a property node.

However, I have attached an example VI that I wrote which might help. This VI will allow you to make �visible� a Boolean that corresponds to a certain mechanical action. The Boolean buttons (with different mechanical actions) are correlated to a menu ring number which can be controlled programmatically. The basic idea behind this VI is to have only one Boolean button (that corresponds to a specific mechanical action) visible at any one time. Please use this VI and modify it to work for the Boolean buttons and mechanical actions that you need.

Hope this helps, if this will not work for
your application then please let me know more about how you intend to use the Boolean buttons.

Have a great day!
Brooks W.
National Instruments
0 Kudos
Message 3 of 13
(4,687 Views)

I know this is a really old post, but I found it when I was searching for how to read the mechanical action of a boolean. I needed it for a tool I'm writing to analyze running VIs and one of the things I want to check about them is the controls that are latching booleans. 

 

Ben's suggestion of checking for an error coming out of the value property node worked great for my application! But there is something slightly tricky you have to do to get it to work. If the value variant is unwired, LabVIEW tries to be super helpful and compiles the value property node out, since it thinks you are not using it (at least for me, it seems like this is what it did). This makes it so you never get an error, even if the control is a latching boolean. So what you need to do is wire the value variant to something, anything will do, even just a tunnel on a loop or something, so LabVIEW knows you are actually using the property node. Then it will actually give you an error for latching booleans. It took me a while of being confused before I figured this out, so hopefully this helps if someone else comes across this post and wants to do the same thing.

 

--Hope

0 Kudos
Message 4 of 13
(4,098 Views)
Solution
Accepted by Hooovahh

If you activate scripting, you can access a MechAction property, which makes it somewhat easier:

 

Example_VI_BD.png


___________________
Try to take over the world!
0 Kudos
Message 5 of 13
(4,089 Views)

Yeah, that is a much less hack-y way to do it, but scripting doesn't work while it's running, so I can't use it for my application, since I'm trying to monitor VIs that are running.

 

--Hope

0 Kudos
Message 6 of 13
(4,076 Views)

@prettypwnie wrote:

...but scripting doesn't work while it's running, so I can't use it for my application


Scripting is a very general term, so that's definitely right. Certain things which fall under the scripting label (particularly things that change things) don't work on running VIs, but things which just read generally work, including this property.


___________________
Try to take over the world!
0 Kudos
Message 7 of 13
(4,071 Views)

Wow, you're right, it does work, even while the VI is running. Nice! I guess I'll go back and make my code a bit cleaner with this.

0 Kudos
Message 8 of 13
(4,043 Views)

It is not available on runtime. what a shame.

-------------------------------------------------------------------------------------
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 9 of 13
(2,688 Views)

Hi Tony,

 


@dj_tony wrote:

what a shame.


Why do you think so?

Why do you (think you) need that feature at runtime?

Best regards,
GerdW


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