Copyright (c) 2021 Fluke Calibration                        MET/CAL Procedure
=============================================================================
INSTRUMENT:            Sub Initialize /UWSG
INSTRUMENT:            Sub Reset /UWSG
INSTRUMENT:            Sub Output Off /UWSG
INSTRUMENT:            Sub Apply /UWSG
INSTRUMENT:            Sub Get Options /UWSG
INSTRUMENT:            Sub Get Accuracy /UWSG
DATE:                  2021-04-30 08:45:49
AUTHOR:                Fluke
REVISION:              $Revision: 30156 $
ADJUSTMENT THRESHOLD:  70%
NUMBER OF TESTS:       7
NUMBER OF LINES:       871
CONFIGURATION:         Microwave Signal Generator
=============================================================================
#
#  Procedure Author:
#        DAC, DFM, CAD
#
#  Compatibility:
#        MET/CAL 7.2 or later
#
#  This procedure is intended for use with MET/CAL calibration software;
#  the terms and conditions set forth in your MET/CAL license apply to this
#  procedure.
#
#  Due to Fluke's policy of continuously updating our products, this procedure
#  may contain minor differences in methods used and/or specifications to
#  those found in the manual or other documentation. While every effort has
#  been made to ensure that this procedure is accurate, Fluke cannot be held
#  responsible for the consequences of error or omissions found within this
#  procedure.
#
#  The copyright in this procedure is owned by Fluke Corporation.
#
#  Parameters       Values
#  ---------------  ---------------------------------------------------------
#  @UWSG_Freq       <NR3>[][<prefix>]Hz
#
#  @UWSG_Ampl       <NR3>[]dBm | <NR3>[][<prefix>]V | <NR3>[][<prefix>]Vp |
#                   <NR3>[][<prefix>]Vpp
#
#  @UWSG_ModFreq    <NR3>[][<prefix>]Hz
#
#  @UWSG_ModSrc     Int | Ext
#
#  @UWSG_ExtCpl     AC | DC
#
#  @UWSG_AM         On | Off
#
#  @UWSG_AM_Depth   <NR3>[][<prefix>]%
#
#  @UWSG_FM         On | Off
#
#  @UWSG_FM_Dev     <NR3>[][<prefix>]Hz
#
#  @UWSG_PM         On | Off
#
#  @UWSG_PM_Dev     <NR3>[][<prefix>]rad
#
#  @UWSG_PL         On | Off
#
#  @UWSG_PL_Width   <NR3>[][<prefix>]s
#
#  @UWSG_PL_Delay   <NR3>[][<prefix>]s
#
#  @UWSG_PL_Imp     <NR3>[][<prefix>]Ohm
#
#  @UWSG_PL_Slope   Pos | Neg
#
#  @UWSG_PL_Cond    On | Off
#
#  @UWSG_Cond       On | Off
#
#  @UWSG_ROSC *     Int | Ext
#
#  NOTES:
#  * Manual selection prompts for rear panel switches will ONLY be displayed
#    when explicitly requesting "Int" or "Ext".  Leaving @UWSG_ROSC blank
#    after calling Sub Initialize will NOT prompt the operator for a change.
#
#  Example Usage:
#
#      CALL         Sub Initialize /UWSG
#      CALL         Sub Reset /UWSG
#
#      MATH         @UWSG_Freq     = "500 MHz"
#      MATH         @UWSG_Ampl     = "-10 dBm"
#      MATH         @UWSG_ModSrc   = "Int"
#      MATH         @UWSG_ModFreq  = "1 kHz"
#      MATH         @UWSG_AM_Depth = "30%"
#      MATH         @UWSG_AM       = "On"
#      CALL         Sub Apply /UWSG
#
#      CALL         Sub Output Off /UWSG
#
 STEP    FSC    RANGE NOMINAL        TOLERANCE     MOD1        MOD2  3  4 CON

  1.001  JMPL         INITIALIZE                   PSUBI("Initialize")
  1.002  JMPL         RESET                        PSUBI("Reset")
  1.003  JMPL         OUTPUT_OFF                   PSUBI("Output Off")
  1.004  JMPL         APPLY                        PSUBI("Apply")
  1.005  JMPL         GET_OPTIONS                  PSUBI("Get Options")
  1.006  JMPL         GET_ACCURACY                 PSUBI("Get Accuracy")
  1.007  DISP         Called subprocedure not found!
  1.008  END

  1.009  EVAL   Increment Step Number


# =====  Sub Initialize /UWSG  ==============================================

  2.001  LABEL        INITIALIZE

