From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Advice - Asynchronous call to a subVI?

Hi all,

I would like some advice/help programming my application 🙂

 

I currently have a LabVIEW Listbox that displays all of my data.  I have a 2D array of data and each record has a corresponding numeric integer.  This numeric integer holds  some status bits to give information about the record (I use the number to Boolean array function).  Therefore, I have a 2D array of Data and 1D array of Status numerics.
 
Bit1: Is the record deleted?  (if yes, it doesn’t show up)
Bit2: Is the record selected? (if yes, the background for that row is a different colour)
Bit3: Is the record a search hit? (if yes, change to bold)

 

I have an event driven state machine and written all the code to allow the user to interact with the table and change these status bits.  All of the manipulation is performed on my status array and then I update my table to reflect the status array.

The next step is to launch a new window allowing the user to specify filter parameters that looks something like this:

subVI fp.png

 

I need the Search button to interact with the table in my main application and update it in real time while this window is still open.

The term “Dismiss” on the control button means to close the search window pop up.

The term “Search/Dismiss” means to perform the search and close the search window pop up straight away.

 

I currently call my search as a subVI with the front panel enabled in one of my states and pass it the array of data and the array of status numerics. I manipulate the status bits and then once you click dismiss, the status’ gets passed back to the main application and I update my table.  This is not what I want/need.

 

To have them running in parallel, I was thinking about using the Start Asynchronous Call Node to launch my Search VI.  Then creating a variable of my status array which I can monitor from my main application.  If any of the records status changes, update my main applications front panel to reflect the change.

 

I was also wondering If I could I pass a reference to my message handler queue to my subVI?  If I could do that, when I click search, I could perform all of the functionality for the search within my main application.  I think the difficulty be passing back all of my search parameters.

 

I hope I have explained well enough.

 

To summarise, I need the Search button to interact with the table in my main application and update while this window is still open.

Does anybody have any ideas?

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 1 of 12
(3,208 Views)

Sounds like your Table should really be a GERM (GUI Element Resource Module)

When you need your GUI to be updated from anywhere in an application its time to talk about GUI Handelers (Ben had a very nice nugget about this and there are examples)

Although there are several ways to get the job done they all involve one basic component- use an action engine that is responsible for updating user information rather than the GUI itself.


"Should be" isn't "Is" -Jay
Message 2 of 12
(3,201 Views)

Hey Jeff,

 

Thanks for the input.  I have been looking at the GERM and it looks good.  However, in my main application, I have an event case for a double click on my Multicolumn ListBox.

 

I would need to be able to add a message onto my queue in the main application if a row is double clicked.  I can't see how I would do this with a GERM.

 

If I have understood correctly, a GERM is great when you want to use indicator for display throught your application but not interact with it?

 

What do you think?

 

Lewis

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 3 of 12
(3,175 Views)
Generate a dynamic event from the GERM

"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 12
(3,158 Views)

Hi Jeff,

 

Thanks for the suggestion but I'm not to sure on how to implement it?

 

The GERM is just an FGV right so I can't put a event structure in there to capture a double click on my Multicolumn Listbox because it will block executing while it waits for a click.

 

If I could get it to run in parallel, I could have an event case and then use the "Generate User Event" function to send a message back to the main application?

 

If I did that though, any time I call the GERM it wouldn't run because it was stuck in the event structure?

 

I'm confused Smiley Sad

 

Thanks again, your help is appreciated

 

 

 

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 5 of 12
(3,151 Views)

The GERM implementation is a AE with a FP object (Or group of objects) loaded into a subpanel of a Main vi.  This implementation allows the user to directly interact with a GUI element in a sub-vi


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 12
(3,137 Views)

I personally would use either user events or a message queue to pass data back to the UI. Define your messages appropriately to pass the necessary data and then fire the event or post to the queue. I would not use an AE for this since that would require polling. I prefer event driven systems which are accomplished using the ueser events or queues. If you only need to worry about the latest message you could also use a notifier.

 

If you are using LV 2012 then an even better option would be to use actor framework. A google search will show you earlier versions of the actor framework that can be used in earlier versions of LV.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 12
(3,123 Views)

Drat,(Well, maybe "Huzzah!:)  Perhaps, I really DO need to generate an example.  Not that I can not but, I need source too work work to make it salient.

 

Lewis, can you aid me with some sample source code (My e-mail is in my profile)  

 

Let's "Get=R=done"  in a manner approachable to non-LabVIEW ers.

 

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 12
(3,110 Views)

Hey Guys,

 

Thank you both for you help.  My program is doing what I want but I'm not sure how elegant it is.

 

In the main application I Asynchronously call my pop up window and pass it a reference to a user event I created:

Asynch Call .png

 

Then In my pop up window, I generate a user event when the user clicks search.  This invokes my message generator in my top level VI which in turn, controls my state machine to do all of the logic:

Search Event.png

 

If not sure whether it is good or bad, but to pass the Search criteria around I use the Flatten to String and Unflatten from string.  I guess this is ok providing I use TypeDefs which I have.

 

What do you guys think?

 

Thanks again for your help.

 

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 9 of 12
(3,093 Views)
First glance, I have no problems with the theory.

"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 12
(3,088 Views)