Page tree
Skip to end of metadata
Go to start of metadata

Summary

AWRDE provides the Output File object to allow S-Parameters to be generated. You have to add an Output File to your project and the file is then written/updated every time analysis is run. Because of this (frequently unwanted) update behavior, a very common set of operations is to add an output file, run the analysis, and then delete the output file. This script automates that process.

A dialog is presented that allows the user to select a data source type (schematic, EM structure, or Data File) and then select the specific source object from a dropdown list:  This also shows off the Dialog Function that allows advanced controls of a dialog.  You will see this when you select the data source type, the pull-down controls will either activate or deactivate.  

The name of the exported file is the same as the name of the data source and the proper extension (S2P, S3P, etc) is automatically added. I recommend you install this as a global script so it's available from any project.

Code Snippets

Option Explicit
Dim i  As Integer
Dim dfNames()  As String
Dim emNames()  As String
Dim scNames()  As String ' Code Module
 Sub Main
      For i = 1  To Project.Schematics.Count
           ReDim Preserve scNames(i)  As String
           scNames(i) = Project.Schematics(i).Name
      Next i

      For i = 1  To Project.EMStructures.Count
           ReDim Preserve emNames(i)  As String
           emNames(i) = Project.EMStructures(i).Name
      Next i

      For i = 1  To Project.DataFiles.Count
           ReDim Preserve dfNames(i)  As String
           dfNames(i) = Project.DataFiles(i).Name
      Next i

     Begin Dialog UserDialog 640,203, "Select Schematic",.dlgFunc  ' %GRID:10,7,1,1
          OKButton 280,168,90,21
          GroupBox 20,21,610,126, "Select Data Source",.GroupBox1
          OptionGroup .src
               OptionButton 50,50,90,14, "Schematic",.sch
               OptionButton 50,80,110,14, "EM Structure",.em
               OptionButton 50,110,90,14, "Data File",.df
          DropListBox 280,50,320,70,scNames(),.scName
          DropListBox 280,80,320,70,emNames(),.emName
          DropListBox 280,110,320,70,dfNames(),.dfName
      End Dialog
      Dim dlg  As UserDialog
      Dialog dlg

      Select Case dlg.src
           Case 0
               Project.OutputFiles.AddPortParameterFile(Project.Schematics(dlg.scName + 1).Name,Project.Schematics(dlg.scName + 1).Name,mwOFP_SParameter,mwOFF_Magnitude_Angle,mwOFU_GHz, False)
               Project.Simulator.Analyze
               Project.OutputFiles.Remove(Project.OutputFiles.Count)
           Case 1
               Project.OutputFiles.AddPortParameterFile(Project.EMStructures(dlg.emName + 1).Name,Project.EMStructures(dlg.emName + 1).Name,mwOFP_SParameter,mwOFF_Magnitude_Angle,mwOFU_GHz, False)
               Project.Simulator.Analyze
               Project.OutputFiles.Remove(Project.OutputFiles.Count)
           Case 2
               Project.OutputFiles.AddPortParameterFile(Project.DataFiles(dlg.dfName + 1).Name,Project.DataFiles(dlg.dfName + 1).Name,mwOFP_SParameter,mwOFF_Magnitude_Angle,mwOFU_GHz, False)
               Project.Simulator.Analyze
               Project.OutputFiles.Remove(Project.OutputFiles.Count)
      End Select
End Sub
Rem See DialogFunc help topic  for more information.
 Private Function dlgFunc(DlgItem$, Action%, SuppValue&)  As Boolean
 Select Case Action%
      Case 1  ' Dialog box initialization
          DlgEnable  "emName",  False
          DlgEnable  "dfName",  False
      Case 2  ' Value changing or button pressed
           Select Case SuppValue&
                Case 0
                    DlgEnable  "scName",  True
                    DlgEnable  "emName",  False
                    DlgEnable  "dfName",  False
                Case 1
                    DlgEnable  "scName",  False
                    DlgEnable  "emName",  True
                    DlgEnable  "dfName",  False
                Case 2
                    DlgEnable  "scName",  False
                    DlgEnable  "emName",  False
                    DlgEnable  "dfName",  True
                End Select
                Rem dlgFunc =  True ' Prevent button press from closing the dialog box
      Case 3  ' TextBox or ComboBox text changed
      Case 4  ' Focus changed
      Case 5  ' Idle
          Rem Wait .1 : dlgFunc =  True ' Continue getting idle actions
      Case 6  ' Function key
      End Select
End Function
  • No labels