Ejemplo n.º 1
0
    def test4(self):
        """ Verify only one instance of a specific device can be opened with a lock
        """
        try:
            inst0a = vxi11.Instrument("TCPIP::127.0.0.1::inst0::INSTR", lock_on_open=True)    
            inst0a.open()

            inst0b = vxi11.Instrument("TCPIP::127.0.0.1::inst0::INSTR", lock_on_open=True)
            with self.assertRaisesRegex(Exception, "Device locked by another link") as cm:
                inst0b.open()
        finally:
            inst0a.close()
            inst0b.close()
Ejemplo n.º 2
0
    def test6(self):
        """ Verify multiple instances of a specific device can be accessed without a lock
        """
        try:
            inst0a = vxi11.Instrument("TCPIP::127.0.0.1::inst0::INSTR")            
            inst0a.open()

            inst0b = vxi11.Instrument("TCPIP::127.0.0.1::inst0::INSTR")            
            inst0b.open()

            inst0a.write("*IDN?\n")
            dbytes = inst0a.read()
            assert dbytes == 'my instrument zero', "has returned %r" % dbytes
            
            inst0b.write("*IDN?\n")
            dbytes = inst0b.read()
            assert dbytes == 'my instrument zero', "has returned %r" % dbytes
        finally:
            inst0a.close()
            inst0b.close()
Ejemplo n.º 3
0
    def test3(self):
        """ Verify multiple devices on the same server can be opened with locks
        """
        try:
            inst0 = vxi11.Instrument("TCPIP::127.0.0.1::inst0::INSTR", lock_on_open=True)
            inst0.open()
            
            inst1 = vxi11.Instrument("TCPIP::127.0.0.1::inst1::INSTR", lock_on_open=True)
            inst1.open()
            
            inst0.write("*IDN?\n")
            dbytes = inst0.read()
            assert dbytes == 'my instrument zero', "has returned %r" % dbytes

            inst1.write("*IDN?\n")
            dbytes = inst1.read()
            assert dbytes == 'my instrument one', "has returned %r" % dbytes
        finally:
            inst0.close()
            inst1.close()
Ejemplo n.º 4
0
    def test2(self):
        """ Verify inst1 instrument
        """
        try:
            inst1 = vxi11.Instrument("TCPIP::127.0.0.1::inst1::INSTR")
            inst1.open()

            inst1.write("*IDN?\n")
            dbytes = inst1.read()
            assert dbytes == 'my instrument one', "has returned %r" % dbytes
        finally:
            inst1.close()
Ejemplo n.º 5
0
 def test1(self):
     """ Verify default (inst0) instrument
     """
     try:
         inst0 = vxi11.Instrument("TCPIP::127.0.0.1::INSTR")
         inst0.open()
         
         inst0.write("*IDN?\n")
         dbytes = inst0.read()
         assert dbytes == 'my instrument zero', "has returned %r" % dbytes
     finally:
         inst0.close()
Ejemplo n.º 6
0
    def test5(self):
        """ test create_link with invalid device name
        """
        try:
            with self.assertRaisesRegex(Exception, "Device not accessible") as cm:
                inst0 = vxi11.Instrument("TCPIP::127.0.0.1::inst3::INSTR")            
                inst0.open()

                inst0.write("*IDN?\n")
                dbytes = inst0.read()
                assert dbytes == 'my instrument zero', "has returned %r" % dbytes
        finally:
            inst0.close()
            pass
Ejemplo n.º 7
0
import time

# use the python-vxi11 client library for interacting with the server.
#import vxi11

# use our vxi11 module so we can tinker with the lock client.
import sys
import os
sys.path.append(os.path.abspath('..'))
import vxi11_server as vxi11

# with a default instrument, inst0 is implied.
default_instr = vxi11.Instrument("TCPIP::127.0.0.1::INSTR")
time_instr = vxi11.Instrument("TCPIP::127.0.0.1::inst1::INSTR")

print('The INSTR instrument:')

default_instr.write('*IDN?')
print(default_instr.read())

print('contains the following devices:')
default_instr.write('*DEVICE_LIST?')
print(default_instr.read())

print()
print('The TIME device has a current value of:')

time_instr.lock_timeout= 10

time_instr.lock(wait=True)
time.sleep(1)
Ejemplo n.º 8
0
import sys
import os
import time

sys.path.append(os.path.abspath('..'))
import vxi11_server as vxi11

# with a default instrument, inst0 is implied.
default_instr = vxi11.Instrument("TCPIP::127.0.0.1::INSTR")
test1_instr = vxi11.Instrument("TCPIP::127.0.0.1::inst1::INSTR")
test2_instr = vxi11.Instrument("TCPIP::127.0.0.1::inst2::INSTR")


def asknprint(instr, q):
    print("send: %s" % q)
    print("answer: %s" % instr.ask(q))


asknprint(default_instr, "*IDN?")
asknprint(test1_instr, "*IDN?")
asknprint(test2_instr, "*IDN?")


def srq_intr_handler1():
    print("got SRQ for instrument 1")


def srq_intr_handler2():
    print("got SRQ for instrument 2")