AF (operator frame) series (2) - derived Actor core (command mode) frame in the Actor

In order to improve the reusability of the program, we are ready with the Actor Framework framework, to demonstrate they meet this need (and later in this chapter, you need to have basic knowledge of OOP).

First, a brief look at the process of running ActorFramework:

In QDSM inside each queue by a different instruction, executes the corresponding processing. Message stored in the message queue data, the message is passed through the queue handle.

In ActorFramework in when there is a demand, appropriate methods of running asynchronous process. Actors receiving the message, based on the content of the message transmission task.

Look at the relationship between the data and the implementation of official information explained:

(1) data stored in the object. (2) operation is performed on the defined data. (3) A class defines a set of data, respective method is performed on the data base. (4) the object is a specific instance of the class.

Here we show you the run ActorFramework. In this statement about the name for the function involved ActorFramework framework, in article after this series, as far as possible in order to express the English name. First, the framework of a lot of information is in English, conducive to learning unity. Second, in the official documentation of the NI also expressed through a vocabulary Actor source is the computer industry which, if translated in Chinese, I feel sometimes expressed not in place.

In addition the term actor, is a common primitive in computer science already exist. We look at the Wikipedia definition:

——————————————————————————————————————

From Wikipedia:

The actor model in computer science is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received.

The Actor model adopts the philosophy that everything is an actor. This is similar to the everything is an object philosophy used by some object-oriented programming languages.

"Actor model in computer science is a mathematical model of concurrent computation, it will actors seen as universal primitives of concurrent computation: actor can make local decisions, as its response to the received message, create more actors, send for more information and to determine how to respond to the next message received.
philosophy Actor model is used in everything Actor. similar to the "everything is an object" this object-oriented programming language with a number of applications of philosophy. "

————————————————————————————————————

Here Tucao about, a lot of information, especially in highly specialized technical information, Google still fly. That bear's company, a search for basically all the advertising and SEO optimized websites, turned a page find the information 3,5 normal. It can only be regarded as a profitable company, not a social morality of the company.

The foregoing is part of the learning materials I collect, I feel this series of articles to help some to understand.

First, start parsing the content of the following:

1. Open a Launch Root Actor.vi (root operator).

2. Open, which is called a Launch (launch operator core) Actor Core.vi

3. Open the Launch Actor Core.vi, you can see the program uses the Start Asynchronous Call (start asynchronous call), when the program runs, a static function Actor.vi cited as a reference of the VI.

4. Open Actor.vi static call to view Actor.vi

5. See Actor Core.vi, key Actor Core.vi can see essentially a queuing structure, but he was in accordance with the principles of object-oriented design encapsulates, this model is also known in the language of the text command mode.

Now, let's show you a QDSM computing architecture written addition and subtraction function, and then use OOP rewrite it.

Explain:-------------------------------------

The original author only shows the general structure, and there is no written operating procedures. In order to better show, I wrote a program for example, to facilitate the full function display. This sample program does not represent the level of Tom's programming.

Second, the program comparison

1. First, write a QDSM architecture calculator to do addition, subtraction calculation presentation.

2. Then, we create a class, to replace the state handler queue. UML class diagram is shown below:

The uml file, the new three categories: Counter, Standard, Complex (this can not be built, primarily to demonstrate the function expansion of convenience), writing dynamic allocation of functions Counter, initialise, Add, Substract, Result, Stop. MessageData write custom data type for storing.

4. A process according to one class of a logic queue, the schema into QDSM OOP architecture. Overall application architecture is simple some, among the various functions to achieve a reduction coupled relationship. If you create a function similar function, only need to re-do a class can be realized, as shown circled the place, you can very quickly add new features without changing the overall structure.

5. Run it and see the results and QDSM same. Success!

 

6.将OOP程序和ActorFramework里面的Actor core.vi进行比对,发现两者基本一致,所以,在将QDSM架构用OOP重构时,已经有了ActorFramework的雏形。

综上,通过将架构替换编程,可以看到刚刚开始编写时,面向过程和面向对象所花费的时间基本相同,但是在中大型程序中,面向对象的优势就开始明显了。

——————————————————————————————————

原创码字不易,如有收获,希望关注、点赞和喜欢。

发布了25 篇原创文章 · 获赞 14 · 访问量 7610

Guess you like

Origin blog.csdn.net/qq_26647635/article/details/104546106