What Is NI TestStand?

peanutunderwearΛογισμικό & κατασκευή λογ/κού

7 Νοε 2013 (πριν από 3 χρόνια και 10 μήνες)

177 εμφανίσεις

What Is NI TestStand?

Overview

NI TestStand is ready
-
to
-
run

test management software

designed to help you develop automated test and validation
systems faster. You can use NI TestStand

to develop, execute, and deploy test system software. In addition, you can
develop test sequences that integrate code modules written in any test programming language. Sequences also specify
execution flow, reporting, database logging, and connectivity to

other enterprise systems. Finally, you can deploy test
systems to production with easy
-
to
-
use operator interfaces.

Table of Contents

1.





Developing Test Systems with NI TestStand

2.





Deploying Test Systems with NI TestStand

3.





Where Would I Use NI TestStand?

4.





Conclusion

Developing Test Systems with NI TestStand

NI TestStand includes the Sequence Editor development environment for automated test system development, as seen
in Figure 1.


Figure

1.

The NI TestStand Sequence Editor helps you develop automated test systems faster.

With the Sequence Editor, you can create test sequences, which automate the execution of code modules written in
any programming language. Each code module executes a tes
t on the device under test and returns measurement
information to NI TestStand. You can log test result information in a report or database automatically. In addition,
systems written in NI TestStand can integrate with source code control, requirements man
agement, and data
management systems.

Watch this four
-
minute demo to discover how you can develop automated test systems with NI TestStand.


Deploying Test Systems with NI TestStand

After development is complete, you can use NI TestStand to deploy automated test systems to production. NI
TestStand helps deployment by providing simple operator interfaces that can execute the test system and reduce
operator error. You can create operato
r interfaces, like the one seen in Figure 2, in a number of different programming
languages to meet a variety of application requirements.


[+] Enlarge Image

Figure 2.

You can create simple operator interfaces to execute test systems.

NI TestStand also of
fers a
deployment utility
, which helps you create a distribution of code modules, test sequences,
and related files. You can copy this distribution to a central code repository or directly to a production machine, or you
can include it in an installer.

Where Would I Use NI TestStand?

NI TestStand automates a sequence of steps. These steps can be individual tests, measurements, actions, or
commands. Any application needing automation of executable pieces of code can benefit from the use of NI TestStand
.
NI TestStand was designed to address four key areas: (1) simplify complex sequence development; (2) accelerate
complex sequence development; (3) increase code and test system reusability and maintenance; and (4) improve test
system execution performance.

This has led to its adoption in consumer electronics for validation and manufacturing
test, military and aerospace applications, and the medical industry, as well as IC characterization and

simple code
sequencing.


[+] Enlarge Image

Figure 3.

This diagra
m shows where NI TestStand fits into the development and manufacturing cycle.

Read more in the “Where Would I Use NI TestStand?” white paper.


NI TestStand in the Electronics Industry

The electronics industry has to meet high test
-
throughput challenges. Device production can increase quickly, requiring
test systems to scale and test more units in less time. Using NI TestStand, engineers in the electronics industry can
develop test syste
ms quickly to reduce time to market. NI TestStand parallel test features also help engineers develop
scalable test systems that can increase, as necessary, the number of devices tested in parallel.

Learn more about how Flextronics saved millions of dollars and met its test
-
throughput challenges using NI TestStand.


NI TestStand in the Aerospace and Defense Industry

Engineers in the aerospace industry face
the challenge of testing some of the most complex and innovative devices
today
. With NI TestStand, engineers can rely on a commercial off
-
the
-
shelf tool that is compatible with industry
standards such as

ATML
, IVI, PXI, ATLAS, and others.

In addition, the modular architecture of NI TestStand helps
reduce obsolescence by supporting the execution of both legacy and next
-
generation programming languages in the
same test system.

See how Lockheed Martin used NI TestStand to standardize the test architecture for the Joint Strike Fighter.


Conclusion

NI TestStand offers a flexible and powerful framework for developing, managing,

and executing test systems. The
components of NI TestStand work together and seamlessly integrate the features of enterprise systems and software.

As test management software, NI TestStand delivers easy integration of independent test modules into a testi
ng
framework. With this easy integration, you can focus on developing tests instead of the test framework needed to build
the test system.

NI TestStand is an integral part of any test where accelerated development, code reusability, improved performance,
a
nd automation are desired. It offers a ready
-
to
-
run yet fully customizable environment for developing and managing
test systems.



What's New in NI TestStand 4.2


Questions?

Get real
-
time
assistance now!

Upgrade to NI TestStand 4.2 Now

Reduce test system development time with NI TestStand 4.2 by reusing your existing software investment in NI
LabVIEW, NI LabWindows
™/CVI, scripting languages, and .NET with a commercial test executive. With faster
deployment of LabVIEW code, better integration with scripting languages such as Perl and Python, and Visual Studio
2008 support, you can now integrate different software mor
e easily into NI TestStand.

Improved Integration with LabVIEW, .NET, and Scripting Languages

Simplified Integration with Scripting Languages

The redesigned Call Executable step type provides a more powerful interface for calling common scripting languages
such as Python, Perl, and Tcl.

Read the in
-
depth white paper

Accelerated Deploym
ent of LabVIEW Files in NI TestStand

The NI TestStand 4.2 deployment utility uses improved internal caching to accelerate the analysis and build time of
deployments.

Validation of LabVIEW Code Modules

The new software engineering tools for LabVIEW can help

you ensure the quality and reliability of your LabVIEW code.

Support for Visual Studio 2008

NI TestStand 4.2 supports direct integration with Visual Studio 2008 and the ability to target the .NET 3.5 framework.

Memory Leak Detection with LabWindows/CVI

Th
e new Resource Tracking Window in LabWindows/CVI 9.0 can help you identify places where memory was allocated
but not released.

View webcast on the new NI TestStand 4.2 features

Improved Report Perf
ormance and Customization

Report Path Customization Using Expressions

NI TestStand 4.2 gives you the ability to use expressions to customize the path where reports are stored.

Faster XML Style Sheet Performance and Enhanced Documentation

XML report style
sheets have been completely restructured to enhance report generation efficiency and customization.

Processor Affinity Control for Improving Multicore Performance

With new functionality for controlling processor and core affinity, you have tools to optimiz
e symmetric multiprocessing
system performance.

Support for PropertyObject Attributes

The new PropertyObject attributes, available for any PropertyObject, let you store additional information about
PropertyObjects.














Automated Test Equipment: Instrumentation, Software, Services,
and Integrators


National Instruments offers a complete software and hardware platform, allowing you to build a software
-
defined test
system that meets your exact test requirements. With this
platform, you gain the assurance of ongoing technology
support and the flexibility to customize your instrumentation as your needs change. NI offers service programs for
individual engineers, global organizations, integrators, and OEMs. These services are
designed to meet your needs
throughout the application life cycle


from planning and development through deployment and ongoing maintenance.

NI supplies this framework through its modular, automated test platform shown below. Select individual components
to
learn more about these instruments. Or, view

example reference test systems

that employ software
-
defined
architecture.






http://zone.ni.com/devzone/cda/tut/p/id/8847

Calling Scripting Languages from NI TestStand

3 ratings |

5.00

out of 5

Read in









[]

|


Print

Overview

The ability to re
-
use existing code while migrating to a new test software framework can save developers both time and
money.

