示例#1
0
文件: VSA.py 项目: supergravity/PYQUM
def Configure_Acquisition(session, PreselectorEnabled, Frequency, Power, Bandwidth, Time, TriggerSource):
    '''
    Sets the most-often used measurement parameters. These settings have no effect on the hardware until Measurements.Initiate() is called.
    PreselectorEnabled 
    Set to true to enable the Preselector. Set to false to select the "Bypass" path (changes the microwave downcoverter [M9361A] RF input range to 2.25 GHz to 26.5 GHz). Requires a Preselector (M9360A) module in the configuration.
    Frequency 
    The nominal (sometimes called center) frequency, in hertz, of the signal to be measured. The allowable range of values depend on hardware configuration, absolute limits are 50 MHz to 26.5 GHz. This parameter sets Acquisition Frequency.
    Power 
    Expected RMS power of the input signal, in dBm. Limits depend on hardware configuration. Absolute max is +30 dBm. This parameter sets Acquisition Power.
    Bandwidth 
    The digital IF will be configured to provide at least the bandwidth specified. The allowable range of values depend on hardware configuration. The absolute maximum is 250 MHz. This parameter sets Acquisition Bandwidth.
    Time 
    Approximate acquisition time of the measurement, in seconds. The allowable range of values depend on bandwidth, absolute maximum is 100 seconds. This parameter sets Acqusition Time. NOTE: The minimum settable acquisition time is the larger of the two quantities: 3/SampleRate and 1e-8 seconds (that is, 10ns).
    TriggerSource 
    The trigger source. May be AgM9392TriggerSourceImmediate, AgM9392TriggerSourceVideo, AgM9392TriggerSourceExternal. This parameter sets Trigger Source.
    '''
    AGM = dll.AgM9392_ConfigureAcquisition
    AGM.restype = c_int
    status = AGM(c_long(session), c_bool(PreselectorEnabled), c_double(Frequency), c_double(Power), c_double(Bandwidth), c_double(Time), c_long(TriggerSource))
    if status == 0:
        set_status(mdlname, dict(Acquisition="Configured Successfully"))
    else: set_status(mdlname, dict(Acquisition="Error: " + str(status)))
    if eval(debugger):
        print(Fore.LIGHTGREEN_EX + "%s's acquisition configured: %s" % (mdlname, status_code(status)))
    return status_code(status)
示例#2
0
def char_cwsweep_resume():
    set_status("CW_Sweep", dict(pause=False))
    wday = int(request.args.get('wday'))
    wmoment = int(request.args.get('wmoment'))
    fluxbias = request.args.get('fluxbias')
    xyfreq = request.args.get('xyfreq')
    xypowa = request.args.get('xypowa')
    sparam = request.args.get('sparam')
    ifb = request.args.get('ifb')
    freq = request.args.get('freq')
    powa = request.args.get('powa')
    CORDER = {
        'Flux-Bias': fluxbias,
        'XY-Frequency': xyfreq,
        'XY-Power': xypowa,
        'S-Parameter': sparam,
        'IF-Bandwidth': ifb,
        'Frequency': freq,
        'Power': powa
    }
    M_cwsweep[session['user_name']].accesstructure()
    CW_Sweep(session['people'],
             corder=CORDER,
             dayindex=wday,
             taskentry=wmoment,
             resumepoint=M_cwsweep[session['user_name']].resumepoint)
    return jsonify(resumepoint=str(
        M_cwsweep[session['user_name']].resumepoint),
                   datasize=str(M_cwsweep[session['user_name']].datasize))
