derekmurray - add-multiply actor project tutorial (issue 1.0)

154
Actor Framework Basics (1) Add-Multiply Actor Project Revision: Issue 1.0 Date: 17/05/2015 Author: DMurray Revision History Rev Description of Change Author Active Date Draft A First Draft DMurray 31/04/2015 Draft B Add section 2.13- "Improved Stop Functionality" Minor edits and typo fixes. DMurray 02/05/2015 Issue 1.0 Major overhaul, including: - Root Actor changed to Calculator Actor. - Actor Framework.lvlib not added to the project, but listed in dependencies. - Launcher code changed entirely to run once only. - No program stop functionality in Launcher. - Launcher now saved in project root directory. - Calculator Actor Core modified to run when opened, and close afterwards. - Class methods and message naming changed to NI recommendations. - Minor edits of Introduction. DMurray 17/05/2015

Upload: derek-murray

Post on 11-Feb-2017

469 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Basics (1) Add-Multiply Actor Project

Revision: Issue 1.0

Date: 17/05/2015

Author: DMurray

Revision History

Rev Description of Change Author Active Date

Draft A First Draft DMurray 31/04/2015

Draft B Add section 2.13- "Improved Stop Functionality" Minor edits and typo fixes.

DMurray 02/05/2015

Issue 1.0

Major overhaul, including: - Root Actor changed to Calculator Actor. - Actor Framework.lvlib not added to the project, but listed in dependencies. - Launcher code changed entirely to run once only. - No program stop functionality in Launcher. - Launcher now saved in project root directory. - Calculator Actor Core modified to run when opened, and close afterwards. - Class methods and message naming changed to NI recommendations. - Minor edits of Introduction.

DMurray 17/05/2015

Page 2: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 2 of 154 Issue 1.0

Contents

1 Introduction ............................................................................................................................... 4

1.1 Launch Diagram ...................................................................................................................... 5

1.2 Stop Diagrams ......................................................................................................................... 5

1.3 Essential Actor Framework Classes .......................................................................................... 6

1.4 Message Flow Explanation ....................................................................................................... 8

2 Step-by-Step Tutorial ................................................................................................................ 11

2.1 Create Directory Structure ..................................................................................................... 11

2.2 Create the LabVIEW Project ................................................................................................... 12

2.3 Create Actor Classes .............................................................................................................. 15

2.4 Create the Launcher .............................................................................................................. 26

2.5 Basic Code for Calculator Actor .............................................................................................. 34

2.5.1 Create Stop Event for Calculator Actor ....................................................................................... 37

2.5.2 Add a Calculator Actor Front Panel Stop Button ......................................................................... 46

2.5.3 Alternative Stop Method- Panel Close ........................................................................................ 51

2.5.4 Set Calculator Actor to 'Run When Opened' ............................................................................... 54

2.6 Early Stage Test ..................................................................................................................... 57

2.7 Launch Code for Nested Actors .............................................................................................. 59

2.8 Add Calculator Actor Front Panel Controls/Indicators ............................................................. 61

2.9 Creating Messages................................................................................................................. 62

2.9.1 Create the Method ...................................................................................................................... 62

2.9.2 Create the Message Class ............................................................................................................ 68

2.9.3 Override Do.vi .............................................................................................................................. 77

2.9.4 Create a Send Method ................................................................................................................. 86

2.9.5 Repeat for the Multiplication message class ............................................................................... 92

2.10 Add Logic to Execute Sending of Messages ............................................................................. 94

2.10.1 Test the Sending of Messages ................................................................................................. 96

2.11 Creating Result Messages ...................................................................................................... 98

2.11.1 Add an Addition Result User Event to Calculator Actor .......................................................... 99

2.11.2 Create the Addition Result Method ...................................................................................... 105

2.11.3 Create the Message Class for the Addition Reply ................................................................. 110

2.11.4 Create the Do.vi Method for the Addition Reply .................................................................. 118

2.11.5 Create the Send Method for the Addition Reply ................................................................... 123

2.11.6 Place the Send Method in the Add Numbers() Method ........................................................ 129

2.11.7 Test the Addition Functionality ............................................................................................. 130

Page 3: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 3 of 154 Issue 1.0

2.11.8 Add a Multiplication Result Reference to Calculator Actor ................................................... 131

2.11.9 Create the Multiplication Result Method .............................................................................. 133

2.11.10 Create the Message Class for the Multiplication Reply ......................................................... 136

2.11.11 Create the Do.vi method for the Multiplication Reply .......................................................... 143

2.11.12 Create the Send Method for the Multiplication Reply .......................................................... 148

2.11.13 Place the Send Method in the Multiply Numbers Method ................................................... 153

2.12 Test the Complete Program ................................................................................................. 154

Page 4: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 4 of 154 Issue 1.0

1 Introduction

In this tutorial I go through the step-by-step process of building a very basic actor system to illustrate some introductory concepts of Actor Framework (AF). The system comprises the three actors as shown in Figure 1.1, where, first, a Calculator Actor takes two numbers as input and sends them in messages to an Addition and Multiplication actor. Those actors then carry out the calculations and send the results back (in messages again) to the Calculator Actor for display. While the system is indeed very simple, it shows one of the principle motives in using an actor-based system, which is that the addition and multiplication tasks are carried out concurrently.

Figure 1.1. Actor/Message Diagram

Page 5: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 5 of 154 Issue 1.0

The Actor/Message diagram in Figure 1.1 is generally my starting point for all actor systems/subsystems, as it gives a clear idea of the required message flow. In this tutorial I use the simple message syntax as shown, and use a similar syntax in naming the methods and message classes required for messaging. This makes the code somewhat easier to understand, as programs developed using Actor Framework can be very difficult to follow.

That being said, I make no claim that the methods I use should be adopted as best or even good practice! They are just little idiosyncrasies I developed while learning Actor Framework, and I am still in the early stages of using the AF approach to coding. There may be other things I do which other users may not like, such as sometimes referring to an "Enqueuer" as a "Mail Queue", as this fits better with my understanding of the Actor Model. Note also that I do not use any project wizards/scripting tools/automatic message makers in this tutorial, as I believe knowing how to create everything from a blank slate is much more important for beginners. Still I hope that this guide will be useful, particularly for new users, as it contains a lot of the basic concepts that I could not find properly explained when I started using AF. That is not to say that the material on, for example, the NI forums is not useful, but it just does not cover the very basic level that I'm trying to cover here.

For the rest of this introduction, then, I will give some more details on the basic actor system that forms the core of this tutorial.

1.1 Launch Diagram

As well as the Actor/Message diagram already discussed, there are other diagrams which are helpful in understanding an actor system. One of these is the Launch Diagram shown in Figure 1.2. In the program in this tutorial, a stand-alone VI (Launcher.vi) is used to launch the Calculator Actor, which in turn launches the Addition and Multiplication Actors.

