Measure Data Example Program

This Visual Basic program does the following:

Public Function Example_Measure() As Boolean

        'create PLTS application

        Dim app = New PLTS.CPLTSApplication()

        System.Threading.Thread.Sleep(1000) 'grace time for PLTS startup

        app.ShowWindow(3)

        'overwrite checkbox status in 'Measure' button dropdown menu

        Dim xmlUserPref As XElement = _

            <UserPreferencesApiArgs>

                <DoNotShowConnectDutWzdPg>true</DoNotShowConnectDutWzdPg>

                <DoNotShowSelectViewWzdPg>true</DoNotShowSelectViewWzdPg>

            </UserPreferencesApiArgs>

        app.SetUserPreferences(xmlUserPref.ToString())

        '!NOTE! ATE software should call PNA API directly to setup measurement

        'then call PLTS API to do sweep and pull data from PNA to PLTS

        Dim xmlMeasSettings As XElement = _

            <MeasurementSettings>

                <WizardWorkMode>NewMeas</WizardWorkMode>

                <CalAction>LoadCal</CalAction>

                <SelectedAnalysisViewName>Create New</SelectedAnalysisViewName>

                <NumOfSweepPoints>201</NumOfSweepPoints>

                <VelocityFactor>1</VelocityFactor>

                <AverageFactor>1</AverageFactor>

                <IFBandWidthKHz>30</IFBandWidthKHz>

                <IsLogSweep>false</IsLogSweep>

                <CalSetName>nameOfMyCal</CalSetName>

                <CalDateTime>11/04/2015 09:29:27.320</CalDateTime>

                <NumOfDutPort>4</NumOfDutPort>

                <NumOfPnaPort>4</NumOfPnaPort>

                <PortMap>1|1|label|2|2|label|3|3|label|4|4|label|</PortMap>

                <DiffPortMap>1|2P|2|2P|0|UC|0|UC|</DiffPortMap>

                <Description>Default 4-Port Configuration</Description>

                <VnaPortsList>1,2,3,4</VnaPortsList>

            </MeasurementSettings>

        Dim docObj As Object = Nothing

        Dim viewObj As Object = Nothing

        app.Measure(xmlMeasSettings.ToString(), docObj, viewObj)

        Dim doc As PLTS.IPLTSDocument = docObj

        'get data from PLTS, modify data, then set data back to PLTS

        Dim xmlGetDatSettings As XElement = _

            <DataAccessApiArgs>

                <DataAccessPoint>1</DataAccessPoint>

                <ParameterName>SDD21</ParameterName>

            </DataAccessApiArgs>

        Dim datObj As Object = Nothing

        doc.GetData(xmlGetDatSettings.ToString(), datObj)

        Dim dat As Double() = datObj

        If dat IsNot Nothing Then

            'modify data, for example, here change all real part to be 1, all imag part to be 0

            Dim i As Integer = 0

            While i < dat.Length

                dat(i) = 1.0

                i = i + 1

                dat(i) = 0.0

                i = i + 1

            End While

            Dim xmlSetDatSettings As XElement = _

                <DataAccessApiArgs>

                    <DataAccessPoint>1</DataAccessPoint>

                    <ParameterName>SDD21</ParameterName>

                </DataAccessApiArgs>

            doc.SetData(xmlSetDatSettings.ToString(), datObj)

        End If

        'open a template view, view name is case sensitive

        'and the template view should be pre-defined

        Dim viewName As String = "MyDataView (4p)"

        Dim viewObj2 As Object = Nothing

        doc.OpenTemplateView(viewName, viewObj2)

        'export data

        Dim xmlExportSettings As XElement = _

            <ExportApiArgs>

                <FDYDataFormat>RI</FDYDataFormat>

                <ExportFileName>C:\pltsApi.s4p</ExportFileName>

            </ExportApiArgs>

        doc.Export(xmlExportSettings.ToString())

        'exit

        app.CloseAllFiles()

        app.Exit()

        Return True

    End Function