示例#3
0
def char_fresp_new():
    # Check user's current queue status:
    if session['run_clearance']:
        set_status("F_Response", dict(pause=False))
        global Run_fresp  # need to be removed in the future for security sake
        wday = int(request.args.get('wday'))
        print("wday: %s" % wday)
        fluxbias = request.args.get('fluxbias')
        sparam = request.args.get('sparam')
        ifb = request.args.get('ifb')
        powa = request.args.get('powa')
        freq = request.args.get('freq')
        comment = request.args.get('comment').replace("\"", "")
        simulate = bool(int(request.args.get('simulate')))
        CORDER = {
            'Flux-Bias': fluxbias,
            'S-Parameter': sparam,
            'IF-Bandwidth': ifb,
            'Power': powa,
            'Frequency': freq
        }
        Run_fresp = F_Response(session['people'],
                               corder=CORDER,
                               comment=comment,
                               tag='',
                               dayindex=wday,
                               testeach=simulate)
    else:
        all()
    return jsonify(testeach=simulate)
示例#4
0
def char_cwsweep_new():
    # Check user's current queue status:
    if session['run_clearance']:
        set_status("CW_Sweep", dict(pause=False))
        global Run_cwsweep  # for ETA calculation as well
        wday = int(request.args.get('wday'))
        print("wday: %s" % wday)
        fluxbias = request.args.get('fluxbias')
        xyfreq = request.args.get('xyfreq')
        xypowa = request.args.get('xypowa')
        sparam = request.args.get('sparam')
        ifb = request.args.get('ifb')
        freq = request.args.get('freq')
        powa = request.args.get('powa')
        comment = request.args.get('comment').replace("\"", "")
        simulate = bool(int(request.args.get('simulate')))
        CORDER = {
            'Flux-Bias': fluxbias,
            'XY-Frequency': xyfreq,
            'XY-Power': xypowa,
            'S-Parameter': sparam,
            'IF-Bandwidth': ifb,
            'Frequency': freq,
            'Power': powa
        }
        Run_cwsweep = CW_Sweep(session['people'],
                               corder=CORDER,
                               comment=comment,
                               tag='',
                               dayindex=wday,
                               testeach=simulate)
    else:
        all()
    return jsonify(testeach=simulate)
示例#5
0
文件: AWG.py 项目: RuRu110307/PYQUM
def InitWithOptions(IdQuery=False,
                    Reset=False,
                    OptionsString='Simulate=false, DriverSetup=DDS=false'):
    '''[Initialize the connection]
    status = InitWithOptions(IdQuery, Reset, OptionsString)
    '''
    # rs = address(mdlname, reset=eval(debugger)) # Instrument's Address
    ad = address()
    rs = ad.lookup(mdlname, 2)  # Instrument's Address
    Resource = bytes(rs, 'ascii')
    Option = bytes(OptionsString, 'ascii')  # utf-8
    Session = c_long()

    AGM = dll.AgM933x_InitWithOptions  # from AgM933x.chm
    AGM.restype = c_int
    status = AGM(c_char_p(Resource), c_bool(IdQuery), c_bool(Reset),
                 c_char_p(Option), byref(Session))
    msession = Session.value
    if status == 0:
        set_status(mdlname,
                   dict(state="Initialized Successfully", session=msession))
    else:
        set_status(mdlname, dict(state="Error: " + str(status)))
        msession = get_status(mdlname)["session"]
    print(Fore.GREEN + "%s's connection Initialized at session %s: %s" %
          (mdlname, msession, status_code(status)))

    return msession
