Jump to content

Multitasking Core in LabVIEW


Recommended Posts

QUOTE (Eugen Graf @ Jun 12 2008, 01:29 PM)

which programm architecture do you use in your projects if you use very much parallel loops, which communicates with syncronisation tools (Queues, Notifiers, User Events and so on)?

You're right -- that's a very broad question.

In general, I use as few parallel loops as I think I need to meet my design goals. Sometimes that turns out to be quite a few loops, but other times it's just one. It's driven entirely by the needs of the application, and there is certainly no maximum number I would ever limit myself to in principle. Expressing parallel execution is one of the areas where LabVIEW really shines.

For inter-loop communication, I use mostly Queues and User Events.

As far as a general design pattern, I am just coming off a long love affair with Producer-Consumer designs, but have realized that a lot of what I used to use two loops for can actually be done with just one.

Link to comment

QUOTE (Justin Goeres @ Jun 13 2008, 12:47 AM)

but have realized that a lot of what I used to use two loops for can actually be done with just one.

But if your software should get data from 5 different sources each over RS232, TCP/IP, CAN and you should show some dialogs to user, than it can't be done with one loop, because your buffers will get full and you will lost some data if user don't klick OK or Cancel?

And the next question:

Producer-Consumer Design Pattern is not enough (for me). I want to communicate from every loop to every other loop. What can you suggest for this?

Link to comment

QUOTE (Eugen Graf @ Jun 13 2008, 05:29 AM)

Hello, this Question in not easy, but:

which programm architecture do you use in your projects if you use very much parallel loops, which communicates with syncronisation tools (Queues, Notifiers, User Events and so on)?

Thank you, Eugen

For parallel loop I use what NI label advanced producer consumer (events) a lot.

If the VI is a GUI then normally I run an event loop, main loop and a gui loop at a minimum.

If I have DAQ then I might have another control loop and sometimes a process loop if I want to pipeline my processes.

I use queues with an enum (state) and variant (data) as the datatype.

If I use anything less (e.g. notifier, single datatype, single loop event state machine), the program always grows and I have to upgrade it to this so most of the time.

So I start with this template even if it is overkill to begin with.

I also like to create FGV wrappers to manage the queues in which the refnum persists, so its neater, easier to manage all the queues and I can call them from anywhere.

Each queue has its own manager so its not a large shared resource.

I use User Events to communicate back to the Event structure if I need it e.g. on error or when I want a force closed etc...

If I ever want to create a resource that sits in the background (no UI) then its the above with the event stucture and the gui loop.

I like having muliple loops as it loosely couples everything (logging, DAQ, control, processing, GUI updates, plugins) etc.. this allows me to reuse code alot.

Using a templates its not much work tho to set it up. So if it was a small app and I could do stuff in one loop, I can, as quickly, build up the same thing with templates and I have a more scalable piece of code if required for the future.

Link to comment

QUOTE (Eugen Graf @ Jun 12 2008, 04:06 PM)

But if your software should get data from 5 different sources each over RS232, TCP/IP, CAN and you should show some dialogs to user, than it can't be done with one loop, because your buffers will get full and you will lost some data if user don't klick OK or Cancel?

And the next question:

Producer-Consumer Design Pattern is not enough (for me). I want to communicate from every loop to every other loop. What can you suggest for this?

Justin was saying to use a separate loop for each needed process. Sounds like you have a process needed for each of your communications lines.

And why not use queues or user events to communicate between the loops, as mentioned already? Your question is fairly generic, and I think that generically you got an answer...

Link to comment

FGV is really a good container for references! :thumbup:

What do you do if your application should connect more computers e.g. over ethernet? I mean you can't use one FGV on more than on PCs.

But I find FGV a very nice suggestion.

QUOTE (JDave @ Jun 13 2008, 01:55 AM)

And why not use queues or user events to communicate between the loops, as mentioned already?

Of course, I use it. But my question was how to administrate it.

had some projects where I used about 5 queues, 1 notifier and 7 User Events. Ok, it's not really the biggest, but it can happen, that I get a project with much more loops,where I have to administrate all references and the programm architecture.

