This library provides extensions to the Actor Framework to facilitate the broadcast of messages from one actor to several others. Listeners subscribe to a message when they want to receive it from the Broadcaster, and they unsubscribe when they want to stop receiving it. The library provides a set of common interfaces that decouple Broadcasters from Listeners so any two actors in a messaging hierarchy can communicate via broadcast without having the same caller.
This library extends the Actor Framework; it does not modify the core framework in any way, so it may be used in existing projects as well as new ones.
An actor shouldn't broadcast any kind of message anywhere; that breaks the purpose of the Actor Framework and actor-oriented design because it allows the actor to call state-changing methods on actors other than its caller and callees. When designing a message, first decide its intent. Three kinds of messaging intent were identified in this discussion:
Documentation for the library and the included example program is attached. A class diagram of the library's structure is provided. A "messaging diagram" is also provided to explain the runtime behavior of the example program. The messaging diagram is a UML sequence diagram that shows the lifetimes, activity states, and interactions of each actor's message handler. The user interfaces and other Actor Core.vi override behaviors for actors are not shown in the diagram. The following legend explains the conventions used in the messaging diagram:

The library is distributed as a VI Package. You must install VI Package Manager to install the library.
v1.0.0 of this library depends on the Actor Framework v4.0.1. It is provided for LV 2011 and LV 2012.
v1.1.0 of the library depends on the Actor Framework that is installed in <vi.lib>. It is provided for LV 2013+.
As with Actor Framework.lvlib, It is recommended that you add the library to your LV Project in order to more easily access its methods and inherit from its classes.

The library includes tools for broadcasting a data message to listeners (Broadcast Registry.lvclass), subscribing to and unsubscribing from a data broadcast (Subscription Token.lvclass), and common types for messages involved in the broadcast mechanism:
In order to decouple Listeners from Broadcasters, Registration and Unregistration messages are stored inside a Subscription Token. The Subscription Token is created by a Broadcaster and shared, via messages sent through the actor call chain, with Listeners. A Listener uses methods in the Subscription Token to send Registration/Unregistration messages to the Broadcaster without having any direct coupling to that Broadcaster.
A Registration Msg holds the Listener's enqueuer and an instance of the concrete Data Msg that it will receive from the Broadcaster. When the Registration message is sent to the Broadcaster, the Broadcaster reads these elements and stores them in its Broadcast Registry to be referenced whenever it broadcasts data. An Unregistration Msg holds the Listener's enqueuer as well. When the message is sent to the Broadcaster, the Broadcaster uses the enqueuer to find and remove that Listener's registration from its Broadcast Registry.
An example program is included with the library and can be found at <labview>\examples\Staab\AF Data Broadcasting\Simple Example\Simple Example.lvproj . It can also be found using the LabVIEW Example Finder when browsing by directory structure.

The program contains an actor that broadcasts two kinds of data, 3-axis coordinates and temperature, and listeners for each kind of data. Any number of listeners may be launched simultaneously; each will register for its broadcast and display updates in real time.

