Function Global and Action Engine

Publisher:代码律动Latest update time:2015-08-24 Source: eefocusKeywords:Function  Global  Action  Engine Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The concept of Action Engine is not found in LV books. Some foreign LV experts created this concept. Let's temporarily translate it into "Actuator".

In any programming language, there is the problem of data encapsulation. It can be seen everywhere in object-oriented programming languages. LABVIEW8.X adds the concept of some classes, which makes data encapsulation much easier. This is another topic.

An Action Engine, as I understand it, is a black box operation that can accept external commands and automatically perform corresponding operations. The specific execution process of the command is invisible to the outside world, similar to the concept of attributes and methods in a class.

For example, when driving, as a driver, you only need to use the steering wheel to control the direction, and use the accelerator and gear to control the speed. The driver does not care about how to achieve it, so the specific implementation process is opaque to the driver. This is the meaning of the actuator.

In essence, it is a mechanism based on message sending.

Windows is a typical example of using messages to send commands.

LRESULT SendMessage(
HWND hWnd, // target window handle
UINT Msg, // message to be sent
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

hWnd---is the window handle that receives the message Msg----message (command), wParam and lParam are the data to be passed.

In fact, the so-called Action Engine is also based on this principle.


Let's take a practical application problem to further illustrate. For simplicity, the message only uses the command method and does not transmit any data.

The general data acquisition card has an 8-bit digital output, each bit corresponds to an external output point, control motor, directional valve, etc.

We named them as: bit 0--->Relay 0, 1--->Relay 1 .....7---Relay 7. We need to set each bit to 0 or 1.

The following command groups can be compiled:

Relay0 On

Relay0 Off

...

Port On (All On)

Port Off (All Off)

Keep (can be changed, but not output)

Obviously we need an Enum type of data to describe the above commands. It is strongly recommended to use strict type def in custom controls so that if modifications are required, they can be automatically updated anywhere in the program.



We need to use the Function Global method to save a U8 data to represent this 8-bit output port.


[page]

 The next step is to configure a CASE project for each command.




 


In this way, an AE is formed, which exists as a sub-VI and can be called very conveniently in other parts.


In this way, for the main loop, it only sends the corresponding command to AE, and the specific implementation process has nothing to do with the main loop, effectively encapsulating the data.

 

Keywords:Function  Global  Action  Engine Reference address:Function Global and Action Engine

Previous article:Shift register and loop structure
Next article:Shift Register and Function Global

Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号