01-22-2015 08:25 AM
I have a user event being created in a sub VI which produces a string command originating from my .NET DLL. This user event sits within a loop so that it can repeatedly act on events received - so the sub VI will never stop executing. I know that data is not passed via the output terminals until a VI stops executing, so I need another way of this event string being made available in the parent VI for processing as soon as the event occurs.
I have been able to update an indicator on my main VI with this string, using the method outlined here: https://decibel.ni.com/content/docs/DOC-6037
However, this is not suitable because I need to be able to use the string in logic (e.g. in a case structure) to decide what action needs taken. I need more than simply displaying the value in an indicator. Here is the steps I need:
1. Sub VI receives string via event from .NET DLL and keeps executing so that the next event is also caught (this part works)
2. Sub VI passes string directly to parent VI
3. Parent VI acts on string using case structure e.g. if the string is "Initialise", do X. If it is "Execute" do Y, and so on...
Thanks.
This is my 3rd post in a week - can you tell I'm new to this?
01-22-2015 08:40 AM - edited 01-22-2015 08:40 AM
Consider a custom event: You CREATE the event in the main loop and pass the event ID to the subVI.
The subVI does a GENERATE EVENT, using the event refnum and the string you want to pass.
The main loop has an EVENT structure. Register to receive your custom event.
Then you get an EVENT case assigned to your custom event.
When the subVI generates the event, your main loop event will wake up and there's your string.
OR
Consider a NOTIFIER.
Same idea, basically:
Create a NOTIFIER in the main loop and pass the refnum to the subVI.
The subVI does a SEND NOTIFICATION, using the notifier refnum and the string.
The main loop does a WAIT ON NOTIFIER (use a zero timeout if you want), using the notifier refnum.
When the WAIT ON NOTIFIER comes back without a timeout, there's your string.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-22-2015 08:42 AM
01-22-2015 09:37 AM
I am trying to implement Steve's first option with the event refnum. Can you please list what nodes I need? Thanks
01-22-2015 10:00 AM - edited 01-22-2015 10:01 AM
Attached is an example.
Run the MAIN vi.
The subVI generates new events every few seconds (random) and the main vi catches the new data.
Blog for (mostly LabVIEW) programmers: Tips And Tricks