Exemplo n.º 1
0
class RGA_Server( SerialDeviceServer ):
    name = SERVERNAME
    regKey = 'SRSRGA'
    port = None
    serNode = getNodeName()
    timeout = T.Value(TIMEOUT,'s')

    filsignal = Signal(FILSIGNAL, 'signal: filament changed', 'w')
    mlsignal = Signal(MLSIGNAL, 'signal: mass lock changed', 'v')
    hvsignal = Signal(HVSIGNAL, 'signal: high voltage changed', 'w')
    bufsignal = Signal(BUFSIGNAL, 'signal: buffer read', 's')
    quesignal = Signal(QUESIGNAL, 'signal: query sent', 's')

    listeners = set()

    @inlineCallbacks
    def initServer( self ):
        if not self.regKey or not self.serNode: raise SerialDeviceError( 'Must define regKey and serNode attributes' )
        port = yield self.getPortFromReg( self.regKey )
        self.port = port
        try:
            serStr = yield self.findSerial( self.serNode )
            self.initSerial( serStr, port, baudrate = BAUDRATE )
        except SerialConnectionError, e:
            self.ser = None
            if e.code == 0:
                print 'Could not find serial server for node: %s' % self.serNode
                print 'Please start correct serial server'
            elif e.code == 1:
                print 'Error opening serial connection'
                print 'Check set up and restart serial server'
            else: raise
Exemplo n.º 2
0
class eVPump(SerialDeviceServer):
    name = SERVERNAME
    regKey = 'evpump'
    port = None
    serNode = getNodeName()
    timeout = T.Value(TIMEOUT, 's')

    @inlineCallbacks
    def initServer(self):
        if not self.regKey or not self.serNode:
            raise SerialDeviceError('Define regKey and serNode attributes')
        port = yield self.getPortFromReg(self.regKey)
        self.port = port
        try:
            serStr = yield self.findSerial(self.serNode)
            print serStr, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
            self.initSerial(serStr, port, baudrate=BAUDRATE)
        except SerialConnectionError, e:
            self.ser = None
            if e.code == 0:
                print 'Could not find serial server for node %s' % self.serNode
                print 'Please start correct serial server'
            elif e.code == 1:
                print 'Error opening serial connection'
                print 'Check set up and restart serial server'
            else:
                raise
Exemplo n.º 3
0
def getConnection(host=C.MANAGER_HOST, port=None, name=None,
                  password=None, tls_mode=C.MANAGER_TLS, username=None,
                  headless=False):
    """Connect to LabRAD and return a deferred that fires the protocol object."""
    name = name or 'Python Client ({})'.format(support.getNodeName())
    p = yield protocol.connect(host, port, tls_mode, username, password,
                               headless)
    yield p.loginClient(name)
    returnValue(p)
Exemplo n.º 4
0
 class ServerOptions(usage.Options):
     optParameters = [
         ['name', 'n', name, 'Server name.'],
         ['node', 'd', getNodeName(), 'Node name.'],
         ['host', 'h', C.MANAGER_HOST, 'Manager location.'],
         ['port', 'p', None, 'Manager port.', int],
         ['password', 'w', C.PASSWORD, 'Login password.'],
         [
             'tls', 's', C.MANAGER_TLS,
             'TLS mode for connecting to manager (on/starttls/off)'
         ]
     ]
Exemplo n.º 5
0
def connect(host=C.MANAGER_HOST, port=None, name=None, timeout=C.TIMEOUT, **kw):
    """Create a backend connection to labrad.

    This connects to labrad asynchronously and then wraps the underlying async
    connection object in a synchronous TwistedConnection interface.
    """
    name = name or 'Python Client ({})'.format(support.getNodeName())

    thread.startReactor()
    future = concurrent.call_future(getConnection, host, port, name, **kw)
    cxn = future.result(timeout=timeout)

    return TwistedConnection(cxn)
Exemplo n.º 6
0
def connect(host=C.MANAGER_HOST,
            port=None,
            name=None,
            timeout=C.TIMEOUT,
            **kw):
    """Create a backend connection to labrad.

    This connects to labrad asynchronously and then wraps the underlying async
    connection object in a synchronous TwistedConnection interface.
    """
    name = name or 'Python Client ({})'.format(support.getNodeName())

    thread.startReactor()
    future = concurrent.call_future(getConnection, host, port, name, **kw)
    cxn = future.result(timeout=timeout)

    return TwistedConnection(cxn)
Exemplo n.º 7
0
class TrapServer( SerialDeviceServer ):
    name = SERVERNAME
    regKey = 'TrapControl'
    port = None
    serNode = getNodeName()
    timeout = T.Value(TIMEOUT,'s')

    @inlineCallbacks
    def initServer( self ):
        if not self.regKey or not self.serNode: raise SerialDeviceError( 'Must define regKey and serNode attributes' )
        port = yield self.getPortFromReg( self.regKey )
        self.port = port
        try:
            serStr = yield self.findSerial( self.serNode )
            self.initSerial( serStr, port, baudrate = BAUDRATE )
        except SerialConnectionError, e:
            self.ser = None
            if e.code == 0:
                print 'Could not find serial server for node: %s' % self.serNode
                print 'Please start correct serial server'
            elif e.code == 1:
                print 'Error opening serial connection'
                print 'Check set up and restart serial server'
            else: raise

        # Define the trap electronics parameters
        self.max_frequency = 500.e6 # Hz
        self.max_amplitude = 1233. #V
        self.max_phase = 360. # degrees
        self.max_hv = 1600. # V
        self.max_dc = 52.9 # V
        self.frequency_steps = 2**32-1
        self.amplitude_steps = 2**10-1
        self.phase_steps = 2**14-1
        self.dc_steps = 2**12-1
        self.hv_steps = 2**12-1

        # Set the state of the rf map
        self.use_RFMap = False

        # Set the state of RF
        self.enable_RF = True

        # Set the battery charging
        self.bat_charging = False
Exemplo n.º 8
0
class M2pump(SerialDeviceServer):
    name = SERVERNAME
    regKey = 'M2pump'
    port = None
    serNode = getNodeName()
    timeout = T.Value(TIMEOUT, 's')
    temperature = None
    power = None
    current = None

    currentchanged = Signal(UPDATECURR, 'signal: current changed', 'v')
    powerchanged = Signal(UPDATEPOW, 'signal: power changed', 'v')
    temperaturechanged = Signal(UPDATETMP, 'signal: temp changed', 'v')

    @inlineCallbacks
    def initServer(self):
        if not self.regKey or not self.serNode:
            raise SerialDeviceError(
                'Must define regKey and serNode attributes')
        port = yield self.getPortFromReg(self.regKey)
        self.port = port
        print port
        try:
            serStr = yield self.findSerial(self.serNode)
            self.initSerial(serStr, port, baudrate=BAUDRATE)
        except SerialConnectionError, e:
            self.ser = None
            if e.code == 0:
                print 'Could not find serial server for node: %s' % self.serNode
                print 'Please start correct serial server'
            elif e.code == 1:
                print 'Error opening serial connection'
                print 'Check set up and restart serial server'
            else:
                raise
        self.measurePump()
Exemplo n.º 9
0
 def __init__(self, name=None):
     self.name = name or 'Python Client (%s)' % getNodeName()
     self.connected = False
     self._nextContext = 1
Exemplo n.º 10
0
 def __init__(self, name=None):
     self.name = name or 'Python Client ({})'.format(support.getNodeName())
     self._connected = threading.Event()
     self._nextContext = 1