示例#6
0
def Initiate(reset=False, current=False):
    ad = address()
    rs = ad.lookup(mdlname)  # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(
            rs)  #establishing connection using GPIB# with the machine
        if reset:
            bench.write('RC')  #Clear buffer memory
        if current:
            stat = bench.write(
                'H0;F5;M1')  #No header; DC current in A; Single sweep
        else:
            stat = bench.write(
                'H0;F1;M1')  #No header; DC current in V; Single sweep
        bench.read_termination = '\n'  #omit termination tag from output
        bench.timeout = 15000  #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" %
              (mdlname, str(stat[1])[-7:]))
    except:
        # raise
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#7
0
文件: ENA.py 项目: supergravity/PYQUM
def Initiate(reset=False):
    ad = address()
    rs = ad.lookup(mdlname)  # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(
            rs)  #establishing connection using GPIB# with the machine
        if reset:
            stat = bench.write('*RST;*CLS')  #Clear buffer memory;
        else:
            bench.write(':ABORt;:INIT:CONT OFF;')  #hold the trigger
            stat = bench.write('*CLS')  #Clear buffer memory;
            bench.write('OUTPut:STATE ON')  #open the port
        bench.write(
            "SENS:CORR:EXT:AUTO:RESet")  #clear port-extension auto-correction
        bench.read_termination = '\n'  #omit termination tag from output
        bench.timeout = 80000000  #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" %
              (mdlname, str(stat[1])[-7:]))
    except:
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#8
0
文件: VSA.py 项目: LanHsuanLee/PYQUM
def Get_Data(session, ComplexDataBufferSize):
    """[Extracting Complex Data]
    Gets the I/Q measurement results.
    ComplexData:
        Array to hold the measurement data. Allocated by the caller (for performance). 
        The array size should be >= 2 * Measurements.NumberOfSamples (2* since the array will hold interleaved complex data)
    """
    AGM = dll.AgM9392_GetData
    AGM.restype = c_int
    ComplexData = (c_double * int(ComplexDataBufferSize))()
    ComplexDataActualSize = c_long()
    NumberCopied = c_long()
    status = AGM(c_long(session), c_long(ComplexDataBufferSize),
                 byref(ComplexData), byref(ComplexDataActualSize),
                 byref(NumberCopied))
    answer = {}
    answer["ComplexData"] = [x for x in ComplexData]
    answer["ComplexDataActualSize"], answer[
        "NumberCopied"] = ComplexDataActualSize.value, NumberCopied.value
    if status == 0:
        set_status(mdlname, {stack()[0][3]: answer
                             })  #logging the name and value of the attribute
    else:
        set_status(mdlname, {stack()[0][3]: "Error: " + str(status)})
    if eval(debugger):
        print(Fore.LIGHTWHITE_EX +
              "%s out of %s actual %s's Data extracted & copied: %s" %
              (NumberCopied.value, ComplexDataActualSize.value, mdlname,
               status_code(status)))
    return status, answer
示例#9
0
文件: RDS.py 项目: supergravity/PYQUM
    def wrapper(*a, **b):

        global debug
        bench, SCPIcore, action = Name(*a, **b)
        SCPIcore = SCPIcore.split(";")
        headers = SCPIcore[0].split(':')
        parakeys, paravalues, getspecific, command = [headers[-1]] + SCPIcore[1:], [], [], []

        if action[0] == 'Get':
            try:
                for i in range(len(parakeys)):
                    if len(str(action[i+1])) > 0: #special type of query (e.g. commentstate)
                        getspecific.append(" " + str(action[i+1]))
                    else: getspecific.append('')
                    command.append(parakeys[i] + "?" + getspecific[i])

                command = ':'.join(headers[:-1] + [";".join(command)])
                paravalues = bench.query(command).split(';')
                #just in case of the presence of query parameters, which is rare
                paravalues = [paravalues[i] + '(' + str(action[i+1]) + ')' for i in range(len(parakeys))]
                paravalues = [x.replace('()', '') for x in paravalues]

                status = "Success"
            except: # get out of the method with just return-value at exception?
                status = "query unsuccessful"
                ans = None

        if action[0] == 'Set':

            for i in range(len(parakeys)):
                if str(action[i+1]) == '':
                    paravalues.append("NIL") # allow for arbitrary choosing
                else: 
                    paravalues.append(str(action[i+1]))
                    command.append(parakeys[i] + " " + paravalues[i])

            command = ':'.join(headers[:-1] + [";".join(command)])
            status = str(bench.write(command)[1])[-7:]
            
        # formatting return answer
        ans = dict(zip([a.replace('*','') for a in parakeys], paravalues))

        # Logging answer
        if action[0] == 'Get': # No logging for "Set"
            set_status(mdlname, {Name.__name__ : ans})

        # debugging
        if eval(debugger):
            print(Fore.BLUE + "SCPI Command: {%s}" %command)
            if action[0] == 'Get':
                print(Fore.YELLOW + "%s %s's %s: %s <%s>" %(action[0], mdlname, Name.__name__, ans, status))
            if action[0] == 'Set':
                print(Back.YELLOW + Fore.MAGENTA + "%s %s's %s: %s <%s>" %(action[0], mdlname, Name.__name__ , ans, status))

        return status, ans
