Ejemplo n.º 1
0
 def initServer(self):
     DeviceServer.initServer(self)
     # register a message handler for connect/disconnect messages
     handler = lambda c, data: self.handleDeviceMessage(*data)
     self._cxn.addListener(handler, ID=self.messageID)
     if self.deviceManager in self.client.servers:
         yield self.connectToDeviceManager()
Ejemplo n.º 2
0
 def initServer(self):
     """This method loads default settings from the registry,
        sets up instruments, and sets up listeners for GPIB device 
        connect/disconnect messages."""
     DeviceServer.initServer(self)
     try:
         yield self.client.registry.cd(self.ADRSettingsPath)
         self.file_path = yield self.client.registry.get('Log Path')
     except Exception as e:
         self.logMessage( '{Saving log failed.  Check that AFS is working.} ' )
     yield self.loadDefaults()
     yield util.wakeupCall( 3 ) # on the round ADR, the HP DMM takes forever to initialize.  This prevents it from going on before it is ready.
     yield self.initializeInstruments()
     # subscribe to messages
     # the server ones are not used right now, but at some point they could be
     connect_func = lambda c, (s, payload): self.gpib_device_connect(*payload)
     disconnect_func = lambda c, (s, payload): self.gpib_device_disconnect(*payload)
     serv_conn_func = lambda c, (s, payload): self.serversChanged(*payload)
     serv_disconn_func = lambda c, (s, payload): self.serversChanged(*payload)
     mgr = self.client.manager
     self._cxn.addListener(connect_func, source=mgr.ID, ID=10)
     self._cxn.addListener(disconnect_func, source=mgr.ID, ID=11)
     self._cxn.addListener(serv_conn_func, source=mgr.ID, ID=12)
     self._cxn.addListener(serv_disconn_func, source=mgr.ID, ID=13)
     yield mgr.subscribe_to_named_message('GPIB Device Connect', 10, True)
     yield mgr.subscribe_to_named_message('GPIB Device Disconnect', 11, True)
     yield mgr.subscribe_to_named_message('Server Connect', 12, True)
     yield mgr.subscribe_to_named_message('Server Disconnect', 13, True)
     self.updateState()
 def initServer(self):
     """Initializes the server"""
     print("Server initializing")
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible pressures. This is a list
     # of 6 values corresponding to the 6 sensors.
     # Index 0 of thresholdMax corresponds to the maximum acceptible
     # value of sensor 1 and index 5, sensor 6. Likewise, index 0 of
     # thresholdMin corresponds to sensor 1.
     # These values can be left as is (default) or they can be changed
     # using the set_thresholds setting.
     # In order to use the setting, type:
     #   [instance name].set_thresholds([low], [high])
     # As an example:
     #   vacuum.set_thresholds([0, 0, 0, 5E-5, 5E-5, 5E-5],
     #                         [0, 0, 0, 5E-4, 5E-4, 5E-4])
     # It is a good idea to allow for a wide range of values if you
     # know that a sensor is not connected because the unit sometimes
     # misreports status codes. This makes it seem as though a sensor
     # is connected, and a 'don't-care' value is treated as an error.
     self.thresholdMax = [1500, 1500, 1500, 5e-4, 5e-4, 1e-1] * mbar
     # Set the minimum acceptible pressures.
     self.thresholdMin = [0, 0, 0, 5E-5, 5E-5, 5E-5] * mbar
     self.alertInterval = 10  # seconds
     self.measurements = [0, 0, 0, 0, 0, 0] * mbar
     self.statusCodes = [0, 0, 0, 0, 0, 0]
     self.t1 = [0, 0, 0, 0, 0, 0]
     self.t2 = [0, 0, 0, 0, 0, 0]
Ejemplo n.º 4
0
 def initServer(self):
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print 'done.'
     print self.serialLinks
     yield DeviceServer.initServer(self)
 def initServer(self):
     print("loading config info...")
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print("done.")
     print(self.serialLinks)
     yield DeviceServer.initServer(self)
