Event Structure --- Using UserEvent

Publisher:沭阳小黄同志Latest update time:2015-08-26 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In LV6.1, LabVIEW introduced event structure. Event-driven is the basic design concept of popular programming languages ​​such as VB and VC. The introduction of LV+EVENT STRUCTURE is a great improvement for LabVIEW. It may be that the user events and dynamic registration events added in 7.1 are eagerly awaited by engineers who used to program in VC language.

Anyone familiar with VC knows that WM_USER is a message reserved by Microsoft specifically for users, through which various commands and data can be sent to the main window.

Now, LABVIEW also has this capability. I wonder if you have used it.

If a project controls several devices and they work in parallel, how do the parallel control loops exchange data with the main loop? You can do this through global variables, shared variables, control references, and queues.

Today I'll introduce a new method to make full use of USER EVENT.



 

First, use Custom Control to create a strict type def cluster. The example I gave is to simulate a WINDOWS message, but it can actually be of any type. Using variant data may be more appropriate.



 

Here I define 50 kinds of messages


The information that each event needs to pass is:

1. Message number (50 types, which can be understood as 50 commands)

2. String, used to transmit information

3.4 are two data, simulating wParam and lParam of WINDOWS

The next step is to use the Action Engine method to encapsulate all operations in a SUBVI

First, a user event is generated in First call=TRUE, and a reference is returned and stored in SHIFT REGISTER.



 


 

[page]
 

There are three commands defined here: GetRef (get reference) Fire (generate event) Release (release)





 

Such a complete AE is formed, and the specific calling method is as follows:



 

Specific effect demonstration:


 

 

Reference address:Event Structure --- Using UserEvent

Previous article:Event structure--the meaning of basic parameters.
Next article:Property Node Series--Owner and OwningVI

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号