示例#10
0
文件: VSA.py 项目: supergravity/PYQUM
def close(session):
    '''[Close the connection]
    '''
    AGM = dll.AgM9392_close
    AGM.restype = c_int
    status = AGM(c_long(session))
    if status == 0:
        set_status(mdlname, dict(state="Closed Successfully"))
    else: set_status(mdlname, dict(state="Error: " + str(status)))
    print(Back.WHITE + Fore.BLACK + "%s's connection Closed: %s" %(mdlname, status_code(status)))
    return status
示例#11
0
def Initiate():
    rs = address(mdlname, reset=eval(debugger))  # Instrument's Address
    rm = visa.ResourceManager()
    bench = rm.open_resource(
        rs)  #establishing connection using GPIB# with the machine
    stat = bench.write('*CLS')  #Clear buffer memory
    bench.read_termination = '\n'  #omit termination tag from output
    bench.timeout = 15000  #set timeout in ms
    set_status(mdlname, dict(state='connected'))
    print(Fore.GREEN + "%s's connection Initialized: %s" %
          (mdlname, str(stat[1])[-7:]))
    return bench
示例#12
0
文件: AWG.py 项目: zeyanchen/PYQUM
    def wrapper(*a, **b):

        session, Type, RepCap, AttrID, buffsize, action = Name(*a, **b)
        RepCap = bytes(RepCap, "ascii")

        AGMmodel = getattr(dll, 'AgM933x_' + action[0] + 'AttributeVi' + Type)
        AGMmodel.restype = c_int  # return status (error)

        if action[0] == "Get":
            if Type == 'String':
                action[1] = (
                    c_char *
                    888)()  # char array: answer value format (use byref)
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), c_long(buffsize),
                                  byref(action[1]))
                ans = [x.decode("ascii") for x in action[1]
                       ]  # decoding binary # if x is not b'\x00'
                while '\x00' in ans:
                    ans.remove('\x00')
                ans = "".join(ans)  # join char array into string
            elif Type == 'Int32':
                action[1] = c_long()
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), byref(action[1]))
                ans = action[1].value
            elif Type == 'Real64':
                action[1] = c_double()
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), byref(action[1]))
                ans = action[1].value
        elif action[0] == "Set":
            if Type == 'String':
                ans = action[1]
                action[1] = bytes(action[1], 'ascii')
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), c_char_p(action[1]))
            elif Type == 'Int32':
                ans = action[1]
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), c_long(action[1]))
            elif Type == 'Real64':
                ans = action[1]
                status = AGMmodel(c_long(session), c_char_p(RepCap),
                                  c_int(AttrID), c_double(action[1]))
        if status == 0:
            set_status("AWG", {Name.__name__: ans
                               })  #logging the name and value of the attribute
        else:
            set_status("AWG", {Name.__name__: "Error: " + str(status)})
        print(Fore.YELLOW + "[AWG module] %s: %s, error:%s" %
              (Name.__name__, ans, status))
        return status, ans
示例#13
0
文件: AWG.py 项目: zeyanchen/PYQUM
def close(session):
    '''status = close(session)
    '''

    AGMclose = dll.AgM933x_close
    status = AGMclose(c_long(session))
    if status == 0:
        set_status("AWG", dict(state="Closed", session=session))
    else:
        set_status("AWG", dict(state="Error: " + str(status)))
    print(Back.WHITE + Fore.BLACK +
          "AWG module closed with error: %s" % status)
    return status
