0

i have a ex1.vi which has 2 inputs 1).Signal(boolean) 2).Message(String)

has 1 output Parsed message(String)

now this vi has a while loop where it detects the changes in input and should give the output. this ex1.vi itself is in a message loop in a main.vi that instantiates it. this main.vi produces the Sensor and message data and consumes Parsed message.

eg. the main.vi gives Signal = true and message = "hello" the ex1.vi will give parsed message = "hi". since the ex1.vi is in while loop how will i give the output? if i update a local variable and wire that to the output main.vi is still not able to consume because ex1.vi has not completed. how can i achieve this without the use of global variables?

Koushik Shetty
  • 2,146
  • 4
  • 20
  • 31

2 Answers2

1

Use queues or user-events to share messages between running VIs.

I'm confused how you have your ex1.vi setup. For each call to the subVI you can only have one set of inputs and one output -- you can't monitor an input. If the input data is coming in through a queue then you're halfway there. You just need a queue to return messages to the calling VI.

As you already know, the output of a VI is the same as a return function so you can't return and keep running.

Simon
  • 66
  • 2
  • simon the call to the subVI has only one set of inputs and one output but the call is lodged in a loop. i changed this and made it such that the ex1.vi and main.vi run in parallel(are two seperate threads). for this i thought of using Action engines. i had user events in mind but dint want to pursue it. queues as you said might be a good idea. thanks for the suggestion. – Koushik Shetty Mar 14 '13 at 17:45
1

You could utilize a functional global variable, this is likely the quicker solution. See here: Functional Global Variables

Message queues could also work well, my choice would likely be one of these two depending on application. See here: Queued Message Handler

Which is the better solution is really application dependent and you should weigh the benefits based on the big picture.

crlanglois
  • 3,537
  • 2
  • 14
  • 18
  • functional globals was my first thought, infact **action engines** but then i was also thinking of user events to pass data between the VIs [this](https://decibel.ni.com/content/docs/DOC-7314) and [this](http://digital.ni.com/public.nsf/allkb/A882E27D1D7A949386256E0D0066B91A)which felt more clean(in terms of implemrntation). right now i have 3 options and i think its best to sort them. thanks for the suggestion. – Koushik Shetty Mar 15 '13 at 17:08