200 likes | 322 Views
Event Queue – “unstructured” dynamic events. As presented by Jim Kring June 3 rd , 2003. Presentation Outline. Dynamic & User Events Object Model Dynamic Events API User Defined Events API OpenG Event Queue Added features Possibilities. Object Model – Dyn. & User Events.
E N D
Event Queue –“unstructured” dynamic events As presented by Jim Kring June 3rd, 2003
Presentation Outline • Dynamic & User Events Object Model • Dynamic Events API • User Defined Events API • OpenG Event Queue • Added features • Possibilities OpenG Group Meeting
Object Model – Dyn. & User Events • Two new object Refnums in LabVIEW 7 • User Event Refnum (UER) • Event Registration Refnum (ERR) • Currently they are Un(der)documented • What are these objects? • How do they behave? • How do their API calls affect them? • As with many LabVIEW features, the documentation gives us “recommendations” for using them, but not the cold hard facts. OpenG Group Meeting
Event Registration Refnum (ERR) VI Server Object Events and User Events may be “registered” with an Event Registration Object using a Register for Events node. OpenG Group Meeting
Event Registration Refnum (ERR) • Points to an object that contains references to individual event queues – either VI Server Object or User Defined Event Queues. • When we “Register for Events”, we are creating a new (component) queue and telling an event source (object) to enqueue an event into that component queue. • When an Event Structure is passed an ERR it acts like a dequeue operation for all queues associated with the ERR. Dequeues in a round-robin fashion OpenG Group Meeting
ERR – Strict Type Checking • Event Registration Refnums are strictly typed. Changing events will change type. Note - The only way to create an ERR control (or indicator) is to right-click Create Control (or Indicator) Type Definition Custom Controls must be updated by opening .ctl file and replacing entire Refnum control. TypeChanged Added Event OpenG Group Meeting
ERR –Type used by Event Structure • Event Registration Refnum’s type is used to constrain the edit-time choices for configuring cases of the Event Structure. OpenG Group Meeting
1 2 3 4 Register for Events nodes – 2 modes unwired wired Modes: • ERR input unwired (Create ERR & Registers for Events) • ERR input wired(Modify Event Registration) Bottom-Line: • The most upstream RFE node defines the type. • If the ERR input is wired, the RFE node becomes a slave to the input ERR type. OpenG Group Meeting
User Events • A User Event is an event that the developer is allowed to generate. • As with VI Server Object Events, User Events are registered with an Event Registration Object and are dequeued by an Event Structure. OpenG Group Meeting
Shortcomings of Dynamic Events • At edit-time, the developer must define the entire scope of event types that will be handled. • Strictness of ERR requires use of strict type-definitions which will permeate an architecture. Changes to type-def, which may be frequent, will cause changes to VIs containing an instance of the type-def. • Events (especially Filter Events) must be handled inside of an Event Structure. OpenG Group Meeting
Shortcomings of Dynamic Events • The queue abstraction does not expose core properties, features, and behaviors of the registration and queue objects involved • Destroying ERR does not cause a waiting Event Structure (dequeue) to return • No Error I/O on Event Structure (dequeue) • No queue-like API (named queues, queue status, etc.) • No unique Create Event Registration function – functionality is bundled into Register for Events node OpenG Group Meeting
Other Recommendations • Don’t wire an ERR into two Event Structures. The Event Structure does more than just dequeue events, it discards events that are not handled (“cased”) by an event structure. • Always register a user event with an ER so that you can kill an Event Structure programmatically. • Use ERR type definitions • If you get fancy, you might crash LabVIEW OpenG Group Meeting
OpenG “Event Queue” – Goals The Goals of the Event Queue are to: • wrap dynamic events into a queue-like API tailored to the needs of advanced users, • generalize event data using a structure compatible with all event types, • and move event handling (especially Filter Events) out of the event structure, … so that flexible architectures and reuse tools may be built which employ dynamic event type introspection and handling. OpenG Group Meeting
Event Queue API OpenG Group Meeting
Event Data Cluster The Event Data Cluster is a Generic Data structure for storing event data from all classes of events OpenG Group Meeting
Event Agents • When an event is registered, an agent (process) is spawned for dequeuing it’s the event using an Event Structure and enqueuing it into the Event Queue (a real LabVIEW queue) • Notify events only need one agent per class of event, but Filter events need one agent per VI Server Object. This is because Filter events are blocked until filter data is received. OpenG Group Meeting
Notify Event Agent OpenG Group Meeting
Filter Event Agent OpenG Group Meeting
Example – Panel Closing? OpenG Group Meeting
Recap • Dynamic typing in a Queue-like API provides more flexibility than strictly typed ERR and Event Structure • Great for reuse tools and application frameworks • OpenG Event Queue is still in the design phase OpenG Group Meeting