コード例 #1
0
def get_pi_comm(config, ctype=None, **opts):
    """
    Returns PI communication channel from configuration.
    See :func:`bliss.comm.util.get_comm` for more info.
    """
    config = config.config_dict
    if 'tcp' in config:
        opts.setdefault('port', 50000)
    opts.setdefault('timeout', 1)
    try:
        return get_comm(config, ctype=ctype, **opts)
    except ValueError:
        if config.has_key('host'):
            warn("'host' keyword is deprecated. Use 'tcp' instead",
                 DeprecationWarning)
            host = config.get("host")
            opts.setdefault('port', 50000)
            config = {'tcp': {'url': host}}
            return get_comm(config, ctype=ctype, **opts)
        elif config.has_key('serial_line'):
            serial_line = self.config.get("serial_line")
            warn("'serial_line' keyword is deprecated. Use 'serial' instead",
                 DeprecationWarning)
            config = {'serial': {'url': serial_line}}
            return get_comm(config, ctype=ctype, **opts)
    raise ValueError('No communication channel found in config')
コード例 #2
0
ファイル: pi_gcs.py プロジェクト: tiagocoutinho/bliss
def get_pi_comm(config, ctype=None, **opts):
    """
    Returns PI communication channel from configuration.
    See :func:`bliss.comm.util.get_comm` for more info.
    """
    config = config.config_dict
    if 'tcp' in config:
        opts.setdefault('port', 50000)
    opts.setdefault('timeout', 1)
    try:
        return get_comm(config, ctype=ctype, **opts)
    except ValueError:
        if config.has_key('host'):
            warn("'host' keyword is deprecated. Use 'tcp' instead",
                 DeprecationWarning)
            host = config.get("host")
            opts.setdefault('port', 50000)
            config = {'tcp': {'url': host } }
            return get_comm(config, ctype=ctype, **opts)
        elif config.has_key('serial_line'):
            serial_line = self.config.get("serial_line")
            warn("'serial_line' keyword is deprecated. Use 'serial' instead",
                 DeprecationWarning)
            config = {'serial': {'url': serial_line } }
            return get_comm(config, ctype=ctype, **opts)
    raise ValueError('No communication channel found in config')
コード例 #3
0
 def initialize(self):
     try:
         self.sock = get_comm(self.config.config_dict, ctype=TCP, port=4000)
     except ValueError:
         host = config.get("host")
         warn("'host' keyword is deprecated. Use 'tcp' instead", DeprecationWarning)
         comm_cfg = {'tcp': {'url': host } }
         self.sock = get_comm(comm_cfg, port=4000)
