Actor Framework Basics: Walkthrough – Creating a Logger Actor

This article is part of the Actor Framework Basics series. See the other parts:

This walkthrough will show you how to create a very basic logging actor. All it needs to do is receive a “Log” message. This Log message will append a string to be logged to a text file.

Note: The built in tools for working with actors have been significantly improved in LabVIEW 2015. See this document for more instructions on the LabVIEW 2015 AF Project Provider. In LabVIEW 2014 and before use MGI’s Improved AF Message Maker. I’ll include instructions for both versions.

First Step: Creating the actor

Start by creating a blank project.

In your new project right click on “My Computer” and select New -> Actor

Creating an actor

Next you’ll see the following dialog. Enter “Logger” into the “Name” Field and click OK

Naming an Actor

Since you’re starting from a blank project then the Actor Framework won’t be loaded into memory, so you won’t be able to inherit from it. So you’ll first need to add the framework LVLib to your project.

<vi.lib>\ActorFramework\Actor Framework.lvlib

Next create a class and name it “Logger.lvclass”. Finally change it’s inheritance to inherit from Actor Framework.lvlib:Actor.lvclass

Actor Inheritance

Style Recommendation:

Project Style Example for the "Logger" Actor

Project Style Example for the “Logger” Actor

In the project: Each actor will have a handful of messages associated with it (we haven’t created any yet, but the messages are separate LabVIEW Classes). We want these message classes to be strongly coupled to our actor, so it makes sense to group them all together. To do this, create a LVLib and name it the same thing as your actor. Put your actor class inside it. Create a virtual folder inside the LVLib and name it something like “Messages”

Files System Style for the "Logger" Actor

Files System Style for the “Logger” Actor

On the File System: Actors will have a bunch of class methods associated with them, and we’ll have all the message classes that are related too. This creates a decent number of files and as you’re adding/deleting/renaming things you’ll want to be consistent with file placement. First, create a folder that will contain everything related to your actor.

That folder should contain:

  • The LVLib that contains all files related to your actor
  • A folder for your actor class and it’s methods
  • A folder for all the messages
    • This folder will contain a folder for each message

If you’re using the right click menus and other AF tools these style guidelines will be enforced automatically.

Questions? Ask them on this discussion topic and I’ll try to answer them!