#This program enables to test any of the methods of the classes AFG5000 and AWG5000
import pyvisa
import AFG_7000
from AFG_7000 import Channel
from AFG_7000 import State
from AFG_7000 import VoltageUnit
from AFG_7000 import Value
from AFG_7000 import Shape1
from AFG_7000 import ModulatingSource
from AFG_7000 import ModulatingInput
from AFG_7000 import ModulatingShape
from AFG_7000 import SweepMode
from AFG_7000 import TriggerMode
from AFG_7000 import SweepShape
from AFG_7000 import BurstMode
from AFG_7000 import Ncycles
from AFG_7000 import WaitState
from AFG_7000 import NoiseState
from AFG_7000 import Polarity
from AFG_7000 import ChannelOptimization
from AFG_7000 import ClockSource
from AFG_7000 import ExtClockFrequency
from AFG_7000 import SyncClockOutFrequency
from AFG_7000 import APP
from AFG_7000 import BufferTarget
from AFG_7000 import Memory
from AFG_7000 import ArbitraryWaveformSource
from AFG_7000 import TriggerSource
from AFG_7000 import Slope
from AFG_7000 import Impedance
from AFG_7000 import Speed
from AFG_7000 import Trigger

try:
    # Initialize VISA
    rm = pyvisa.ResourceManager()

    # List connected resources
    resources = rm.list_resources()
    print(f"\n\n\nConnected devices: {resources}")

    #Intrumetn TCP/IP address
    address_listed = resources[1]
    address_not_listed = "TCPIP0::192.168.0.59::inst0::INSTR"

    #If you use NI MAX or similar, you can also use one of the adresses in the list 
    master = rm.open_resource(address_not_listed)

    #Master Encoding: Necessary if you use non-ascii characters, like accented vocals.
    master.encoding = "latin-1"

    # Ask device ID
    idn = master.query("*IDN?")
    print(f"The device's ID is: {idn}\n")

    #Initialize AWG_5062
    Master = AFG_7000.AFG7000(master)





    #Instructions to try
    val = Value.PRESENT
    Master.ConfigureChannelCouplingNoiseOrDC(Channel.Channel2, State.ON, 0, 0)
    #print(f"Instrument answer: {Master.GetArbitraryPoints(Channel.Channel1, val, BufferTarget.Carrier)}")
except Exception as e: print(f"The following exception has occured: {e}")