# Get and store:
#   device name
#   converage factor
#   programming section name for looking up programming codes in .ini file.
#   FSC used for IEEE-488 I/O
#   Connection terminal names

  2.002  MATH         @UWSG_DevName = INSTR("UWSG")

  2.003  IF           0
  2.004  MATH         @UWSG_Conf = CONF(@UWSG_DevName)
  2.005  ENDIF

  2.006  MATH         @UWSG_ProgSecName = RINFE(@UWSG_DevName, "ProgSecName")
  2.007  MATH         @UWSG_FSC = RINFE(@UWSG_ProgSecName, "FSC")
  2.008  MATH         @UWSG_Output = RINFE(@UWSG_ProgSecName, "Output50_Ohm")
  2.009  MATH         @UWSG_RefIn  = RINFE(@UWSG_ProgSecName, "RefIn")
  2.010  MATH         @UWSG_RefOut = RINFE(@UWSG_ProgSecName, "RefOut")

# Initialize parameters to the empty string (unset).
  2.011  MATH         @UWSG_CPT      = ""
  2.012  MATH         @UWSG_Freq     = ""
  2.013  MATH         @UWSG_Ampl     = ""
  2.014  MATH         @UWSG_ModFreq  = ""
  2.015  MATH         @UWSG_ModSrc   = ""
  2.016  MATH         @UWSG_ExtCpl   = ""
  2.017  MATH         @UWSG_AM       = ""
  2.018  MATH         @UWSG_AM_Depth = ""
  2.019  MATH         @UWSG_FM       = ""
  2.020  MATH         @UWSG_FM_Dev   = ""
  2.021  MATH         @UWSG_PM       = ""
  2.022  MATH         @UWSG_PM_Dev   = ""
  2.023  MATH         @UWSG_PL       = ""
  2.024  MATH         @UWSG_PL_Width = ""
  2.025  MATH         @UWSG_PL_Delay = ""
  2.026  MATH         @UWSG_PL_Imp   = ""
  2.027  MATH         @UWSG_PL_Slope = ""
  2.028  MATH         @UWSG_PL_Cond  = ""
  2.029  MATH         @UWSG_Cond     = ""
  2.030  MATH         @UWSG_ROSC     = ""

# Check for the flag that triggers operator message to manually select
# frequency reference source.  Initialize variable if does not exist, else
# retain existing switch position.
  2.031  IF           NOT(ISVAR("@UWSG_ROSC_Set"))
  2.032  MATH         @UWSG_ROSC_Set = ""
  2.033  ENDIF

# Check for options that affect accuracy lookup.
  2.034  CALL         Sub Get Options /UWSG

# Get programming string for RESET FSC.
  2.035  MATH         ResetCmd = RINF(@UWSG_ProgSecName, "ResetFSC")

# If RESET_FSC is defined, establish the RESET FSC.
  2.036  IF           NOT(EMPTY(ResetCmd))

  2.037  IF           ZCMPI(ResetCmd, "[SDC]")
  2.038  RESET        [@UWSG][SDC]
  2.039  ELSE
  2.040  RESET        [@UWSG][V ResetCmd]

  2.041  ENDIF

  2.042  ENDIF

  2.043  END

  2.044  EVAL   Increment Step Number


# =====  Sub Reset /UWSG  ===================================================

  3.001  LABEL        RESET

  3.002  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, "Reset")
  3.003  CALL         Sub Send Command /UWSG
  3.004  END

  3.005  EVAL   Increment test number


# =====  Sub Output Off /UWSG  ==============================================

  4.001  LABEL        OUTPUT_OFF

  4.002  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "OutputOff")

# If "Output_Off" is defined, send the command.
  4.003  IF           NOT(EMPTY(@UWSG_Cmd))
  4.004  CALL         Sub Send Command /UWSG
  4.005  ENDIF

  4.006  END

  4.007  EVAL   Increment test number


# =====  Sub Apply /UWSG  ===================================================

  5.001  LABEL        APPLY

# -----  Frequency  -------------------------------

# Get the command string.
  5.002  MATH         FreqCmd = RINFE(@UWSG_ProgSecName, "Freq")
# Convert to base units and insert in programming string.
  5.003  MATH         @UWSG_Cmd = REPL("<val>", BASE(@UWSG_Freq), FreqCmd)
  5.004  CALL         Sub Send Command /UWSG

# -----  Amplitude  -------------------------------

  5.005  MATH         Ampl = BASE(@UWSG_Ampl); AmplUnits = UNIT(@UWSG_Ampl)
  5.006  MATH         AmplCmd = ""

  5.007  IF           ZCMPI(AmplUnits, "dBm")

# Use discrete command for negative dBm, if one exists.
  5.008  IF           Ampl < 0
  5.009  MATH         AmplCmd = RINF(@UWSG_ProgSecName, "Ampl_dBmNeg")
# Otherwise use discrete command for positive dBm, if one exists.
  5.010  ELSE
  5.011  MATH         AmplCmd = RINF(@UWSG_ProgSecName, "Ampl_dBmPos")
  5.012  ENDIF

