380 likes | 580 Views
OpenGOOP - a component framework. As presented by Jim Kring June 3 rd , 2003. Presentation Outline. LabVIEW Components What is GOOP? How is OpenGOOP different? Advanced GOOP design patterns and building the patterns into the framework. LabVIEW Components.
E N D
OpenGOOP - a component framework As presented by Jim Kring June 3rd, 2003
Presentation Outline • LabVIEW Components • What is GOOP? • How is OpenGOOP different? • Advanced GOOP design patterns and building the patterns into the framework OpenG Group Meeting
LabVIEW Components • A set of VIs that allow you to instantiate and interface with an “object”. • Abstracts the implementation and the hides its data • Operate by reference (Refnum) OpenG Group Meeting
LabVIEW Component Examples • Queues • File I/O • Config File I/O OpenG Group Meeting
Why Components? Encapsulation • Benefits of Encapsulation • Maintainable • Scalable • Useable (and therefore Reusable) • Testable • Enable Multiple Developer Collaboration OpenG Group Meeting
What is GOOP? • GOOP Toolkit from NI (Endevo) • JörgenJehander & Stepan Riha • An Object and Data Manager (CIN) • A Class Template and Wizard • Object Inspector OpenG Group Meeting
The GOOP Core • <Class> New.vi • Creates an object • <Class> Delete.vi • Destroys the object • <Class> Get Data.vi • Reads object state information (read-only) • <Class> Get Data to Modify.vi • Locks and then Reads object state information • <Class> Set Modified Data.vi • Writes object state information and releases lock OpenG Group Meeting
Locking – Synchronous Write Access • Two parallel processes want to write data to the object. • Allowed Sequences 1) A B C D 2) C D A B • Else, Race Cond’n • B • A • C • D OpenG Group Meeting
The Class Template • <Class>Create.vi • Allocates space for, and allows initialization of, object data • <Class>Read Data.vi • Reads the object data • <Class>Modify Data.vi (Write Data) • Allows you to modify object data • <Class>Destroy.vi • Deallocates the object data OpenG Group Meeting
Object Data Store • NI GOOP • ?? Password Protected • OpenGOOP • Reentrant LV-2 Global Called By Reference • Object Refnum is a VI Reference OpenG Group Meeting
Reentrant LV-2 Global Called-by-Ref Call-by-Reference Wrapper Reentrant LV-2 Global Reentrancy of the data-store allows multiple concurrent object instances to be created. OpenG Group Meeting
Benefits of RLV2GCBR data store • Multiple object instances • LabVIEW (VI Server) handles the memory management, housekeeping, and garbage collection, etc. • When the top-level VI goes idle, the object is destroyed (as with all VI server object references). OpenG Group Meeting
Locking the Data Store Acquire Semaphore Release Semaphore OpenG Group Meeting
Generating the Semaphore • Named Semaphore “<ObjName> - 0xFFFFFFFF” OpenG Group Meeting
2 3 1 OpenGOOP Wizard • Instantiates a Class Template, adding a name prefix to the new class. OpenG Group Meeting
New Class Main VI Tree Core VI Tree OpenG Group Meeting
Advanced GOOP Design Patterns • Object State Persistence and Initialization • Saving and restoring object data to and from file • Encapsulation of Processes • Make the class responsible for starting and stopping its processes • Encapsulation of User Interfaces • Build User Interfaces into Class • Component Abstraction • Define a class’s “abstract” interface at edit-time, but choose the “concrete” implementation at run-time OpenG Group Meeting
Object State Persistence - Write • Write object data cluster to ini file using OpenG variant configuration file I/O OpenG Group Meeting
Object State Persistence - Read • Read object data cluster from ini file using OpenG variant configuration file I/O OpenG Group Meeting
Encapsulation of Processes • Users of components should NOT have to interact with process VIs • Processes should run asynchronously • Spawning should be done behind the scenes during object instantiation • Processes should be killed automatically when object is destroyed OpenG Group Meeting
1 2 6 3 4 5 The Old Way – User Interaction Req’d Temp Controller Obj • Create New Obj • Start Process(Blocked until 5) • Set Temp • Monitor Process • Stop Process • Destroy Obj loop OpenG Group Meeting
A Better Way – Hide the Process • “Spawn” within constructor • “Kill” within destructor • Non-blocking “enable” & “disable” controller methods are still an option OpenG Group Meeting
Spawning Processes • Process VIs are reentrant (multi-instance) • 1st Pass process the object reference • 2nd Run the process OpenG Group Meeting
Killing Processes (1) Send Kill Signal (2) Wait on not running (3) Force Kill (abort) OpenG Group Meeting
User Interface Encapsulation • Many user interfaces, especially component configuration panels, are not application specific. • LV7 subpanels open up new options for class UIs. • LV7 Express nodes are a good example of how UIs can be part of a component. • Other examples – XY Stage Control Pad, User manager, etc. OpenG Group Meeting
FYI - Express Nodes User Interfaces double-click OpenG Group Meeting
Component User Interfaces How can we build user interfaces into classes? • User Interfaces can be just like processes except that their Front Panels are designed for user interaction • UI framework should support calling UIs synchronously (blocking) or asynchronously (non-blocking) • Framework should support multi-instance User Interfaces (cloning) • Object Destructor should kill open UIs OpenG Group Meeting
Launching Component UIs • We can encapsulate the management of user interfaces within the class • Open UI, Close UI, UI Position, etc. • We can modify the template to accept UI names as Enums OpenG Group Meeting
Example - MyComponent OpenG Group Meeting
Component Abstraction • An “Abstract Class” defines an interface, but not an implementation. • A “Concrete Class” has both an interface and an implementation. • The Interchangeable Virtual Instruments (IVI) framework is a perfect example… so is VISA OpenG Group Meeting
Abstraction using proxy VIs (CBR) • An abstract class is merely a set of Call-by-Reference proxy VIs. • At run-time, a concrete class is loaded, by the abstract class, to fulfill its implementation. • Loading requires checking for correct interface. OpenG Group Meeting
Example Abstract and Concrete VIs Abstract VI obtains a reference to the concrete VI and calls it dynamically OpenG Group Meeting
Loading a concrete class • Many methods may be used • Abstract class must know which concrete class (or instance) to load • Concrete class (or instance) should tell Abstract class what its interface looks like. • Abstract class can then choose to continue loading concrete class OpenG Group Meeting
EXAMPLE – Conc & Abs Class OpenG Group Meeting
Recap • LabVIEW Components are a good way of approaching application and reuse code development • GOOP is a good way to implement components • OpenGOOP is OpenG’s GOOP implementation • OpenG developers are working to push the limits of component based design by identifying component design patterns and building them into the OpenGOOP framework. OpenG Group Meeting
Other GOOP References • App Note 143 - Graphical Object Oriented Programming (Jorgen Jehander) http://zone.ni.com/devzone/conceptd.nsf/appnotebynumber/1A7B60096CE0CDA986256A9A0074E4EC?OpenDocument&node=dz52000_us • Graphical Object-Oriented Programming with LabVIEW - NI Week 1999 Presentation by Jörgen Jehander and Stepan Riha http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&958B0EEC7BE032B986256863000A6B64 • Object-Oriented Techniques in LabVIEW - Pure G examples from LV 4.1 http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3EB6B56A4E034080020E74861&p_node=DZ52067&p_source=external OpenG Group Meeting