コード例 #4
0
ファイル: nf8753.py プロジェクト: tiagocoutinho/bliss
    def initialize(self):
        try:
            self.sock = get_comm(self.config.config_dict, TCP, port=23)
        except ValueError:
            host = self.config.get("host")
            warn("'host' keyword is deprecated. Use 'tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': host } }
            self.sock = get_comm(comm_cfg, port=23)

        if '=2' in self._write_read(None, "DRT", raw=True):
            raise RuntimeError("Uncompatible closed-loop driver detected in daisy chain")
コード例 #5
0
    def initialize(self):
        try:
            self.sock = get_comm(self.config.config_dict, TCP, port=23)
        except ValueError:
            host = self.config.get("host")
            warn("'host' keyword is deprecated. Use 'tcp' instead",
                 DeprecationWarning)
            comm_cfg = {'tcp': {'url': host}}
            self.sock = get_comm(comm_cfg, port=23)

        if '=2' in self._write_read(None, "DRT", raw=True):
            raise RuntimeError(
                "Uncompatible closed-loop driver detected in daisy chain")
コード例 #6
0
    def initialize(self):
        log.debug("initialize() called")
        try:
            self.sock = get_comm(self.config.config_dict, TCP)
        except ValueError:
            host = config.get("host")
            port = int(config.get("port"))
            warn("'host' and 'port' keywords are deprecated. " \
                 "Use 'tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': '{0}:{1}'.format(host, port)}}
            self.sock = get_comm(comm_cfg)

        log.info("initialize() create socket %s" % str(self.sock))
        # read spurious 'd' character when connected
        self.sock.readline(eol="\r")
コード例 #7
0
ファイル: pm600.py プロジェクト: tiagocoutinho/bliss
    def initialize(self):
        log.debug("initialize() called")
        try:
            self.sock = get_comm(self.config.config_dict, TCP)
        except ValueError:
            host = config.get("host")
            port = int(config.get("port"))
            warn("'host' and 'port' keywords are deprecated. " \
                 "Use 'tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': '{0}:{1}'.format(host, port)}}
            self.sock = get_comm(comm_cfg)

        log.info("initialize() create socket %s" % str(self.sock))
        # read spurious 'd' character when connected
        self.sock.readline(eol="\r")
コード例 #8
0
ファイル: keller.py プロジェクト: tiagocoutinho/bliss
    def __init__(self, name, config):
        self._cache = {}
        self._configured_address = int(config.get('address', TRANSPARENT_ADDR))
        self._log = logging.getLogger('PressureTransmitter.{0}'.format(name))
        self._comm_lock = gevent.lock.RLock()
        self.counters = {}
        self.debug = self._log.debug
        self.config = config
        self.name = name
        self.comm = get_comm(config, baudrate=9600)
        self.echo = config.get('echo', 1)
        self.expected_serial_nb = config.get('serial_nb', None)

        # Create counters
        for counter_config in self.config.get('counters', []):
            counter_name = counter_config['counter_name']
            if hasattr(self, counter_name):
                self._log.error('Skipped counter %r (controller already ' \
                                'has a member with that name)', counter_name)
                continue
            channel = counter_config.get('channel', 'P1')
            counter = self.__create_counter(counter_name, channel=channel)
            self.counters[counter_name] = counter
            setattr(self, counter_name, counter)

        self.initialize()
コード例 #9
0
    def initialize(self):
        """
        Opens a single communication socket to the controller for all 1..6 axes.
        """
        try:
            self.sock = get_comm(self.config.config_dict, TCP, port=9760)
        except ValueError:
            host = self.config.get("host")
            warn("'host' keyword is deprecated. Use 'tcp' instead",
                 DeprecationWarning)
            if not host.startswith('command://'):
                host = 'command://' + host
            comm_cfg = {'tcp': {'url': host}}
            self.sock = get_comm(comm_cfg, port=9760)

        elog.debug("socket open : %r" % self.sock)
コード例 #10
0
    def __init__(self, name, config):
        self._cache = {}
        self._configured_address = int(config.get('address', TRANSPARENT_ADDR))
        self._log = logging.getLogger('PressureTransmitter.{0}'.format(name))
        self._comm_lock = gevent.lock.RLock()
        self.counters = {}
        self.debug = self._log.debug
        self.config = config
        self.name = name
        self.comm = get_comm(config, baudrate=9600)
        self.echo = config.get('echo', 1)
        self.expected_serial_nb = config.get('serial_nb', None)

        # Create counters
        for counter_config in self.config.get('counters', []):
            counter_name = counter_config['counter_name']
            if hasattr(self, counter_name):
                self._log.error('Skipped counter %r (controller already ' \
                                'has a member with that name)', counter_name)
                continue
            channel = counter_config.get('channel', 'P1')
            counter = self.__create_counter(counter_name, channel=channel)
            self.counters[counter_name] = counter
            setattr(self, counter_name, counter)

        self.initialize()
コード例 #11
0
 def __init__(self, config):
     self._log = logging.getLogger('SHexapod')
     self.config = config
     self.eol = '\r\n'
     self.comm = get_comm(config,
                          ctype=TCP,
                          port=self.DEFAULT_PORT,
                          eol=self.eol)
コード例 #12
0
    def initialize(self):
        """
        Opens one socket for 2 channels.
        """
        try:
            self.serial = get_comm(self.config.config_dict, SERIAL, timeout=1)
            self._status = "SERIAL communication configuration found"
            elog.debug(self._status)
        except ValueError:
            try:
                serial_line = self.config.get("serial_line")
                warn(
                    "'serial_line' keyword is deprecated. Use 'serial' instead",
                    DeprecationWarning)
                comm_cfg = {'serial': {'url': serial_line}}
                self.serial = get_comm(comm_cfg, timeout=1)
            except:
                self._status = "Cannot find serial configuration"
                elog.error(self._status)

        try:
            # should be : 'VSCANNER 01.02\r\n'
            _ans = self.serial.write_readline("?VER\r\n")
            self._status += "\ncommunication ok "
            elog.debug(self._status + _ans)
        except OSError:
            _ans = "no ans"
            self._status = sys.exc_info()[1]
            elog.error(self._status)
        except:
            _ans = "no ans"
            self._status = "communication error : cannot communicate with serial \"%s\"" % self.serial
            elog.error(self._status)
            traceback.print_exc()

        try:
            _ans.index("VSCANNER")
            self._status += "VSCANNER found (substring VSCANNER found in answer to ?VER)."
        except:
            self._status = "communication error : no VSCANNER found on serial \"%s\"" % self.serial

        elog.debug(self._status)
コード例 #13
0
ファイル: vscanner.py プロジェクト: tiagocoutinho/bliss
    def initialize(self):
        """
        Opens one socket for 2 channels.
        """
        try:
            self.serial = get_comm(self.config.config_dict, SERIAL, timeout=1)
            self._status = "SERIAL communication configuration found"
            elog.debug(self._status)
        except ValueError:
            try:
                serial_line = self.config.get("serial_line")
                warn("'serial_line' keyword is deprecated. Use 'serial' instead",
                     DeprecationWarning)
                comm_cfg = {'serial': {'url': serial_line } }
                self.serial = get_comm(comm_cfg, timeout=1)
            except:
                self._status = "Cannot find serial configuration"
                elog.error(self._status)

        try:
            # should be : 'VSCANNER 01.02\r\n'
            _ans = self.serial.write_readline("?VER\r\n")
            self._status += "\ncommunication ok "
            elog.debug(self._status + _ans)
        except OSError:
            _ans = "no ans"
            self._status = sys.exc_info()[1]
            elog.error(self._status)
        except:
            _ans = "no ans"
            self._status = "communication error : cannot communicate with serial \"%s\"" % self.serial
            elog.error(self._status)
            traceback.print_exc()

        try:
            _ans.index("VSCANNER")
            self._status += "VSCANNER found (substring VSCANNER found in answer to ?VER)."
        except:
            self._status = "communication error : no VSCANNER found on serial \"%s\"" % self.serial

        elog.debug(self._status)
コード例 #14
0
def test_get_comm():
    config = dict()
    with pytest.raises(ValueError):
        get_comm_type(config)

    config = dict(gpib={}, tcp={})
    with pytest.raises(ValueError):
        get_comm_type(config)

    config = dict(tcp={})
    with pytest.raises(KeyError):
        get_comm(config)

    config = dict(tcp={})
    with pytest.raises(TypeError):
        get_comm(config, ctype=SERIAL)

    config = dict(tcp=dict(url='toto'))
    with pytest.raises(KeyError) as err:
        get_comm(config)

    # should work always since tcp uses lazy connection
    tcp = get_comm(config, port=5000)
    assert tcp._host == 'toto'
    assert tcp._port == 5000

    config = dict(tcp=dict(url='toto:4999'))
    tcp = get_comm(config, port=5000)
    assert tcp._host == 'toto'
    assert tcp._port == 4999

    config = dict(gpib=dict(url='enet://toto'))
    gpib = get_comm(config)
    assert gpib.gpib_type == gpib.ENET

    config = dict(serial=dict(url='/dev/tty0', eol='\r'))
    sl = get_comm(config, baudrate=38400, eol='\r\n')
    assert sl._port == config['serial']['url']
    assert sl._serial_kwargs['baudrate'] == 38400
    assert sl._eol == config['serial']['eol']
コード例 #15
0
ファイル: elmo.py プロジェクト: tiagocoutinho/bliss
 def initialize(self):
     config = self.config.config_dict
     if get_comm_type(config) == UDP:
         opt = {'port':5001,'eol':';'}
     else:                   # SERIAL
         opt = {'baudrate':115200,'eol':';'}
         
     self._cnx = get_comm(config,**opt)
     self._elmostate = AxisState()
     for state,human in (('SLAVESWITCH','Slave switch activate'),
                         ('INHIBITSWITCH','Inhibit switch active'),
                         ('CLOSEDLOOPOPEN','Closed loop open'),
                         ('DRIVEFAULT','Problem into the drive')):
         self._elmostate.create_state(state,human)
コード例 #16
0
    def initialize(self):
        config = self.config.config_dict
        if get_comm_type(config) == UDP:
            opt = {'port': 5001, 'eol': ';'}
        else:  # SERIAL
            opt = {'baudrate': 115200, 'eol': ';'}

        self._cnx = get_comm(config, **opt)
        self._elmostate = AxisState()
        for state, human in (('SLAVESWITCH', 'Slave switch activate'),
                             ('INHIBITSWITCH', 'Inhibit switch active'),
                             ('CLOSEDLOOPOPEN', 'Closed loop open'),
                             ('DRIVEFAULT', 'Problem into the drive')):
            self._elmostate.create_state(state, human)
コード例 #17
0
    def __init__(self, name, config):
        self.log = logging.getLogger('{0}({1})'.format(
            type(self).__name__, name))
        self.config = config
        self.name = name
        self.comm = get_comm(config, eol='\r')
        self.comm.flush()

        form = []
        self.__formatter = OrderedDict()
        for counter_config in config.get('counters', ()):
            channel = counter_config['channel']
            quantity = QUANTITIES[channel]
            counter_config['unit'] = quantity['unit']
            self.__formatter[channel] = quantity
            form.append(quantity.formatter())
        self.formatter = ' #t '.join(form) + ' #r'
コード例 #18
0
    def __init__(self, name, config_tree):
        self.name = name

        comm_type = None
        try:
            comm_type = get_comm_type(config_tree)
            key = 'serial' if comm_type == SERIAL else 'tcp'
            config_tree[key]['url']  # test if url is available
            comm_config = config_tree
        except:
            if "serial" in config_tree:
                comm_type = SERIAL
                comm_config = dict(serial=dict(url=config_tree['serial']))
                warn("'serial: <url>' is deprecated. " \
                     "Use 'serial: url: <url>' instead", DeprecationWarning)
            elif "socket" in config_tree:
                comm_type = TCP
                comm_config = dict(tcp=dict(url=config_tree['socket']))
                warn("'socket: <url>' is deprecated. " \
                     "Use 'tcp: url: <url>' instead", DeprecationWarning)
            else:
                raise RuntimeError(
                    "opiom: need to specify a communication url")

        if comm_type not in (SERIAL, TCP):
            raise TypeError('opiom: invalid communication type %r' % comm_type)

        self._cnx = get_comm(comm_config, ctype=comm_type, timeout=3)
        self._cnx.flush()
        self.__program = config_tree['program']
        self.__base_path = config_tree.get('opiom_prg_root', OPIOM_PRG_ROOT)
        self.__debug = False
        try:
            msg = self.comm("?VER", timeout=50e-3)
        except serial.SerialTimeout:
            msg = self.comm("?VER", timeout=50e-3)

        if not msg.startswith('OPIOM'):
            raise IOError("No opiom connected at %s" % serial)
        self.comm("MODE normal")
コード例 #19
0
ファイル: opiom.py プロジェクト: tiagocoutinho/bliss
    def __init__(self,name,config_tree):
        self.name = name

        comm_type = None
        try:
            comm_type = get_comm_type(config_tree)
            key = 'serial' if comm_type == SERIAL else 'tcp'
            config_tree[key]['url'] # test if url is available
            comm_config = config_tree
        except:
            if "serial" in config_tree:
                comm_type = SERIAL
                comm_config = dict(serial=dict(url=config_tree['serial']))
                warn("'serial: <url>' is deprecated. " \
                     "Use 'serial: url: <url>' instead", DeprecationWarning)
            elif "socket" in config_tree:
                comm_type = TCP
                comm_config = dict(tcp=dict(url=config_tree['socket']))
                warn("'socket: <url>' is deprecated. " \
                     "Use 'tcp: url: <url>' instead", DeprecationWarning)
            else:
                raise RuntimeError("opiom: need to specify a communication url")

        if comm_type not in (SERIAL, TCP):
            raise TypeError('opiom: invalid communication type %r' % comm_type)

        self._cnx = get_comm(comm_config, ctype=comm_type, timeout=3)
        self._cnx.flush()
        self.__program = config_tree['program']
        self.__base_path = config_tree.get('opiom_prg_root',OPIOM_PRG_ROOT)
        self.__debug = False
        try:
            msg = self.comm("?VER",timeout=50e-3)
        except serial.SerialTimeout:
            msg = self.comm("?VER",timeout=50e-3)
            
        if not msg.startswith('OPIOM') :
            raise IOError("No opiom connected at %s" % serial)
        self.comm("MODE normal")
コード例 #20
0
    def __init__(self, name, config):
        """ FireFlash hardware controller.

        name -- the controller's name
        config -- controller configuration,
        in this dictionary we need to have:
        command_url -- url of the command port
        control_url -- url of the control port
        """
        # Status bits for getStatus command
        self.StatusBits = {'IDLE': 0, 'BUSY': 1, 'REMOTE': 2, 'STREAMING': 4}
        # Status bits for Remote Data Toggle
        self.ToggleBits = {'OFF': 0, 'XFIT': 1, 'YFIT': 2, 'COG': 4}

        try:
            self.command_socket = get_comm(self.config['command'], ctype=TCP)
        except KeyError:
            command_url = config["command_url"]
            warn("'command_url' keyword is deprecated." \
                 " Use 'command: tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': command_url}}
            self.command_socket = get_comm(comm_cfg)

        try:
            self.control_socket = get_comm(self.config['control'], ctype=TCP)
        except KeyError:
            control_url = config["control_url"]
            warn("'control_url' keyword is deprecated." \
                 " Use 'control: tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': control_url}}
            self.control_socket = get_comm(comm_cfg)

        # Commands ready packed in network byte order
        self.commandReset = struct.pack(">H", 0xAA00)
        self.commandInterrupt = struct.pack(">H", 0xAA01)
        self.commandStatus = struct.pack(">H", 0xAA02)
        self.commandDataToggle = struct.pack(">H", 0xAA03)
        self.commandGetDeviceInfo = struct.pack(">H", 0xAA20)
        self.commandSetConfig = struct.pack(">H", 0xAA22)
        self.commandGetConfig = struct.pack(">H", 0xAA21)
        self.commandGetIntTime = struct.pack(">H", 0xAA23)
        self.commandSetIntTime = struct.pack(">H", 0xAA24)
        self.commandSetParams = struct.pack(">H", 0xAA26)
        self.commandGetParams = struct.pack(">H", 0xAA27)
        self.commandReadImage16 = struct.pack(">H", 0xAA30)
        self.commandReadImage8 = struct.pack(">H", 0xAA31)
        self.commandReadDark16 = struct.pack(">H", 0xAA32)
        self.commandAve16Sum32 = struct.pack(">H", 0xAA33)
        self.commandContinuous = struct.pack(">H", 0xAA37)
        self.commandStreamData = struct.pack(">H", 0xAA3A)

        self._errorCode2string = {
            self.NO_ERROR: "No Error",
            self.CODE1: "Error parsing .ini file",
            self.CODE2: "Could not establish network connection",
            self.CODE3: "Network data transfer failed",
            self.CODE4: "Incorrect FPGA type",
            self.CODE5: "Invalid argument or config param error",
            self.CODE6: "I^C-bus communication error",
            self.CODE7: "Memory initialization error",
            self.CODE8: "I^C-bus initialization error"
        }
        # Device Info structure keys
        self._deviceInfoKeys = [
            'ProcessorType', 'ProcessorVersion', 'FPGAType', 'FPGAVersion',
            'BoardType', 'BoardVersion', 'BuidYear', 'BuildMonth', 'Buildday',
            'BuildHour', 'BuildMinute', 'BuildSecond', 'SWMajor', 'SWMinor',
            'SWbuild', 'FirmWare Major', 'FirmWareMinor', 'FirmWareBuild'
            ', BoardID'
        ]
        # Device configuration parameter keys
        self._deviceConfigKeys = [
            'Settings', 'Gain', 'Offset', 'LineIntTime', 'YEnd',
            'FrameIntTime', 'YStart', 'XStart', 'XEnd', 'AdcPhase',
            'SubtractDarkImage'
        ]
        #Image Descriptor keys
        self._imageDescriptorKeys = [
            'FrameNb', 'IntegrationTime', 'XSize', 'YSize', 'InternalPtr'
        ]
        self._quadConfigKeys = [
            'XCentre', 'YCentre', 'WinStartX', 'WinEndX', 'WinStartY',
            'WinEndY'
        ]
        self._sensorConfigKeys = ['YSize', 'DarkImageSubtract']
        #device parameter keys
        self._deviceParameterKeys = [
            'configurationKeys', 'DAC0Keys', 'DAC1Keys', 'DAC2keys',
            'DAC3Keys', 'fitParameterKeys', 'verticalFitResultCriteria',
            'horizontalFitResultCriteria'
        ]
        self._configurationKeys = [
            'Control', 'XStart', 'YStart', 'Width', 'Height', 'Gain',
            'SensorFineOffset', 'SensorCourseOffset', 'IntegrationTime',
            'ImageClock', 'AdcPhase', 'Orientation', 'RampInc'
        ]
        self._DAC0Keys = self._DAC1Keys = self._DAC2Keys = self._DAC3Keys = [
            'MinOutVoltage', 'MaxOutVoltage', 'MinDACCode', 'MaxDACCode',
            'Action;'
        ]
        self._fitParameterKeys = [
            'MaxDeltaChiSq', 'Threshold', 'MaxIter', 'FilterSpan', 'FilterCtrl'
        ]
        self._fitResultCriteriaKeys = [
            'MaxWidth', 'MinWidth', 'MinRSQ', 'MinAmp', 'CalibCoeff',
            'CalibOffset'
        ]

        self._logger = logging.getLogger("NanoBpmCtrl.NanoBpm")
        logging.basicConfig(level=logging.INFO)
        self._logger.setLevel(logging.DEBUG)
        self._controlWord = 0
        self._nbFramesToSum = 8
        self._thread = None
        self._lock = lock.Semaphore()
        self._remoteDataSelector = 0
        self._frameNbAcquired = -1
        self._actionByte = 0
        self._imageDescriptor = None
        self._configurationParameters = None
        self._dac0Parameters = None
        self._dac1Parameters = None
        self._dac2Parameters = None
        self._dac3Parameters = None
        self._fitParameters = None
        self._vertFitResultParameters = None
        self._horFitResultParameters = None
        self._deviceInfo = self.getDeviceInfo()
        self._deviceConfig = self.getDeviceConfig()
        self._deviceParameters = self.getDeviceParameters()
        # This defines the quad window as the full Image - We do not use the Quad's ROI
        self._quadConfig = OrderedDict(
            zip(self._quadConfigKeys,
                ((self._deviceConfig['XEnd'] - self._deviceConfig['XStart']) /
                 2,
                 (self._deviceConfig['YEnd'] - self._deviceConfig['YStart']) /
                 2, self._deviceConfig['XStart'], self._deviceConfig['XEnd'],
                 self._deviceConfig['YStart'], self._deviceConfig['YEnd'])))
コード例 #21
0
 def initialize(self):
     """
     """
     self.comm = get_comm(self.config)
コード例 #22
0
 def __init__(self, config, port=None):
     port = self.PORT if port is None else port
     self._req_nb = 0
     self._sock = get_comm(config, ctype=TCP, port=port, eol='\r\n')
コード例 #23
0
ファイル: nano_bpm.py プロジェクト: tiagocoutinho/bliss
    def __init__(self, name, config):
        """ FireFlash hardware controller.

        name -- the controller's name
        config -- controller configuration,
        in this dictionary we need to have:
        command_url -- url of the command port
        control_url -- url of the control port
        """
        # Status bits for getStatus command
        self.StatusBits = {'IDLE':0, 'BUSY':1, 'REMOTE':2, 'STREAMING':4}
        # Status bits for Remote Data Toggle
        self.ToggleBits = {'OFF':0,'XFIT':1,'YFIT':2,'COG':4}

        try:
            self.command_socket = get_comm(self.config['command'], ctype=TCP)
        except KeyError:
            command_url = config["command_url"]
            warn("'command_url' keyword is deprecated." \
                 " Use 'command: tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': command_url } }
            self.command_socket = get_comm(comm_cfg)

        try:
            self.control_socket = get_comm(self.config['control'], ctype=TCP)
        except KeyError:
            control_url = config["control_url"]
            warn("'control_url' keyword is deprecated." \
                 " Use 'control: tcp' instead", DeprecationWarning)
            comm_cfg = {'tcp': {'url': control_url } }
            self.control_socket = get_comm(comm_cfg)

        # Commands ready packed in network byte order
        self.commandReset         = struct.pack(">H",0xAA00)
        self.commandInterrupt     = struct.pack(">H",0xAA01)
        self.commandStatus        = struct.pack(">H",0xAA02)
        self.commandDataToggle    = struct.pack(">H",0xAA03)
        self.commandGetDeviceInfo = struct.pack(">H",0xAA20)
        self.commandSetConfig     = struct.pack(">H",0xAA22)
        self.commandGetConfig     = struct.pack(">H",0xAA21)
        self.commandGetIntTime    = struct.pack(">H",0xAA23)
        self.commandSetIntTime    = struct.pack(">H",0xAA24)
        self.commandSetParams     = struct.pack(">H",0xAA26)
        self.commandGetParams     = struct.pack(">H",0xAA27)
        self.commandReadImage16   = struct.pack(">H",0xAA30)
        self.commandReadImage8    = struct.pack(">H",0xAA31)
        self.commandReadDark16    = struct.pack(">H",0xAA32)
        self.commandAve16Sum32    = struct.pack(">H",0xAA33)
        self.commandContinuous    = struct.pack(">H",0xAA37)
        self.commandStreamData    = struct.pack(">H",0xAA3A)

        self._errorCode2string = {
            self.NO_ERROR : "No Error",
            self.CODE1 : "Error parsing .ini file",
            self.CODE2 : "Could not establish network connection",
            self.CODE3 : "Network data transfer failed",
            self.CODE4 : "Incorrect FPGA type",
            self.CODE5 : "Invalid argument or config param error",
            self.CODE6 : "I^C-bus communication error",
            self.CODE7 : "Memory initialization error",
            self.CODE8 : "I^C-bus initialization error"
        }
        # Device Info structure keys
        self._deviceInfoKeys = ['ProcessorType', 'ProcessorVersion', 'FPGAType', 'FPGAVersion', 'BoardType', 'BoardVersion',
            'BuidYear', 'BuildMonth', 'Buildday', 'BuildHour', 'BuildMinute', 'BuildSecond', 'SWMajor', 'SWMinor', 'SWbuild',
            'FirmWare Major', 'FirmWareMinor', 'FirmWareBuild'', BoardID']
        # Device configuration parameter keys
        self._deviceConfigKeys = ['Settings', 'Gain', 'Offset', 'LineIntTime', 'YEnd',
             'FrameIntTime', 'YStart', 'XStart', 'XEnd', 'AdcPhase', 'SubtractDarkImage']
        #Image Descriptor keys
        self._imageDescriptorKeys = ['FrameNb', 'IntegrationTime', 'XSize', 'YSize', 'InternalPtr']
        self._quadConfigKeys = ['XCentre', 'YCentre', 'WinStartX', 'WinEndX', 'WinStartY', 'WinEndY']
        self._sensorConfigKeys = ['YSize', 'DarkImageSubtract']
        #device parameter keys
        self._deviceParameterKeys = ['configurationKeys', 'DAC0Keys', 'DAC1Keys', 'DAC2keys', 'DAC3Keys', 'fitParameterKeys',
                                    'verticalFitResultCriteria', 'horizontalFitResultCriteria']
        self._configurationKeys = ['Control', 'XStart', 'YStart', 'Width', 'Height', 'Gain', 'SensorFineOffset', 'SensorCourseOffset',
                                   'IntegrationTime', 'ImageClock', 'AdcPhase', 'Orientation', 'RampInc']
        self._DAC0Keys = self._DAC1Keys = self._DAC2Keys = self._DAC3Keys = ['MinOutVoltage', 'MaxOutVoltage', 'MinDACCode',
                                                                             'MaxDACCode', 'Action;']
        self._fitParameterKeys = ['MaxDeltaChiSq', 'Threshold', 'MaxIter', 'FilterSpan', 'FilterCtrl']
        self._fitResultCriteriaKeys = ['MaxWidth', 'MinWidth', 'MinRSQ', 'MinAmp', 'CalibCoeff', 'CalibOffset']

        self._logger = logging.getLogger("NanoBpmCtrl.NanoBpm")
        logging.basicConfig(level=logging.INFO)
        self._logger.setLevel(logging.DEBUG)
        self._controlWord = 0
        self._nbFramesToSum = 8
        self._thread = None
        self._lock = lock.Semaphore()
        self._remoteDataSelector = 0
        self._frameNbAcquired = -1
        self._actionByte = 0
        self._imageDescriptor = None
        self._configurationParameters = None
        self._dac0Parameters = None
        self._dac1Parameters = None
        self._dac2Parameters = None
        self._dac3Parameters = None
        self._fitParameters = None
        self._vertFitResultParameters = None
        self._horFitResultParameters = None
        self._deviceInfo = self.getDeviceInfo()
        self._deviceConfig = self.getDeviceConfig()
        self._deviceParameters = self.getDeviceParameters()
        # This defines the quad window as the full Image - We do not use the Quad's ROI
        self._quadConfig = OrderedDict(zip(self._quadConfigKeys, ((self._deviceConfig['XEnd'] - self._deviceConfig['XStart']) / 2,
                                (self._deviceConfig['YEnd'] - self._deviceConfig['YStart']) / 2, self._deviceConfig['XStart'],
                                self._deviceConfig['XEnd'], self._deviceConfig['YStart'], self._deviceConfig['YEnd'])))
コード例 #24
0
    def __init__(self, name, config):
        """ Linkam controller with either hot stage or dsc stage
            config_-- controller configuration,
        """
        self.name = name
        self._logger = logging.getLogger(str(self))
        logging.basicConfig(level=10)
        try:
            self._cnx = get_comm(config,
                                 SERIAL,
                                 baudrate=19200,
                                 eol='\r',
                                 timeout=10)
        except ValueError:
            if "serial_url" in config:
                warn(
                    "'serial_url' keyword is deprecated. Use 'serial' instead",
                    DeprecationWarning)
                comm_cfg = {'serial': {'url': config['serial_url']}}
                self._cnx = get_comm(comm_cfg,
                                     baudrate=19200,
                                     eol='\r',
                                     timeout=10)
            else:
                raise ValueError, "Must specify serial"

        #Possible values of the status byte
        self.STOPPED = 0x1
        self.HEATING = 0x10
        self.COOLING = 0x20
        self.HOLDINGLIMIT = 0x30
        self.HOLDINGTIME = 0x40
        self.HOLDINGTEMP = 0x50

        self.StatusToString = {
            self.STOPPED: "Stopped",
            self.HEATING: "Heating",
            self.COOLING: "Cooling",
            self.HOLDINGLIMIT: "Holding the limit time",
            self.HOLDINGTEMP: "Holding the current temperature",
        }
        # Linkam error codes
        self.LINKAM_COOLING_TOOFAST = 0x01
        self.LINKAM_OPEN_CIRCUIT = 0x02
        self.LINKAM_POWER_SURGE = 0x04
        self.LINKAM_EXIT_300 = 0x08
        self.LINKAM_LINK_ERROR = 0x20
        self.LINKAM_OK = 0x80

        self.ErrorToString = {
            self.LINKAM_COOLING_TOOFAST: "Cooling too fast",
            self.LINKAM_OPEN_CIRCUIT:
            "Stage not connected or sensor is open circuit",
            self.LINKAM_POWER_SURGE: "Current protection due to overload",
            self.LINKAM_EXIT_300:
            "No Exit (300 TS 1500 tried to exit profile at a temperature > 300 degrees)",
            self.LINKAM_LINK_ERROR:
            "Problems with RS-232 data transmission - RESET Linkam !",
            self.LINKAM_OK: "OK"
        }

        self._maximumTemp = config.get('max_temp', 1500.0)
        self._minimumTemp = config.get('min_temp', -196.0)
        self._model = config.get('model', "T95")
        self._profile_task = None
        self._lock = lock.Semaphore()
        self._hasDSC = self._hasDscStage()
        (self._state, self._errCode, _, _) = self._getStatus()
        self._temperature = self.getTemperature()
        self._limit = self._temperature
        self._rampNb = 1
        self._rate = 10
        self._holdTime = 1
        self._dscSamplingRate = 0.3
        self._statusString = None
        self._pumpSpeed = 0
        self._dscValue = 0.
        self._startingRamp = 1
        self._pollTime = 0.1
        self._pipe = os.pipe()
        self._hold = True
        self._tstamp = 0
        self._profileCompleteCallback = None
        self._profileData = [[]]
コード例 #25
0
ファイル: linkam.py プロジェクト: tiagocoutinho/bliss
    def __init__(self, name, config):
        """ Linkam controller with either hot stage or dsc stage
            config_-- controller configuration,
        """
        self.name = name
        self._logger = logging.getLogger(str(self))
        logging.basicConfig(level=10)
        try:
            self._cnx = get_comm(config, SERIAL, baudrate=19200, eol='\r',
                                 timeout=10)
        except ValueError:
            if "serial_url" in config:
                warn("'serial_url' keyword is deprecated. Use 'serial' instead",
                     DeprecationWarning)
                comm_cfg = {'serial': {'url': config['serial_url'] }}
                self._cnx = get_comm(comm_cfg, baudrate=19200, eol='\r', timeout=10)
            else:
                raise ValueError, "Must specify serial"

        #Possible values of the status byte
        self.STOPPED = 0x1
        self.HEATING = 0x10
        self.COOLING = 0x20
        self.HOLDINGLIMIT = 0x30
        self.HOLDINGTIME = 0x40
        self.HOLDINGTEMP = 0x50

        self.StatusToString = {
            self.STOPPED: "Stopped",
            self.HEATING: "Heating",
            self.COOLING: "Cooling",
            self.HOLDINGLIMIT: "Holding the limit time",
            self.HOLDINGTEMP: "Holding the current temperature",
        }
        # Linkam error codes
        self.LINKAM_COOLING_TOOFAST = 0x01
        self.LINKAM_OPEN_CIRCUIT = 0x02
        self.LINKAM_POWER_SURGE = 0x04
        self.LINKAM_EXIT_300 = 0x08
        self.LINKAM_LINK_ERROR = 0x20
        self.LINKAM_OK = 0x80

        self.ErrorToString = {
            self.LINKAM_COOLING_TOOFAST: "Cooling too fast",
            self.LINKAM_OPEN_CIRCUIT: "Stage not connected or sensor is open circuit",
            self.LINKAM_POWER_SURGE: "Current protection due to overload",
            self.LINKAM_EXIT_300: "No Exit (300 TS 1500 tried to exit profile at a temperature > 300 degrees)",
            self.LINKAM_LINK_ERROR: "Problems with RS-232 data transmission - RESET Linkam !",
            self.LINKAM_OK: "OK"
        }

        self._maximumTemp = config.get('max_temp', 1500.0)
        self._minimumTemp = config.get('min_temp', -196.0)
        self._model = config.get('model', "T95")
        self._profile_task = None
        self._lock = lock.Semaphore()
        self._hasDSC = self._hasDscStage()
        (self._state, self._errCode, _, _) = self._getStatus()
        self._temperature = self.getTemperature()
        self._limit = self._temperature
        self._rampNb = 1
        self._rate = 10
        self._holdTime = 1
        self._dscSamplingRate = 0.3;
        self._statusString = None
        self._pumpSpeed = 0
        self._dscValue = 0.
        self._startingRamp = 1
        self._pollTime = 0.1
        self._pipe = os.pipe()
        self._hold = True;
        self._tstamp=0
        self._profileCompleteCallback = None
        self._profileData = [[]]
コード例 #26
0
ファイル: template.py プロジェクト: tiagocoutinho/bliss
 def initialize(self):
     """
     """
     self.comm = get_comm(self.config)
コード例 #27
0
ファイル: shexapod.py プロジェクト: tiagocoutinho/bliss
 def __init__(self, config):
     self._log = logging.getLogger('SHexapod')
     self.config = config
     self.eol = '\r\n'
     self.comm = get_comm(config, ctype=TCP, port=self.DEFAULT_PORT,
                          eol=self.eol)