Ejemplo n.º 6
0
 def initServer(self):
     print 'Loading config from registry...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print 'Finished.'
     print("Serial links found: %s"%str(self.serialLinks))
     yield DeviceServer.initServer(self)
 def initServer(self):
     """Initializes the server"""
     print("Server initializing")        
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible pressures. This is a list
     # of 6 values corresponding to the 6 sensors.
     # Index 0 of thresholdMax corresponds to the maximum acceptible
     # value of sensor 1 and index 5, sensor 6. Likewise, index 0 of
     # thresholdMin corresponds to sensor 1.
     # These values can be left as is (default) or they can be changed
     # using the set_thresholds setting.
     # In order to use the setting, type:
     #   [instance name].set_thresholds([low], [high])
     # As an example:
     #   vacuum.set_thresholds([0, 0, 0, 5E-5, 5E-5, 5E-5],
     #                         [0, 0, 0, 5E-4, 5E-4, 5E-4])
     # It is a good idea to allow for a wide range of values if you
     # know that a sensor is not connected because the unit sometimes
     # misreports status codes. This makes it seem as though a sensor
     # is connected, and a 'don't-care' value is treated as an error.
     self.thresholdMax = [1e-2, 1e-2, 1e-2, 5e-7, 5e-7, 1e-4] * units.bar
     # Set the minimum acceptible pressures.
     self.thresholdMin = [0, 0, 0, 5E-8, 5E-8, 5E-8] * units.bar
     self.alertInterval = 10 # seconds
     self.measurements = [0, 0, 0, 0, 0, 0] * units.bar
     self.statusCodes = [0, 0, 0, 0, 0, 0]
     self.t1 = [0,0,0,0,0,0]
     self.t2 = [0,0,0,0,0,0]
Ejemplo n.º 8
0
 def initServer(self):
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print 'done.'
     print self.serialLinks
     yield DeviceServer.initServer(self)
Ejemplo n.º 9
0
 def initServer(self):
     self.mydevices = {}
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # start refreshing only after we have started serving
     # this ensures that we are added to the list of available
     # servers before we start sending messages
     callLater(0.1, self.refreshDevices)
 def initServer(self):
     self.output = None
     self.current = None
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print self.serialLinks
     yield DeviceServer.initServer(self)
Ejemplo n.º 11
0
 def initServer(self):
     """
     Makes a connection to the registry where port information and other server
     specific settings can be retrieved.
     """
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)  # starts server after configurations loaded
Ejemplo n.º 12
0
 def initServer(self):
     """
     Makes a connection to the registry where port information and other server
     specific settings can be retrieved.
     """
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(
         self)  # starts server after configurations loaded
Ejemplo n.º 13
0
 def initServer(self):
     self.current_state = {}
     self.frequency = [0., 0.]
     self.power = [0., 0.]
     self.channel = 0
     self.onoff = [0, 0]
     self.phase = [0., 0.]
     print('loading config info...', )
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 14
0
 def initServer(self):
     """Initializes the server"""
     print("Server Initializing...")
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     time.sleep(1)
     print(self.devices)
     self.alertInterval = 10 # seconds
     self.t1 = 0
     self.t2 = 0
 def initServer(self):
     """Initialize the Temperature Monitor Server"""
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible temperature.
     self.thresholdMax = 50 * units.degF
     # Set the minimum acceptible temperature.
     self.thresholdMin = 30 * units.degF
     self.alertInterval = 10 # seconds
     self.t1 = 0
     self.t2 = 0
Ejemplo n.º 16
0
 def initServer(self):
     """Initialize the Temperature Monitor Server"""
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible temperature.
     self.thresholdMax = 50 * units.degF
     # Set the minimum acceptible temperature.
     self.thresholdMin = 30 * units.degF
     self.alertInterval = 10  # seconds
     self.t1 = 0
     self.t2 = 0
Ejemplo n.º 17
0
 def initServer(self):
     """Initializes the server"""
     print("Server Initializing...")        
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible flow rate.
     self.thresholdMax = 5 * units.galUS / units.min
     # Set the minimum acceptible flow rate.
     self.thresholdMin = 1.5* units.galUS / units.min
     self.alertInterval = 10 # seconds
     self.t1 = 0
     self.t2 = 0