# Otherwise use the general command.
  5.013  IF           EMPTY(AmplCmd)
  5.014  MATH         AmplCmd = RINFE(@UWSG_ProgSecName, "Ampl_dBm")
  5.015  ELSEIF       Ampl < 0
  5.016  MATH         Ampl = ABS(Ampl)
  5.017  ENDIF

  5.018  ELSEIF       ZCMPI(AmplUnits, "V")
  5.019  MATH         AmplCmd = RINFE(@UWSG_ProgSecName, "Ampl_Vrms")
  5.020  ELSEIF       ZCMPI(AmplUnits, "Vp")
  5.021  MATH         AmplCmd = RINF(@UWSG_ProgSecName, "Ampl_Vp")

# If there is no Vp command see if there is a Vpp command.
  5.022  IF           EMPTY(AmplCmd)
  5.023  MATH         AmplCmd = RINFE(@UWSG_ProgSecName, "Ampl_Vpp")
# Convert Vp to Vpp.
  5.024  MATH         Ampl = Ampl * 2
  5.025  ENDIF

  5.026  ELSEIF       ZCMPI(AmplUnits, "Vpp")
  5.027  MATH         AmplCmd = RINF(@UWSG_ProgSecName, "Ampl_Vpp")

# If there is no Vpp command see if there is a Vp command.
  5.028  IF           EMPTY(AmplCmd)
  5.029  MATH         AmplCmd = RINFE(@UWSG_ProgSecName, "Ampl_Vp")
# Convert Vpp to Vp.
  5.030  MATH         Ampl = Ampl / 2
  5.031  ENDIF

  5.032  ENDIF

  5.033  MATH         @UWSG_Cmd = REPL("<val>", Ampl, AmplCmd)
  5.034  CALL         Sub Send Command /UWSG

# -----  AM  --------------------------------------

  5.035  IF           NOT(EMPTY(@UWSG_AM))

# -----  Modulation Source
  5.036  IF           NOT(EMPTY(@UWSG_ModSrc))

  5.037  IF           ZCMPI(@UWSG_ModSrc, "Int")

# For devices where internal modulation source and frequency are programmed
# with a single command, postpone programming these settings to the mod
# frequency block below.
  5.038  IF           NOT(EMPTY(RINF(@UWSG_ProgSecName, "AM_Int400Hz")))
  5.039  MATH         ModSrc = ""
  5.040  ELSEIF       NOT(EMPTY(RINF(@UWSG_ProgSecName, "AM_Int1kHz")))
  5.041  MATH         ModSrc = ""
  5.042  ELSE
  5.043  MATH         ModSrc = "AM_Int"
  5.044  ENDIF

  5.045  ELSE         ; External Coupling

  5.046  IF           ZCMPI(@UWSG_ExtCpl, "AC")
  5.047  MATH         ModSrc = "AM_ExtAC"
  5.048  ELSEIF       ZCMPI(@UWSG_ExtCpl, "DC")
  5.049  MATH         ModSrc = "AM_ExtDC"
  5.050  ELSE
  5.051  MATH         ModSrc = "AM_Ext"
  5.052  ENDIF

  5.053  ENDIF        ; ZCMPI(@UWSG_ModSrc, "Int")

  5.054  IF           NOT(EMPTY(ModSrc))
  5.055  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, ModSrc)
  5.056  CALL         Sub Send Command /UWSG
  5.057  ENDIF

  5.058  ENDIF        ; IF Modulation Source

# -----  Modulation Frequency.
  5.059  IF           NOT(EMPTY(@UWSG_ModFreq))
  5.060  MATH         ModFreq = BASE(@UWSG_ModFreq); ModFreqCmd = ""

# Use discrete command for 400 Hz Mod. Freq., if one exists.
  5.061  IF           ModFreq == 400
  5.062  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "AM_Int400Hz")
# Otherwise use discrete command for 1 kHz Mod. Freq, if one exists.
  5.063  ELSEIF       ModFreq == 1E+3
  5.064  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "AM_Int1kHz")
  5.065  ENDIF

# Otherwise use the general command.
  5.066  IF           EMPTY(ModFreqCmd)
  5.067  MATH         ModFreqCmd = RINFE(@UWSG_ProgSecName, "AM_ModFreq")
  5.068  MATH         @UWSG_Cmd  = REPL("<val>", ModFreq, ModFreqCmd)
  5.069  ELSE
  5.070  MATH         @UWSG_Cmd  = ModFreqCmd
  5.071  ENDIF

  5.072  CALL         Sub Send Command /UWSG
  5.073  ENDIF        ; IF Modulation Frequency

# -----  AM Depth
  5.074  IF           NOT(EMPTY(@UWSG_AM_Depth))
  5.075  MATH         AMDepth    = BASE(@UWSG_AM_Depth)
  5.076  MATH         AMDepthCmd = RINF(@UWSG_ProgSecName, "AM_Depth")
  5.077  MATH         @UWSG_Cmd  = REPL("<val>", AMDepth, AMDepthCmd)
  5.078  CALL         Sub Send Command /UWSG
  5.079  ENDIF