And of course the reusability of the code, so modularity is very important for me. I want to use some loops, tasks packed in a VI for future projects too. So I want to make it more general.

Link to comment

QUOTE (Eugen Graf @ Jun 13 2008, 08:08 AM)

FGV is really a good container for references! :thumbup:

What do you do if your application should connect more computers e.g. over ethernet? I mean you can't use one FGV on more than on PCs.

Ok - my answer was relating to single Computer.

There are network version producer consumer using TCP/IP VIs.

We usually do embedded to PC and make use of NI-PSP protocol and use shared variables alot for network comms.

There is no reason you couldn't take a standard producer-consumer and create a proxy wrapper for it that does all the networking.

So you would still queue events from all the producers like before, but replace the consumer loop with TCP/IP comms.

Cut and paste your old consumer loop to a new PC and build a TCP/IP loop that reads in commands/data over the network and passes that to the old consumer.

A bit more overhead, but the TCP/IP would be loosely coupled, (basically your old PC would not have to know its there) so you could still reuse your old code!

Link to comment

QUOTE (Eugen Graf @ Jun 12 2008, 05:08 PM)

What do you do if your application should connect more computers e.g. over ethernet? I mean you can't use one FGV on more than on PCs.

<snip>

Of course, I use it. But my question was how to administrate it.

had some projects where I used about 5 queues, 1 notifier and 7 User Events. Ok, it's not really the biggest, but it can happen, that I get a project with much more loops,where I have to administrate all references and the programm architecture.

And of course the reusability of the code, so modularity is very important for me. I want to use some loops, tasks packed in a VI for future projects too. So I want to make it more general.

With all due respect, you seem to be looking for a single, perfect answer to the general problem of software architecture in LabVIEW. There isn't one.

If your application is confined to a single computer, then events, queues, notifiers, producer-consumer, and state machine designs will solve a lot of different problems. But each solution will have unique components.

If your application requires communication among different computers, then you will need some kind of network transport, like TCP/IP. Any given solution might use some of the same tools & techniques as a local-only problem, but it will have its own twists and turns, as well.

If you practice good coding style and use opportunities to explore the nooks & crannies of the LabVIEW Examples and the obscure corners of your function palettes, you will gain skill in choosing the right building blocks for each situation you encounter. But there's no One Right Answer. Even Local Variables have use cases.

Link to comment

QUOTE (Eugen Graf @ Jun 12 2008, 05:29 PM)

Hello, this Question in not easy, but:

which programm architecture do you use in your projects if you use very much parallel loops, which communicates with syncronisation tools (Queues, Notifiers, User Events and so on)?

Thank you, Eugen

I am involved in the design of many of the applications that come out of my office. I have taught my developers to first evaluate the applications needs before deciding on an architecture. I do not believe any two application have left our house that use the same architecture.

App Design in 15 minutes (an obvious oxymoron)

1) Understand the requirements of the app. Create a diagram (model) that illustrates the various responcibilties and the interaction between any cooperative entities.

2) Give the entities descriptive names and list their actions.

3) Define the data used to in the inter process communications.

4) Evaluate the naute of each interaction (these are data paths). 1-to-1 1-to-Many, Many-to-1, etc. Also concider failure scenarios, and performance req's. A high data rate app may require multiple CPU's work cooperatively to keep up with the data stream.

5) For each of the Data paths, identify a comm mechanism that will meet the req's. If possible use built in mech's queue, notifier, etc. If no "out-of-the-box" sync mechanism fits the bill, then design a custom one. In the case of customs I favor AE types but will use others.

So I guess the answer to your question is I use all of them and sometimes invent my own.

Have fun,

Ben

Link to comment

QUOTE (Eugen Graf @ Jun 13 2008, 06:33 AM)

It depends on the requirements of the application, and there is no one right answer. See any of the previous posts in this thread.

Whole books have been written about this question.

EDIT: I apologize if I am starting to sound exasperated, but really, you're pounding on a question that is way beyond the scope of this (or any other) forum. The book linked above is highly recommended for learning about design patterns in general. Everything beyond that comes from experience, and 90% of what I know about LabVIEW comes from having done it wrong the first time.

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.