# -*- coding: utf-8 -*-
"""

@author: David S. De Lorenzo

This script controls the following devices:
    1. two HP-8648C signal generators at GPIB addresses 16 & 18
    2. two DAT64L digital step attenuators on COM ports 4 & 22

"""


import dat64L
import hp8648C


# This is the maximum output power
# of the HP-8648C signal generator.
MAX_OUTPUT_POWER_dBm = 10.0

# Write the attenuation values to HW
dat64L.set_attenuation_dB(4, 10)    # 10 dB attenuation on COM 4
dat64L.set_attenuation_dB(22, 10)   # 10 dB attenuation on COM 22

# Set the HP signal generator at GPIB 16 to 1580.42 MHz
hp = hp8648C.device_connect(16)
hp.set_freq_MHz(1580.42)
if hp.get_power_dBm() != MAX_OUTPUT_POWER_dBm:
    hp.set_power_dBm(MAX_OUTPUT_POWER_dBm)
if hp.is_rf_on() != 1:
    hp.set_rf_on()
hp.disconnect()

# Set the HP signal generator at GPIB 18 to 1579.0 MHz
hp = hp8648C.device_connect(18)
hp.set_freq_MHz(1579.0)
if hp.get_power_dBm() != MAX_OUTPUT_POWER_dBm:
    hp.set_power_dBm(MAX_OUTPUT_POWER_dBm)
if hp.is_rf_on() != 1:
    hp.set_rf_on()
hp.disconnect()
