LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically click a Boolean button with VI Server and generate UI event

Hi,

 

I have a "slave" subVI that I would like to control via VI Server with a "master" subVI.

If run as a stand alone, the "slave" subVI waits for the user to press a Boolean Start button to initiate a series of actions. The Start button triggers a User Interface event that fires the rest of the code.

I can run the "slave" subVI with VI Server and change the value of the Boolean Start control but of course this does not trigger the User Interface event.

 

My question is: is there a way to programmatically "click" the Start button on the "slave" subVI and at the same time trigger the user event?

 

The constraint I have is that I cannot modify the "slave" subVI but I need to use it as it is.

 

Thank you very much!!!

 

Best Regards, Luca

 

0 Kudos
Message 1 of 7
(5,526 Views)
It depends on how the slave VI button is configured. If it has a mechanical action associated with it you're hosed. If it doesn't you can write to the Value(Signaling) property to programatically click the button.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(5,509 Views)

Hi,

When a button has a latch mechanical action, you cannot use the Value property to read or write its value.

I would suggest using instead User Events: (http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/user_events/) 

 

 

Regards,

Marco

 

0 Kudos
Message 3 of 7
(5,505 Views)

Ops....

I just realized you cannot modify the slave vi.

 

So:

if the button is not latched you can do as mike suggested.

if the button is latched, you could try to simulate the mouse click....

 

Here's a starting point:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000001De0QSAS&l=en-US

 

Marco

0 Kudos
Message 4 of 7
(5,503 Views)

The best way would be to create a user event which you connect to the slave vi, and it then register for listening.

 

Else you can get the Controls[] property and scan through all controls labels until you find the one you're looking for and use that ref to set a Value(signalling) ...

 

Use an event. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 7
(5,493 Views)

Dear All 🙂

 

Thank you for your replies. As suggested, I retrieved the references of all the controls on the front panel of the slave subVI, I searched for the ones of the Start and Stop Boolean buttons and I changed their values using the Val(Sgnl) property. Unfortunately this doesn't work when the buttons are configured as "latch". The LabVIEW Help for the property Val(Sgnl) is rather explicit:

 

If this is a Boolean value configured with a latching mechanical action, this property always returns an error. Due to race conditions that can occur when you have a Boolean value with latching mechanical action, you cannot programmatically read Boolean values that are set with a latching mechanical action.

 

So I think Mike is correct: when the Boolean buttons are configured as "latch", there is nothing that can be done programmatically.

I think that I will need to modify the mechanical action of the Boolean buttons on the slave subVI to "switch" and slightly modify the code behind so not to alter any of its functionalities.

I would have hoped to avoid touching the slave subVI but I think I will have to.

The idea of generating the mouse click through Windows is clever but I have decided for the simpler approach.

 

Just in case someone will get interested in this thread in the future, I have included some test subVI to show the architecture of the implementation. The couple DataSource_Latch.vi (slave) and DataReader_Latch.vi (master) don't work (because of the reason above) but the couple DataSource_Switch.vi (slave) and DataReader_Switch.vi do (master). To work they need to be put under C:\ViTest\ (otherwise you can change the path within the subvi).

 

I may be wrong but I think that the couple DataSource_Latch.vi and DataReader_Latch.vi cannot be made to work because of the restriction imposed by the 'latch' mechanical action.

 

Thank you all for your help clarifying this point!!!

 

Ciao, Luca

Message 6 of 7
(5,470 Views)
For situations like this I created a subVI that accepts the control reference for a boolean control, waits 100msec and then forces the button off. This a pretty reasonable approximation of the default mechanical action.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(5,461 Views)