예제 #1
0
def dataserver_client(serveraddr='127.0.0.1', serverport=55556, localaddr='127.0.0.1'):
    import objectsharer as objsh
    if objsh.helper.backend is None:
        zbe = objsh.ZMQBackend()
        zbe.start_server(addr=localaddr)
        zbe.connect_to('tcp://%s:%d' % (serveraddr, serverport))  # Data server
    return objsh.helper.find_object('dataserver')
예제 #2
0
def plotwindow_client(serveraddr='127.0.0.1',
                      serverport=55557,
                      localaddr='127.0.0.1'):
    zbe = objsh.ZMQBackend()
    zbe.start_server(addr=localaddr)
    zbe.refresh_connection('tcp://%s:%d' %
                           (serveraddr, serverport))  # Data server
    return objsh.helper.find_object('plotwin')
예제 #3
0
 def setup_server(self):
     self.zbe = objsh.ZMQBackend()
     self.zbe.start_server('127.0.0.1', 55563)
     try:
         self.connect_dataserver()
     except objsh.TimeoutError:
         logger.warning('Could not connect to dataserver on startup')
     self.public_interface = WindowInterface(self)
     self.zbe.add_qt_timer()
예제 #4
0
def start(qt=False):
    if hasattr(objsh, 'ZMQBackend'):
        backend = objsh.ZMQBackend()
    else:
        backend = objsh.backend
    backend.start_server(addr='127.0.0.1', port=55556)
    if qt:
        backend.add_qt_timer(10)
    else:
        import signal
        for sig in (signal.SIGABRT, signal.SIGINT, signal.SIGTERM):
            signal.signal(sig, lambda *args: dataserv.quit())
        backend.timeout_add(10000, print_stats)
        backend.main_loop()
예제 #5
0
    logging.info('  Creating instrument %s of type %s' % (insname, instype))

    sys.path.append('instrument_plugins')
    sys.path.append('user_instruments')

    start = time.time()
    insmod = __import__(instype)
    insclass = getattr(insmod, instype, None)
    if insclass is None:
        raise ValueError('Instrument module does not contain instrument class')
    end = time.time()
    logging.debug('Loading instrument module %.03f sec', end - start)

    logging.debug('Starting sharing server and connecting to %s' % isrv)
    if hasattr(objsh, 'ZMQBackend'):
        backend = objsh.ZMQBackend()
    else:
        backend = objsh.backend

    try:
        addr = localconfig.instrument_server_addr
    except AttributeError:
        addr = '127.0.0.1'

    backend.start_server(addr=addr)
    backend.connect_to(isrv) 

    logging.debug('Creating instrument, name %s, kwargs %s' % (insname, kwargs))
    start = time.time()
    ins = insclass(insname, **kwargs)
    ins.set_remove_cb(close)
예제 #6
0
파일: datatest.py 프로젝트: yiwenchu/qrlab
import logging
#logging.getLogger().setLevel(logging.DEBUG)
import numpy as np
import time

import objectsharer as objsh
if objsh.helper.backend is None:
    zbe = objsh.ZMQBackend()
    zbe.start_server(addr='127.0.0.1')
zbe.connect_to('tcp://127.0.0.1:55556')  # Data server


def group_changed_cb(key, group=None):
    print 'Key %s changed in group %s' % (
        key,
        group,
    )


dataserver = objsh.helper.find_object('dataserver')

xs = np.linspace(-1, 1, 1001)
ys = np.linspace(-2, 2, 1001)
XS, YS = np.meshgrid(xs, ys)
RS = np.sqrt(XS**2 + YS**2)
ZS = np.sin(XS) * np.cos(YS) * np.sin(XS + YS)

start = time.time()
f = dataserver.get_file('test.hdf5')
g = f.create_group('data%s' % time.strftime('%Y%m%d_%H%M%S', time.localtime()))
g.set_attrs(instruments=('abc', 'def'))