# Get the AM On programming command string.
  5.080  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "AM_On")

  5.081  IF           NOT(EMPTY(@UWSG_Cmd))
  5.082  CALL         Sub Send Command /UWSG
  5.083  ENDIF

  5.084  ENDIF        ; IF AM

# -----  FM  --------------------------------------

  5.085  IF           NOT(EMPTY(@UWSG_FM))

# -----  Modulation source.
  5.086  IF           NOT(EMPTY(@UWSG_ModSrc))

  5.087  IF           ZCMPI(@UWSG_ModSrc, "Int")

# See comments in AM Modulation source, above.
  5.088  IF           NOT(EMPTY(RINF(@UWSG_ProgSecName, "FM_Int400Hz")))
  5.089  MATH         ModSrc = ""
  5.090  ELSEIF       NOT(EMPTY(RINF(@UWSG_ProgSecName, "FM_Int1kHz")))
  5.091  MATH         ModSrc = ""
  5.092  ELSE
  5.093  MATH         ModSrc = "FM_Int"
  5.094  ENDIF

  5.095  ELSE         ; External Coupling

  5.096  IF           ZCMP(@UWSG_ExtCpl, "AC")
  5.097  MATH         ModSrc = "FM_ExtAC"
  5.098  ELSEIF       ZCMP(@UWSG_ExtCpl, "DC")
  5.099  MATH         ModSrc = "FM_ExtDC"
  5.100  ELSE
  5.101  MATH         ModSrc = "FM_Ext"
  5.102  ENDIF

  5.103  ENDIF

  5.104  IF           NOT(EMPTY(ModSrc))
  5.105  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, ModSrc)
  5.106  CALL         Sub Send Command /UWSG
  5.107  ENDIF

  5.108  ENDIF        ; IF Modulation Source

# -----  Modulation Frequency.
  5.109  IF           NOT(EMPTY(@UWSG_ModFreq))
  5.110  MATH         ModFreq = BASE(@UWSG_ModFreq); ModFreqCmd = ""

# Use discrete command for 400 Hz Mod. Freq., if one exists.
  5.111  IF           ModFreq == 400
  5.112  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "FM_Int400Hz")
# Otherwise use discrete command for 1 kHz Mod. Freq., if one exists.
  5.113  ELSEIF       ModFreq == 1E+3
  5.114  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "FM_Int1kHz")
  5.115  ENDIF

# Otherwise use the general command.
  5.116  IF           EMPTY(ModFreqCmd)
  5.117  MATH         ModFreqCmd = RINFE(@UWSG_ProgSecName, "FM_ModFreq")
  5.118  MATH         @UWSG_Cmd = REPL("<val>", ModFreq, ModFreqCmd)
  5.119  ENDIF

  5.120  CALL         Sub Send Command /UWSG
  5.121  ENDIF        ; IF Modulation Frequency

# -----  FM Deviation
  5.122  IF           NOT(EMPTY(@UWSG_FM_Dev))
  5.123  MATH         FMDevCmd = RINFE(@UWSG_ProgSecName, "FM_Dev")
  5.124  MATH         @UWSG_Cmd = REPL("<val>", BASE(@UWSG_FM_Dev), FMDevCmd)
  5.125  CALL         Sub Send Command /UWSG
  5.126  ENDIF

# FM On programming command string.
  5.127  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "FM_ON")

  5.128  IF           NOT(EMPTY(@UWSG_Cmd))
  5.129  CALL         Sub Send Command /UWSG
  5.130  ENDIF

  5.131  ENDIF        ; IF FM

# -----  Phase Modulation  ------------------------

  5.132  IF           NOT(EMPTY(@UWSG_PM))

# -----  Modulation Source
  5.133  IF           NOT(EMPTY(@UWSG_ModSrc))

  5.134  IF           ZCMPI(@UWSG_ModSrc, "Int")
  5.135  MATH         ModSrc = "PM_Int"
  5.136  ELSE

  5.137  IF           ZCMP(@UWSG_ExtCpl, "AC")
  5.138  MATH         ModSrc = "PM_ExtAC"
  5.139  ELSEIF       ZCMP(@UWSG_ExtCpl, "DC")
  5.140  MATH         ModSrc = "PM_ExtDC"
  5.141  ELSE
  5.142  MATH         ModSrc = "PM_Ext"
  5.143  ENDIF

  5.144  ENDIF

  5.145  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, ModSrc)
  5.146  CALL         Sub Send Command /UWSG
  5.147  ENDIF        ; IF Modulation Source

# -----  Modulation Frequency
  5.148  IF           NOT(EMPTY(@UWSG_ModFreq))
  5.149  MATH         ModFreq = BASE(@UWSG_ModFreq); ModFreqCmd = ""

# Use discrete command for 400 Hz Mod. Freq., if one exists.
  5.150  IF           ModFreq == 400
  5.151  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "PM_Int400Hz")
