Jump to content

Recommended Posts

I'd like to implement different data sources. The configuration file defines, which one(s) are loaded. All datasources are first initialized and the they shlould run. The datasources should not have frontpanels open

What is the appropriate way to do this?

datasource 1: active: OK, load and write your data into a queue

datasource 2: active: OK, load and write your data into a queue

datasource 3: not active: don't load

....

At the moment I have static parallel loops for all datasources, this seems to be a little bit bulky and rather not easily expandable in future.

I just found examples with VI-Reference, property-node "FP.open", invoke-node "Run" ... perhaps I have to make the front panels transparent?

Thank you all for your help/ideas!

Martin

Link to comment

Use named queues. Each data source binds to a specific named queue and the consumer is able to select the correct queue based on its needs. If your data sources will all have different data (eg, Type A, Type B, Type C), you'll either have to find a common container format to exchange data in and have routines to correct identify the Type of data to process it correctly. Alternatively, you have one static loop for each Type of data and go from there.

Link to comment

Hi Matin,

To answer your specific question, you can set the FP.Open property to false, which means the front panel will not be opened. Yes you are on the right track if your program requires run-time variability. You can set up each data source as a SubVI which accepts an "output queue" as input to the VI. Make this queue of type "Variant Message" where Variant Message is a bundle consisting of a string and a variant. In this way, each SubVI can send a message on its output queue saying whatever you want it to in the text field and loading its data in the variant field.

In your main code, you create a message handler loop which monitors this output queue (into which all your SubVIs are placing their data messages) reads the text field to figure out what to do (a string based "state machine", probably more accurately, but less commonly called a message handler), and then processes the data as you require. For each data message, you will require a Variant to Data of the appropriate type to be able to process the data.

Launch each Sub VI in a separate loop using the Run method with wait until done set to false, something like below:

gallery_16778_60_15107.png

You don't have to have an input queue if your Subs are self initialising.

You may run into troubles stopping the SubVI's, there are many approaches you can take to deal with this, the simplest to use a global Stop Boolean (make sure that only one loop writes to this and all others read it).

Link to comment

I would suggest one option even better than all these solutions:

Use the Asynch Call By Reference node to spin up instances and set them running, and easily pass parameters into them. You can pass in your favorite data communications mechanism (queue, notifier, etc) to use to signal them as needed.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.