NI LabVIEW Object-Oriented Programming ni.com/labviewzone.
-
Upload
gianni-swanick -
Category
Documents
-
view
238 -
download
3
Transcript of NI LabVIEW Object-Oriented Programming ni.com/labviewzone.
![Page 1: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/1.jpg)
NI LabVIEW Object-Oriented Programming
ni.com/labviewzone
![Page 2: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/2.jpg)
2
Agenda
• Object-oriented programming• Benefits of object-oriented programming • Object-oriented development in LabVIEW
![Page 3: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/3.jpg)
3
Object-Oriented Programming
• An approach to application development• Appropriate for large-scale applications with teams of
developers
![Page 4: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/4.jpg)
4
Benefits of Object-Oriented Development
• Promotes code reuse• Reduces code maintenance• Simplifies extending applications
![Page 5: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/5.jpg)
5
Modular Development in LabVIEW
• VIs and subVIs• Project libraries (LabVIEW 8)• Classes (LabVIEW 8.20)
![Page 6: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/6.jpg)
6
• SubVIs improve code readability and maintainability
• You need subVIs if:– The same code appears twice on the block diagram– Block diagram is larger than one screen– You repeatedly use sequence structures
SubVIs
![Page 7: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/7.jpg)
7
Project Library
•Set of related VIs and other LabVIEW files• Information on library is stored in a text file (.lvlib)
![Page 8: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/8.jpg)
8
Advantages of Project Libraries
• Reduced naming conflicts– Namespace applied to VI
names• Restricted access to
specific VIs– Public VIs – Private VIs
• Consistent icon appearance
Public Private
![Page 9: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/9.jpg)
9
Object-Oriented Programming
• For power programmers and large-scale application development
Parent Class
Child Class
•
Encapsulation
Classes and objects
Inheritance
![Page 10: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/10.jpg)
10
Classes and Objects
• Objects are actors in your application– Refer to individual pieces of data
• A class defines the data and behavior of objects– Objects in your application are instances of a class
![Page 11: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/11.jpg)
11
OO Design – Testing Cell Phones
• Test cell phones and camera phones by the cell phone placing calls and the camera phone placing calls and taking pictures
• Break the application into “nouns” and “action verbs”– Camera phones are types of cell phones that also contain a camera– Cell phones make calls– Camera phones make calls and take pictures– To test a cell phone, a call must be placed and verified– To test a camera phone, the cell phone and camera functionality must be tested– To test a camera, an image must be taken and compared to a reference
• Nouns generally map to classes or objects• Verbs generally map to functions
![Page 12: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/12.jpg)
12
Creating Classes in LabVIEW
• Create a class in the project• Specify the data with the .ctl for the class
– Defining a class in effect defines a new data type• Additional features
– Specify the class icon– Specify a VI icon template– Specify the wire color
![Page 13: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/13.jpg)
13
Classes Demonstration
![Page 14: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/14.jpg)
14
Testing Cell Phones – Classes
• Cell phone• Camera phone• Camera
![Page 15: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/15.jpg)
15
Creating Methods for a Class
• Methods– Actions or requests– Performed by objects– Generally verbs
• Create a VI• Specify scope
– Public– Private– Protected
![Page 16: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/16.jpg)
16
Testing Cell Phones – Methods
• Cell phone– Data
• Phone Type (CDMA, GSM)– Methods
• Initialize• Turn On• Place Call• Verify Call• Test
![Page 17: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/17.jpg)
17
Methods Demonstration
![Page 18: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/18.jpg)
18
Inheritance
• Defines subclasses• Creates “is a” relationship
– Example: Camera phone “is a” cell phone– Reuse common functionality
• Specialization– Extend or override common functionality for specific
needs
![Page 19: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/19.jpg)
19
Testing Cell Phones – Inheritance
• Camera Phone Class– Inherits from cell phone– Data
• Camera– Methods
• Test – Extends “Cell Phone Class” Test method to test camera functionality
![Page 20: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/20.jpg)
20
Inheritance Demonstration
![Page 21: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/21.jpg)
21
Encapsulation
• Treat each object as a black box– Well-defined interface of data and
methods– Must use this interface in the application
• All data is private• Methods can be public, private, or
protected
![Page 22: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/22.jpg)
22
Testing Cell Phones – Encapsulation
• Top-level application only needs to initialize phone and test it– Init and Test methods are public
• Camera phone needs to be able to turn on the phone– Turn On method is protected
![Page 23: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/23.jpg)
23
Encapsulation Demonstration
![Page 24: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/24.jpg)
24
Class Composition
• Defining a class creates a new data type• A class can be made up of other classes
![Page 25: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/25.jpg)
25
Testing Cell Phones – Class Composition
• Camera Phone Class– Inherits from Cell Phone– Data
• Camera Class– Methods
• Test (Cell Phone and Camera)• Camera Class
– Data• Camera Type
– Methods• Take Image• Verify Image• Test Camera
![Page 26: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/26.jpg)
26
Class Composition Demonstration
![Page 27: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/27.jpg)
27
LabVIEW Application Using Classes
• Call methods on objects• Reduce code rework with inheritance and
dynamic dispatching
![Page 28: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/28.jpg)
28
Testing Cell Phones – Calling Test Methods
![Page 29: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/29.jpg)
29
Top-Level Application Demonstration
![Page 30: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/30.jpg)
30
Resources
• LabVIEW Object-Oriented Programming FAQ• A Note on Learning Object-Oriented Programming• LabVIEW Object-Oriented Programming: The Deci
sions Behind the Design• Graphical Object-Oriented Programming (GOOP)• www.ni.com/info - objectoriented
![Page 31: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/31.jpg)
31
Certified LabVIEW Architect Exam
Skills tested:• LabVIEW application development
mastery
Certified LabVIEW Developer Exam
Skills tested:• LabVIEW application development
expertise
Certifications
Certified LV Associate Developer Exam
Skills tested:• LabVIEW environment knowledge
Skills learned:• Modular application development• Structured design and
development practices• Interapplication communication
and connectivity techniques
New User
LabVIEW Basics I
LabVIEW Basics II
Experienced User
LabVIEW Intermediate I
LabVIEW Intermediate II
Advanced User
LabVIEW Advanced I
Skills learned:• LabVIEW environment navigation• Basics of application creation
using LabVIEW• Basics of data acquisition and
instrument control
Skills learned:• Large application design• Advanced development
techniques• Multideveloper project
implementation
Courses
![Page 32: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/32.jpg)
32
Connect with the LabVIEW Community
![Page 33: NI LabVIEW Object-Oriented Programming ni.com/labviewzone.](https://reader037.fdocuments.in/reader037/viewer/2022102520/5518c6e4550346881f8b5883/html5/thumbnails/33.jpg)
Questions?
Thank You