Both NI TestStand test management software and NI LabVIEW give users the ability to directly call and
integrate with code written

in a variety of languages such as Perl, Python and Tcl.

NI TestStand, starting with version 4.2, has the ability to call your scripts written in languages such as Perl, Python and
Tcl using the Call Executable step type.


In particular, NI TestStand can p
ass data in and out of scripts as well as
access the script’s error information.











Passing Data to Scripts:

Developers can pass data from TestStand to their scripts either through
command line arguments or directly through
the Standard Input stream
.

Using the Standard Input stream allows developers to reuse scripts that traditionally took
user input from the keyboard during run
-
time, and run it in an automated fashion from TestStand.











Accessing Output in TestStand:

Once the execution of the

script is complete, anything that the script wrote to the Standard Output can be accessed
from the TestStand sequence. This will enable developers to base the status of a step on the result of a script.











Accessing Script Errors in TestStand:

If a
n error occurred during execution of the script, the error information is also available to TestStand through the
Standard Error stream
. This enables developers to handle the error appropriately.

What this means is that developers can effectively utilize t
he full power of their scripts by taking advantage of the hooks
that TestStand provides to the executable’s Standard Input (stdin), Standard Output (stdout) and Standard Error
(stderr).

This article is Part 2 of a three
-
part series on calling scripting lan
guages from TestStand with a focus on the needs of
engineers and scientists.






Table of Contents

1.





Calling a Simple Script from TestStand


2.





Accessing Script Outputs from TestStand: Standard Output

3.





Passing Data to Scripts from TestStand: Command Line

4.





Passing Data to Scripts from TestStand: Standard Input

5.





Evaluating Script Results: Pass/Fail Test
using Status Expression

6.





Evaluating Script Results: Numeric Limit Test using <None> Adaptor

7.





Handling
Script Errors in TestStand

8.





Next Steps

Calling a Simple Script from TestStand


Getting Started

If you are new to scripting or don’t have an interpreter installed, we recommend
reading Part 1 of this series:

Developer Zone Tutorial: Introduction to Scripting

Also,

if you are looking to call scripts from LabVIEW, instead of NI TestStand, you can use the System Exec VI.

For a
tutorial, refer to:

Developer Zone Tutorial: Call Perl and Python Scripts from LabVIEW

In order to
call a script from TestStand

you will have to have the following:











A script to c
all (we will use examples in Perl, Python and Tcl)











An interpreter for the scripting language you choose











The NI TestStand Sequence Editor (or an Operator Interface that allows you to modify sequences)

If you are currently part of the Nat
ional Instruments

Standard Service

Program
, you can also access the interactive
training module on calling scripts from TestStand here:

On Demand Training:

TestStand Modules

The Script: HelloWorld

The script used in this example is a simple HelloWorld script that will simply write “Hello World!” to the Standard Output
stream.

Note:

You can download any of the script files by clicking on their filename above the code snippets.

Perl
:

HelloWorld.pl

#!/usr/bin/perl
-
w

use strict;


print "Hello World!
\
n";



Python
:

HelloWorld.py

#!/usr/bin/env python


print "Hello World!"



Tcl
:

HelloWorld.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-


# The next line is executed by /bin/sh, but not tcl
\

exec tclsh "$0" ${1+"$@"}


puts "Hello World!";



Calling the HelloWorld Script from TestStand

The process of calling a script from TestStand

is very similar to calling it from the Windows command line. In fact, all you
have to do is

use the
Call Executable

step and specify the path and file for the script you want to execute
. (The reason
this works is because we associated the script file exte
nsion with the appropriate interpreter
. If you haven’t associated
the script file with a particular interpreter, you will have to specify the interpreter as the executable and pass in the scr
ipt
file as a command line argument).

1.





Open the NI TestStan
d

Sequence Editor

and a new sequence file.

2.





Add a

Call Executable

step and rename it “Call HelloWorld Script”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Specify the name of the script you want to call in the

File
PathName

Perl: HelloWorld.pl

Python: HelloWorld.py

Tcl: HelloWorld.tcl


[+] Enlarge Image

5.





Save the sequence file as

CallingHelloWorld.seq

in the same folder as the script.

6.





Run your sequence file. Your report should say that the test passed and that the Call Executable script had an
ExitCode of 0, which indicates success.

Note:

If you haven’t associated the script file’s extension with the appropriate interpreter, you wi
ll have to call the
interpreter directly from the Call Executable step and pass in the script as a command line argument. See the following
screenshot for an example:


[+] Enlarge Image



Accessing Script Outputs from TestStand: Standard Output

Most
programming languages define a standard output stream that programs can write their output to. While this
standard output stream (stdout) defaults to the terminal (monitor), NI

TestStand gives you the ability to access the
standard output stream from the C
all Executable Step type.

In the following example, you will learn how to use the previous Hello World example and modify it so that you can
write
the output of the script to your TestStand report.

Accessing the Standard Output Stream from TestStand

We wil
l use the same HelloWorld script and continue from the same sequence CallingHelloWorld sequence that you
created in the previous section,

Calling a Simple S
cript from TestStand
.

1.





Open the sequence file

CallingHelloWorld.seq
.

2.





Highlight the “Call HelloWorld Script” step.

3.





On the

Step Setting

pane, switch to the

Standard
Output/Error

tab.

4.





On the

Output Destination

combo box, pick

Store in Variable/Property
.

Leave the default value, i.e.,

Step.StdOutput.Text
.


[+] Enlarge Image

5.





On the

Step Settings

pane, switch to the

Properties

tab and select the

Additional
Results
category.

6.





Click the

Add Result from List

button and select

Standard Output
. This will include the stdout stream in the
report.


[+] Enlarge Image

7.





Save the sequence file as

CallingHelloWorldWithStdOut.seq

in the same folder as the script.

8.





Run your sequence file. Your report should look like the following screenshot:


[+] Enlarge Image

Passing Data to Scripts from TestStand: Command Line

Most programming languages allow you to
pass data to them when you launch them through command line arguments


extra parameters that you type in after the name of the script on the command line. TestStand’s

Call Executable step
allows you to pass parameters to your scripts in this method.

The Script: AddNumbersCommandLine

This is a fairly basic script that will accept a series of numbers as command line arguments and writes their sum to the
standard output s
tream.

Perl
:

AddNumbersCommandLine.pl

#!/usr/bin/perl

w

use strict;


#Command Line Arguements are stored in list @ARGV

my $numArgs = $#ARGV + 1;

my $sum = 0;


#Iterate
through each element and add to the sum

foreach my $currentNumber (@ARGV)

{





$sum += $currentNumber;

}


print "Sum: ", $sum, "
\
n";



Python
:

AddNumbersCommandLine.py

#!/us
r/bin/env python

import sys


#Command Line Arguements are stored in list argv

numArgs = len(sys.argv)
-

1


sum = 0


#Iterate through each element and add to the sum

for n in range (1, len(sys.argv)):





sum = sum + int(sys.argv[n])


print "Sum:", sum, "
\
n
"



Tcl
:

AddNumbersCommandLine.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-

# The next line is executed by /bin/sh, but not tcl
\

exec tclsh "$0" ${1+"$@"}


#Command Line Arguements

are stored in list argv

set numArgs $argc

set sum 0


#Iterate through each element and add to the sum