示例#14
0
    def wrapper(*a, **b):

        global debug
        bench, SCPIcore, action = Name(*a, **b)
        SCPIcore = SCPIcore.split(";")
        parakeys, paravalues, getspecific, command = [(SCPIcore[0]).split(':')[-1]] + SCPIcore[1:], [], [], []

        if action[0] == 'Get':
            try:
                for i in range(len(parakeys)):
                    if len(str(action[i+1])) > 0: #special type of query (e.g. commentstate)
                        getspecific.append(" " + str(action[i+1]))
                    else: getspecific.append('')
                    command.append(str(SCPIcore[i]) + "?" + getspecific[i])
                command = ";".join(command)

                paravalues = bench.query(command).split(';')
                paravalues = [paravalues[i] + '(' + str(action[i+1]) + ')' for i in range(len(parakeys))]
                paravalues = [x.replace('()', '') for x in paravalues]

                status = "Success"
            except:
                status = "query unsuccessful"
                ans = None

        if action[0] == 'Set':

            for i in range(len(parakeys)):
                paravalues.append(str(action[i+1]))
                command.append(str(SCPIcore[i]) + " " + paravalues[i])

            command = ";".join(command)
            status = str(bench.write(command)[1])[-7:]
            
        # formatting return answer
        if len(SCPIcore) > 1:
            ans = dict(zip(parakeys, paravalues))
        else: ans = paravalues[0]

        # Logging answer
        if action[0] == 'Get': # No logging for "Set"
            set_status(mdlname, {Name.__name__ : str(ans)})
        
        # debugging
        if eval(debugger):
            if action[0] == 'Get':
                print(Fore.YELLOW + "%s %s's %s: %s <%s>" %(action[0], mdlname, Name.__name__, ans, status))
            if action[0] == 'Set':
                print(Back.YELLOW + Fore.MAGENTA + "%s %s's %s: %s <%s>" %(action[0], mdlname, Name.__name__ , ans, status))

        return status, ans
示例#15
0
文件: ESG.py 项目: zeyanchen/PYQUM
def control(switch, frequency=3, power=-5):
    info = dict()
    rm = visa.ResourceManager()
    esg = rm.open_resource(
        ESGrs)  #establishing connection using GPIB# with the machine
    esg.write('*CLS')  #Clear buffer memory
    esg.write('*RST')
    esg.read_termination = '\n'  #omit termination tag from output
    esg.timeout = 15000  #set timeout in ms
    info['Identity'] = esg.query(
        '*IDN?')  #inquiring machine identity: "who r u?"

    if switch is True:
        fa, powa = frequency, power

        # esg.write(':SOUR:FREQ %sMHZ' %fa)
        stat = esg.write(':SOUR:FREQ:FIX %sMHZ' % fa)
        print("\nwrite freq:", str(stat[1]))
        print("write freq:", str(stat[1])[-7:])

        # esg.write(':SOUR:FREQ:FIX %sGHZ' %fa)

        # esg.write(':SOUR:POW %sDBM' %powa)
        stat = esg.write(':SOUR:POW:LEV %sDBM' % powa)
        print("write pow:", stat)
        # esg.write(':POWer:LEVel %sDBM' %powa)

        ans = esg.query(':SOUR:FREQ?')
        info['Frequency'] = float(ans)
        ans = esg.query(':SOUR:POW?')
        # ans = esg.query(':SOUR:POW:LEV?')
        info['Power'] = float(ans)

        # stat = esg.write('OUTP ON')
        stat = esg.write('OUTP:STAT 1')
        print("ON:", stat)

    elif switch is False:
        esg.write('OUTP OFF')

    info['State'] = esg.query('OUTP?')
    # info['State'] = esg.query(':OUTPut:STATe?')
    if info['State'] == '0':
        esg.close()  #close if switched off
        info['State'] = 'OFF'
    elif info['State'] == '1':
        info['State'] = 'ON'
    # else: info['State']='ERROR'

    set_status("ESG", info)
    return info
