NI Home > Community > NI Discussion Forums
Reply
Member
tmhw1
Posts: 2
0 Kudos

programmically push a button with latch mechanism

I'm an experienced programmer who is new to Labview. I'm trying to control some Labview programs written by someone using Java/C++. One of the requirement is to change the existing labview program as little as possible and the same technique show works with a number of different labview programs. The idea is to simulate user interaction, pushing buttons and chaning edit boxes etc, I I'm planning to use TCP/IP to communicate between the labview program and Java, the Java program send the name of the control and the action I want to perform to the labview program via TCP/IP. I'm planning to implement the command decoder in a sub-vi and change the value property in the property node.

I've already figured out how to get the reference of the control using it's name and I've already make some protype code that can push some buttons, changing and reading the edit box and so on. However, I run into problems when the control has  latch mechansim. Apparently, the value(signaling) property is not compatible with boolean with latch mechanism. Is there any way round this? Is there any other way to fire an event?


Knight of NI
RavensFan
Posts: 15,010
0 Kudos

Re: programmically push a button with latch mechanism

[ Edited ]
What you will need to do is set the action of the control to switch rather than latch.  Of course, that doesn't cause it to automatically pop back up once it is read by labview.
 
So then you will need to set a case structure so that if the switch is true, it will do whatever you want it to do, and also programmatically set the value of the switch back to false.
 
I am sure there is a good reason as to why latch type switches can't be set programmatically, but I'm not sure why.  Can someone who knows explain it so I can have a better idea why?

Message Edited by Ravens Fan on 11-17-2006 12:58 AM

Member
tmhw1
Posts: 2
0 Kudos

Re: programmically push a button with latch mechanism

Thanks for the reply. I know that I can change the control to switching type. However, as stated in the begining, I want to change as little as possible in the labview program, ideally I want to add a sub-vi in the block diagram and be done with it. If it is not possible then I guess I have to bite the bullet and change the program.

Active Participant
chrisger
Posts: 1,033
0 Kudos

Re: programmically push a button with latch mechanism

hi there

please consider to use the "ActiveX Server" ability of LabVIEW and Executables generated with LabVIEW (aka "VI server"). By doing so you can connect to VIs, their front panels and controls placed on the front panels without adding any code to the LabVIEW application at all!

see the LabVIEW documentation for how to access LabVIEW and LabVIEW executables with ActiveX.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Active Participant
chrisger
Posts: 1,033
0 Kudos

Re: programmically push a button with latch mechanism

oh, yes:

you could assign a key to the button (right click "Advanced"->"Key navigation"). then you could emulate a keyboard stroke with some windows apis to switch the button. search for keyboard stroke emulation on this forum. 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Knight of NI
Knight of NI
tst
Posts: 10,703
0 Kudos

Re: programmically push a button with latch mechanism

There is a LatchValue property, which allows you to write a value to a latched boolean, but it's a private property and might be unstable, so I would avoid using it in any real code. It might not even be exposed through the ActiveX interface for the VI Server, so you might need a VI as a mediator.

If you want to check it out, you can start at the LAVA forums' scripting board.

Another option, similar to Chris's method, is to simulate a mouse click.


___________________
Try to take over the world!