From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-15-2010 04:49 PM
I'm new to TS. I've developed board-testing automation using VB.Net. I'd like to integrate what I already have into TS. I tried something simple like below but got an "Object reference not set to an instance of an object" error as I should, since SequenceContext is an Interface type. I took the DummyFunctionName function straight out of the dotnet.vb example from NI. Any help/guidance is greatly appreciated.
Thx,
VuN
Imports NationalInstruments.TestStand.Interop.API
Imports System.Runtime.InteropServicesPublic Class Form1
Private m_SC As SequenceContext
Private m_report As String
Private m_ERROR As Boolean
Private m_errCode As Integer
Private m_errorMsg As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DummyFunctionName(m_SC, m_report, m_ERROR, m_errCode, m_errorMsg)
If m_ERROR Then
MsgBox("Error code: " & m_errCode & ". Error Message: " & m_errorMsg)End If
End Sub
Public Sub DummyFunctionName(ByVal seqContext As NationalInstruments.TestStand.Interop.API.SequenceContext, ByRef reportText As String, ByRef errorOccurred As Boolean, ByRef errorCode As Integer, ByRef errorMsg As String)
Try
' INSERT YOUR SPECIFIC TEST CODE HERE
' The following code shows how to access properties and variables via the TestStand API
Dim propertyObject As PropertyObject = seqContext.AsPropertyObject()' Dim lastUserName As String = propertyObject.GetValString("StationGlobals.TS.LastUserName", 0)
Dim stationName As String = propertyObject.GetValString("StationGlobals.StationName", 0)MsgBox(stationName)
Catch ex As COMExceptionerrorOccurred = True
errorMsg = ex.Message
errorCode = ex.ErrorCode
End Try
End SubEnd Class
04-15-2010 05:00 PM
I'm assuming you get the error when you try to execute your step in TS? How do you have your step configured (what values are you passing for your parameters)? SequenceContext is an interface yes, but you should be passing the object in from TS (just specify "ThisContext" for the value of that parameter on your .NET step in TS).
-Jeff
04-15-2010 05:06 PM
What I did was compile the VB.Net code and have TS launch the .exe. You're right, I need to have a way to instansiate the object but I'm not sure how to do that in my code.
04-15-2010 05:47 PM
You should generally be creating a class library assembly (.dll), not an .exe. You can then call that from a step in a teststand sequence which uses the .NET adapter. Please be more specific about what you are trying to do if this is not what you are looking for. The way you have it written doesn't really make sense since you will just be calling your method will unintialized variables as the parameters. You should instead likely be calling your method from a TestStand sequence rather than the Load callback of your .exe.
If you are trying to write a user-interface application rather than a code module to be called from a sequence, you might want to start with the example VB.NET UI code installed with TestStand.
Hope this helps,
-Doug