示例#16
0
def Initiate():
    ad = address()
    rs = ad.lookup(mdlname) # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(rs) #establishing connection using GPIB# with the machine
        stat = bench.write('*ESR?') #basic query
        bench.read_termination = '\n' #omit termination tag from output 
        bench.timeout = 150000 #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" % (mdlname, str(stat[1])[-7:]))
    except: 
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#17
0
文件: RDS.py 项目: supergravity/PYQUM
def Initiate():
    rs = address(mdlname, reset=eval(debugger)) # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(rs) #establishing connection using GPIB# with the machine
        stat = bench.write('*CLS') #Clear buffer memory; Load preset
        bench.write(':RUN') #Super-IMPORTANT for RiGoL!
        bench.write(':AUTOSCALE')
        bench.read_termination = '\n' #omit termination tag from output 
        bench.timeout = 150000 #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" % (mdlname, str(stat[1])[-7:]))
    except: 
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#18
0
def allstatus():
    dr = bluefors()
    dr.selectday(-1)

    # Logging Latest Key-Readings for ALL
    latestbdr = {}
    for i in range(6):
        latestbdr.update({"P%s" % (i + 1): dr.pressurelog(i + 1)[1][-1]})
    for i in [1, 2, 5, 6, 7]:
        latestbdr.update({"T%s" % (i + 1): dr.temperaturelog(i + 1)[1][-1]})
    set_status("BDR", latestbdr)

    status = {}
    status['PSGV'] = get_status('PSGV')["state"]
    status['AWG'] = get_status('AWG')["state"]

    log = pauselog()  #disable logging (NOT applicable on Apache)
    return jsonify(log=str(log), latestbdr=latestbdr, status=status)
示例#19
0
文件: AWG.py 项目: zeyanchen/PYQUM
def InitWithOptions(IdQuery=True,
                    Reset=True,
                    OptionsString='Simulate=false, DriverSetup=DDS=false'):
    '''status = InitWithOptions(IdQuery, Reset, OptionsString)
    '''
    Resource = bytes(AWGrs, 'ascii')
    Option = bytes(OptionsString, 'ascii')  # utf-8
    Session = c_long()
    AGM = dll.AgM933x_InitWithOptions  # from AgM933x.chm
    AGM.restype = c_int
    status = AGM(c_char_p(Resource), c_bool(IdQuery), c_bool(Reset),
                 c_char_p(Option), byref(Session))
    if status == 0:
        set_status("AWG", dict(state="Initialized", session=Session.value))
    else:
        set_status("AWG",
                   dict(state="Error: " + str(status), session=Session.value))
    print(Fore.GREEN +
          "Initialized from AWG module at session %s" % Session.value)
    return status, Session.value
示例#20
0
文件: MXA.py 项目: asqum/PYQUM_SEEDS
def Initiate():
    ad = address()
    rs = ad.lookup(mdlname)  # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(
            rs)  #establishing connection using GPIB# with the machine
        stat = bench.write('*CLS')  #Clear buffer memory
        bench.write(':SYSTem:PRESet')  #Mode preset
        bench.read_termination = '\n'  #omit termination tag from output
        bench.timeout = 150000  #set timeout in ms
        bench.write(":INIT:CONT ON")  #continuous mode
        sleep(3)
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" %
              (mdlname, str(stat[1])[-7:]))
    except:
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#21
0
文件: PNA.py 项目: supergravity/PYQUM
def Initiate():
    rs = address(mdlname, reset=eval(debugger))  # Instrument's Address
    rm = visa.ResourceManager()
    try:
        bench = rm.open_resource(
            rs)  #establishing connection using GPIB# with the machine
        stat = bench.write(
            '*RST;*CLS;SYST:FPReset')  #Clear buffer memory; Load preset
        bench.write(
            "CALCulate:PARameter:DELete:ALL")  #clear all params (S-params)
        bench.write(
            "SENS:CORR:EXT:AUTO:RESet")  #clear port-extension auto-correction
        bench.read_termination = '\n'  #omit termination tag from output
        bench.timeout = 80000000  #set timeout in ms
        set_status(mdlname, dict(state='connected'))
        print(Fore.GREEN + "%s's connection Initialized: %s" %
              (mdlname, str(stat[1])[-7:]))
    except:
        set_status(mdlname, dict(state='DISCONNECTED'))
        print(Fore.RED + "%s's connection NOT FOUND" % mdlname)
        bench = "disconnected"
    return bench