# Otherwise use discrete command for 1 kHz Mod. Freq., if one exists.
  5.152  ELSEIF       ModFreq == 1E+3
  5.153  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "PM_Int1kHz")
  5.154  ENDIF

# Otherwise use the general command.
  5.155  IF           EMPTY(ModFreqCmd)
  5.156  MATH         ModFreqCmd = RINFE(@UWSG_ProgSecName, "PM_ModFreq")
  5.157  MATH         @UWSG_Cmd = REPL("<val>", ModFreq, ModFreqCmd)
  5.158  ENDIF

  5.159  CALL         Sub Send Command /UWSG
  5.160  ENDIF        ; IF Modulation Frequency

# -----  Phase Deviation
  5.161  IF           NOT(EMPTY(@UWSG_PM_Dev))
  5.162  MATH         PMDevCmd = RINFE(@UWSG_ProgSecName, "PM_Dev")
  5.163  MATH         @UWSG_Cmd = REPL("<val>", BASE(@UWSG_PM_Dev), PMDevCmd)
  5.164  CALL         Sub Send Command /UWSG
  5.165  ENDIF

# Get the Phase Modulation On programming command string.
  5.166  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "PM_ON")

  5.167  IF           NOT(EMPTY(@UWSG_Cmd))
  5.168  CALL         Sub Send Command /UWSG
  5.169  ENDIF

  5.170  ENDIF        ; IF PM

# -----  Pulse Modulation  ------------------------

  5.171  IF           NOT(EMPTY(@UWSG_PL))

# -----  Modulation Source
  5.172  IF           NOT(EMPTY(@UWSG_ModSrc))
# Check modulation source selection capability.
  5.173  MATH         PL_SrcSel = RINF(@UWSG_ProgSecName, "PL_SourceSelect")

  5.174  IF           ZCMPI(PL_SrcSel, "Programmable")

  5.175  IF           ZCMPI(@UWSG_ModSrc, "Int")
  5.176  MATH         ModSrc = "PL_Int"
  5.177  ELSE
  5.178  MATH         ModSrc = "PL_Ext"
  5.179  ENDIF

  5.180  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, ModSrc)
  5.181  CALL         Sub Send Command /UWSG

  5.182  ELSEIF       ZCMPI(PL_SrcSel, "Fixed")
  5.183  MATH         PL_FxdSource = RINFE(@UWSG_ProgSecName, "PL_Source")

  5.184  IF           NOT(ZCMPI(PL_FxdSource, @UWSG_ModSrc))
  5.185  DISP         The required Pulse Modulation Source ([V @UWSG_ModSrc])
  5.185  DISP         capability is not supported for the configured
  5.185  DISP         [V @UWSG_DevName].
  5.185  DISP
  5.185  DISP         [V @UWSG_DevName] only supports fixed ([V PL_FxdSource])
  5.185  DISP         source for pulse modulation.  The calling procedure
  5.185  DISP         requires an "[V @UWSG_ModSrc]" source.
  5.185  DISP
  5.185  DISP         Select "Terminate" to abort this procedure, configure
  5.185  DISP         a suitable UWSG model, then restart this procedure.
  5.186  END
  5.187  ENDIF

  5.188  ELSE
  5.189  DISP         The required Pulse Modulation Source ([V @UWSG_ModSrc])
  5.189  DISP         capability is not supported for the configured
  5.189  DISP         [V @UWSG_DevName].
  5.189  DISP
  5.189  DISP         This may be due to a lack of hardware capability, or
  5.189  DISP         lack of support within user_config_instr.ini.
  5.189  DISP
  5.189  DISP         Select "Terminate" to abort this procedure.  Either
  5.189  DISP         configure a suitable UWSG model or add the required
  5.189  DISP         parameters to user_config_instr.ini, then restart this
  5.189  DISP         procedure.
  5.190  END
  5.191  ENDIF        ; PL Source Selection

  5.192  ENDIF        ; NOT(EMPTY(@UWSG_ModSrc))

# -----  Modulation Frequency
  5.193  IF           NOT(EMPTY(@UWSG_ModFreq))
  5.194  MATH         ModFreq = BASE(@UWSG_ModFreq); ModFreqCmd = ""

# Use discrete command for 400 Hz Mod. Freq., if one exists.
  5.195  IF           ModFreq == 400
  5.196  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "PL_Int400Hz")
# Otherwise use discrete command for 1 kHz Mod. Freq., if one exists.
  5.197  ELSEIF       ModFreq == 1E+3
  5.198  MATH         ModFreqCmd = RINF(@UWSG_ProgSecName, "PL_Int1kHz")
  5.199  ENDIF

# Otherwise use the general Mod. Freq. command.
  5.200  IF           EMPTY(ModFreqCmd)
  5.201  MATH         ModFreqCmd = RINFE(@UWSG_ProgSecName, "PL_ModFreq")
  5.202  MATH         @UWSG_Cmd = REPL("<val>", ModFreq, ModFreqCmd)
  5.203  ENDIF

  5.204  CALL         Sub Send Command /UWSG
  5.205  ENDIF        ; IF Modulation Frequency

