NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Results from Executing Sequence in VB

I�m trying to control the TestStand engine from
Visual Basic. I�m using the Automation Server
interface rather than the ActiveX control because
ultimately I want to be able to interface with it
from script running in a web browser.

The problem I'm having is that I can execute a
sequence file but I can't get any meaningful
results out of it. For example the ResultStatus
property of each step in a sequence is blank.
However, when I run the same file in the sample
VB Test Operator program everything seems to work.

I guess it's probably because I'm not handling
the engine's UIMessageHandler properly.

The relevant code is as follows:


Set moTS = New TS.Engine 'using as Automation
Server

'Get a sequence file
Set moSequenceFile = moTS.GetSequenceFile
("c:\program
files\teststand\tutorial\sample2.seq")

'Get the main sequence
Set oSequence = moSequenceFile.GetSequence(0)
SequenceName = oSequence.Name

'Enable polling for UIMessages
moTS.UIMessagePollingEnabled = True
Timer1.Enabled = True

'Start an execution on this sequence, bypassing
the Proces model
Set moExecution = moTS.NewExecution
(moSequenceFile, SequenceName, Nothing, False,
ExecTypeMask_Normal)

'In UIMessage Handler code

Dim UIMsgCode As TS.UIMessageCodes

If Not moTS Is Nothing Then

If moTS.IsUIMessageQueueEmpty Then

Set moUIMsg = moTS.GetUIMessage

UIMsgCode = moUIMsg.Event

Select Case UIMsgCode
Case UIMsg_StartExecution
Case UIMsg_EndExecution

Debug.Print "Num Threads = " &
moExecution.NumThreads
Debug.Print "Execution Status = "
& moExecution.ResultStatus

'Print info about the steps
Set moSequenceFile =
moExecution.GetSequenceFile
Set oSequence =
moSequenceFile.GetSequence(0)

NumSteps = oSequence.GetNumSteps
(StepGroup_Main)

For i = 0 To NumSteps - 1
Set oStep = oSequence.GetStep
(i, StepGroup_Main)
Debug.Print "Name = " &
oStep.Name
Debug.Print "Description = "
& oStep.Description
Debug.Print "Result Status
= " & oStep.ResultStatus 'This is empty
Next

Debug.Print "Report = " &
moExecution.Report.All 'This is empty
Set oSequence = Nothing
Set moThread = Nothing

Timer1.Enabled = False

Case UIMsg_BreakOnUserRequest
Case UIMsg_BreakOnBreakpoint
'etc.

End Select

Set moUIMsg = Nothing

End If
End If


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 4
(3,147 Views)
Kevin,

You'll need to use a timer callback or some asynchronous technique to poll
for UIMessages. Furthermore, you need to release the UIMessage before TestStand
will continue with the execution. The execution pauses while you are handling
the UIMessage. And the execution continues only when you release the UIMessage
(or set it to Nothing).

THere is a Simple VB Operator Interface example on the web at www.ni.com/support/epd/

Hope this helps,
Paul

kevin_mcfarlane@my-deja.com wrote:
>I�m trying to control the TestStand engine from>Visual Basic. I�m using
the Automation Server>interface rather than the ActiveX control because>ultimately
I want to be able to interface with it>from script running in a web browser.>>The
problem I'm having is that I can execute a>sequence file but I can't get
any meaningful>results out of it. For example the ResultStatus>property of
each step in a sequence is blank.>However, when I run the same file in the
sample>VB Test Operator program everything seems to work.>>I guess it's probably
because I'm not handling>the engine's UIMessageHandler properly.>>The relevant
code is as follows:>>>Set moTS = New TS.Engine 'using as Automation>Server>>'Get
a sequence file>Set moSequenceFile = moTS.GetSequenceFile>("c:\program>files\teststand\tutorial\sample2.seq")>>'Get
the main sequence>Set oSequence = moSequenceFile.GetSequence(0)>SequenceName
= oSequence.Name>>'Enable polling for UIMessages>moTS.UIMessagePollingEnabled
= True>Timer1.Enabled = True>>'Start an execution on this sequence, bypassing>the
Proces model>Set moExecution = moTS.NewExecution>(moSequenceFile, SequenceName,
Nothing, False,>ExecTypeMask_Normal)>>'In UIMessage Handler code>>Dim UIMsgCode
As TS.UIMessageCodes>>If Not moTS Is Nothing Then>> If moTS.IsUIMessageQueueEmpty
Then>> Set moUIMsg = moTS.GetUIMessage>> UIMsgCode = moUIMsg.Event>>
Select Case UIMsgCode> Case UIMsg_StartExecution>
Case UIMsg_EndExecution>> Debug.Print "Num Threads =
" &>moExecution.NumThreads> Debug.Print "Execution Status
= ">& moExecution.ResultStatus>> 'Print info about the steps>
Set moSequenceFile =>moExecution.GetSequenceFile>
Set oSequence =>moSequenceFile.GetSequence(0)>> NumSteps
= oSequence.GetNumSteps>(StepGroup_Main)>> For i = 0 To NumSteps
- 1> Set oStep = oSequence.GetStep>(i, StepGroup_Main)>
Debug.Print "Name = " &>oStep.Name>
Debug.Print "Description = ">& oStep.Description> Debug.Print
"Result Status>= " & oStep.ResultStatus 'This is empty> Next>>
Debug.Print "Report = " &>moExecution.Report.All 'This is
empty> Set oSequence = Nothing> Set moThread
= Nothing>> Timer1.Enabled = False>> Case UIMsg_BreakOnUserRequest>
Case UIMsg_BreakOnBreakpoint> 'etc.>> End Select>>
Set moUIMsg = Nothing>> End If>End If>>>Sent via Deja.com http://www.deja.com/>Before
you buy.
0 Kudos
Message 2 of 4
(3,147 Views)
Hi Paul,

Thanks for the examples web reference. The simple VB example will be
useful as there's less stuff to wade through! Plus, I'll probably also
eventually need to refer to the C++ examples.

Re: the current problem, I had in the meantime solved it on my own. I'd
done what you say below, but the critical thing I missed was defining
the sequence context object.

Kevin

In article <39709fed@newsgroups.ni.com>,
"Paul Mueller" wrote:
>
> Kevin,
>
> You'll need to use a timer callback or some asynchronous technique to
poll
> for UIMessages. Furthermore, you need to release the UIMessage
before TestStand
> will continue with the execution. The execution pauses while you are
handling
> the UIMessage. And the execution continues only when you release the
UIMessage
> (or set it to Nothing).
>
> THere is a Simple VB Operator Interface example on the web at
www.ni.com/support/epd/
>
> Hope this helps,
> Paul
>
> kevin_mcfarlane@my-deja.com wrote:
> >I�m trying to control the TestStand engine from>Visual Basic. I�m
using
> the Automation Server>interface rather than the ActiveX control
because>ultimately
> I want to be able to interface with it>from script running in a web
browser.>>The
> problem I'm having is that I can execute a>sequence file but I can't
get
> any meaningful>results out of it. For example the
ResultStatus>property of
> each step in a sequence is blank.>However, when I run the same file
in the
> sample>VB Test Operator program everything seems to work.>>I guess
it's probably
> because I'm not handling>the engine's UIMessageHandler properly.>>The
relevant
> code is as follows:>>>Set moTS = New TS.Engine 'using as
Automation>Server>>'Get
> a sequence file>Set moSequenceFile = moTS.GetSequenceFile>
("c:\program>files\teststand\tutorial\sample2.seq")>>'Get
> the main sequence>Set oSequence = moSequenceFile.GetSequence(0)
>SequenceName
> = oSequence.Name>>'Enable polling for
UIMessages>moTS.UIMessagePollingEnabled
> = True>Timer1.Enabled = True>>'Start an execution on this sequence,
bypassing>the
> Proces model>Set moExecution = moTS.NewExecution>(moSequenceFile,
SequenceName,
> Nothing, False,>ExecTypeMask_Normal)>>'In UIMessage Handler code>>Dim
UIMsgCode
> As TS.UIMessageCodes>>If Not moTS Is Nothing Then>> If
moTS.IsUIMessageQueueEmpty
> Then>> Set moUIMsg = moTS.GetUIMessage>> UIMsgCode =
moUIMsg.Event>>
> Select Case UIMsgCode> Case
UIMsg_StartExecution>
> Case UIMsg_EndExecution>> Debug.Print "Num
Threads =
> " &>moExecution.NumThreads> Debug.Print "Execution
Status
> = ">& moExecution.ResultStatus>> 'Print info about the
steps>
> Set moSequenceFile
=>moExecution.GetSequenceFile>
> Set oSequence =>moSequenceFile.GetSequence(0)>>
NumSteps
> = oSequence.GetNumSteps>(StepGroup_Main)>> For i = 0
To NumSteps
> - 1> Set oStep = oSequence.GetStep>(i,
StepGroup_Main)>
> Debug.Print "Name = "
&>oStep.Name>
> Debug.Print "Description = ">& oStep.Description>
Debug.Print
> "Result Status>= " & oStep.ResultStatus 'This is
empty> Next>>
> Debug.Print "Report = " &>moExecution.Report.All 'This
is
> empty> Set oSequence = Nothing> Set
moThread
> = Nothing>> Timer1.Enabled = False>> Case
UIMsg_BreakOnUserRequest>
> Case UIMsg_BreakOnBreakpoint> 'etc.>>
End Select>>
> Set moUIMsg = Nothing>> End If>End If>>>Sent via Deja.com
http://www.deja.com/>Before
> you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 3 of 4
(3,147 Views)
Hi Kevin,

I want to implement something like what you did - run TestStand sequences
in a web browser. Can I borrow some of your ideas or code? What references
(books) do you recommend to look at?

Thanks in advance,
Paul Mueller
National Instruments


kevin_mcfarlane@my-deja.com wrote:
>Hi Paul,
>>Thanks for the examples web reference. The simple VB example will be
>useful as there's less stuff to wade through! Plus, I'll probably also
>eventually need to refer to the C++ examples.
>>Re: the current problem, I had in the meantime solved it on my own. I'd
>done what you say below, but the critical thing I missed was defining
>the sequence context object.
>>Kevin
>>
0 Kudos
Message 4 of 4
(3,147 Views)