foreach currentNumber $argv {





set sum [expr $sum + $currentNumber]

}


puts "Sum: $sum
\
n"



Passing Command Line Arguments from TestStand

All you need to do in order to pass Command Line Arguments from TestStand to a script is to include the parameters
you want to pass in the

Argument Expression

field of the Call Executable step.

1.





Create a new sequence file.

2.





Add a

Call
Executable

step and name it “Call AddNumbersCommandLine Script”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Point the

File Pathname

field to the appropriate AddNumbersCommandLine script.

5.





For the

Argument Expression

fie
ld, enter in a series of numbers enclosed in double
-
quotes. For example:

“2 5 8”


[+] Enlarge Image

6.





Switch to the

Standard Output

tab and store the output in the

Variable/Property
Step.StdOutput.Text.

7.





On the

Step Settings

pane, switch to the

Properties

tab and select the

Additional Results
category.

8.





Click the

Add Result from List

button and select

Arguments
. This will include the command line arguments
in the report.

9.





Click the

Add Result from List

button and select

Standard Output
. This will include the stdout stream in the
report.

10.



Save the sequence file as

PassingDataToScriptsCommandLine.seq

in the same folder as the script.

11.



Run your sequen
ce file. Your report should look like the following screenshot:


[+] Enlarge Image

Passing Data to Scripts from TestStand: Standard Input

Most programming languages also define a

standard user input stream that programs can read from during execution
.
While this standard input stream (stdin) defaults to the keyboard, NI TestStand gives you the ability to access the
standard input stream from your sequence. This gives developers more flexibility as your scripts can read these values
during run
-
time rathe
r than right when they begin execution.

The Script: AddNumbersStdIn

Perl
:

AddNumbersStdIn.pl

#!/usr/bin/perl
-
w

use strict;


print "Enter numbers (separate with commas): ";


#Get
input as a string

my $numbersAsString = <STDIN>;

#Parse the numbers into a list

my @numbers = split(/, | |,/,$numbersAsString);


my $sum = 0;


#Iterate through the list and add to the sum

foreach my $currentNumber (@numbers)

{





$sum += $currentNumber;

}


print "Sum: ", $sum, "
\
n";



Python
:

AddNumbersStdIn.py

#!/usr/bin/env python


#Get input as a list

numbers = raw_input('Enter numbers (separate with commas): ')


sum = 0


#Iterate through the list and add to the sum

for currentNumber in numbers:





sum = sum + currentNumber


print "Sum:", sum, "
\
n"



Tcl
:

AddNumbersStdIn.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-

# The next line is executed by /bin/sh, but not tcl
\

exec tclsh "$0" ${1+"$@"}


puts "Enter numbers (separate with commas): "

#Get input as a string

gets stdin numbersAsString

#Parse the numbers into a list

set numbers [split $numbersAsString ,]


set sum

0


#Iterate through the list and add to the sum

foreach currentNumber $numbers {





set sum [expr $sum + $currentNumber]

}


puts "Sum: $sum
\
n"



Passing Data through the Standard Input from TestStand

All you need to do in order access the standard input stream from TestStand is to enable an

Input Method

on
the

Standard Input

tab of the Call Executable step.

1.





Create a new sequence file.

2.





Add a

Call Executable

step and name it “Call AddNumber
sStdIn Script”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Point the

File Pathname

field to the appropriate AddNumbersStdIn script.

5.





On the

Step Settings

pane, switch to the

Standard Input

tab.

6.





Switch the

Input M
ethod

combo box to

String
, and enter in a series of numbers separated by commas. For
example:

2, 5, 8


7.





Switch to the

Standard Output

tab and store the output in the

Variable/Property
Step.StdOutput.Text.

8.





On the

Step Settings

pane, switch to
the

Properties

tab and select the

Additional Results
category.

9.





Click the

Add Result from List

button and select

Standard Input
. This will include the stdin stream in the
report.

10.



Click the

Add Result from List

button and select

Standard Output
.
This will include the stdout stream in the
report.

11.



Save the sequence file as

PassingDataToScriptsStdIn.seq

in the same folder as the script.

12.



Run your sequence file. Your
report should look like the following screenshot:


[+] Enlarge Image



Evaluating Script Results: Pass/Fail Test using Status Expression

The earlier topics discussed how to get the output of a script into TestStand using the Standard Output stream. Once
y
ou have this data in your sequence, NI TestStand gives you the ability to base the result of your sequence based on
this output. One way to do this is to modify the

Status Expression

of the Call Executable step.

The Script: IsVoltageInRange

This simple scr
ipt takes in a range as an input (minimum and maximum) through the standard input stream. It then
compares a simulated voltage which is hardcoded to 5V to the range and prints “Result: True” or “Result: False” to the
standard output.

Perl
:

IsVoltageInRange.pl

#!/usr/bin/perl
-
w

use strict;


#Simulated Voltage

my $voltage = 5;


#Get Range

print "Enter range (separate with commas): ";

my $numbersAsString = <STDIN>;

m
y @numbers = split(/, | |,/,$numbersAsString);


my $min = $numbers[0];

my $max = $numbers[1];


if ($voltage >= $min && $voltage <= $max)

{





print "Result: True
\
n"

}

else

{





print "Result: False
\
n"

}



Python
:

IsVoltageInRange.py

#!/usr/bin/env python


#Simulated Voltage

voltage = 5


#Get Range

numbers = input('Enter range (separate with commas): ')


min = numbers[0]

max = numbers[1]


if voltage > min and voltage <= max:





print "Result: True
\
n"

else:





print "Result: False
\
n"



Tcl
:

IsVoltageInRange.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-

# The next line is executed by /bin/sh, but not tcl
\

exec
tclsh "$0" ${1+"$@"}


#Simulated Voltage

set voltage 5


#Get Range

puts "Enter range (separate with commas): "

gets stdin numbersAsString

set numbers [split $numbersAsString ,]


set min [lindex $numbers 0]

set max [lindex $numbers 1]


if {$voltage >= $min
&& $voltage <= $max} {





puts "Result: True
\
n"

} else {





puts "Result: False
\
n"

}



Evaluating Output in TestStand using Status Expression

Since you know that the script is going to return either “Result: True” or “Result: False”,
you can use a
status
expression

to parse for this string in the standard output stream and set the step status based on the output.

1.





Create a new sequence file.

2.





Add a

Call Executable

step and name it “Pass/Fail Test: IsVoltageInRange (Pass)”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Point the

File Pathname

field to the appropriate IsVoltageInRange script.

5.





On the

Step Settings

pane, switch to the

Standard Input

tab.

6.





Switch the

Input Method

combo box to

String
, an
d enter in a range that will pass separated by commas. For
example:

2, 8


[+] Enlarge Image

7.





Switch to the

Standard Output

tab and store the output in the

Variable/Property
Step.StdOutput.Text.

8.





Create a Boolean local variable named
Locals.isVoltageInRage.

9.





On the

Step Settings

pane, switch to the

Properties

tab and select the

Expressions
category.

10.



Enter the following

Post
-
Expression

to parse the standard output:

Locals.isVoltageInRange =




