mstoeger Posted May 18, 2012 Report Share Posted May 18, 2012 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 Quote Link to comment
asbo Posted May 18, 2012 Report Share Posted May 18, 2012 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. Quote Link to comment
drjdpowell Posted May 18, 2012 Report Share Posted May 18, 2012 Note: you don’t have to open the front panel to “Run” it. Just skip “FP.open”. Quote Link to comment
AlexA Posted May 22, 2012 Report Share Posted May 22, 2012 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: 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). Quote Link to comment
Aristos Queue Posted May 22, 2012 Report Share Posted May 22, 2012 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.