Esempio n. 1
0
def test_interfaces():
    # Nose test generator to run unittests on discovered interfaces
    instr = labtronyx.InstrumentManager()

    for interName, interCls in instr.plugin_manager.getPluginsByBaseClass(
            InterfaceBase).items():
        yield check_interface_api, interCls
Esempio n. 2
0
    def setUpClass(cls):
        cls.manager = labtronyx.InstrumentManager()

        interfaceInstancesByName = {
            pluginCls.interfaceName: pluginCls
            for plugin_uuid, pluginCls in cls.manager.interfaces.items()
        }

        cls.i_visa = interfaceInstancesByName.get('VISA')
Esempio n. 3
0
def test_scripts():
    man = labtronyx.InstrumentManager()

    scr = ScriptStub(manager=man)

    assert (scr.isReady())
    scr.start()
    scr.join()

    props = scr.getProperties()

    assert (len(props.get('results', [])) == 1)
Esempio n. 4
0
def test_resource_integration():
    manager = labtronyx.InstrumentManager()

    # Create a fake interface, imitating the interface API
    interf = InterfaceBase(manager=manager)
    interf.interfaceName = 'Test'

    # Create a fake resource
    res = ResourceBase(manager=manager, interface=interf, resID='DEBUG')

    manager.plugin_manager._plugins_instances[interf.uuid] = interf
    manager.plugin_manager._plugins_instances[res.uuid] = res

    dev = manager.findInstruments(resourceID='DEBUG')
    assert_equal(len(dev), 1)
Esempio n. 5
0
    def setUpClass(cls):
        # Setup a mock manager
        cls.manager = labtronyx.InstrumentManager()

        if 'TRAVIS' in os.environ or cls.manager.interfaces.get(
                'VISA') is None:
            lib_path = os.path.join(os.path.dirname(__file__), 'sim',
                                    'default.yaml')

            cls.manager.disableInterface('VISA')
            cls.manager.enableInterface('VISA', library='%s@sim' % lib_path)

        interfaceInstancesByName = {
            pluginCls.interfaceName: pluginCls
            for plugin_uuid, pluginCls in cls.manager.interfaces.items()
        }
        cls.i_visa = interfaceInstancesByName.get('VISA')
    def setUpClass(self):
        # Setup a mock manager
        self.manager = labtronyx.InstrumentManager()

        dev_list = self.manager.findInstruments(driver='Agilent.SMU.d_B29XX')

        if len(dev_list) == 0:
            lib_path = os.path.join(os.path.dirname(__file__), 'sim', 'agilent_b2901.yaml')

            self.manager.disableInterface('VISA')
            self.manager.enableInterface('VISA', library='%s@sim'%lib_path)

            # Find the instrument by model number
            dev_list = self.manager.findInstruments(driver='Agilent.SMU.d_B29XX')

        if len(dev_list) == 1:
            self.dev = dev_list[0]

        else:
            self.dev = None
Esempio n. 7
0
def test_interface_integration():
    manager = labtronyx.InstrumentManager()

    # Create a fake interface, imitating the interface API
    class TestInterface(InterfaceBase):
        interfaceName = 'Test'
        open = mock.Mock(return_value=True)
        close = mock.Mock(return_value=True)
        enumerate = mock.Mock(return_value=True)

    # Inject the fake plugin into the manager instance
    manager.plugin_manager._plugins_classes['test.Test'] = TestInterface

    assert_true(manager.enableInterface('Test'))
    assert_true(TestInterface.open.called)
    assert_false(TestInterface.close.called)
    assert_true(TestInterface.enumerate.called)
    assert_true(manager.disableInterface('Test'))
    assert_true(TestInterface.open.called)

    manager._close()
Esempio n. 8
0
    def setUpClass(cls):
        import time
        start = time.clock()
        cls.manager = labtronyx.InstrumentManager(server=True)

        cls.startup_time = time.clock() - start

        # Create a test object
        cls.manager.subtract = lambda subtrahend, minuend: int(subtrahend
                                                               ) - int(minuend)
        cls.manager.foobar = mock.MagicMock(return_value=None)
        cls.manager.raise_exception = mock.MagicMock(side_effect=RuntimeError)

        try:
            cls.client = labtronyx.RemoteManager(
                host=labtronyx.InstrumentManager.getHostname())

            cls.TEST_URI = cls.client.uri

        except labtronyx.RpcServerNotFound:
            cls.tearDownClass()
Esempio n. 9
0
def main(search_dirs=None):
    parse = argparse.ArgumentParser(
        description="Labtronyx Automation Framework")
    parse.add_argument('-g', dest='gui', action='store_const', const=True)
    parse.add_argument('-d',
                       dest='dirs',
                       nargs='*',
                       help='plugin search directory')
    args = parse.parse_args()

    if args.gui:
        launch_gui()
        return

    # Add OS-specific application data folders to search for plugins
    if search_dirs is None:
        search_dirs = []

    dirs = appdirs.AppDirs("Labtronyx", roaming=True)
    if not os.path.exists(dirs.site_data_dir):
        os.makedirs(dirs.site_data_dir)
    search_dirs.append(dirs.site_data_dir)

    if not os.path.exists(dirs.user_data_dir):
        os.makedirs(dirs.user_data_dir)
    search_dirs.append(dirs.user_data_dir)

    if args.dirs is not None:
        search_dirs += args.dirs

    # Instantiate an InstrumentManager
    man = labtronyx.InstrumentManager(plugin_dirs=search_dirs)

    # Start the server in the current thread
    try:
        man.server_start(new_thread=False)
    except KeyboardInterrupt:
        man.server_stop()
Esempio n. 10
0
    def __init__(self):
        BaseController.__init__(self)

        self.event_sub = labtronyx.EventSubscriber()
        self.event_sub.registerCallback('', self._handleEvent)

        self._hosts = {}

        # Get proper hostname for localhost
        local_hostname = self.networkHostname('127.0.0.1')

        if not self.add_host(local_hostname):
            try:
                # No local host found, lets start one
                local_host = labtronyx.InstrumentManager(server=True)
                new_controller = ManagerController(local_host)

                ip_address = self.resolveHost(local_hostname)
                self.event_sub.connect(ip_address)

                self._hosts[ip_address] = new_controller

            except Exception as e:
                pass
Esempio n. 11
0
 def setUpClass(cls):
     cls.manager = labtronyx.InstrumentManager()
Esempio n. 12
0
 def setUpClass(cls):
     start = time.clock()
     cls.instr = labtronyx.InstrumentManager()
     cls.init_delta = time.clock() - start
Esempio n. 13
0
import labtronyx

# Enable debug logging
labtronyx.logConsole()

# Instantiate an InstrumentManager
im = labtronyx.InstrumentManager()

# Find the instrument by model number
dev_list = im.findInstruments(deviceVendor="Agilent", deviceModel="34410A")
dev = dev_list[0]

# Open the instrument
with dev:
    # Disable the front panel
    dev.disableFrontPanel()

    # Set the text on the front panel
    dev.frontPanelText("PRIMARY VOLT", "measuring...")

    # Set the mode to DC Voltage
    dev.setMode('DC Voltage')

    # Set the sample count to 10
    dev.setSampleCount(10)

    # Measure the input
    data = dev.getMeasurement()

    # Check for errors
    dev.checkForError()
Esempio n. 14
0
def test_resources():
    instr = labtronyx.InstrumentManager()

    for res_uuid, resCls in instr.plugin_manager.getPluginsByBaseClass(
            ResourceBase).items():
        yield check_resource_api, resCls