(Find(Step.StdOutput.Text, "Resu
lt: True") > 0) ? True : False

11.



Enter the following

Status
-
Expression

to set the result of the step:

Step.Result.Status = Locals.isVoltageInRange ? "Passed" : "Failed"


[+] Enlarge Image

12.



On the

Additional Results

category, enable

Standard
Input

and

Standard Output

using the
Add Result
From List

button. This will include the stdin and stdout stream in the report.

13.



Click the

Add Custom Result

button and enter in “isVoltageInRange” as the

Name

and
“Locals.isVoltageInRange” as the

Value to
Log.

Make sure the

Type

reads Boolean.

14.



Now create a copy of the step and insert it right after the original step. Name the copy “Pass/Fail Test:
IsVoltageInRange (Fail)”.

Modify the Standard Input in this step to cause a fail condition. For example:

3, 4


[+] Enlarge Image

15.



Save the sequence file as

PassFailTestStatusExpression.seq

in the same folder as the script.

16.



Run your sequence file. Your report should look

like the following screenshot:


[+] Enlarge Image



Evaluating Script Results: Numeric Limit Test using <None> Adaptor

The earlier topics discussed how to get the output of a script into TestStand

using the Standard Output stream. Once
you have this data in your sequence, NI TestStand gives you the ability to base the result of your sequence based on
this output. One way to do this is to use Test Step with a <None> Adaptor after the script to evalu
ate the script’s output.

The Script: GetVoltage

This script simply creates simulated voltage reading which is hardcoded to 5V to the range and prints “Voltage:
<voltage>” to the standard output.

Perl
:

GetVoltage.pl

#!/usr/bin/perl
-
w

use strict;


#Simulated Voltage

my $voltage = 5;


print "Voltage: " , $voltage, "
\
n"



Python
:

GetVoltage.py

#!/usr/bin/env python


#Simulated Voltage

voltage = 5


print "Voltage:", voltage, "
\
n"



Tcl
:

GetVoltage.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-

# The next line is executed by /bin/sh, but not tcl
\

exec tclsh

"$0" ${1+"$@"}


#Simulated voltage

set voltage 5


puts "Voltage: $voltage
\
n"



Evaluating Output in TestStand using <None> Adaptor

Since you know that your script is going to return either the voltage in the format “Voltage: <voltage>,
you can use a
status expression to parse for this string in the standard output stream and set a local variable to this value
.
Then, you can use a Numeric Limit Test with a <None> Adaptor to test the output.

1.





Create a new sequence file.

2.





Add a

Call
Executable

step and name it “GetVoltage”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Point the

File Pathname

field to the appropriate GetVoltage script.

5.





On the

Step Settings

pane, switch to the

Standard Input

tab.

6.





Switch to the

Standard Output

tab and store the output in the

Variable/Property
Step.StdOutput.Text.

7.





Create a numeric local variable named Locals.voltage.

8.





On the

Step Settings

pane, switch to the

Properties

tab and select the

Expressions
cat
egory.

9.





Enter the following

Post
-
Expression

to parse the standard output:

Locals.voltage =

Val(






Mid(












Step.StdOutput.Text,












Find(Step.StdOutput.Text, "Voltage: ") + Len("Voltage: "),












Find(Step.StdOutput.Text, "
\
n",

Find(Step.StdOutput.Text, "Voltage: "))















-

(Find(Step.StdOutput.Text, "Voltage: ")) + Len("Voltage")












)






)


[+] Enlarge Image

10.



On the

Additional Results

category, enable


Standard Output

using the

Add Result From List

button.
This will include the stdout stream in the report.

11.



Click the

Add Custom Result

button and enter in “Voltage” as the

Name

and Locals.voltage as the

Value to
Log.

Make sure the

Type

reads Number.


[+] Enlarge Image

12.



Now pick <None> from
the Adaptor dropdown list and a

Numeric Limit Test

step. Name the step “Numeric
Limit Test: IsVoltageInRange (Pass)”.

13.



Set the

Data Source

for this step to Locals.voltage.

14.



Set the

Limits

of the step to a range that covers 5 so that the test will

pass. For example:

Low: 3

High: 8

15.



Now create a copy of the two steps and insert them right after the original steps. Name the copy of the
Numeric Limit Test “Numeric Limit Test: IsVoltageInRange (Fail)”.

Modify the

Limits

on this step to cause a fai
l condition. For example:

Low: 3

High: 4


[+] Enlarge Image

16.



Save the sequence file as

NumericLimitTestNoneAdaptor.seq

in the same folder as the script.

17.



Run your sequence
file. Your report should look like the following screenshot:


[+] Enlarge Image



Handling Script Errors in TestStand

Finally, NI TestStand also gives you access to the
Standard Error (stderr) stream. Anytime an error occurs in your Perl,
Python or Tcl

scripts, they will write out to this stream. Using this, you can handle any errors eloquently in your
TestStand sequence.

The Script: AddNumbersWithErrorHandling

This is a modified version of our AddNumbersStdIn script that will check to make sure that al
l the inputs were numeric
values; otherwise it will throw an error, write to the stderr stream and exit with ExitCode
-
1.

Perl
:

AddNumbersWithErrorHandling.pl

#!/usr/bin/perl
-
w

use strict;


print "Enter numbers (separate with commas): ";

my $numbersAsString = <STDIN>;

my @numbers = split(/, | |,/,$numbersAsString);


my $sum = 0;

foreach my $currentNumber (@numbers)

{





die("Input is not a number!, stopped") unless ($currentNumb
er =~ /^
\
d+$/);





$sum += $currentNumber ;

}


print "Sum: ", $sum, "
\
n";



Python
:

AddNumbersWithErrorHandling.py

#!/usr/bin/env python

import sys


try:





numbers =
input('Enter numbers (separate with commas): ')

except:





print >> sys.stderr, 'Input is not a number!'





sys.exit(
-
1)


sum = 0

for currentNumber in numbers:





sum = sum + currentNumber


print "Sum:", sum, "
\
n"



Tcl
:

AddNumbersWithErrorHandling.tcl

#!/bin/sh

#
-
*
-

tcl
-
*
-

# The next line is executed by /bin/sh, but not tcl
\

exec tclsh "$0" ${1+"$@"}


puts "Enter numbers (separate with commas): "

gets stdin numbersAsString


set numbers [split $numbersAsString ,]


set sum 0

foreach currentNumber $numbers {





if ![string is integer
-
strict $currentNumber] {









#error "Input is not a number!"









puts stderr "Input is not a number!"









return
-
1





}





set su
m [expr $sum + $currentNumber]

}


puts "Sum: $sum
\
n"



Handling Script Errors in TestStand

TestStand

makes it easy not only to access the Standard Error stream in our sequence, but also makes it easy to make
decisions based on the contents of this stream and eloquently handle any errors.

1.





Create a new sequence file.

2.





Add a

Call Executable

ste
p and name it “Call AddNumbers Script (Correct Input)”.

3.





On the

Step Settings

pane, switch to the

Call Settings

tab.

4.





Point the

File Pathname

field to the appropriate AddNumbersWithErrorHandling script.

5.





On the

Step Settings

pane, switch
to the

Standard Input

tab.

6.





Switch the

Input Method

combo box to

String
, and enter in a series of numbers separated by commas. For
example:

2, 5, 8

7.





Switch to the

Standard Output

tab and store the output in the

Variable/Property
Step.StdOutput.T
ext.

8.





Enable the Standard Error by switching the

Error Destination

dropdown to

Store in Value/Property.

Leave
the default destination,

Step.StdError.Text
.


9.





Check the

Set Error.Msg to Standard Error Test

checkbox.

10.



Switch the

If Standard
Error is Non
-
Empty

dropdown to

Set Step Status to Error
.

11.



On the

Step Settings

pane, switch to the

Properties

tab and select the

Additional Results
category.

12.



Click the

Add Result from List

button and add

Standard Input, Standard Output and Standa
rd Error
.


[+] Enlarge Image

13.



Now create a copy of the step and insert it right after the original step. Name the copy “Call AddNumbers
Script (Incorrect Input)”.

Modify the Standard Input in this step to cause an error condition. For example:

2,
Five, 8


[+] Enlarge Image

14.



Save the sequence file as

HandlingScriptErrors.seq

in the same folder as the script.

15.



Run your sequence file. Your report should look like th
e following screenshot:


[+] Enlarge Image

Next Steps

Now that you know how to integrate simple scripts into TestStand sequences, the next article will show you how to
create more complex scripts that can call DLLs, perform data acquisition in NI
-
DAQmx

and communicate with
instruments using NI
-
VISA.

Developer Zone Tutorial:

Advanced Scripting in Perl, Python and Tcl

If you are currently enrolled in the

Standard Service

Program
, you can also access the interactive training module on
calling scripts from TestStand here:

On
Demand Training:

TestStand Modules










Introduction to TestStand


Creating a TestStand System


Creating a TestStand
-
based test solution is a process that includes

designing the test system, developing test sequences for UUTs,

customizing the
TestStand framework, debugging the test sequences,

and deploying the test solution system to test stations.




The major software components of TestStand include the engine, sequence

editor, user interfaces, module adapters, process models, and the

deployment utility.


Steps in a TestStand sequence can invoke code in another sequence or in a

code module. When invoking code in a code module, TestStand uses a

module adapter to determine the type of the code module, the calling

conventions for the code
module, the list of parameters the code module

requires, and how to pass parameters to the code module.


Testing a unit under test (UUT) requires more than just executing a set of

tests. The test management system must also perform a series of operations

b
efore and after the test sequence executes to handle common test system

tasks, such as identifying the UUT, notifying the operator of pass/fail

status, generating a test report, and logging results. These operations define

the testing process, and the set
of operations and the flow of execution is

called a process model.


TestStand includes a Sequential process model, a Parallel process model,

and a Batch process model. Use the Sequential model to run a test sequence

on one UUT at a time. Use the Parallel a
nd Batch models to run the same

test sequence on multiple UUTs at the same time.



Loading and Running Sequences


launch the sequence editor




Sequence Hierarchy Toolbar

Contains buttons for using the

Sequence Hierarchy window, which displays a graph of
the sequence

call and callback relationships among sequence files and sequences to

more easily visualize, navigate, and maintain test sequences.


Sequence Analyzer Toolbar

Contains buttons for analyzing a

sequence file or analyzer project and for configuri
ng the TestStand

Sequence Analyzer options.



Understanding Sequences and Sequence Files



A
sequence

is a series of steps
. A step can initialize an instrument, perform

a complex test, or change the flow of an execution. Steps can call an

external code mod
ule, change the value of a variable or a property, jump to

another step, or call another sequence.


A sequence file can contain any number of sequences along with sequence

file

global variables
, which you can use to share data among multiple

sequences
within a sequence file
. The sequence editor color codes

sequences by type, such as Execution entry points, Configuration entry

points, process model callbacks, subsequences, and engine callbacks.


The Steps pane for
an individual sequence includes

the
Setup
,
Main
, and

Cleanup

step groups.


The steps in the
Setup

step group execute before the

steps in the Main step group. These steps typically perform operations such

as initializing and configuring instruments, fixtures, and units under test

(UUTs).


T
he steps in the
Main

step group typically perform UUT test

operations.


The steps in the
Cleanup

group execute after the steps in the

Main step group or when a sequence terminates. These steps typically

perform operations such as powering down or releasin
g handles to

instruments, fixtures, and UUTs.


A sequence can have parameters and any number of local variables. Use

parameters

to pass and receive values between sequences. Use

local

variables

to hold values, maintain counts, hold intermediate values, and

perform any other type of local data storage within a sequence.


Use the
Variables

pane in the sequence editor to show and modify local

variables, parameters, sequence file global variables, and station global

variables. You can also

use the Variables pane to show sequence context

and run state information when executing sequences
. Refer to the
Sequence

Context
section of Chapter 3,
Executions
, of the
NI TestStand Reference

Manual
and to the
NI TestStand Help
for more information abou
t the

sequence context.




Running a Sequence



When you run a sequence in the sequence editor, you initiate an
execution
.

You can run a sequence directly or run a sequence using a process model
.

The process model sequence contains a series of steps that
specify the

high
-
level flow of a sequence execution.


When you initiate an execution, by default, the
TestStand Sequence Analyzer uses the rules
and settings in the current sequence analyzer
project to analyze the active sequence file and
detect the most c
ommon situations that can
cause run
-
time failures.


The sequence analyzer prompts

you to resolve the reported errors before you execute the sequence file.

If no errors exist or if you select to continue execution with errors, the

sequence editor opens an
Execution window.


Click the
Toggle Analyze File Before Executing
button, shown at left,

on the Sequence Analyzer toolbar or select


Debug»Sequence Analyzer»Toggle Analyze File Before Executing


to enable or disable this option.


Click the
Analyze <
sequence filename
>
button on the Sequence Analyzer

toolbar to analyze a sequence file at any time during development.


Refer to the
NI TestStand Help
for more information about using the sequence analyzer.


When an execution starts, the sequence editor op
ens an
Execution window
.

Use the Execution window to view, or trace, steps as they execute, to

monitor the values of variables and properties, and to examine the test

report when the execution completes.



Running a Sequence Directly


Complete the followin
g steps to run
MainSequence
in the

Computer.seq
sequence file directly.

1. Select
Execute»Run MainSequence
. The sequence editor opens an

Execution window to show the sequence as it executes. The first step

in the Setup step group of
MainSequence
launches t
he Test Simulator

dialog box, as shown in Figure 2
-
4. The Test Simulator dialog box

prompts you to designate the computer component(s), if any, you want

to fail during the execution.

2. Place a checkmark in the
RAM
test option.

3. Click
Done
.

4. Observe the Execution window as it traces through the steps TestStand

runs. The sequence editor uses a yellow pointer icon called the

execution pointer, shown at left, to the left of the currently executing

step in the Steps pane to indicate the progres
s of an execution. After

the execution completes, the Execution window dims and the Status

column of the
RAM
test contains the value
Failed
.







Running a Sequence Using the Sequential Process Model



In addition to executing sequences directly, you ca
n execute sequences

using an Execution entry point, which is a sequence in a process model

sequence file that invokes a test sequence file. Executing an Execution

entry point performs a series of operations before and after calling

MainSequence
of the sequ
ence file. Common operations of the process

model include identifying the UUT, notifying the operator of pass/fail

status, generating a test report, and logging results.


The Sequential process model includes the Test UUTs and the Single Pass

Execution
entry points.







Introduction to Scripting in Perl, Python and Tcl


Print

|


PDF

2 ratings |

5.00

out of 5

Overview

The ability to re
-
use existing code while migrating to a new test software framework can save developers both time
and money.

Both NI TestStand test management software and NI LabVIEW give users the ability to directly call and
integrate with code written

in a variety of languages such as Perl, Python and Tcl.

This article examines the basics of three of the commonly used scripting languages


Perl, Python and Tcl.

This is
Part 1 of a three
-
part series on calling scripting languages from TestStand

with a focus on the needs of engineers and
scientists. In this first part we will discuss the basic syntax of Perl, Python and Tcl and illustrate how to write simple
scripts in these languages.






Table of Contents

1.

Introduct
ion

2.

Running Scripts

3.

Basic Syntax

4.

Next Steps

Introduction

What is a scripting language?

Scripting languages are programming languages that are typically written using high
-
level
programming constructs,
which makes them easy to learn. While there is no fixed definition of what constitutes a scripting language, some of
the common distinguishing traits of these languages include:

Interpreted
: Scripting languages are typically convert
ed into machine level code during runtime by an interpreter, rather
than being compiled into an executable before running. While this leads to a performance hit as each line has to be
interpreted on the fly, it makes for easier portability between systems.

Typeless
: Variables can be used to hold any type of data without having to explicitly declare their type. While this can
make it easy to run into typecasting errors, it makes the language easier to learn and can improve readability of the
script.

Native C
omplex Types
: Most scripting languages also natively provide certain complex data types like strings, arrays,
lists and hashes.

Garbage Collection
: Most scripting languages automate garbage collection (freeing of memory used by data). This can
reduce the l
ikelihood of memory leaks occurring.

What do scripting language names mean?

Perl: Stands for Practical Extraction and Report Language

Python: Named after the BBC show “Monty Python’s Flying Circus”

Tcl: Stands for Tool Command Language



Running Scripts

In
stalling an Interpreter

The first step in running a script is downloading an interpreter that will take your script and convert it into machine level

language.

For our tutorials and examples, we used ActiveState’s free interpreters for Perl, Python and Tcl
:

Perl:

ActivePerl

(version 5.10)

Python:

ActivePython

(version 2.6)

Tcl:

ActiveTcl

(version
8.5)

Setting up the Interpreter

One of the benefits of using ActiveState’s interpreters is that the installers will automatically set up the computer’s
Path environment variable so that you can call your scripts from any directory. In addition, they will a
lso set up file
associations with the file extension (.pl, .py, .tcl) with their interpreters so that you can run the script directly by call
ing
its filename.

One caveat to be aware of is that, by default, ActiveTcl will associate .tcl files with a windows

shell interpreter
-

wish
-

rather than a command line interpreter. In order to run your Tcl scripts directly from the command line, you need to
modify the .tcl file association to point to the Tcl command line interpreter
-

tclsh.


The following direction

will step you
through pointing the .tcl file association to the Tcl command line interpreter.

1.

Open Windows Explorer

2.

Click

Tools»Folder Options

3.

Switch to the

File Types

tab

4.

On the

Registered file types

listbox, scroll down to the extension TCL and select i
t

5.

The

Opens with

details defaults to

Wish Application

6.

Click the

Change

button

7.

On the

Opens With

dialog, click

Browse

and select the ActiveTcl command line interpreter, tclsh

This defaults to:

C:
\
Tcl
\
Bin
\
tclsh<version_number>.exe

8.

Click the

OK

button on the

Open With

dialog

9.

Make sure that the TCL extension is now associated with

Tclsh Application
. Click the

Apply
button.



NOTE:

If you use an interpreter other than ActivePerl, ActivePython and ActiveTcl, you may have to manually set up
your Path environment
variable to point to the interpreter’s executable. For instructions on how to do this on Windows
XP, refer to

Microsoft KnowledgeBase 310519: How To Manage Environment Variables in Windows XP
.

Executin
g a Script

The typical syntax for running a script from the command line is:

<interpreter.exe> <script_filename > <command_line_arguments>

However, since we already associated the script file extensions with the interpreters, we can also directly run the
script from the command line using:

<script_filename> <command_line_arguments>

To make sure that your interpreter installed properly, you can try to run the following scripts from the command line.


Perl:

Download hello_world.pl

Run using: perl.exe HelloWorld.pl

Python:

Download hello_world.py

Run using: python.exe HelloWorld.py

Tcl:

Download hello_world.tcl

Run using: tclsh<version_number>.exe HelloWorld.tcl

Editing Scripts

While you can edit a script file in any text editor like notepad, or any text based Development Envi
ronment
like

LabWindows/CVI

or Microsoft Visual Studio, we wrote our examples in ActiveState’s free Integrated
Development Environment,

Komodo Edit

(version 5.0). W
e chose Komodo Edit because it’s built in features
(autocomplete, calltips, syntax coloring and checking) support these three scripting languages amongst others.

Basic Syntax

The following section walks you through the basic syntax used in Perl, Python and

Tcl. You can download the entire
sample here:

scripting_basics.zip


Perl

#Create a numeric variable

my $myNumber = 5;


#Create a string

my $myString = "Hello World";


#Create a new
numeric and assign the original to it

my $myNewNumber = $myNumber;


Perl

#Print a string to the screen

print "Hello World
\
n";


#Print a string and a number

my $sum = 5;


print "The sum is: ", $sum, "
\
n
\
n";


Perl

#Declare a list with three elements

my @
myList = (5, "foo", 3.14);

#The index of the last element is accessed by $#<listname>

print "Size of myList: ", $#myList + 1, "
\
n";

#Access a single element in the list

print "The second element in the list is: ", $myList[1], "
\
n
\
n";


Perl

#Command line
arguments are stored in list ARGV

#Get number of arguments

print "Number of Command Line Arguments: ", $#ARGV + 1, "
\
n";

#Access individual argument

print "The first Command Line Argument is: ", $ARGV[0], "
\
n
\
n";


Perl

#Read a user input from the
keyboard (terminates on return key)

print "Enter value, and then press Enter: ";

my $myUserInput = <STDIN>;

Perl

#if, elseif, else

if ($myNumber == 5)

{





print "My Number is Five
\
n";

}

elsif ($myNumber == 3.14)

{





print "My Number is Pi
\
n";

}

else

{





print "My Number is neither Five nor Pi
\
n
\
n"

}


#while loop

while ($myNumber != 0) #could do: until ($myNumber == 0)

{





print "My Number is: ", $myNumber, "
\
n";





$myNumber
-
= 1;

}

print "
\
n";

#for loop

for ($myNumber = 0; $myNumber < 5; $
myNumber++)

{





print "My Number is: ", $myNumber, "
\
n";

}

print "
\
n";

#foreach loop

foreach my $currentElement (@myList)

{





print "The current element is: ", $currentElement, "
\
n";

}




Python

#Create a numeric variable

myNumber = 5;


#Create a
string

myString = "Hello World";


#Create a new numeric and assign the original to it

myNewNumber = myNumber;

Python

#Print a string to the screen

print "Hello World";


#Print a string and a number


sum = 5;


print "The sum is: ", sum, "
\
n";

Python

#Declare a list with three elements

myList = [5, "foo", 3.14];

#The length of the list is accessed by len(<listname>)

print "Size of myList: ", len(myList);

#Access a single element in the list

print "The second element in the list is: ", myList[1], "
\
n";


Python

import sys;

#Command line arguments are stored in list sys.argv

#Get number of arguments

print "Number of Command Line Arguments: ", len(sys.argv)
-

1;

#Access individual argument

print "The first Command Line Argument is: ", sys.argv[1], "
\
n";


Python

#Read a user input from the keyboard

(terminates on return key)

myUserInput = raw_input("Enter value, and then press Enter: ");


Python

#if, elseif, else

if (myNumber == 5):





print "My Number is Five";

elif (myNumber == 3.14):





print "My
Number is Pi";

else:





print "My Number is neither Five nor Pi
\
n";



#while loop

while (myNumber != 0):





print "My Number is: ", myNumber;





myNumber
-
= 1;

print "
\
n";

#for loop

for myNumber in range (0, 5):





print "My Number is: ", myNumber;

pr
int "
\
n";

#foreach loop

for currentElement in myList:





print "The current element is: ", currentElement;





Tcl

#Create a numeric variable

set myNumber 5;


#Create a string

set myString "Hello World";


#Create a new numeric and assign the original to

it

set myNewNumber $myNumber;


Tcl

#Print a string to the screen

puts "Hello World";


#Print a string and a number

set sum 5;

puts "The sum is: $sum
\
n";


Tcl

#Declare a list with three elements

set myList {5 "foo" 3.14};


#The index of the last eleme
nt is accessed by llength

puts "Size of myList: [llength $myList]";

#Access a single element in the list

puts "The second element in the list is: [lindex $myList 1]
\
n";


Tcl

#Command line arguments are stored in list
$argv

and
$argc

#Get number of
arguments

puts "Number of Command Line Arguments:
$argc
";

#Access individual argument

puts "The first Command Line Argument is: [lindex
$argv

0]
\
n";


Tcl

#Read a user input from the keyboard

(terminates on return key)

puts "Enter value, and then press E
nter: ";

gets stdin myUserInput;


Tcl

#if, elseif, else

if {$myNumber == 5} {





puts "My Number is Five
\
n";

} elseif {$myNumber == 3.14} {





puts "My Number is Pi
\
n";

} else {





puts "My Number is neither Five nor Pi
\
n
\
n";

}


#while loop

while
{$myNumber != 0} {





puts "My Number is: $myNumber";





incr myNumber
-
1;

}

puts "
\
n";

#for loop

for {set myNumber 0} {$myNumber < 5} {incr myNumber} {





puts "My Number is: $myNumber";

}

puts "
\
n";

#foreach loop

foreach currentElement $myList {





p
uts "The current element is: $currentElement";

}



Next Steps

Now that we have looked at the basics of these three scripting languages, we are ready to start integrating our scripts
into our test sequences in TestStand.


Click on the following link to go
to the next article in the series.

Developer Zone Tutorial: Calling Scripting Languages from TestStand

Downloads

hello_world.zip

scripting_basics.zip





Call Perl and Python Scripts from LabVIEW


Print

4 ratings |

2.75

out of 5

Overview

The ability to call and re
-
use existing code can save a developer time and money. LabVIEW gives users the ability to
directly access and integrate code written in a variety of languages. This article explains how to re
-
use test scripts
developed in either
the Perl or Python scripting languages using the System Exec VI in LabVIEW.

Table of Contents

1.

Calling the Script Interpreter

2.

Calling Perl and Python Scripts From the Command Line

3.

Calling Perl and Python Scripts from LabVIEW

4.

Using the Attached LabVIEW Code

5.

Related Links

Perl and Python are high
-
level programming languages that use an interpreter to translate the source code into an
executable format at run time instead of being pre
-
compiled. An interpreter, such as ActivePerl or ActivePython, is
necessary to execute this
translation.

Calling the Script Interpreter

Calling the interpreter can be simplified by
changing the Environment Path Variable

to include the location where your
interpreter and corresponding library files are saved. You can edit the Environment Path usin
g the System Properties
Editor. You will need to ensure that the Environmental Path Variable is modified to include the directory in which the
Interpreter and corresponding library files are located in order for the machine to recognize the Perl and Python

tokens as commands to use the interpreter.

1.

Right
-
click on

My Computer


and select

Properties

2.

Select the

Advanced

tab

3.

Click

Environment Variables

4.

In System Variables, select the

Path

variable, and then click

Edit

5.

Add the directory for where your
Interpreter is saved

Note
: This example was prepared using the Using the ActivePerl 5.10.0 Interpreter and the ActivePython


2.6.1
Interpreter, which can be downloaded from the

APSN Act
ivePerl Website

and
ActiveState ActivePython Website
,
respectively. Both Installers have built in functionality to edit the Environmental Path Variable to include the directory
location of the interpr
eter and corresponding library files.

Calling Perl and Python Scripts From the Command Line

1.

Select

Start»Run

2.

Enter

cmd

to launch the command line

3.

Navigate to the directory where the Perl or Python script is saved

4.

To call the interpreter that will execute
the script use the following command(s):

For Perl scripts, use:

'perl scriptName.pl

argument'

as shown in the image below.


[+] Enlarge Image

For Python scripts, use:


'python

scriptName.py

argument'

as shown in the image below.


[+] Enlarge Image

Call
ing Perl and Python Scripts from LabVIEW

In LabVIEW you can

use the System Exec.vi to execute a system
-
level command line that can include any
parameters supported by the application you want to launch
. This VI can be used to call a command line argument
that will launch the Perl or Python script. Ensuring that your Environment Path Variable includes the directory in which
you Interpreter and corresponding library files are saved will allow any System E
xec call to recognize the perl and
python tokens as commands to use the Perl and Python Interpreters to execute the script.


Click here for further do
cumentation on the System Exec VI

To call a Perl or Python script from LabVIEW you will need to pass in the following parameters to the System Exec.vi

command line:

indicates the command LabVIEW calls to run a program. If the executable is not in a directo
ry listed in
the PATH environment variable, the command line must contain the full path to the executable.

working directory:

the file system directory from which you want to execute the command.

Using the Attached LabVIEW Code

1.

Set
-
up your Environment Path

Variable to include the directory in which your Interpreter is saved

2.

Save the

TestScripts

folder to your machine. This folder includes a Perl and Python script as well as LabVIEW
code that is generated to call these scripts.

3.

Open the

TestScripts

Folder
and launch the

TestVI.vi

by double
-
clicking on it.

4.

Configure the TestVI to include:

a.

Working directory: The directory where you have saved the TestScripts folder <Path>
\
TestScripts

b.

Command line: The command you will send to the command line

i.

PERL SCRIPTS:


p
erl MyScripts.pl

argument

ii.

PYTHON SCRIPTS:


python MyScript.py

argument

5.

Click the

Run

arrow to execute the program


Related Links

Calling LabVIEW VIs from Other Programming Languages

Writing Win32 DLLs and Calling Them from LabVIEW

Integrating LabVIEW Code into Other Programming Languages

ActiveX and COM Article Series

Webcast:

External Code Advances in LabVIEW

Loading .NET

Assemblies from LabVIEW

Downloads

test
-
scripts.zip









This is a list of
the objectives of the course.

This course prepares you to do the following:

• Use LabVIEW to create applications.

• Understand front panels, block diagrams, and icons and connector panes.

• Use built
-
in LabVIEW functions.

• Create and save programs in
LabVIEW so you can use them as subroutines.

• Create applications that use plug
-
in DAQ devices.

This course does
not
describe any of the following:

• Programming theory

• Every built
-
in LabVIEW function or object

• Analog
-
to
-
digital (A/D) theory

NI doe
s provide free reference materials on the above topics on
ni.com
.

The
LabVIEW Help
is also very helpful:

LabVIEW»Help»Search the LabVIEW Help…





Virtual Instrumentation

For more than 30 years, National Instruments has revolutionized the way engineers
and

scientists in industry, government, and academia approach measurement and automation.

Leveraging PCs and commercial technologies, virtual instrumentation increases

productivity and lowers costs for test, control, and design applications through easy
-
to
integrate

software, such as NI LabVIEW, and modular measurement and control hardware

for PXI, PCI, USB, and Ethernet.

With virtual instrumentation, engineers use graphical programming software to create
userdefined

solutions that meet their specific needs,

which is a great alternative to proprietary,

fixed
-
functionality traditional instruments. Additionally, virtual instrumentation capitalizes

on the ever
-
increasing performance of personal computers. For example, in test,

measurement, and control, engineers

have used virtual instrumentation to downsize

automated test equipment (ATE) while experiencing up to a 10 times increase in

productivity gains at a fraction of the cost of traditional instrument solutions. Last year

25,000 companies in 90 countries inves
ted in more than 6 million virtual instrumentation

channels from National Instruments.




National Instruments LabVIEW is an industry
-
leading software tool for designing test,

measurement, and control systems. Since its introduction in 1986, engineers and

scientists

worldwide who have relied on NI LabVIEW graphical development for projects throughout

the product design cycle have gained improved quality, shorter time to market, and greater

engineering and manufacturing efficiency. By using the integrated L
abVIEW environment

to interface with real
-
world signals, analyze data for meaningful information, and share

results, you can boost productivity throughout your organization. Because LabVIEW has the

flexibility of a programming language combined with built
-
in tools designed specifically for

test, measurement, and control, you can create applications that range from simple

temperature monitoring to sophisticated simulation and control systems. No matter what

your project is, LabVIEW

has the necessary tools to make you successful quickly.




Virtual Instrumentation Applications

Virtual instrumentation is effective in many different types of applications, from design to

prototyping to deployment. The LabVIEW platform provides specific

tools and models to meet

specific application challenges, ranging from designing signal processing algorithms to making

voltage measurements, and can target any number of platforms from the desktop to embedded

devices


with an intuitive, powerful graphic
al paradigm.

With Version 8.6, LabVIEW scales from design and development on PCs to several embedded

targets, from rugged toaster
-
size prototypes to embedded systems on chips.
LabVIEWstreamlines

system design with a single graphical development platform
. I
n doing so, it encompasses
better

management of distributed, networked systems because as the targets for LabVIEW grow varied
and

embedded, you need to be able to more easily distribute and communicate between the various

LabVIEW code pieces in your system
.




Integrated Hardware Platforms

A virtual instrument consists of an industry
-
standard computer or workstation equipped with

powerful application software, cost
-
effective hardware such as plug
-
in boards, and driver

software, which together perform the f
unctions of traditional instruments.

Virtual instruments represent a fundamental shift from traditional hardware
-
centered

instrumentation systems to software
-
centered systems that exploit the computing power,

productivity, display, and connectivity capabil
ities of popular desktop computers and

workstations.

Although the PC and integrated circuit technology have experienced significant advances in

the last two decades, software truly offers the flexibility to build on this powerful hardware

foundation to
create virtual instruments, providing better ways to innovate and significantly

reduce cost. With virtual instruments, engineers and scientists build measurement and

automation systems that suit their needs exactly (user
-
defined) instead of being limited b
y

traditional fixed
-
function instruments (vendor
-
defined).







This LabVIEW course is designed for audiences with or without access to National

Instruments hardware.

Each exercise is divided into three tracks, A, B, and C:

Track A
is designed to be use
d with hardware supported by the NI
-
DAQmx driver. This

includes most USB, PCI, and PXI data acquisition devices with analog input. Some signal

conditioning and excitation (external power) is required to use a microphone with a DAQ

device.

Track B
is design
ed to be used with no hardware. You can simulate the hardware with NIDAQmx

Version 8.0 and later. This is done by using the NI
-
DAQmx Simulated Device

option in the Create New menu of MAX. The simulated device’s driver is loaded, and

programs using it are f
ully verified.

Track C
is designed to be used with a standard sound card and microphone. LabVIEW

includes simple VIs for analog input and analog output using the sound card built into many

PCs. This is convenient for laptops because the sound card and micr
ophone are usually

already built
-
in.









The next level of software is called Measurement & Automation Explorer (MAX). MAX is

a software interface that gives you access to all of your National Instruments DAQ, GPIB,

IMAQ, IVI, Motion, VISA, and VXI
devices. The shortcut to MAX appears on your

desktop after installation. A picture of the icon is shown above. MAX is mainly used to

configure and test your National Instruments hardware, but it does offer other functionality

such as checking to see if you

have the latest version of NI
-
DAQmx installed. When you

run an application using NI
-
DAQmx, the software reads the MAX configuration to

determine the devices you have configured. Therefore, you must configure DAQ devices

first with MAX.

The functionality o
f MAX falls into six categories:

• Data Neighborhood

• Devices and Interfaces

• IVI Instruments

• Scales

• Historical Data

• Software

This course will focus on Data Neighborhood, Devices and Interfaces, Scales, Software, and

learn about the functiona
lity each one offers.







LabVIEW

LabVIEW is a graphical programming language that uses icons instead of lines of text

to create applications. In contrast to text
-
based programming languages, where

instructions determine program execution, LabVIEW

uses dataflow programming,

where the flow of data determines execution order.

You can purchase several add
-
on software toolkits for developing specialized

applications. All the toolkits integrate seamlessly in LabVIEW. Refer to the National

Instruments We
b site for more information about these toolkits.

LabVIEW also includes several wizards to help you quickly configure your DAQ

devices and computer
-
based instruments and build applications.

LabVIEWExample Finder

LabVIEW features hundreds of example VIs you

can use and incorporate into VIs that

you create. In addition to the example VIs that are shipped with LabVIEW, you can

access hundreds of example VIs on the NI Developer Zone (
zone.ni.com
). You can

modify an example VI to fit an application, or you can
copy and paste from one or

more examples into a VI that you create.



LabVIEW programs are called virtual instruments (VIs).

Controls are inputs and indicators are outputs.

Each VI contains three main parts:

• Front panel


How the user interacts with th
e VI

• Block diagram


The code that controls the program

• Icon/connector


The means of connecting a VI to other VIs

In LabVIEW, you build a user interface by using a set of tools and objects. The user

interface is known as the front panel. You then
add code using graphical representations of

functions to control the front panel objects. The block diagram contains this code. In some

ways, the block diagram resembles a flowchart.

You interact with the front panel when the program is running. You can co
ntrol the

program, change inputs, and see data updated in real time. Controls are used for inputs such

as adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a

program. Indicators are used as outputs. Thermometers, ligh
ts, and other indicators display

output values from the program. These may include data, program states, and other

information.

Every front panel control or indicator has a corresponding terminal on the block diagram.

When you run a VI, values from control
s flow through the block diagram, where they are

used in the functions on the diagram, and the results are passed into other functions or

indicators through wires.




Use the
Controls
palette to place controls and indicators on the front panel. The
Contro
ls

palette is available only on the front panel. To view the palette, select
Window»Show

Controls Palette
. You also can display the