The library can be downloaded from LAVAG.org here. It is provided under the 2-clause BSD license.
The library is not there!
Edit: I spoke with one of the LAVA admins, and the link should be fixed now.
Hi,
Download works fine now!
By the way, which tool did you use to make the messaging diagrams?
Thanks for posting the library!
Hi David,
I am having trouble to install the data broadcast library in labview 2013. Probably because the Actor Framework version in labview 2013 is newer than the version that your library requires. Do you have a updated version of the data broadcast library that would install without problems in labview 2013?
thanks
2013 should be fully backward compatible with 2012. At least, it tested that way and no one has reported any bugs contrariwise. 😉
Nice work David. So would this fall under the an actor framework implementation of the observer pattern?
mtat76 wrote:
Nice work David. So would this fall under the an actor framework implementation of the observer pattern?
I'm not falling for that trap.
There are ten implementations of Observer and a hundred opinions on how they're each wrong. Let's just stick with "Data Broadcasting" for the title.
Edit: (I just can't shut up and leave it alone.) The more I see people trying to start their design with Patterns (capital "P"), the more I see them over-designing their software. Don't use Patterns. Learn them, try to understand their intent, and then throw the book away. Design software iteratively, with the minimal code necessary in each iteration to solve one specific, extant problem. This lets your code evolve instead of being framed up from the start, and as we've seen, evolution always wins.
Meh. If it publishes and subscribes like a duck....
Must.not.take.bait....Argggggh!
David Staab wrote:
Edit: (I just can't shut up and leave it alone.) The more I see people trying to start their design with Patterns (capital "P"), the more I see them over-designing their software. Don't use Patterns. Learn them, try to understand their intent, and then throw the book away. Design software iteratively, with the minimal code necessary in each iteration to solve one specific, extant problem. This lets your code evolve instead of being framed up from the start, and as we've seen, evolution always wins.
I think that we can all agree that patterns are to programming as theoretical physics is to engineering - the fundamental knowledge is powerful, but most will find that there is no ideal way of applying these Design Patterns as you might see in textbook. That being said, you can travel years down a path when you find that massive refactoring is required due to a poor (but not obvious) design decision that might have been avoided had you been aware of some of these key "Patterns". I will whole heartedly agree that you should not try to design an application around patterns in a book, but it is absurd to think that you should throw out the book just because you might use it in an unnatural way.
And I would argue that evolution in many cases is a poor analogy for the design process. Many of us (particularly free lance consultants) do not have the luxury to work iteratively, so evolution can be an unacceptably slow process. Why not stand on the shoulders of those who have thought long and hard about this and take away what we can from them (even when there work is not in our field)? And, if you don't understand how a similar problem might have been solved in the past, do you have any hope of developing a better way of solving the problem in a reasonable amount of time (i.e. before you die)? I guess if even a monkey can write Shakespeare....
My feeling is the statement "Don't use Patterns" seems a tad bit histrionic. How about - don't attempt to mold your development process around patterns, but rather fold patterns into your development process as the opportunity arises? "Don't use Patterns" is a little less wordy, so I am betting that will stick. Sigh.
This discussion seems a tad ironic given that we are sitting in the Actor Framework forums; the same concerns that we talk about here could easily be pushed up into a discussion of frameworks. Alas, any good idea can be easily misused.
And now, a leavener: what did the fish say when he ran into a wall? Dam.
Cheers, Matt
Language is a funny thing--the same words mean different things to different people. All David is saying is, "Don't go around looking for ways to apply patterns in your applications. It creates more work than necessary." We all get excited when we learn new ways of thinking about things, and we've all gone through the stage of looking for nails to pound on with our Pattern hammer. And while I learned an awful lot by doing that, I now recognize that those applications are more complex than necessary.
Personally I find the patterns themselves have relatively limited usefulness. The really valuable lessons I learned had to do with creating application components and making sure they are loosely coupled. I have a couple design pattern books and rarely crack them open any more, not because I know all the patterns, but because I rarely need design patterns.
"And I would argue that evolution in many cases is a poor analogy for the design process. Many of us (particularly free lance consultants) do not have the luxury to work iteratively, so evolution can be an unacceptably slow process."
Evolution is an extremely good analogy for how some consultants design and build software. I have found it is not only faster, but my clients are happier with the end result. It's not a matter of luxury, it's simply saying "this is how I can most effectively meet my customer's needs."
As a physicist, I dealt with less-than-ideal reality all the time. But I refuse to become a software engineer until all my actors are totally decoupled -- like my design patterns book promised
.
David Staab wrote:
I agree. That's part of why I don't use AF anymore. It's a hell of boilerplate.
Good ideas! Since I don't use AF anymore, the odds of me going back and refactoring the library in this way are nil. It's licensed open-source, though, so go ahead and make the edits and add yourself to the list of contributors/copyright holders!
Interesting comment, Dave, since many of us are just now looking at using AF and are building applications using it and the scripting engines that have been built around it. Can you talk about where you have moved onto with you current architecture? May not be appropriate in this thread, perhaps in a sidebar convo or a new thread?
Thanks,
Drew