示例#1
0
 def debug_this_thread():
     try:
         # Only available during debugging session. It's important to not install this module in Python evnironment.
         import debugpy
         debugpy.debug_this_thread()
     except:
         pass
示例#2
0
        def callback_duplex(indata, outdata, frames, time, status):
            import time
            # print(time.time_ns()/1e6)

            global sweep_data
            global pt_data

            if 'debugpy' in sys.modules:
                import debugpy
                debugpy.debug_this_thread()

            if status:
                print(status)

            out_length = frames
            if pt_data + out_length > record_data.shape[0]:
                out_length -= pt_data + out_length - record_data.shape[0]
            # print(out_length)

            # print(data.shape)
            # print(indata.shape)

            if out_length > 0:
                snippet = sweep_data[pt_data:pt_data + out_length, :]

                # level = np.sqrt(np.mean(snippet ** 2))
                # if not np.isnan(level):
                #     anzeige = '#' * int(level*80)
                #     print(anzeige)

                outdata[:out_length, :] = snippet
                pt_data += out_length

                if pt_data + out_length < record_data.shape[0]:
                    record_data[pt_data:pt_data +
                                out_length, :] = indata[:out_length, :]
示例#3
0
def connect_vscode_debugger(port=5678):
    """
	Connect to Visual Studio Code for debugging. This function blocks until the debugger
	is connected! Not recommended for use in startup.py

	.. note:: See https://docs.binary.ninja/dev/plugins.html#remote-debugging-with-vscode for step-by-step instructions on how to set up Python debugging.

	:param port: Port number for connecting to the debugger.
	"""
    # pip install --user debugpy
    import debugpy  # type: ignore
    import sys
    if sys.platform == "win32":
        debugpy.configure(python=f"{sys.base_exec_prefix}/python",
                          qt="pyside2")
    else:
        debugpy.configure(python=f"{sys.base_exec_prefix}/bin/python3",
                          qt="pyside2")
    debugpy.listen(("127.0.0.1", port))
    debugpy.wait_for_client()
    execute_on_main_thread(lambda: debugpy.debug_this_thread())
示例#4
0
 def foo(x):
     debugpy.debug_this_thread()
     event.set()  # @bp
     return 0
示例#5
0
    def on_activate(self):
        """ Initialisation performed during activation of the module.
        """
        # Store references to connected modules
        self._streamer = self._streamer_con()
        self._savelogic = self._savelogic_con()

        debugpy.debug_this_thread()

        # Flag to stop the loop and process variables
        self._stop_requested = True
        self._data_recording_active = False
        self._record_start_time = None

        # Check valid StatusVar
        # active channels
        avail_channels = tuple(ch.name
                               for ch in self._streamer.available_channels)
        if self._active_channels is None:
            if self._streamer.active_channels:
                self._active_channels = tuple(
                    ch.name for ch in self._streamer.active_channels)
            else:
                self._active_channels = avail_channels
        elif any(ch not in avail_channels for ch in self._active_channels):
            self.log.warning(
                'Invalid active channels found in StatusVar. StatusVar ignored.'
            )
            if self._streamer.active_channels:
                self._active_channels = tuple(
                    ch.name for ch in self._streamer.active_channels)
            else:
                self._active_channels = avail_channels

        # averaged channels
        if self._averaged_channels is None:
            self._averaged_channels = self._active_channels
        else:
            self._averaged_channels = tuple(ch
                                            for ch in self._averaged_channels
                                            if ch in self._active_channels)

        # Check for odd moving averaging window
        if self._moving_average_width % 2 == 0:
            self.log.warning(
                'Moving average width ConfigOption must be odd integer number. '
                'Changing value from {0:d} to {1:d}.'
                ''.format(self._moving_average_width,
                          self._moving_average_width + 1))
            self._moving_average_width += 1

        # set settings in streamer hardware
        settings = self.all_settings
        settings['active_channels'] = self._active_channels
        settings['data_rate'] = self._data_rate
        self.configure_settings(**settings)

        # set up internal frame loop connection
        self._sigNextDataFrame.connect(self.acquire_data_block,
                                       QtCore.Qt.QueuedConnection)
        return
示例#6
0
文件: countergui.py 项目: kiotex/qudi
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Qudi. If not, see <http://www.gnu.org/licenses/>.

Copyright (c) the Qudi Developers. See the COPYRIGHT.txt file at the
top-level directory of this distribution and at <https://github.com/Ulm-IQO/qudi/>
"""

import numpy as np
import os
import pyqtgraph as pg

import debugpy
debugpy.debug_this_thread()

from core.connector import Connector
from gui.colordefs import QudiPalettePale as palette
from gui.guibase import GUIBase
from qtpy import QtCore
from qtpy import QtWidgets
from qtpy import uic


class CounterMainWindow(QtWidgets.QMainWindow):
    """ Create the Main Window based on the *.ui file. """
    def __init__(self, **kwargs):
        # Get the path to the *.ui file
        this_dir = os.path.dirname(__file__)
        ui_file = os.path.join(this_dir, 'ui_slow_counter.ui')