Figure 1.2. Launch Diagram

1.2 Stop Diagram

Related to the Launch Diagram is the Stop Diagram, showing how the system will shut down. In the tutorial I will illustrate two methods for closing the system down. The first of these is shown in Figure 1.3, where a standard boolean Stop button is used to close the Calculator Actor down. Because the nested actors are configured to stop when their launching actor (i.e. Calculator Actor) closes down, they will also shut down at that time. The second method is shown in Figure 1.4 where a Panel Close event is used to stop the Calculator Actor; this again has the knock-on effect of causing the nested actors to shut down.

Page 6: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 6 of 154 Issue 1.0

Figure 1.3. Stop Diagram using standard Stop button

Figure 1.4. Stop Diagram using Panel Close event

1.3 Essential Actor Framework Classes

In this section, a brief description of the project class structure will be given. While there are several classes defined in Actor Framework, the essential ones (for the beginner, at least) are Actor.lvclass and Message.lvclass. These are the classes that will always be used. (The Enqueue.vi method of Enqueue.lvclass is also critical, and that will be discussed in Section 1.4.)

Figure 1.5 shows the class structure for this simple project. Each actor in our system must inherit from Actor.lvclass, as shown. Then, specific methods can be coded using standard LVOOP techniques to carry out the required tasks e.g. "Add Numbers" and "Multiply Numbers". As will be seen, the program is coded in such a way that these methods will be executed when the relevant message is de-queued by the actor. This will hopefully become clearer as the user goes through the tutorial.

Page 7: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 7 of 154 Issue 1.0

Figure 1.5. Basic Actor Class Diagram

Next, Figure 1.6 shows the message class hierarchy for the project. Similarly to the way actors are created, user message classes must inherit from Message.lvclass. Then, to carry out messaging, two main methods are generally defined, a "Send" method and a "Do" method. The "Send" method is user-created, and, as the name suggests, it is used to send the related message object to the target actor. The "Do" method is slightly more complicated in that it is a dynamic dispatch method declared in Message.lvclass (its VI name is "Do.vi"). When the user message class is created and set to inherit from Message.lvclass, the user overrides this method, and adds logic to call the method which will carry out the desired functionality, as mentioned earlier. Note that "Do.vi" must be overridden!

The description below may make this clearer, using the Addition actor and its related message "Addition Request Msg" as examples:

1. A class called Addition Actor is created, and set to inherit from Actor.lvclass.

2. A static method called "Add Number" is created in the Addition Actor class.

3. A message class called "Addition Request Msg" is created and set to inherit from Message.lvclass.

4. A static Send method is created for sending the message.

5. Do.vi of Message.lvclass is overridden, and modified to call the "Add Numbers' method defined in Addition Actor.lvclass.

Page 8: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 8 of 154 Issue 1.0

Figure 1.6. Basic Message Class Diagram

1.4 Message Flow Explanation

The third critical Actor Framework class is Enqueue.lvclass. In this case, however, there is no need to inherit from the class; instead the Enqueue.vi method owned by the class will be used constantly in the user message Send methods, which were introduced in the previous section. Figure 1.7 shows the basic concepts of message flow as they apply to the Addition functionality in our basic actor system.

The flow is as follows:

1. "Addition Request Msg" is added to the Addition Actor Mail Queue using Enqueue.vi. Note that the numbers to be added are included in the message.

2. There may be other messages in the mail queue, but once our message reaches the top of the queue (or bottom, depending on perspective!), it is de-queued and the message class method "Do.vi" is executed. As will be seen in the tutorial, "Do.vi" has been overridden to form a wrapper around the "Add Numbers.vi" method, and so the Add Numbers operation is also carried out.

3. The addition result is then included in the payload of a reply message " Addition Result Msg", and added to the Calculator Actor Mail Queue using Enqueue.vi.

4. Similarly to above, there may be other messages in the Calculator Actor Mail Queue to be dealt with first (e.g. the "Multiplication Result Msg" from the other concurrent actor may be in the queue), but the Addition Result message will be de-queued in turn, and its "Do.vi" method is executed.

Page 9: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 9 of 154 Issue 1.0

Figure 1.7. Message Flow Explanation

5. Once again, Do.vi of the reply message will be overridden with suitable logic for the Calculator

Actor to process the message. In this tutorial a standard LabVIEW dynamic user event is used to update the addition result indicator on the Calculator Actor front panel.

The flow above illustrates an important element of the Actor Model, which is that message flow is always asynchronous1 and one-way. Even though it appears that there is a two-way request-reply mechanism happening, really the Calculator Actor sends its "Addition Request Msg" and forgets about it, carries out other tasks (if it had any), and then processes the addition result message whenever it arrives. For example, in this simple project it may receive the multiplication result first, and have to process that message, before the addition result message even arrives.

Another point about the program in this tutorial is that, in terms of the Actor Model, it is considered a static system. All actors in the system are launched when the program starts, and their behavior is fixed. The functionality of each actor never changes, and there is no possibility for other actors to be launched dynamically, as would be the case in a dynamic actor system. The actors are also considered to be "unserialized" i.e. their functionality is not history-sensitive. To elaborate, the Addition and Multiplication actors simply carry out their respective calculations on the data that arrives, and send the

1 Synchronous message passing can also be implemented in Actor Framework, but its use is discouraged.

Page 10: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 10 of 154 Issue 1.0

result back to the caller actor. There is no need for the nested actors to store the addition/multiplication results. This is in contrast to a "serialized" actor where the actor state needs to be stored; consider, for example a simple counter actor which needs to store the count state every time it receives an 'increment' message.

Another important point is that the messaging mechanism in the program is considered to be "highly-coupled". To elaborate, the Addition and Multiplication actors are designed to interact only with the Calculator Actor, and cannot be re-used with any other type of caller actor. In a more flexible implementation, the Addition and Multiplication actors would be re-usable with any type of caller; this messaging mechanism is called "zero-coupling", and will be the topic of a second tutorial.

The remainder of this document outlines in detail each step required to build the simple actor system. Again, it is stressed that the techniques are of an introductory nature and are not meant to be used as the basis for complex Actor Framework programs.

Page 11: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 11 of 154 Issue 1.0

2 Step-by-Step Tutorial

2.1 Create Directory Structure

The first step is to create the directory structure, as shown below in Figure 2.1. This is similar to the approach used by NI when creating .lvlib files for actor systems, although my naming is slightly different. Note that the "trunk" directory is simply my version control working area for these tutorials; feel free to omit it if desired in your own version.

As can be seen in this example, every actor has its own directory, and separate sub-directories for the actor class and messages.

Figure 2.1 Directory Structure

