没有合适的资源?快使用搜索试试~ 我知道了~
首页LabVIEW Actor 框架 示例文件
资源详情
资源评论
资源推荐
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
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
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
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
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.
剩余153页未读,继续阅读
jlfzhz
- 粉丝: 4
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论3