Actor Framework Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Test Launch For Nested Actor Without Caller.vi

Here’s a fun one.  Turn your favorite actor into a worker daemon that runs, finishes, and returns data to the caller.

 

First, a little background.  When Actor Framework first shipped, we only had Launch Actor.vi to launch root and nested actors.  Launch Actor.vi required that you provide a valid enqueuer as input.  This wasn’t bad for launching nested actors, because you just passed it the caller’s enqueuer, but it turned out to be confusing for launching the root actor, because you had to obtain a message queue, and then an enqueuer, just to pass it to an actor that was never going to send messages to its caller.  Oh, and you couldn’t destroy the enqueuer until after Launch Actor.vi returned, or Launch Actor would get cranky with you and return an error.

                                 

So we gave you Launch Root Actor.vi and Launch Nested.vi, which cleaned up the code in both cases quite a bit, and gave pretty good indicators of intent, even if the underlying code was the same.  Launch Actor is still around; it’s just no longer on the palette, and you can only find it by rooting around in the actor framework folder.

 

But we’ve made it hard to get to something that is still pretty useful in some cases.  It turns out that, when building automated suites to test actors, it is immensely useful to be able to launch an actor from non-actor code, let it run to completion, and then inspect the actor’s final attribute values.  To do that, you need to go back to what we used to do in the early days:  create a caller enqueuer, pass that enqueuer to the old version of Launch Actor when you launch the actor under test, and then wait for a message from that actor. 

 

(We normally frown on this sort of behavior, because you have to make some assumptions about the messages your non-actor code will receive, and those assumptions can lead to some ugly design problems down the road.  I take a more relaxed view of the issue when you are writing test harnesses; you are making the same assumptions, but you aren’t making design decisions based on those assumptions.)

 

So with that background, allow me to introduce you to Test Launch For Nested Actor Without Caller.vi.  This VI does exactly what I just described, with the assumption that the one and only message returned from the actor is Last Ack.  Last Ack, of course, returns the final state of the actor.  The assumption is that you intend to inspect that object’s attributes, but you can use the object however you wish.

 

To use the VI, pass it the actor to run and a timeout value.  The default timeout is -1, but you probably want to set an actual timeout value to avoid hangs.  You can also pass in a debug alias, for use with AF debug tracing, and you can show the actor's front panel.  This VI will launch the actor, wait for it to finish, and return the actor object.  If the actor fails to stop before the timeout value, you will get an Error 1639.

 

This VI was originally intended to support the automated testing of actors; in fact, we use it in the Automated Testing module of Actor-Oriented Design in LabVIEW.  However, we can easily envision using this VI for other purposes.  Personally, I hope to see it added to the framework as an official feature, though of course, I can’t promise that.

 

Enjoy!

Contributors