示例#22
0
def close(bench, reset=True):
    if reset:
        bench.write('*RST') # reset to factory setting (including switch-off)
        set_status(mdlname, dict(config='reset'))
    else: set_status(mdlname, dict(config='previous'))
    try:
        bench.close() #None means Success?
        status = "Success"
    except: status = "Error"
    set_status(mdlname, dict(state='disconnected'))
    print(Back.WHITE + Fore.BLACK + "%s's connection Closed" %(mdlname))
    return status
示例#23
0
def close(bench, reset=False):
    if reset:
        bench.write('*RST') # reset to factory setting
        set_status(mdlname, dict(config='reset'))
    else: set_status(mdlname, dict(config='previous'))
    try:
        acquire(bench, action=['Set','OFF','']) # STOP ACQUISITION
        bench.close() #None means Success?
        status = "Success"
    except: status = "Error"
    set_status(mdlname, dict(state='disconnected'))
    print(Back.WHITE + Fore.BLACK + "%s's connection Closed" %(mdlname))
    return status
示例#24
0
文件: YOKO.py 项目: zeyanchen/PYQUM
def close(bench, reset=False):
    if reset:
        previous(bench, True) # log last-applied voltage
        sweep(bench, 0, 0) # return to zero
        output(bench, 0) # off output
        set_status(mdlname, dict(config='return to zero-off'))
    else: set_status(mdlname, dict(config='previous'))
    try:
        bench.close() #None means Success?
        status = "Success"
    except: status = "Error"
    set_status(mdlname, dict(state='disconnected'))
    print(Back.WHITE + Fore.BLACK + "%s's connection Closed" %(mdlname))
    return status
示例#25
0
文件: VSA.py 项目: supergravity/PYQUM
def Wait_Data(session, Timeout=1000):
    """wait for Data
       Timeout in ms
    """
    AGM = dll.AgM9392_WaitForData
    AGM.restype = c_int
    status = AGM(c_long(session), c_int(Timeout))
    
    if status == 0: set_status(mdlname, {"wait_status" : "Complete"}) #logging the name and value of the attribute
    elif status == 1: set_status(mdlname, {"wait_status" : "Complete with Timeout"}) #logging the name and value of the attribute
    else: set_status(mdlname, {"wait_status" : "Expired"}) #logging the name and value of the attribute
    
    if eval(debugger):
        print(Fore.LIGHTWHITE_EX + "Wait Status: %s" %status)
    return status
示例#26
0
def close(bench, reset=False):
    bench.write(":OUTPUT OFF")
    if reset:
        bench.write(':SYSTem:PRESet')
        set_status(mdlname, dict(config='return to zero-off'))
    else:
        set_status(mdlname, dict(config='previous'))
    try:
        bench.close()  #None means Success?
        status = "Success"
    except:
        status = "Error"
    set_status(mdlname, dict(state='disconnected'))
    print(Back.WHITE + Fore.BLACK + "%s's connection Closed" % (mdlname))
    return status
