Sei sulla pagina 1di 15

Design Techniques

A. Design Pattern Template


B. Single Loop
C. Multiple(Parallel) Loop
D. State Machine
E. Master/Slave Loop
F. Producer/Consumer(Data) Loop
G. Producer/Consumer(Event) Loop
H. User Interface Event Handler

2
A. Design Pattern Template
Access by:
File New

Useful for quick


design prototyping
using specific
design techniques

3
B. Single Loop

Single simple VI

4
C. Multiple(Parallel) Loop

Loops running in parallel


May have race condition

5
D. State Machine

Used for algorithms that can be explicitly represented


with a state diagram

6
E. Master/Slave Loop

Solution to parallel
loop eliminating race
condition
Slave loop executes
when master loop
sends notification
Transfer data using
notifiers

7
E. Master/Slave Loop - Notifiers

Use to suspend the


execution of a block
diagram until data is
received from another
section of the block
diagram or from
another VI
Not a buffer
8
Demonstration
Master/Slave Programming
MasterSlaveDemo.vi

DEMONSTRATION

9
F. Producer/Consumer(Data) Loop
Enhance data sharing for
parallel loop running at
different rates
Producer loop
produce data
Consumer loop
consume data
Data is continuously
queued by producer loop
into the consumer loop
queue
10
F. Producer/Consumer(Data) Loop -
Queues
Used for
communicating data
between sections of a
block diagram or from
another VI

11
Demonstration
Producer/Consumer Programming
ProducerConsumerDemo.vi

DEMONSTRATION

12
G. Producer/Consumer(Event) Loop

Similar to
Producer/Consumer
(Data) loop
Consumer loop
executes as an
event occurrence is
detected in the
producer loop

13
H. User Interface Event Handler
Benefits in design efficiency as
it only responds when an event
occurs
Block diagram components:
1. Event Structure:
Contains program code for each
detected user interface event.
2. While Loop:
Monitor user interface event
continuously.
3. Timeout Terminal:
Controls when the timeout
event executes.
4. Event Data Node

14
Demonstration
Event Programming
EventStructureDemo.vi

DEMONSTRATION

15

Potrebbero piacerti anche