Ejemplo n.º 18
0
 def initServer(self):
     """Initializes the server"""
     print("Server Initializing...")        
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
     # Set the maximum acceptible flow rate.
     self.thresholdMax = 5 * units.galUS / units.min
     # Set the minimum acceptible flow rate.
     self.thresholdMin = 1.5* units.galUS / units.min
     self.alertInterval = 10 # seconds
     self.t1 = 0
     self.t2 = 0
Ejemplo n.º 19
0
 def initServer(self):
     print('Server initializing...')
     self.reg = self.client.registry()
     yield self.loadSensorInfo()
     # default excitation and range: 30uV, 20kOhm
     self.excitation = "3"
     self.excitation_values = [
         '0V', '3uV', '10uV', '30uV', '100uV', '300uV', '1mV', '3mV'
     ]
     self.range = "5"
     self.range_values = [
         '2 Ohm', '20 Ohm', '200 Ohm', '2 kOhm', '20 kOhm', '200 kOhm',
         '2 MOhm'
     ]
     yield self.loadConfigInfo()
     yield self.loadCalibrationInfo()
     yield DeviceServer.initServer(self)
     print self.sensors
Ejemplo n.º 20
0
    def initServer(self):
        """
        This method loads default settings from the registry,
        sets up instruments, and sets up listeners for GPIB device
        connect/disconnect messages.
        """
        yield DeviceServer.initServer(self)
        try:
            yield self.client.registry.cd(self.ADRSettingsPath)
            self.file_path = yield self.client.registry.get('Log Path')
        except Exception as e:
            self.logMessage('{Saving log failed. '
                            ' Check that AFS is working.} ')
        yield self.loadDefaults()
        yield self.initializeInstruments()
        # subscribe to messages
        # the server ones are not used right now, but at some point they could be
        serv_conn_func = lambda c, (s, payload): self.serversChanged(*payload)
        serv_disconn_func = lambda c, (s, payload): self.serversChanged(*payload)
        mgr = self.client.manager
        self._cxn.addListener(serv_conn_func, source=mgr.ID, ID=12)
        self._cxn.addListener(serv_disconn_func, source=mgr.ID, ID=13)
        yield mgr.subscribe_to_named_message('Server Connect', 12, True)
        yield mgr.subscribe_to_named_message('Server Disconnect', 13, True)

        # listen for device connect/disconnect signals
        dev_con_changed = lambda c, payload: self.device_connection_changed(*payload)
        try: # in case the device manager is not running
             # &&& do this whenever device manager starts or something?
            devManager = self.client.gpib_device_manager
            yield devManager.device_connection_changed(self.ID)
            yield devManager.addListener(listener = dev_con_changed,
                                         source = None,
                                         ID = self.ID)
        except Exception as e:
            print str(e)
        self.updateState()
Ejemplo n.º 21
0
 def initServer(self):
     print 'loading config info...',
     yield self.loadConfigInfo()
     print 'done.'
     # Is analogous to a super call?
     yield DeviceServer.initServer(self)
Ejemplo n.º 22
0
 def initServer(self):
     print("Server <%s> of type <%s>" % (self.name, self.deviceName))
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print(self.serialLinks)
     yield DeviceServer.initServer(self)