Page 12: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 12 of 154 Issue 1.0

2.2 Create the LabVIEW Project

The steps in creating the project are:

1. Create a blank project.

2. Save the project as "Add-Multiply Actor Project".

3. Create virtual folders in the project.

So, first, create the blank project as shown in Figure 2.2 and Figure 2.3.

Figure 2.2 Select Create Project

Figure 2.3 Select Blank Project and click on Finish

Page 13: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 13 of 154 Issue 1.0

Next, save the project as "Add-Multiply Actor Project" (Figure 2.4 and Figure 2.5).

Figure 2.4 Click on Save All (this project).

Figure 2.5 Save the Project

Page 14: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 14 of 154 Issue 1.0

Finally, create virtual folders as shown below (or, obviously you're free to choose your own structure). To start creating the folders, right-click on My Computer in the project window, and select New -> Virtual Folder.

Figure 2.6 Create virtual folders

Page 15: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 15 of 154 Issue 1.0

2.3 Create Actor Classes

The steps in creating an Actor class are:

1. For the first class, ensure that Actor Framework.lvlib is open. It doesn't have to be added the project.

2. Right-click the specific virtual folder in the project window, and select New -> Class.

3. Name the class.

4. Change the class properties so that it inherits from Actor.lvclass.

5. Save the class.

Figure 2.7 and Figure 2.8 show how to open the Actor Framework library, while Figure 2.9 to Figure 2.17 show the steps required to create the "Calculator Actor" class.

Figure 2.7 Select File -> Open

Page 16: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 16 of 154 Issue 1.0

Figure 2.8 Navigate to the Actor Framework library location and open it

Page 17: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 17 of 154 Issue 1.0

Figure 2.9 Right-click Calculator Actor Class -> New -> Class

Figure 2.10 Name the class 'Calculator Actor' and click OK.

Page 18: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 18 of 154 Issue 1.0

Figure 2.11 Right-click on the class and select Properties

Page 19: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 19 of 154 Issue 1.0

Figure 2.12 Go to Inheritance Pane and click on Change Inheritance...

Page 20: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 20 of 154 Issue 1.0

Figure 2.13 Select Actor.lvclass and click on Inherit From Selected

Page 21: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 21 of 154 Issue 1.0

Figure 2.14 Updated class inheritance. Click OK to continue.

Page 22: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 22 of 154 Issue 1.0

Figure 2.15 Right-click the class and select Save -> Save

Note that the Calculator Actor class should be saved in the correct directory as created in section 2.1 (../Add-Multiply Actor Project/Calculator Actor/Calculator Actor Class); see Figure 2.16, next page.

Page 23: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 23 of 154 Issue 1.0

Figure 2.16 Save in directory created at start of tutorial

Page 24: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 24 of 154 Issue 1.0

Figure 2.17 First Actor class created

Figure 2.17 shows the updated project with the Calculator Actor class added.

While I won't repeat the above for the other actors in the system, they can be created in the exact same manner. Figure 2.18 (next page) shows the project structure with all three actors created and saved.

Page 25: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 25 of 154 Issue 1.0

Figure 2.18 All three actors created

Page 26: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 26 of 154 Issue 1.0

2.4 Create the Launcher

Next, we create a simple launcher. The aim of this VI is to launch the Calculator Actor, after which the launcher will stop and close itself (refer back to Figure 1.2). The steps are:

1. Add a standard New VI.

2. Add the 'Launch Root Actor' function from Actor Framework.lvlib.

3. Wire up the Calculator Actor class to it.

4. Add an Invoke Node on the block diagram, and set the method to close the VI when done.

5. Save the launcher.

Figure 2.19 to Figure 2.28 illustrate the process. Note that the Actor Framework library can be found in the project dependencies.

Figure 2.19 Right-click on My Computer and select New-> VI

Page 27: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 27 of 154 Issue 1.0

Figure 2.20 Drag 'Launch Root Actor' and 'Calculator Actor.lvclass' onto the block diagram, and wire as shown

Page 28: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 28 of 154 Issue 1.0

Figure 2.21 Add an 'Invoke Node' to the launcher block diagram

Page 29: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 29 of 154 Issue 1.0

Figure 2.22 Connect the error terminals

Page 30: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 30 of 154 Issue 1.0

Figure 2.23 Add a 'Static VI Reference'

Page 31: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 31 of 154 Issue 1.0

Figure 2.24 Wire the Static VI Reference to the Invoke Node reference input. The node type changes to 'VI'

Figure 2.25 Change the Invoke Node method to 'Front Panel -> Close'

Page 32: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 32 of 154 Issue 1.0

Figure 2.26 Delete the Static VI Reference. The finished launcher block diagram is shown above

Figure 2.27 Save the Launcher to the project top-level directory

Page 33: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 33 of 154 Issue 1.0

Figure 2.28 Finished launcher

The finished Launcher and updated project is shown above in Figure 2.28. Note that the front panel is simply blank, and after launching the Calculator Actor it will close.

Page 34: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 34 of 154 Issue 1.0

2.5 Basic Code for Calculator Actor

When starting to add code for the actors, the process gets more involved. In a lot of cases there will be no need to override any of the inherited Actor Framework methods in your own actors, but in the case of Calculator Actor we will use the Actor Core as the main input/output front panel, meaning we must override it. Also, as we will use a 'While Loop-Event Case' structure on the block diagram, then we will add a dynamic Stop event to stop the While Loop. This, in turn, means that we need to override Stop Core.vi. We will also add two User Interface mechanisms to close the Calculator Actor down, namely a standard boolean 'Stop' button and a 'Panel Close' event. Finally, we will modify the Actor Core properties so that it will 'Run When Opened' and 'Close When Finished'.

There are a lot of steps here, and they can be summarized as follows:

1. Override the class Actor Core method.

2. Add a 'While Loop-Event Case' Structure, with dynamic events enabled.

3. Add a 'Register Events' function.

4. Add a boolean 'Stop' event to the Actor Core block diagram, and connect to 'Register Events'.

5. Add the boolean 'Stop' event to the Calculator Actor .ctl private data structure.

6. Apply changes to the private data structure, and save any unsaved files.

7. Override Stop Core.vi, and add the 'Generate Event' function to trigger the Stop event to stop the While Loop on Actor core as part of the shut-down process.

8. Save Stop core.vi.

9. Add a UI boolean Stop event, and place the 'Normal Stop' message inside it.

10. Add a UI 'Panel Close' event, and place the 'Normal Stop' message inside it.

11. Modify the Calculator Actor properties so that it will 'Run When Opened' and 'Close When Finished'.

Page 35: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 35 of 154 Issue 1.0

Figure 2.29 Right-click Calculator Actor.lvclass -> New -> VI for Override...

Figure 2.30 Select Actor Core.vi and click OK

Page 36: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 36 of 154 Issue 1.0

Figure 2.31 Actor Core Front Panel for Calculator Actor

Figure 2.32 Clean up block diagram if desired

Page 37: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 37 of 154 Issue 1.0

2.5.1 Create Stop Event for Calculator Actor

Figure 2.33 Add logic to the Actor Core block diagram

Above:

1. Add the While Loop.

2. Add the Event Case.

3. Enable dynamic events.

4. Add the Register Events function.

5. Add the 'Create Event' function, and wire the boolean Stop event to it.

6. Wire up as shown.

Page 38: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 38 of 154 Issue 1.0

Figure 2.34 Add the Dynamic Stop Event

Figure 2.35 Stop event created. Note: also create the Stop Event indicator as shown, for the next step.

Page 39: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 39 of 154 Issue 1.0

Figure 2.36 Drag Stop Event indicator into Calculator Actor.ctl

In the above figures, we add the Stop event to the Calculator Actor private data. Open Calculator Actor.ctl from the project, place it side by side with the Actor Core front panel, and drag the Stop Event indicator into it. Delete the copy from the Actor Core front panel.

Figure 2.37 On the Calculator Actor .ctl file, Select Apply Changes, then select Save

Page 40: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 40 of 154 Issue 1.0

Figure 2.38 If you haven't already saved Actor Core, a Dialog will prompt you to save it

Figure 2.39 Save Actor Core in Calculator Actor Class directory (this will come up by default)

Page 41: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 41 of 154 Issue 1.0

Figure 2.40 Add virtual folder Framework Overrides, and drag Actor Core into it

In the project, I like to add a virtual folder called Framework Overrides, and add Actor Core to it (Figure 2.40, above). Back on the block diagram, bundle the stop event into the Calculator Actor private data Stop Event (Figure 2.41, below).

Figure 2.41 Bundle the event into the private data Stop Event

Page 42: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 42 of 154 Issue 1.0

Next step is to override the Stop Core (Figure 2.42 to Figure 2.48):

Figure 2.42 Right-click on Calculator Actor.lvclass -> New -> VI for Override

Figure 2.43 Select Stop Core and click OK

Page 43: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 43 of 154 Issue 1.0

Figure 2.44 Stop Core VI will open

Figure 2.45 Stop Core block-diagram

Page 44: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 44 of 154 Issue 1.0

Figure 2.46 Add logic to generate the Stop event

Figure 2.47 Save Stop Core.vi

Page 45: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 45 of 154 Issue 1.0

Figure 2.48 Drag Stop Core.vi into Framework Overrides virtual folder

Finally, you can also add the Stop Core into the Framework Overrides virtual folder. The updated project is shown above. Select File->Save All to save progress (click on the Save All icon on the toolbar).

Page 46: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 46 of 154 Issue 1.0

2.5.2 Add a Calculator Actor Front Panel Stop Button

The code required to implement the first Stop method is detailed in this section. A standard boolean Stop button will be placed on the Calculator Actor core front panel, and a related 'stop' event added to the event case structure. Logic will be added to the event case so that when Stop is pressed, the Calculator Actor will send a 'Normal Stop' message to itself, causing the Calculator actor and the nested actors to shut down. (Note that no changes are required for nested actor shut-down; they are still configured to shut down automatically when the caller shuts down.)

Figure 2.49 shows the Stop Diagram, and Figure 2.50 to Figure 2.55 show the steps required to implement the Stop functionality.

Figure 2.49 Stop Diagram using a standard boolean Stop button.

Page 47: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 47 of 154 Issue 1.0

Figure 2.50 Add a boolean 'Stop' button to Calculator Actor Core front panel

Figure 2.51 'Stop' button added

Page 48: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 48 of 154 Issue 1.0

Figure 2.52 Right-click the event case and select Add Event Case...

Page 49: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 49 of 154 Issue 1.0

Figure 2.53 Select the 'stop' event as the source, and Value Change as the event. Click OK to continue

Page 50: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 50 of 154 Issue 1.0

Figure 2.54 Drag the 'Send Normal Stop.vi' method into the Stop event case

Figure 2.55 Add the 'Read Self Enqueuer', and wire as shown. Note that the Calculator Actor is sending the stop message to itself.

Page 51: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 51 of 154 Issue 1.0

2.5.3 Alternative Stop Method- Panel Close

The second Stop method is detailed in this section. In this case, the Panel Close operation will cause the Normal Stop message to be sent to the Calculator Actor, and everything will shut down as before (Figure 2.56). The steps are illustrated in Figure 2.57 to Figure 2.59.

Figure 2.56 Stop Diagram using Panel Close functionality

Figure 2.57 Right-click the event case and select Add Event Case...

Page 52: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 52 of 154 Issue 1.0

Figure 2.58 Select <This VI> as the source, and Panel Close as the event

Page 53: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 53 of 154 Issue 1.0

Figure 2.59 Add the "Send Normal Stop.vi" method to the Panel Close case, and wire as shown

Page 54: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 54 of 154 Issue 1.0

2.5.4 Set Calculator Actor to 'Run When Opened'

When an actor is launched, there is an option to automatically open the Actor Core front panel. This option, however, should only be used for debug purposes. Instead, if it is desired that an Actor Core front panel should open on launch, then the VI properties should be modified as shown in this section.

In this case, we want the Calculator Actor Core front panel to open when it is launched. Start by opening the VI and selecting File -> VI Properties (Figure 2.60).

Figure 2.60 Select File -> VI Properties

Page 55: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 55 of 154 Issue 1.0

Figure 2.61 Select the 'Window Appearance' category, and click on 'Customize...'

Select the 'Window Appearance' category and click on 'Customize...' .

Page 56: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 56 of 154 Issue 1.0

Figure 2.62 Settings to ensure that the Calculator Actor will appear when it is called

Enable the following settings:

Show front panel when called.

Close afterward if originally closed.

Also (optionally), disable the following:

Show Abort button.

Show Run button.

Page 57: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 57 of 154 Issue 1.0

2.6 Early Stage Test

At this point we can run a very simple start-up/shut-down test. Open the Launcher as shown below, and click on the Run button to start as normal (Figure 2.63). The launcher should disappear, and a clone 'Calculator Actor.lvclass:Actor Core.vi' should run as shown in (Figure 2.64, next page). Run the test twice, first using the Stop boolean to close the program, and then using the Panel Close button. If the program shuts down correctly each time, it means that the code up to this point is correct.

Note that if there any 'locked' icons on the project classes after shutting down (or attempting to shut down), this indicates the actor has not shut-down correctly. Re-check the steps in the previous section to try and debug the issue.

Figure 2.63 Run the launcher: it will close down automatically and a clone Calculator Actor: Actor Core will run (see next page)

Page 58: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 58 of 154 Issue 1.0

Figure 2.64 Run the test twice and shut the program down using both the Stop button and the Panel Close button

Page 59: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 59 of 154 Issue 1.0

2.7 Launch Code for Nested Actors

The next step is to add the code to launch the nested Addition and Multiplication actors; refer back to Figure 1.2 for the Launch Diagram. Open up the Actor Core BD of Calculator Actor, and drag across 2x Launch Nested Actors VIs from the Actor Framework library.

Figure 2.65 Add two 'Launch Nested Actors.vi' sub-vi's to the Actor Core block diagram

Page 60: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 60 of 154 Issue 1.0

Wire up in series as shown, drag the nested actor class objects onto the BD, and connect the classes to the Nested Actor inputs. Also, connect the nested actor enqueuers to the While loop for use later; note that I often use the term 'Mail Queue' rather than enqueuer.

Figure 2.66 Connect up nested actors

Page 61: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 61 of 154 Issue 1.0

2.8 Add Calculator Actor Front Panel Controls/Indicators

Next, add the relevant controls and indicators to the Calculator Actor front panel, as shown in Figure 2.67. We need two controls, 'Number1' and 'Number2', that will be sent in messages to the Addition and Multiplication actors. Then we need two Result indicators, one each for Addition and Multiplication. These controls and indicators are all of type 'double'. Finally, a Boolean control ('Calculate') is used to execute the sending of messages to the nested actors.

Figure 2.67 Add controls and indicators to Actor Core FP

Page 62: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 62 of 154 Issue 1.0

2.9 Creating Messages

Next, we will start creating messages. In this tutorial, the flow is as follows:

1. Create the required method which will go in the Do.vi wrapper.

2. Create the message class, and inherit from Message.lvclass.

3. Override Do.vi in the message class, and add in the method created in (1).

4. Create the Send method.

2.9.1 Create the Method

First, static methods must be created for each nested actor to carry out the respective Add/Multiply operations. Figure 2.68 to Figure 2.71 shows the process for the Addition method; this can be repeated for the Multiplication method. Once the methods are created, the related messages can then be built using either the Actor Framework Message Maker tool (AFMM), or manually. In this tutorial I concentrate solely on creating messages manually.

Figure 2.68 To create the method, right-click on the Actor class, and select 'New->VI from Static Dispatch Template'

Page 63: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 63 of 154 Issue 1.0

Figure 2.69 Add controls 'Number1' and 'Number2' to the static method FP. Don't forget to wire the terminals!

Page 64: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 64 of 154 Issue 1.0

Figure 2.70 Update BD with Add function and Read Caller Enqueuer.vi

Use the Add function (obviously) to carry out the actor task of adding the two numbers. Also, drag the 'Read Caller Enqueuer.vi' function on to the block diagram. This will be used later to get the target for the Reply message.

Page 65: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 65 of 154 Issue 1.0

Next, save the method in the Addition Actor Class directory (this location should come up by default).

Figure 2.71 Save the method as 'Add Numbers.vi'

Page 66: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 66 of 154 Issue 1.0

Create a virtual folder in the Addition actor class shown called 'Static Methods - Messaging', and drag the new method into it. This is the convention I use; if I had some standard class methods I would have another folder called 'Static Methods- General', and similarly I might have a folder called 'Private Methods', depending on the project.

Figure 2.72 Add a Virtual folder for 'Static Methods - Messaging'

Page 67: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 67 of 154 Issue 1.0

Figure 2.73 Repeat the process for the Multiplication Actor

Next, the entire process from Figure 2.68 to Figure 2.72 can be repeated for the Multiplication method, with the only change being (rather obviously) that the Multiply function is used in the method instead of the Add function. The project structure when done should look like Figure 2.73.

Page 68: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 68 of 154 Issue 1.0

2.9.2 Create the Message Class

To create the message class, start by first creating a virtual folder for the class under Addition Actor Messages (Figure 2.74). Note that the steps given are for the Addition message class, and they can be repeated for the Multiplication message.

Figure 2.74 Select New->Virtual Folder

Page 69: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 69 of 154 Issue 1.0

Figure 2.75 Enter a name for the folder: 'Addition Request Msg'

Figure 2.76 Right-click virtual folder -> New -> Class

Page 70: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 70 of 154 Issue 1.0

Figure 2.77 Enter the class name 'Addition Request Msg' and click OK

Figure 2.78 Create a directory to store the class

Each message class should have its own directory on disk, as shown in Figure 2.78. Create the directory before saving the message class.

Page 71: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 71 of 154 Issue 1.0

Figure 2.79 Right-click to save the class

Figure 2.80 Save it in the directory just created

Page 72: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 72 of 154 Issue 1.0

Figure 2.81 To change the class inheritance, start by right-clicking the class and selecting Properties

Once the class is created and saved, it should be set to inherit from Message.lvclass. Right-click on the class and select Properties (Figure 2.81).

Page 73: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 73 of 154 Issue 1.0

Figure 2.82 Select Inheritance -> Change Inheritance...

Page 74: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 74 of 154 Issue 1.0

Figure 2.83 Select Message.lvclass and click on Inherit From Selected

Page 75: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 75 of 154 Issue 1.0

Figure 2.84 The inheritance tree is as shown. Click OK to continue.

Page 76: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 76 of 154 Issue 1.0

Figure 2.85 Add the message payload (Number1 and Number2) to the class private data

Next, open up the class private data cluster, and add two doubles as shown (Number1 and Number2). This matches up with the inputs of the method created in section 2.9.1. One concept that is important here is that the message data payload is part of the class private data.

Page 77: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 77 of 154 Issue 1.0

Figure 2.86 Apply Changes, and also Save the .ctl

Apply the changes to the .ctl file and save it (Figure 2.86).

2.9.3 Override Do.vi

At this point, you may have noticed that all the VIs in the project are broken. This is because when you inherit from Message.lvclass in Actor Framework, its "Do.vi" method must be overridden. That is, it is a dynamic dispatch method that descendent classes must override. So the next step is to override Do.vi for this message class. Start by right-clicking on the class, and select New -> VI for Override... (Figure 2.87).

Page 78: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 78 of 154 Issue 1.0

Figure 2.87 Right-click on the class, and select New -> VI for Override..

Figure 2.88 Select * Do.vi and click OK

Page 79: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 79 of 154 Issue 1.0

Figure 2.89 Do.vi front panel

The Do.vi front panel appears (Figure 2.89). There is no need to change anything on the front panel.

Page 80: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 80 of 154 Issue 1.0

Figure 2.90 Initial Do.vi block diagram

The initial Do.vi block diagram is shown in Figure 2.90. Delete the main VI and broken wires, and set the controls/indicators to appear as standard LV terminals (this last step is optional). The result is shown in Figure 2.91.

Figure 2.91 Clean block diagram for Do.vi

Page 81: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 81 of 154 Issue 1.0

Figure 2.92 Do.vi logic (part 1)

The new logic for Do.vi is shown in Figure 2.92 to Figure 2.95. In Figure 2.92 above, do the following:

1. Add a case structure.

2. Add two 'To More specific Class' functions, and wire as shown

Figure 2.93 Do.vi logic (part 2)

In Figure 2.93, drag the Add Numbers method created earlier (section 2.9.1) into the Case structure and wire up as shown.

Page 82: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 82 of 154 Issue 1.0

Figure 2.94 Do.vi logic (part 3)

In Figure 2.94, do the following:

1. On the 'Add Numbers.vi' method, right click on the input terminal 'Addition Actor in', and create an Addition Actor constant.

2. Wire the object to the 'To More Specific Class' functions as shown.

3. Complete any other wiring connections (for example, in the false case).

Page 83: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 83 of 154 Issue 1.0

Figure 2.95 Do.vi logic (part 4)

Finally, as shown in Figure 2.95, do the following:

1. From the message object input, unbundle the private data 'Number1' and 'Number2'. Note that because the 'Do.vi' method is a member of the class, we have direct access to the data.

2. Wire to the 'Add Numbers.vi' method.

Page 84: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 84 of 154 Issue 1.0

Figure 2.96 Save the class

Before continuing, 'Do.vi' should be saved (assuming you have not already done so). Right-click on the message class and click Save -> Save. The dialog as shown in Figure 2.96 appears; Click Yes.

Page 85: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 85 of 154 Issue 1.0

Figure 2.97 Save the Do.vi method in its message class directory; this should be the location by default

Page 86: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 86 of 154 Issue 1.0

2.9.4 Create a Send Method

The last step in creating the message is to create a Send method. Start by right-clicking on the class, and select New -> VI from Static Dispatch Template (Figure 2.98). The front panel appears as in Figure 2.99. Save the method as 'Send Addition Request Msg.vi' (Figure 2.100).

Figure 2.98 Right-click on the message class and select New -> VI from Static Dispatch Template

Page 87: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 87 of 154 Issue 1.0

Figure 2.99 The front panel appears as shown. For now, don't make any changes.

Figure 2.100 Save the method as 'Send Addition Request Msg.vi'

Page 88: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 88 of 154 Issue 1.0

Figure 2.101 Initial block diagram

Switch to the block diagram, as shown in Figure 2.101. Delete the case structure and 'Msg out' terminal. Then, from Actor Framework.lvlib, drag in the 'Enqueue.vi' VI, and wire as shown in Figure 2.102.

Figure 2.102 Drag Enqueue.vi onto the block diagram

Page 89: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 89 of 154 Issue 1.0

Figure 2.103 Change the input message terminal to a constant

Change the input message terminal to a constant (Figure 2.103). Then add two controls for data input as shown below in Figure 2.104, and bundle them into the message object.

Figure 2.104 Add controls Number1 and Number2 and bundle into the message object

Page 90: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 90 of 154 Issue 1.0

Figure 2.105 Add remaining controls/indicators

Add remaining Controls/indicators: Message Enqueuer in, Message Enqueuer out, and Message Priority (Normal).

Page 91: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 91 of 154 Issue 1.0

Figure 2.106 Configure terminals as shown

Wire up the terminals as shown above in Figure 2.106.

Page 92: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 92 of 154 Issue 1.0

Figure 2.107 Modify the Icon

Finally, it's a good idea to modify the Send VI icon to make the method look more like it is used for sending messages. In Figure 2.107 I just add a 'message' and 'right arrow' glyph.

2.9.5 Repeat for the Multiplication message class

When you're done, save the project. The entire process can now be repeated for the Multiplication message. If you already created the Actor multiplication method following the steps in Section 2.9.1, then follow the steps in Sections 2.9.2 to 2.9.4 to create the message class (save it as "Multiplication Request Msg.lvclass"), Do.vi method, and Send method.

When done, the project should look like that shown in Figure 2.108.

Page 93: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 93 of 154 Issue 1.0

Figure 2.108 Project with both message classes created

Page 94: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 94 of 154 Issue 1.0

2.10 Add Logic to Execute Sending of Messages

Figure 2.109 Right-click -> Add Event Case...

The next step is to add code on the Calculator Actor core block diagram to trigger the sending of messages. Earlier we added a 'Calculate' button on the front panel of Calculator Actor, and that will be the trigger event. On the Calculator Actor block diagram, right-click on the User Event case selector and select Add Event Case... (Figure 2.109).

Page 95: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 95 of 154 Issue 1.0

Figure 2.110 Select 'Calculate' as the source, and 'Value Change' as the event

Page 96: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 96 of 154 Issue 1.0

Figure 2.111 Modify the 'Calculate' event case

Next, modify the event case as follows:

1. Drag the message Send methods created in the last section into the event case.

2. Wire the correct enqueuer to each send method.

3. Wire the Number1 and Number 2 controls to each Send method.

Note that by making the labels visible on the Send methods, the diagram is much more readable.

2.10.1 Test the Sending of Messages

We can run another quick test of the program at this point to see that messages are being sent correctly (refer to Figure 2.112). Open up the 'Add Numbers.vi' method of the Addition Actor class (note: not the message class!) that was created in Section 2.9.1. Run the Launcher again as done in the previous test in Section 2.6. The Calculator Actor Core should run, and this time you can enter the numbers to be added/multiplied. When you click 'Calculate', the two numbers should appear in the 'Add Numbers().vi' method. Stop the test as before.

While the messages are being sent correctly at this point and the calculations are being carried out, we still need messages to handle the sending of the results back to the Calculator Actor, and that will be covered in the next section.

Page 97: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 97 of 154 Issue 1.0

Figure 2.112 Open 'request- Add Numbers().vi' to see that the Send message is working

Page 98: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 98 of 154 Issue 1.0

2.11 Creating Result Messages

We currently have two actors carrying out addition and multiplication tasks, and we also have message classes to send the data payload to these actors. Next, we need to create messages for each nested actor to send its result back to the Calculator Actor. This illustrates another principle concept of the Actor Model, which is that actors only ever communicate by message passing.

In this tutorial I will show two ways that work in this particular tutorial for sending replies. First, because we already have an Event Case in the Calculator Actor, we will create an 'addition result' event to handle that reply. Then, to illustrate a second method, we will use a standard indicator reference for the multiplication result reply.

We will start with the Addition Result message. The steps required are:

1. Add a suitable event to Calculator Actor core.

2. Create a Calculator Actor method for generating the event.

3. Create the message class for sending the reply.

4. Create the "Do.vi" method, and add the method created in (2) to it.

5. Create the message Send method.

Note that steps 2-5 are similar to those discussed already in Section 2.9, showing that there is a very consistent flow in creating messages.

Page 99: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 99 of 154 Issue 1.0

2.11.1 Add an Addition Result User Event to Calculator Actor

Figure 2.113 Create an Addition Result Event

We start by adding the required Addition Result Event to Calculator Actor:

1. Add a constant of type double called 'Result - Addition'.

2. Add the 'Create Event' function from the Events palette.

3. Wire the event to 'Reg Events'.

4. Also create an 'Addition Result Event' indicator and disconnect as shown; this will be used in the next step.

Page 100: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 100 of 154 Issue 1.0

Figure 2.114 Add the Addition Result Event to the Calculator Actor private data, and delete when copied

Page 101: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 101 of 154 Issue 1.0

Figure 2.115 Wire the event into the Calculator Actor private data

Page 102: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 102 of 154 Issue 1.0

Figure 2.116 Right-click and select Add Event Case...

Next, to receive the result back in Calculator Actor, we will create the dynamic event. Start by right-clicking on the Event Case and select Add Event Case...

Page 103: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 103 of 154 Issue 1.0

Figure 2.117 Choose <Result - Addition> as the source, and User Event as the event

Page 104: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 104 of 154 Issue 1.0

Figure 2.118 Wire up the 'Result - Addition' indicator

Finally, connect the 'Result - Addition' Indicator that we created much earlier (Section 2.8) to the event case output as shown above.

Page 105: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 105 of 154 Issue 1.0

2.11.2 Create the Addition Result Method

Figure 2.119 Right-click on Calculator Actor class and select New -> Virtual Folder

The next step is to create the method that will be used in "Do.vi" to generate the user event that was created in the previous section. Start by right-clicking on the Calculator Actor class and select New -> Virtual Folder.

Page 106: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 106 of 154 Issue 1.0

Figure 2.120 Call the folder 'Static Methods - Messaging'

Page 107: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 107 of 154 Issue 1.0

Figure 2.121 Select New -> VI from Static Dispatch Template

Figure 2.122 On the front panel, add a double called 'Addition Result' and set the connector terminal

Page 108: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 108 of 154 Issue 1.0

Figure 2.123 Add the logic to generate the Add Result Event

On the method block diagram, do the following:

1. Unbundle the 'Addition Event Result' from the class private data.

2. Add a 'Generate User Event' function as shown.

3. Connect the 'Addition Result' control to the 'Generate User Event' input.

Page 109: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 109 of 154 Issue 1.0

Figure 2.124 Save the method as 'Generate Addition Result Event'

Finally, save the method as 'Generate Addition Result Event' in the Calculator Actor Class directory (this folder should come up as default as shown).

Page 110: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 110 of 154 Issue 1.0

2.11.3 Create the Message Class for the Addition Reply

The next step is to create the message class for the addition reply, as illustrated in Figure 2.125 to Figure 2.135. As the general process has already been explained in Section 2.9.2, I won't go into as much detail this time, so refer back to that section if anything is unclear.

Figure 2.125 Create a Virtual Folder in 'Calculator Actor Messages' for the new message

Page 111: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 111 of 154 Issue 1.0

Figure 2.126 Name the folder "Addition Result Msg"

Figure 2.127 Also create an identical directory in "/../Calculator Actor Messages/"

Page 112: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 112 of 154 Issue 1.0

Figure 2.128 Create the new class: Right-click the new virtual folder and select New -> Class

Figure 2.129 Name the class " Addition Result Msg"

Page 113: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 113 of 154 Issue 1.0

Figure 2.130 Save the class by right-clicking and selecting Save -> Save

Figure 2.131 Name the class "Addition Result Msg.lvclass"

Page 114: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 114 of 154 Issue 1.0

Figure 2.132 Change the class inheritance: start by right-clicking the class and selecting Properties

Page 115: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 115 of 154 Issue 1.0

Figure 2.133 Select Inheritance -> Change Inheritance

Page 116: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 116 of 154 Issue 1.0

Figure 2.134 Select "Message.lvclass" and click on 'Inherit From Selected"

Page 117: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 117 of 154 Issue 1.0

Figure 2.135 The new inheritance structure is shown above; Click OK to finish.

Page 118: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 118 of 154 Issue 1.0

2.11.4 Create the Do.vi Method for the Addition Reply

Next, the Do.vi method must be created. Again this is similar to the steps detailed in section 2.9.3, so refer back to that section if the following is unclear.

Figure 2.136 Right-click on the class just created and select New -> VI for Override

Figure 2.137 Select "* Do.vi" and click OK

Page 119: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 119 of 154 Issue 1.0

Figure 2.138 "Do.vi" front panel; leave unchanged

Figure 2.139 Do.vi block diagram before editing

Page 120: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 120 of 154 Issue 1.0

Figure 2.140 Add case structure and 2x "To More specific Class' functions"

Figure 2.141 Drag in the Addition Result method, and create the Calculator Actor constant

Page 121: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 121 of 154 Issue 1.0

Figure 2.142 Add the data payload (a double named "Addition Result") to the message class private data. Apply Changes to the cluster.

Page 122: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 122 of 154 Issue 1.0

Figure 2.143 Unbundle the "Addition Result" data and connect to the method

Figure 2.144 Save the Do.vi method

Page 123: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 123 of 154 Issue 1.0

2.11.5 Create the Send Method for the Addition Reply

The Send method is created next. Again, the procedure is explained in more detail in Section 2.9.4, if anything is unclear.

Figure 2.145 Right-click the message class and select New -> VI from Static Dispatch Template

Page 124: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 124 of 154 Issue 1.0

Figure 2.146 The VI front panel initially appears as above

Figure 2.147 Save the method as "Send Addition Result Msg.vi"

Page 125: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 125 of 154 Issue 1.0

Figure 2.148 The block diagram initially appears as above. Delete the case structure and the message object output terminal

Figure 2.149 Add Enqueue.vi from Actor Framework.lvlib, and add the other controls/indicators as shown

Page 126: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 126 of 154 Issue 1.0

Figure 2.150 Change the message object input to a constant, and add the "Addition Result" control

Page 127: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 127 of 154 Issue 1.0

Figure 2.151 Tidy up the front panel, and don't forget to connect the icon terminals!

Page 128: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 128 of 154 Issue 1.0

Figure 2.152 Change the icon

Page 129: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 129 of 154 Issue 1.0

2.11.6 Place the Send Method in the Add Numbers() Method

Figure 2.153 Open up the "request- Add Numbers().vi" method

Next, we need to place the Send method in the right location to send the result message. Open the "Add Numbers.vi" method that we created much earlier in Section 2.9.1. This already has the "Read Caller Enqueuer.vi" ready so that we can send the result back to the Calculator Actor. Add the "Send Addition Result Msg.vi" method that we created in the last section, and wire up as shown below.

Figure 2.154 Wire the Send method for the addition result as shown

Page 130: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 130 of 154 Issue 1.0

2.11.7 Test the Addition Functionality

Figure 2.155 Run the Launcher and test the addition functionality

Before moving on, we can test the addition functionality, as both the request and reply logic is now fully implemented. Run the launcher as before (refer to Section 2.6) and try out some examples to see that the Addition functionality is working. Stop the program using either the Stop button or Panel Close button.

Page 131: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 131 of 154 Issue 1.0

2.11.8 Add a Multiplication Result Reference to Calculator Actor

In the last section we used a LabVIEW user event to obtain the addition result reply. For the multiplication reply, we will use an indicator reference, just to show the different methodology. The steps required to create the complete message class are:

1. Add the indicator reference logic to Calculator Actor core.

2. Create a Calculator Actor method for updating the reference with the multiplication result.

3. Create the message class for sending the reply.

4. Create the Do.vi method for the class, and add the method created in (2) to it.

5. Create the Send method for the message class.

Figure 2.156 to Figure 2.159 covers step 1. Start by opening up the Calculator Actor: Actor Core block diagram, and find the "Result - Multiply" indicator that was added way back in Section 2.8. Right-click on it and select Create -> Reference (Figure 2.156).

Figure 2.156 Right-click on "Result - Multiplication" and select Create -> Reference

Page 132: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 132 of 154 Issue 1.0

Figure 2.157 From the created reference, also create an indicator and disconnect it

Figure 2.158 Drag the indicator reference into the class private data, and delete it from Actor Core. Apply Changes to .ctl

Page 133: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 133 of 154 Issue 1.0

Figure 2.159 Connect the reference to the class private data

2.11.9 Create the Multiplication Result Method

Figure 2.160 to Figure 2.163 show the procedure for creating the Multiplication Result method.

Page 134: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 134 of 154 Issue 1.0

Figure 2.160 Right-click Static Methods -> Messaging and select New -> VI from Static Dispatch Template

Figure 2.161 Add a double "Multiplication Result" control to the method front panel. Wire the terminal.

Page 135: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 135 of 154 Issue 1.0

Figure 2.162 Unbundle "Result - Multiplication Ref", add the property node, and connect the control to it

Figure 2.163 Save the method as "Update Multiplication Result Ref.vi"

Page 136: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 136 of 154 Issue 1.0

2.11.10 Create the Message Class for the Multiplication Reply

Next, create the message class (Figure 2.164 to Figure 2.173).

Figure 2.164 Right-click on the Calculator Actor Messages folder and select New -> Virtual Folder

Page 137: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 137 of 154 Issue 1.0

Figure 2.165 Name the folder "Multiplication Result Msg"

Figure 2.166 Create an identical directory on disk

Page 138: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 138 of 154 Issue 1.0

Figure 2.167 Right-click the new virtual folder and select New -> Class

Figure 2.168 Name the class "Multiplication Result Msg"

Page 139: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 139 of 154 Issue 1.0

Figure 2.169 Right-click the class and select Properties

Page 140: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 140 of 154 Issue 1.0

Figure 2.170 Select Inheritance and click Change Inheritance

Page 141: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 141 of 154 Issue 1.0

Figure 2.171 Select Message.lvclass and click Inherit From Selected

Page 142: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 142 of 154 Issue 1.0

Figure 2.172 The new class inheritance is shown above. Click OK to continue.

Figure 2.173 Save the class to the directory created earlier

Page 143: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 143 of 154 Issue 1.0

2.11.11 Create the Do.vi method for the Multiplication Reply

Next, create the Do.vi method for the message class. Again, this has been explained in detail before, so refer to section 2.9.3 if any of this is unclear.

Figure 2.174 Right-click the class and select New -> VI for Override...

Figure 2.175 Select * Do.vi and click OK

Page 144: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 144 of 154 Issue 1.0

Figure 2.176 Leave the front panel unchanged

Figure 2.177 The initial Do.vi block diagram, before modification

Page 145: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 145 of 154 Issue 1.0

Figure 2.178 Add case structure and 2x "To More specific Class' functions"

Figure 2.179 Drag the multiplication reference method into the Case structure, and wire the constant as shown

Page 146: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 146 of 154 Issue 1.0

Figure 2.180 Open the class private data .ctl file and add the Multiplication Result double. Apply Changes.

Page 147: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 147 of 154 Issue 1.0

Figure 2.181 Unbundle the "Multiplication Result" data and wire to the method

Figure 2.182 Save the Do.vi method (if not already done)

Page 148: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 148 of 154 Issue 1.0

2.11.12 Create the Send Method for the Multiplication Reply

Figure 2.183 Right-click on the message class and select New -> VI from Static Dispatch Template

Figure 2.184 Add the Multiplication Result double, and wire up the terminal

Page 149: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 149 of 154 Issue 1.0

Figure 2.185 The initial block diagram before modification

Figure 2.186 Modify the block diagram (part 1)

Page 150: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 150 of 154 Issue 1.0

Figure 2.187 Modify the block diagram (part 2)

Page 151: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 151 of 154 Issue 1.0

Figure 2.188 Tidy up the block diagram and wire the terminals

Page 152: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 152 of 154 Issue 1.0

Figure 2.189 Change the icon

Figure 2.190 Save as "Send Multiplication Result Msg"

Page 153: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 153 of 154 Issue 1.0

2.11.13 Place the Send Method in the Multiply Numbers Method

Figure 2.191 Place the Send method in the right location

Next, we need to place the Send method in the right location to send the result message back to the Calculator Actor. Open the " Multiply Numbers.vi" method that we created much earlier. This already has the "Read Caller Enqueuer.vi" ready so that we can send the reply back to the Calculator Actor. Add the "Send Multiplication Result Msg.vi" method that we created in the last section, and wire up as shown.

Almost all functionality is in place now and we can test the program; Save all before continuing.

Page 154: DerekMurray - Add-Multiply Actor Project Tutorial (Issue 1.0)

Actor Framework Tutorial (1) Add-Multiply Actor Project

17/05/2015 Page 154 of 154 Issue 1.0

2.12 Test the Complete Program

Figure 2.192 Test the complete program

Now, we can test the complete program. Run the launcher as before (refer to Section 2.6) and verify that the addition and multiplication functionality is working as expected.

This completes the tutorial for this simple, static, tightly-coupled system. While at first glance there appears to be a lot of material in the document, it is hopefully evident that there is a clear, well-defined flow for all the main steps, and they will become second nature with some practice.