Published October 16, 2013

Good News! We’ve updated Monitored Actor, so be sure to checkout the Monitored Actor 2.0 too!

A common question when first starting to work with the actor framework is “what’s actually running?” The question occurs when you encounter a locked library or are presented with the “Are you sure you’d like to abort running VIs?” dialog on project close. Unfortunately (well, by design actually), if you launch an actor and “forget” about its send queue, there’s nothing you can do to get the send queue reference back. This means that the actor will continue to run until it decides it’s done which may never occur. Now the only way to abort the actor is to close the project. Aborting actors this way gets old quickly. We did a bit of brainstorming here at the MGI office and came up with the idea of a monitored actor. Features of monitored actors are:

  1. In development mode, a window lists all running monitored actors.
  2. From the window you can stop actors, open running cores and ping actors.
  3. The window uses a tree representation for nested actor relationships.
  4. Implementation is identical to regular actors (no “must overrides” or special knowledge).
  5. Run-time behavior is identical to regular actors.

Luckily, the actor framework has two built in hooks that let us implement all of this functionality: Pre-Launch Init and Stop Core.

The Monitor Window

The monitor window pops up as soon as a monitored actor starts running. It disappears when no more monitored actors are running. It will look something like this (a right-click menu is open):

Monitored Actor

In the menu, Show Actor Core will pop up the front panel and block diagram of the selected actor. This is the instance of the re-entrant clone that is currently running so you can use debugging tools like breakpoints, probes, and execution highlighting. The Show Actor Core button does the same thing for the current selection. Ping Actor will send a message to the actor and measure the response time. This can be used to see if the actor core is locked up or running slowly. You can use the poll frequency control [Ed. that’s an interval, not a frequency] at the bottom right to ping continuously. Stop Actor and Emergency Stop Actor will send those messages which are built into the framework.

What it doesn’t do

It doesn’t exactly tell you when an actor stops. Stop is called inside Actor.lvclass:Actor If your actor overrides Actor Core and starts a parallel process it’s possible for this parallel process to continue running even though your actor’s core has stopped. There are no hooks in the Actor Framework to know exactly when an actor has stopped running, so the current functionality is as close as we can get. If your parallel processes aren’t being stopped when your actor core is stopped, you’re probably doing something wrong and it’s on you to fix that. Unfortunately this is one of the root causes of the “why is this library locked?” problem.

How do I use it?

All that you have to do to implement a monitored actor is inherit from Monitored Actor.lvclass instead of Actor.lvclass. This means you can use the tool on an existing project without much work, or even add it in and take it out as needed. See this thread on the actor framework community site for a more detailed discussion: See below to download the most recent version. After you download, you just need to change the inheritance of your actors so they inherit from Monitored Actor.lvlib.  This is made even easier with the use of the MGI Monitored Actor Switcher, which is installed in the Tools menu.  When you open the Monitored Actor Switcher, you will see a window like this:

At this point, you can simply use the arrows to switch any of your objects from Actors to Monitored Actors or back.  You can even use this tool to switch an ordinary class into an actor or monitored actor.

Download the MGI Monitored Actor Toolkit from the NI Tools Network. Search for Monitored Actor in VIPM