Software Engineering for LabVIEW Applications Elijah Kerry LabVIEW Product Manager 1
Ensuring Software Quality and Reliability Goals 1. Deliver a working product 2. Prove it works right 3. Mitigate risk of failure 4. Avoid last-minute changes Why? 1. More complex software 2. Mission-critical applications 3. Team size is growing 4. Increased scrutiny 5. Decreased time 2
National Instruments is ISO 9001 Certified 5
Software Quality Standards Company wide certification standard ISO 9000 Voluntary certification standard for consistent processes CMMI Process improvement model sponsored by the National Defense Industrial Association Product specific certification for quality DO-178B FAA standard for avionics software FDA 21 CFR Part 820 Medical device standard 6
Software Engineering V-Model Prototyping Requirements Gathering Review and Test Deployment Service Application Architecture Integration Testing Module Architecture Unit Testing Development & Debugging 7
The Software Engineering Process Requirements Gathering Application Architecture Development Debugging & Testing Deployment Software Configuration Management Process is independent of programming language Demonstrate a particular process for certification Automate this process for LabVIEW with toolkits and add-ons SCM is applied throughout process 8
Software Configuration Management? Requirements Gathering Application Architecture Development Debugging & Testing Deployment Software Configuration Management Provides repository of code Helps manage source code and track changes Crucial for team-based development Important throughout development process 9
Tracking Changes to Source Code A change to the code causes a problem that isn t detected for several revisions How can you track changes over time to identify when the behavior changed? What changed? bug detected bug introduced Change corrected Code Revision 10
Group Development Two developers, Joe and Jack, are working together Jack copies (a.k.a. branches ) Joe s code Joe and Jack are making changes to the same application How do they track changes to shared dependencies and expedite the process of merging their work? Joe s Code Merger Code Revision Jack s Code 11
Source Code Application Control Architecture Requirements Gathering Development Debugging & Testing Deployment Software Configuration Management Merger Code Revision Locked for edit Developer 1 Checked Out Checked In Get Latest Version Code Repository Checked Out Checked In Checked Out Checked In Developer 2 12
SCC Integration with LabVIEW Third-party source control integration with: Microsoft Visual SourceSafe Microsoft Team System Perforce Rational ClearCase PCVS (Serena) Version Manager MKS Source Integrity Seapine Surround SCM Borland StarTeam Telelogic Synergy ionforge Evolution subversion** Access SCC tools via LabVIEW Project *New in LabVIEW 8.5 Project specific settings* **subversion is open source and requires plug-in 13
Cross-Linking Defined A VI references a subvi that you didn t intend. Older version Different branch of same code Basic Calculator Project Scientific Calculator Project Calculator.vi Scientific Calculator.vi Memory Display Memory Display 15
System Level View Track Changes Integrate with SCC Software Configuration Management for LabVIEW Merge Graphical Code Manage Files and Links View Revision History 16
The Software Engineering Process Requirements Gathering Application Architecture Development Debugging & Testing Deployment Software Engineering Tools and Best Practices Requirements Gateway Design Patterns Object Orientation Multicore Dataflow MathScript Statechart Simulation Express VI Analyzer Real Time Execution Trace Desktop Execution Trace Unit Test Framework Application Builder Real Time FPGA Embedded 17
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Challenges Agreeing upon what the application will do Defining acceptable and safe behaviors Defining tests for individual components Traceability from code to documents 18
Software Design Phase Prototype Specifications System Requirements Unit Specifications Test Definitions 19
Requirements Gathering Application Architecture Development Debugging & Testing Deployment 20
Requirements Traceability Solution from NI 21
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Goals Determine how code will be divided based upon functionality Develop standard interfaces and APIs for code modules Ensure code scales and is readable and maintainable 23
Without Architecture, There is Chaos 24
LabVIEW Design Patterns Important architecture concept Common, easily recognized frameworks Improves code readability Avoid reinventing the wheel Take advantage of over 20 years of work Abstracts common problems 25
Producer / Consumer Design Pattern 26
Architecting for Multiple Processors Not all code requires sequential execution Isolate independent chunks of code and mark them as tasks Task A Task B Task C
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Tools: Design Patterns Object-Oriented Design LabVIEW Statechart Module Multicore 28
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Goals Implement the application based upon specifications Abide by style guidelines Document, Document, Document 29
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Develop Using Multiple Models of Computation 30
Documentation Labeled objects In-line comments Distinct Icon Description and Tip HTML Print-Out Requirements Coverage 31
Documenting Coverage Specifications LabVIEW Unit Tests 32
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Practices Iterative testing during development Manual peer code review Static and dynamic code analysis Validation against requirements 33
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Development Environment Tools Constantly compilation Highlight execution Breakpoint manager Automatic Error Handling Diagram cleanup National Instruments Style Guideline VI Profiler Coercion (Memory) Dots Conditional disable structures 34
Simple Application Complexity Advanced Tools for Debugging and Testing Debugging & Testing Unit Test Framework Functional Validation of Code Desktop Execution Trace Real Time Execution Trace Dynamic Code Analysis VI Analyzer Toolkit Static Code Analysis Low Risk High Risk Application Criticality 35
Simple Application Complexity Advanced Tools for Debugging and Testing Debugging & Testing Unit Test Framework Functional Validation of Code Desktop Execution Trace Real Time Execution Trace Dynamic Code Analysis VI Analyzer Toolkit Static Code Analysis Low Risk High Risk Application Criticality 36
Performing a LabVIEW Code Review Walk someone through your code Ask the following questions: Is the code easy to maintain? What happens if the code returns an error? Is too much functionality located in a single VI? Are there any race conditions? Is the memory usage within acceptable limits? 37
Preparing for a Code Review with VI Analyzer Automate code analysis with 60+ configurable tests Performance Style Interactively inspect failures Generate custom reports 38
Simple Application Complexity Advanced Tools for Debugging and Testing Debugging & Testing Unit Test Framework Functional Validation of Code Desktop Execution Trace Real Time Execution Trace Dynamic Code Analysis VI Analyzer Toolkit Static Code Analysis Low Risk High Risk Application Criticality 40
Goals of Dynamic Code Analysis: What is consuming system memory? Am I capturing all the errors in my application? What was the last event to occur before? What was the call-chain that led us to? What thread is it executing in? Am I actually entering a specific event-case? What happened inside a structure? What order to these events occur in? Is a daemon process running in the background? Does the code behave different in an executable? 41
Trace Production Systems Remotely LabVIEW Desktop Execution Trace Toolkit Network Run-Time Execution Information VIs and Debuggable Executables LabVIEW Real-Time Execution Trace Toolkit Network Run-Time Execution Information Deployed Real-Time Applications 42
Desktop Execution Trace Toolkit Trace During Run-Time: Event Structures Memory Allocation Queues / Notifiers Reference Leaks Thread ID Unhandled Errors Dynamic / Static SubVIs Custom User Strings 43
Desktop Execution Trace Toolkit Trace During Run-Time: Event Structures Memory Allocation Queues / Notifiers Reference Leaks Thread ID Unhandled Errors Dynamic / Static SubVIs Custom User Strings 44
Simple Application Complexity Advanced Tools for Debugging and Testing Debugging & Testing Unit Test Framework Functional Validation of Code Desktop Execution Trace Real Time Execution Trace Dynamic Code Analysis VI Analyzer Toolkit Static Code Analysis Low Risk High Risk Application Criticality 46
Unit Testing Black Box Testing INPUTS: -Infinity 0 : 10 +Infinity Code Component EXPECTED RESULTS: 0 0 : 2000 +Infinity ACTUAL RESULTS: -1 0 : 1999 +Infinity Pros: The tester does not need to know how it has been implemented Tester can still verify that the actual results = expected results Asses the behavior of the code component Cons: The tester does not know if all statements have been exercised inside of the Code Component
Integration Testing White Box Testing INPUTS: True False A Input? B EXPECTED RESULTS: False True EXPECTED Statement Coverage: Path A Path B = Pros: Designed to test paths inside of the code component Useful for integration testing to test the structure of the code Cons: Not as useful for determining if requirements are met Test Designer must be knowledgeable of the source code ACTUAL RESULTS: False False ACTUAL Statement Coverage: Path A Path B
LabVIEW Unit Test Framework Input Values Output VI Under Test Unit Test Framework Expected Output Automated Report Generation Test vector = Input value(s) + Expected output(s) 49
LabVIEW Unit Test Framework Input Values Output Unit Test Framework VI Under Test Windows Desktop Expected Output Automated Report Generation Test vector = Input value(s) + Expected output(s) 50
LabVIEW Unit Test Framework Input Values Output Unit Test Framework VI Under Test Real Time Expected Output Automated Report Generation Test vector = Input value(s) + Expected output(s) 51
LabVIEW Unit Test Framework Setup VI Teardown VI Under Test Actual Output Unit Test Framework Expected Output Automated Report Generation 53
Code Coverage Example 2 Edges and 1 Path. 6 Possible Routes. 50% Code Coverage 54
Code Coverage Example 1 ST Test Vector: 2 Edges and 1 Path. 6 Possible Routes. ( 2 + 1 ) / 6 = 50% Code Coverage 2 nd Test Vector (aggregates covered code from 1 st pass) 4 Edges and 1 Path. 6 Possible Routes. ( 4 + 1 ) / 6 = 83.33% Code Coverage 55
Code Coverage Example 1 ST Test Vector: 2 Edges and 1 Path. 6 Possible Routes. ( 2 + 1 ) / 6 = 50% Code Coverage 2 nd Test Vector (aggregates covered code from 1 st pass) 4 Edges and 1 Path. 6 Possible Routes. ( 4 + 1 ) / 6 = 83.33% Code Coverage Uncovered Case 56
Programmatic Unit Testing Programmatically invoke testing and report generation 58
System Level Requirements Hardware Requirements Software Requirements Test Requirements Test Module Requirements Test Requirements Test Unit Requirements Test Requirements Test Results Implementation Implementation Implementation
Integration with Requirements Gateway Implementation Software Requirements Unit Tests Test Results 60
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Goals Determine repeatable process Deploy to determine behavior on other targets Deliver a product to customer or end-user Make every installer and driver required for operation easily portable Remove information about sensitive code 61
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Deploy Software to Embedded Hardware Targets Build Professional Applications for the Desktop 62
Requirements Gathering Application Architecture Development Debugging & Testing Deployment Programmatic build processes Programmatic control of source code control 64
The Software Engineering Process Requirements Gathering Application Architecture Development Debugging & Testing Deployment Software Engineering Tools and Best Practices Requirements Gateway Design Patterns Object Orientation Multicore Dataflow MathScript Statechart Simulation Express VI Analyzer Real Time Execution Trace Desktop Execution Trace Unit Test Framework Application Builder Real Time FPGA Embedded 65
Software Engineering Tools for Large LabVIEW Applications Requirements Gathering Application Architecture Development Validation Deployment Requirements Gateway LabVIEW Statechart Desktop Execution Trace Unit Test Framework Application Builder Object Orientation Software Validation Developer Suite Option LabVIEW VI Analyzer Real Time FPGA Prove it works. Improve quality. Reduce risk. Save time. Embedded ni.com/softwareengineering 66
Software Engineering Best-Practices ni.com/largeapps
Large Application Community ni.com/community/largeapps
LabVIEW Learning Paths Advanced LabVIEW Advanced I: Large Application Development LabVIEW Object-Oriented Programming System Design Intermediate LabVIEW Intermediate I and II Specialty LabVIEW Real-Time Application Development CompactRIO Fundamentals and LabVIEW FPGA LabVIEW Instrument Control RF Fundamentals and RF Application Development LabVIEW Machine Vision and Image Processing LabVIEW DAQ and Signal Conditioning Foundation LabVIEW Basics I and II
Ways To Learn LabVIEW In A Classroom Near You Held at a local hotel or training facility Personal Interaction with Instructor and other Attendees On-line At Your Desk Live and Instructor-led No travel and reduced time away from work At Your Company Office Tailored course material for your company s needs No travel required At Your Convenience Self-paced course kits On-demand training modules located in the Services Resource Center
Training & Certification Membership Program Unlimited access to all regional and on-line courses for one year Unlimited access to all certification exams for one year Option to retake all courses and exams ONE PRICE