# -----  Pulse Width
  5.206  IF           NOT(EMPTY(@UWSG_PL_Width))
  5.207  MATH         PLWidthCmd = RINFE(@UWSG_ProgSecName, "PL_Width")
  5.208  MATH         PLWidth = BASE(@UWSG_PL_Width)
  5.209  MATH         @UWSG_Cmd = REPL("<val>", PLWidth, PLWidthCmd)
  5.210  CALL         Sub Send Command /UWSG
  5.211  ENDIF

# -----  Pulse Delay
  5.212  IF           NOT(EMPTY(@UWSG_PL_Delay))
  5.213  MATH         PLDelayCmd = RINFE(@UWSG_ProgSecName, "PL_Delay")
  5.214  MATH         PLDelay = BASE(@UWSG_PL_Delay)
  5.215  MATH         @UWSG_Cmd = REPL("<val>", PLDelay, PLDelayCmd)
  5.216  CALL         Sub Send Command /UWSG
  5.217  ENDIF

# -----  Pulse Impedance
  5.218  IF           NOT(EMPTY(@UWSG_PL_Imp))
  5.219  MATH         PLImpCmd = RINF(@UWSG_ProgSecName, "PL_Imp")
  5.220  MATH         PLImp = BASE(@UWSG_PL_Imp)
  5.221  MATH         @UWSG_Cmd = REPL("<val>", PLImp, PLImpCmd)
  5.222  CALL         Sub Send Command /UWSG
  5.223  ENDIF        ; IF Pulse Impedance

# -----  Pulse Slope
  5.224  IF           NOT(EMPTY(@UWSG_PL_Slope))

  5.225  IF           ZCMPI(@UWSG_PL_Slope, "Pos")
  5.226  MATH         PLSlope = "PL_SlopePos"
  5.227  ELSE
  5.228  MATH         PLSlope = "PL_SlopeNeg"
  5.229  ENDIF

  5.230  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, PLSlope)
  5.231  CALL         Sub Send Command /UWSG
  5.232  ENDIF

# -----  Pulse Conditioning
  5.233  IF           NOT(EMPTY(@UWSG_PL_Cond))

  5.234  IF           ZCMPI(@UWSG_PL_Cond, "On")
  5.235  MATH         PLCond = "PL_CondOn"
  5.236  ELSE
  5.237  MATH         PLCond = "PL_CondOff"
  5.238  ENDIF

  5.239  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, PLCond)
  5.240  CALL         Sub Send Command /UWSG
  5.241  ENDIF

# Get the Pulse Modulation On programming command string.
  5.242  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "PL_ON")

  5.243  IF           NOT(EMPTY(@UWSG_Cmd))
  5.244  CALL         Sub Send Command /UWSG
  5.245  ENDIF

  5.246  ENDIF        ; NOT(EMPTY(@UWSG_PL))

# -----  Reference Oscillator  --------------------

  5.247  IF           NOT(EMPTY(@UWSG_ROSC))

  5.248  IF           ZCMPI(@UWSG_ROSC, "Int")
  5.249  MATH         RefOsc = "RefOscInt"
  5.250  ELSE
  5.251  MATH         RefOsc = "RefOscExt"
  5.252  ENDIF

  5.253  MATH         RefSelect = RINF(@UWSG_ProgSecName, "RefSelect")

  5.254  IF           ZCMPI(RefSelect, "Manual")

# Only prompt for switch selection when the desired setting does not match the
# current setting.
  5.255  IF           NOT(ZCMPI(@UWSG_ROSC, @UWSG_ROSC_Set))
  5.256  MATH         Switch = RINFE(@UWSG_ProgSecName, "RefOscSwitch")
  5.257  MATH         Setting = RINFE(@UWSG_ProgSecName, RefOsc)
  5.258  DISP         Set [V @UWSG_DevName] [V Switch] switch to [V Setting].
  5.258  DISP         [7][D250][7][D250][7][D250][7][D250][7]
  5.259  MATH         @UWSG_ROSC_Set = @UWSG_ROSC
  5.260  ENDIF        ; Prompt to set Reference Oscillator switch

  5.261  ELSEIF       ZCMPI(RefSelect, "Auto")
# Automatic selection by UUT, nothing to do here.

  5.262  ELSE         ; Programmable
  5.263  MATH         @UWSG_Cmd = RINFE(@UWSG_ProgSecName, RefOsc)
  5.264  CALL         Sub Send Command /UWSG
  5.265  ENDIF

  5.266  ENDIF        ; IF Reference Oscillator

# -----  Output On  -------------------------------

  5.267  MATH         @UWSG_Cmd = RINF(@UWSG_ProgSecName, "OutputOn")