Ejemplo n.º 23
0
 def initServer(self):
     '''Initialize the MKSPDR2000 server.'''
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
 def initServer(self):
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
 def initServer(self):
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 26
0
    def initServer(self):
        """
        This method loads default settings from the registry,
        sets up instruments, and sets up listeners for GPIB device
        connect/disconnect messages.
        """
        yield DeviceServer.initServer(self)

        yield self.loadDefaults()

        # init start time, create dataChest, etc.
        # If the compressor was last stopped over 24 hours ago, or if the
        # compressor cannot be started and stopped from the computer,
        # a new file will be created each time the server is opened.  If
        # the compressor has not been stopped, the last file will be
        # appended to.  If the compressor has stopped, but it was less
        # than 24 hours ago, the last file will be appended to.  Starting
        # the compressor creates a new file.
        now = datetime.datetime.utcnow()
        start = self.ADRSettings['Start Compressor Datetime']
        stop = self.ADRSettings['Stop Compressor Datetime']
        if start is None or (stop is not None
                             and deltaT(now - stop) > 24 * 60 * 60):
            self.ADRSettings['Start Compressor Datetime'] = now
            reg = self.client.registry
            yield reg.cd(self.ADRSettingsPath)
            yield reg.set('Start Compressor Datetime', now)
        self.initLogFiles()

        # Web Socket Update Stuff:
        log.startLogging(sys.stdout)
        root = File("")

        adrN = int(self.deviceName[-1])
        port = 9879 - adrN

        self.factory = MyFactory(u"wss://127.0.0.1:%i/" % port, adrServer=self)
        self.factory.protocol = MyServerProtocol
        resource = WebSocketResource(self.factory)
        root.putChild(u"ws", resource)

        site = Site(root)
        contextFactory = ssl.DefaultOpenSSLContextFactory(
            'Z:/mcdermott-group/LabRAD/ssl_certificates/adr%i/ssl.key' % adrN,
            'Z:/mcdermott-group/LabRAD/ssl_certificates/adr%i/ssl.crt' % adrN)
        # reactor.listenTCP(port, site, interface='0.0.0.0')
        reactor.listenSSL(port, site, contextFactory, interface='0.0.0.0')

        yield self.initializeInstruments()
        # subscribe to messages
        # the server ones are not used right now, but at some point they could be
        serv_conn_func = lambda c, (s, payload): self.serversChanged(*payload)
        serv_disconn_func = lambda c, (s, payload): self.serversChanged(
            *payload)
        mgr = self.client.manager
        self._cxn.addListener(serv_conn_func, source=mgr.ID, ID=12)
        self._cxn.addListener(serv_disconn_func, source=mgr.ID, ID=13)
        yield mgr.subscribe_to_named_message('Server Connect', 12, True)
        yield mgr.subscribe_to_named_message('Server Disconnect', 13, True)

        # listen for device connect/disconnect signals
        dev_con_changed = lambda c, payload: self.device_connection_changed(
            *payload)
        try:  # in case the device manager is not running
            # &&& do this whenever device manager starts or something?
            devManager = self.client.gpib_device_manager
            yield devManager.device_connection_changed(self.ID)
            yield devManager.addListener(listener=dev_con_changed,
                                         source=None,
                                         ID=self.ID)
        except Exception as e:
            print str(e)

        self.updateState()
Ejemplo n.º 27
0
 def initServer(self):
     '''Initialize the MKSPDR2000 server.'''
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 28
0
 def initServer(self):
     print 'loading config info...',
     yield self.loadConfigInfo()
     print 'done.'
     yield DeviceServer.initServer(self)
Ejemplo n.º 29
0
 def initServer(self):
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 30
0
 def initServer(self):
     print 'loading config info...',
     yield self.loadConfigInfo()
     print 'done.'
     # Is analogous to a super call?
     yield DeviceServer.initServer(self)
Ejemplo n.º 31
0
 def initServer(self):
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 32
0
 def initServer(self):
     print 'loading config info...',
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield self.reg.cd(['', 'settings'], True)
     yield DeviceServer.initServer(self)
Ejemplo n.º 33
0
 def initServer(self):
     print('Server initializing...')
     self.reg = self.client.registry()
     # default excitation and range: 30uV, 20kOhm
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 34
0
 def initServer(self):
     print("Server <%s> of type <%s>"%(self.name,self.deviceName))
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     print(self.serialLinks)
     yield DeviceServer.initServer(self)
Ejemplo n.º 35
0
 def initServer(self):
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 36
0
 def initServer(self):
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 37
0
 def initServer(self):
     print "Server Initializing"
     self.reg = self.client.registry()
     yield self.loadConfigInfo()
     yield DeviceServer.initServer(self)
Ejemplo n.º 38
0
 def initServer(self):
     print 'loading config info...',
     yield self.loadConfigInfo()
     print 'done.'
     yield DeviceServer.initServer(self)