Ejemplo n.º 1
0
    def _get_next(self):
        ret_cmd, ret_args = self._data_queue.get()
        if ret_cmd == "error":
            raise ClientError("exception raised in SPI communcation process")
        elif ret_cmd != "get_next":
            raise ClientError
        info, buffer = ret_args

        data = protocol.decode_output_buffer(buffer, self._mode,
                                             self._num_subsweeps)

        if not self._experimental_stitching:
            cur_seq_num = info.get("sequence_number")
            if cur_seq_num:
                if self._seq_num:
                    if cur_seq_num > self._seq_num + 1:
                        log.info("missed sweep")
                    if cur_seq_num <= self._seq_num:
                        log.info("got same sweep twice")
                self._seq_num = cur_seq_num

        if self.squeeze:
            return info, data
        else:
            return [info], np.expand_dims(data, 0)
Ejemplo n.º 2
0
    def _get_next(self):
        packet = self._recv_packet(allow_recovery_skip=True)

        if not isinstance(packet, protocol.UnpackedStreamData):
            raise ClientError("got unexpected type of frame")

        info = {}
        for addr, enc_val in packet.result_info:
            try:
                reg = protocol.get_reg(addr, self._mode)
                val = protocol.decode_reg_val(reg, enc_val)
            except protocol.ProtocolError:
                log.info("got unknown reg val in result info")
                log.info("addr: {}, value: {}".format(
                    addr, utils.fmt_enc_val(enc_val)))
            else:
                info[reg.name] = val

        data = protocol.decode_output_buffer(packet.buffer, self._mode,
                                             self._num_subsweeps)

        if self.squeeze:
            return info, data
        else:
            return [info], np.expand_dims(data, 0)