# If "Output_On" is defined, send the command.
  5.268  IF           NOT(EMPTY(@UWSG_Cmd))
  5.269  CALL         Sub Send Command /UWSG
  5.270  ENDIF

  5.271  END

  5.272  EVAL   Increment test number


# =====  Sub Get Options /UWSG  =============================================

  6.001  LABEL        GET_OPTIONS

# Check for the variable flag that indicates whether options have previously
# been configured.  This flag will prevent the driver from asking for option
# configuration more than once.  Initialize variable if it does not exist.
  6.002  IF           NOT(ISVAR("@UWSG_Opt_Set"))
  6.003  MATH         @UWSG_FreqOpt = ""; @UWSG_AmplOpt = ""

# Check for Fluke 6080A/82A fitted options.
  6.004  MATH         F608x = FINDI(@UWSG_DevName, "6080", 1)
  6.005  MATH         F608x = FINDI(@UWSG_DevName, "6082", 1) || F608x

  6.006  IF           F608x
  6.007  OPBR         -z The Fluke 6080A/82A Synthesized RF Signal Generators
  6.007  OPBR         Sweepers may include Options -130 or -132 that affect
  6.007  OPBR         its frequency specifications.
  6.007  OPBR
  6.007  OPBR         Does the configured unit have either Option -130 or
  6.007  OPBR         Option -132 fitted?
  6.007  OPBR         [7][D250][7][D250][7][D250][7][D250][7]

  6.008  IF           MEM1
  6.009  OPBR         -z Does the configured unit have Option -130 fitted?

  6.010  IF           MEM1
  6.011  MATH         @UWSG_FreqOpt = "130"
  6.012  ELSE
  6.013  MATH         @UWSG_FreqOpt = "132"
  6.014  ENDIF

  6.015  ENDIF

  6.016  ENDIF        ; F608x

# Check for HP 8340/8341 fitted options.
  6.017  MATH         HP834x = FINDI(@UWSG_DevName, "8340", 1)
  6.018  MATH         HP834x = FINDI(@UWSG_DevName, "8341", 1) || HP834x

  6.019  IF           HP834x
  6.020  OPBR         -z The HP 8340/8341 Synthesized Sweepers may include
  6.020  OPBR         Options 001, 004, or 005 that affects amplitude
  6.020  OPBR         specifications. (The above options are mutually
  6.020  OPBR         exclusive.)
  6.020  OPBR
  6.020  OPBR         Does the configured unit have any of the above
  6.020  OPBR         options fitted?
  6.020  OPBR         [7][D250][7][D250][7][D250][7][D250][7]

  6.021  IF           MEM1

  6.022  DO
  6.023  MEMI         Enter the fitted option number (001, 004, 005):
# Format option correctly for use in mode string.
  6.024  MATH         Opt = FMT(MEM, "%03.0f")
  6.025  UNTIL        (MEM == 1) || (MEM == 4) || (MEM == 5)

  6.026  MATH         @UWSG_AmplOpt = Opt
  6.027  ENDIF

  6.028  ENDIF        ; HP834x

# Check for all HP/Agilent models which have different amplitude accuracy
# when equipped with Option 001.
  6.029  MATH         Opt001_A = FINDI(@UWSG_DevName, "83620", 1)
  6.030  MATH         Opt001_A = FINDI(@UWSG_DevName, "83622", 1) || Opt001_A
  6.031  MATH         Opt001_A = FINDI(@UWSG_DevName, "83623", 1) || Opt001_A
  6.032  MATH         Opt001_A = FINDI(@UWSG_DevName, "83624", 1) || Opt001_A
  6.033  MATH         Opt001_A = FINDI(@UWSG_DevName, "83630", 1) || Opt001_A
  6.034  MATH         Opt001_A = FINDI(@UWSG_DevName, "83640", 1) || Opt001_A
  6.035  MATH         Opt001_A = FINDI(@UWSG_DevName, "83650", 1) || Opt001_A

  6.036  IF           Opt001_A
  6.037  IEEE         [@UWSG]*OPT?[I$]

  6.038  IF           FINDI(MEM2, "001", 1)
  6.039  MATH         @UWSG_AmplOpt = "001"
  6.040  ENDIF

  6.041  ENDIF        ; Opt001_A

# Check for HP 8648A/B/C/D fitted options.
  6.042  IF           FINDI(@UWSG_DevName, "8648", 1)
  6.043  OPBR         -z The HP 8648A/B/C/D Synthesized Signal Generators
  6.043  OPBR         may include Option 1E5 that affects frequency
  6.043  OPBR         specifications.
  6.043  OPBR
  6.043  OPBR         Does the configured unit have Option 1E5 fitted?
  6.043  OPBR         [7][D250][7][D250][7][D250][7][D250][7]

  6.044  IF           MEM1
  6.045  MATH         @UWSG_FreqOpt = "1E5"
  6.046  ENDIF

  6.047  ENDIF

