Event structure labview пример
LabVIEW — графичексое программирование
Событие (Event Structure)
Структура Событие (Event Structure) имеет одну или более поддиаграмм или вариантов событий, из которых только один выполняется при обращении к структуре.
Структура Событие ожидает наступления события на лицевой панели, после чего выполняет соответствующий вариант с целью обработки события. С помощью контекстного меню структуры можно добавить новые варианты событий или определить вид обрабатываемого события. Подключение значения к терминалу времени ожидания, находящемуся в левом верхнем углу структуры, позволяет задать величину интервала ожидания события структурой в миллисекундах. По умолчанию значение на входе этого терминала равно — 1, что соответствует отсутствию времени ожидания.
Overview
Table of Contents
1. Procedural-Driven and Event-Driven Architectures
Events are caused by actions the user performs. For example, clicking the mouse generates a mouse event, pressing a key on the keyboard generates a keyboard event, and so on. When a system event occurs, the operating system is responsible for identifying and responding to the event. Different operating systems implement this process in various ways. However, all operating systems respond to the system event by broadcasting a system event message. Any application running on the system can react to the system event by executing code written for that specific system event.
In procedural-driven or top-down architectures, the application executes a set of instructions in a specified sequence to perform a task. The structure and sequence of the program, not user actions, control the execution order of a procedural-driven application. The program execution begins in main and then flows through method calls and control statements in a fairly predictable manner.
In an event-driven program, the program first waits for events to occur, responds to those events, then returns to waiting for the next event. How the program responds depends on the code written for that specific event. The order in which an event-driven program executes depends on which events occur and on the order in which those events occur. While the program waits for the next event, it frees up CPU resources that might be used to perform other processing tasks.
2. Using Events in LabVIEW
In LabVIEW, you can use the Event structure to handle events in an application. As with a Case structure, you can add multiple cases to the Event structure. You can then configure those cases to handle one or more events. When those events occur, LabVIEW executes the corresponding case. The following block diagram shows an example Event structure.
You configure events by right-clicking the Event structure border and selecting Edit Events Handled by This Case from the shortcut menu. Use the Edit Events dialog box that appears to edit single or multiple cases.
Using the Event structure minimizes the CPU usage because the VI no longer must continually poll the front panel for changes. In contrast to polling, the Event structure does not lose user events because the structure uses an event queue to store user events and handle the user events in the order in which they occur.
3. Types of Events
A given event can either be static or dynamic and a static event can be either a notify event or a filter event. Static events are only for interactions with the front panel. Static, notify events are the most common and only react to what has occurred on the front panel. An example for a static, notify event would be a “Value Change” for an OK button. Static, filter events catch an event performed by the user before LabVIEW processes that event. The code within the Event Structure can then decide if that event should be processed or not. An example of a filter even would be a “Panel Close?” for the user clicking the close on the front panel. In the Edit Events window, filters have red arrows and notifies have green arrows.
There are times when you want to include events that don’t occur on the front panel. This is when you need to register a dynamic event. Using dynamic events will allow your Event Structure to react to code happening anywhere on your block diagram. An example of all these events is attached to this webpage.
Customer Reviews |
---|
x>y dispalys erroneous results after first event — 30.11.2012 By Rand Olmsted, SoundOff Signal. Given that the x>y LED indicator is inside the User Event structure the event should always fire from the Randnum loop. If it does not then x>y indicates always true after the first time the event fires. Leave Generate User Event in the loop with no condition. Move the case statement to the event structure. Problem solved. Better yet, do away with the popup. The LED switching is sufficient. I received a call while this VI was running and by the time I got done I had to click Ok 20 times. By Mike Maher, NOAA. Agree with the other comments. It would be nice if this articled linked to a tutorial on event structures, which I’ve been looking for now for some time. definately need a good tutorial — 18.04.2008 By sydney faria, Pratt & Whitney Aircraft Corp. Having just started using LabVIEW 8.5 and needing to make a popup window activated from a mouse event such as dbl click, then figuring out which controI in an array of controls the mouse was over in the original window in my ultimate goal after figuring out the event mechanism. Two Thumbs Up! — 17.04.2008 Conveys information to the point. The VI provided is also used in some of NI’s tutorial classes. Detailed examples are needed — 01.02.2006 By Patrick Allen, Patrick Allen. I really want to make use of this structure. But I’m having a difficult time fully understanding it. More info and downloads are needed. Needs MUCH more info — 22.06.2004 This isn’t a tutorial, it’s a brief description of event programming. I wthink it would be much more useful for an actual tutorial. For example, make a simple VI with a controller that will do one event if the input control goes above a certain value, do another event if the input control goes below a certain value, and does another event if the user tries to close the window. This would actually show how to make a VI with different types of events work in parallel. Начало Типы данных
Массивы Diagram Disable Structure На этом обзор структур и типов окончен, далее в следующих статьях мы остановимся на каждой структуре более подробно, опишу некоторые тонкости циклов, и дополнительные элементы для управления их работой. Создание законченного EXE приложение я решил посветить отдельный следующую статью, также в ней я расскажу про проект LabVIEW, библиотеки LabVIEW и создание инсталлятора для нашего приложения. Кроме того я расскажу как настроить LabVIEW «под себя». То есть весь следующий урок будет посвящен среде LabVIEW, а не языку G. |