02-23-2012 06:59 PM
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
02-24-2012 04:09 AM
02-24-2012
04:21 AM
- last edited on
04-30-2025
09:07 AM
by
Content Cleaner
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
02-24-2012
04:25 AM
- last edited on
04-30-2025
09:08 AM
by
Content Cleaner
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
02-24-2012 06:34 AM
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
02-26-2012 08:37 PM
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
02-26-2012 09:23 PM