# Check for all HP/Agilent models which have different frequency accuracy
# when equipped with Option 001.
  6.048  MATH         Opt001_F = FINDI(@UWSG_DevName, "8656", 1)
  6.049  MATH         Opt001_F = FINDI(@UWSG_DevName, "8657", 1) || Opt001_F

  6.050  IF           Opt001_F
  6.051  OPBR         -z The [V @UWSG_DevName] may include Option 001,
  6.051  OPBR         which affects frequency specifications.
  6.051  OPBR
  6.051  OPBR         Does the configured unit have Option 001 fitted?
  6.051  OPBR         [7][D250][7][D250][7][D250][7][D250][7]

  6.052  IF           MEM1
  6.053  MATH         @UWSG_FreqOpt = "001"
  6.054  ENDIF

  6.055  ENDIF        ; Opt001_F

# Check for R&S SMF100A fitted options.
  6.056  IF           FINDI(@UWSG_DevName, "SMF100A", 1)
  6.057  SCPI         [@UWSG]*OPT?[I$]

  6.058  IF           FINDI(MEM2, "SMF-B1,", 0)
  6.059  MATH         @UWSG_FreqOpt = "SMF-B1"
  6.060  ENDIF

  6.061  ENDIF        ; SMF100A

# Set flag indicating that options have already been configured.
  6.062  MATH         @UWSG_Opt_Set = 1
  6.063  ENDIF        ; NOT(@UWSG_Opt_Set)

  6.064  END

  6.065  EVAL   Increment Step Number


# =====  Sub Get Accuracy /UWSG  ============================================

  7.001  LABEL        GET_ACCURACY

# -----  Cardinal Point: Frequency  ---------------
  7.002  IF           ZCMPI(@UWSG_CPT, "Freq")
# Specify Nominal value of parameter.
  7.003  MATH         @UWSG_Nominal = @UWSG_Freq
# Specify third and fourth ACCV2 arguments (frequency and amplitude).
  7.004  MATH         FreqBase = BASE(@UWSG_Freq)
  7.005  MATH         AmplBase = BASE(@UWSG_Ampl)
# Specify UWSG frequency mode string in ModeStr from ini file.
  7.006  MATH         ModeStr = RINFE(@UWSG_DevName, "ModeStringFreq")

# Check for option that affects accuracy.
  7.007  IF           NOT(EMPTY(@UWSG_FreqOpt))
# Append option to mode string.
  7.008  MATH         ModeStr = ModeStr & " " & @UWSG_FreqOpt
  7.009  ENDIF        ; Options

# Retrieve UWSG frequency accuracy.
  7.010  MATH         Acc = ACCV2(@UWSG_DevName, ModeStr, FreqBase, AmplBase)

# -----  Cardinal Point: Amplitude  ---------------
  7.011  ELSEIF       ZCMPI(@UWSG_CPT, "Ampl")
  7.012  MATH         @UWSG_Nominal = @UWSG_Ampl
  7.013  MATH         FreqBase = BASE(@UWSG_Freq)
  7.014  MATH         AmplBase = BASE(@UWSG_Ampl)
  7.015  MATH         ModeStr = RINFE(@UWSG_DevName, "ModeStringAmpl")

  7.016  IF           NOT(EMPTY(@UWSG_AmplOpt))
  7.017  MATH         ModeStr = ModeStr & " " & @UWSG_AmplOpt
  7.018  ENDIF        ; Options

  7.019  MATH         Acc = ACCV2(@UWSG_DevName, ModeStr, AmplBase, FreqBase)

# -----  Cardinal Point: Flatness  ----------------
  7.020  ELSEIF       ZCMPI(@UWSG_CPT, "Flat")

  7.021  MATH         @UWSG_Nominal = @UWSG_Ampl
  7.022  MATH         FreqBase = BASE(@UWSG_Freq)
  7.023  MATH         AmplBase = BASE(@UWSG_Ampl)
  7.024  MATH         ModeStr = RINFE(@UWSG_DevName, "ModeStringFlat")

  7.025  IF           NOT(EMPTY(@UWSG_AmplOpt))
  7.026  MATH         ModeStr = ModeStr & " " & @UWSG_AmplOpt
  7.027  ENDIF        ; Options

  7.028  MATH         Acc = ACCV2(@UWSG_DevName, ModeStr, AmplBase, FreqBase)

  7.029  ENDIF        ; Cardinal point parameters.

# Get value of VSET parameter, confidence value.
  7.030  MATH         Confidence = VGET("CONF")

# VGET query returns empty string if CONF is set to default (2).
  7.031  IF           EMPTY(Confidence)
  7.032  MATH         Confidence = 2
  7.033  ENDIF

  7.034  MATH         Acc = (Acc / CONF(@UWSG_DevName)) * Confidence

# Convert to specified units of ACC nominal (e.g. GHz).
  7.035  MATH         @UWSG_Acc = Acc / PSCALE(@UWSG_Nominal)

  7.036  END
