def generate_chip_key(self, **kwargs):
        '''
        Generates a valid ``MultiZMQ_IO`` chip key

        :param chip_id: ``int`` corresponding to internal chip id

        :param io_chain: ``int`` corresponding to daisy chain number

        :param address: ``str`` corresponding to the address of the DAQ board

        '''
        req_fields = ('chip_id', 'io_chain', 'address')
        if not all([key in kwargs for key in req_fields]):
            raise ValueError('Missing fields required to generate chip id'
                             ', requires {}, received {}'.format(
                                 req_fields, kwargs.keys()))
        if not isinstance(kwargs['chip_id'], int):
            raise ValueError('chip_id must be int')
        if not isinstance(kwargs['io_chain'], int):
            raise ValueError('io_chain must be int')
        if not isinstance(kwargs['address'], str):
            raise ValueError('address must be str')
        if kwargs['address'] not in self._io_group_table.inv:
            raise KeyError('no known io group for {}'.format(
                kwargs['address']))
        io_channel = kwargs['io_chain']
        if io_channel in self._miso_map:
            io_channel = self._miso_map[io_channel]
        return Key.from_dict(
            dict(io_group=self._io_group_table.inv[kwargs['address']],
                 io_channel=io_channel,
                 chip_id=kwargs['chip_id']))
示例#2
0
    def generate_chip_key(self, **kwargs):
        '''
        Generates a valid ``ZMQ_IO`` chip key

        :param chip_id: ``int`` corresponding to internal chip id

        :param io_chain: ``int`` corresponding to daisy chain number

        '''
        req_fields = ('chip_id', 'io_chain')
        if not all([key in kwargs for key in req_fields]):
            raise ValueError('Missing fields required to generate chip id'
                ', requires {}, received {}'.format(req_fields, kwargs.keys()))
        io_channel = kwargs['io_chain']
        if io_channel in self._miso_map:
            io_channel = self._miso_map[io_channel]
        return Key.from_dict(dict(
                io_channel = io_channel,
                chip_id = kwargs['chip_id'],
                io_group = self._io_group_table.inv[self._address]
            ))