示例#27
0
文件: ENA.py 项目: zeyanchen/PYQUM
def close(bench, reset=True):
    try:
        if reset:
            bench.write('OUTP OFF')
            set_status(mdlname, dict(config='reset-off'))
        else: set_status(mdlname, dict(config='previous'))
        try:
            bench.close() #None means Success?
            status = "Success"
        except: status = "Error"
        set_status(mdlname, dict(state='disconnected'))
        print(Back.WHITE + Fore.BLACK + "%s's connection Closed" %(mdlname))
    except: 
        status = "disconnected per se!!!"
        pass
    return status
示例#28
0
文件: PNA.py 项目: supergravity/PYQUM
def close(bench, reset=True):
    try:
        if reset:
            bench.write('SYSTem:PRESet'
                        )  # reset to factory setting (except data-format)
            set_status(mdlname, dict(config='reset'))
        else:
            set_status(mdlname, dict(config='previous'))
        try:
            bench.close()  #None means Success?
            status = "Success"
        except:
            status = "Error"
        set_status(mdlname, dict(state='disconnected'))
        print(Back.WHITE + Fore.BLACK + "%s's connection Closed" % (mdlname))
    except:
        status = "disconnected per se!!!"
        pass
    return status
示例#29
0
文件: AWG.py 项目: RuRu110307/PYQUM
    def wrapper(*a, **b):

        session, Type, RepCap, AttrID, buffsize, action = Name(*a, **b)
        RepCap = bytes(RepCap, "ascii")

        AGM = getattr(dll, 'AgM933x_' + action[0] + 'AttributeVi' + Type)
        AGM.restype = c_int  # return status (error)

        if action[0] == "Get":
            if Type == 'String':
                action[1] = (
                    c_char *
                    888)()  # char array: answer value format (use byref)
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             c_long(buffsize), byref(action[1]))
                ans = [x.decode("ascii") for x in action[1]
                       ]  # decoding binary # if x is not b'\x00'
                while '\x00' in ans:
                    ans.remove('\x00')
                ans = "".join(ans)  # join char array into string
            elif Type == 'Int32':
                action[1] = c_long()
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             byref(action[1]))
                ans = action[1].value
            elif Type == 'Real64':
                action[1] = c_double()
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             byref(action[1]))
                ans = action[1].value
            elif Type == 'Boolean':
                action[1] = c_bool()
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             byref(action[1]))
                ans = action[1].value

        elif action[0] == "Set":
            if Type == 'String':
                ans = action[1]
                action[1] = bytes(action[1], 'ascii')
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             c_char_p(action[1]))
            elif Type == 'Int32':
                ans = action[1]
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             c_long(action[1]))
            elif Type == 'Real64':
                ans = action[1]
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             c_double(action[1]))
            elif Type == 'Boolean':
                ans = action[1]
                status = AGM(c_long(session), c_char_p(RepCap), c_int(AttrID),
                             c_bool(action[1]))

        # Reformatting Answer if RepCap has something:
        RepCap = RepCap.decode('ascii')
        if RepCap != "":
            hashtag = " #Channel %s" % (RepCap)
        else:
            hashtag = ""

        # Logging Answer:
        if action[0] == "Get":  # No logging for "Set"
            if status == 0:
                set_status(mdlname,
                           {Name.__name__ + hashtag: ans
                            })  #logging the name and value of the attribute
            else:
                set_status(mdlname,
                           {Name.__name__ + hashtag: "Error: " + str(status)})

        # Debugging
        if eval(debugger):
            if action[0] == "Get":
                print(Fore.YELLOW + "%s %s's %s: %s, %s" %
                      (action[0], mdlname, Name.__name__ + hashtag, ans,
                       status_code(status)))
            if action[0] == "Set":
                print(Back.YELLOW + Fore.MAGENTA + "%s %s's %s: %s, %s" %
                      (action[0], mdlname, Name.__name__ + hashtag, ans,
                       status_code(status)))

        return status, ans
示例#30
0
文件: YOKO.py 项目: zeyanchen/PYQUM
def previous(bench, log=False):
    prev = bench.query('OD')
    if log:
        set_status(mdlname, dict(voltage=float(prev)))
    return prev