예제 #1
0
def flock_demo(args=None):

    # TODO: Make this an actual flock

    print(
        'Please make sure that the simulator is running.\n'
        'You can start it by running the following command in another terminal:\n\n'
        'lantz sims fungen tcp')

    # We import a helper function to start the app
    from lantz.qt import start_gui_app, wrap_driver_cls

    # The block consists of two parts the backend and the frontend
    from lantz.qt.blocks import FeatScan, FeatScanUi

    # An this you know already
    from lantz.drivers.examples import LantzSignalGenerator

    QLantzSignalGenerator = wrap_driver_cls(LantzSignalGenerator)

    with QLantzSignalGenerator('TCPIP::localhost::5678::SOCKET') as fungen:

        # Here we instantiate the backend setting 'frequency' as the Feat to scan
        # and specifying in which instrument
        app = FeatScan('frequency', instrument=fungen)

        # Now we use the helper to start the app.
        # It takes a Backend instance and a FrontEnd class
        start_gui_app(app, FeatScanUi)
예제 #2
0
    def testpanel(args=None):
        """Run simulators.
        """

        parser = argparse.ArgumentParser(
            description='Open a testpanel. Requires lantz.qt')
        parser.add_argument('packfile',
                            help='Path of the pack file.',
                            type=common.Packfile.from_file)

        args = parser.parse_args(args)

        from lantz.qt.utils.qt import QtGui

        klass = _load_class(args.packfile.class_spec)

        from lantz.qt import start_test_app, wrap_driver_cls

        from lantz.core.log import log_to_screen, DEBUG

        log_to_screen(DEBUG)

        Qklass = wrap_driver_cls(klass)
        with Qklass.via_packfile(args.packfile, check_update=True) as inst:
            start_test_app(inst)
예제 #3
0
def uifile_demo(args=None):
    print(
        'Please make sure that the simulator is running.\n'
        'You can start it by running the following command in another terminal:\n\n'
        'lantz sims fungen tcp')

    import os

    UIFILE = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                          'assets', 'fungen.ui')

    from lantz.drivers.examples import LantzSignalGenerator

    from lantz.qt import start_gui, wrap_driver_cls

    QLantzSignalGenerator = wrap_driver_cls(LantzSignalGenerator)
    with QLantzSignalGenerator('TCPIP::localhost::5678::SOCKET') as inst:
        start_gui(UIFILE, inst)
예제 #4
0
def testpanel_demo(args=None):
    """Run simulators.
    """

    from lantz.qt.utils.qt import QtGui
    """
    QtGui.QMessageBox.information(None,
                                  'Lantz Test Panel Demo'
                                  'Please run the following command in the console\n'
                                  'to start the simulator:\n\n'
                                  '    lantz sims fungen tcp')
    """
    print(
        'Please make sure that the simulator is running.\n'
        'You can start it by running the following command in another terminal:\n\n'
        'lantz sims fungen tcp')

    from lantz.drivers.examples import LantzSignalGenerator

    from lantz.qt import start_test_app, wrap_driver_cls

    QLantzSignalGenerator = wrap_driver_cls(LantzSignalGenerator)
    with QLantzSignalGenerator('TCPIP::localhost::5678::SOCKET') as inst:
        start_test_app(inst)
예제 #5
0
    from lantz.core import ureg

    from lantz.core.log import log_to_screen, log_to_socket, DEBUG

    from lantz.qt import start_gui_app, wrap_driver_cls

    # Uncommment this line to log to socket
    # log_to_socket(DEBUG)

    # or comment this line to stop logging
    log_to_screen(DEBUG)

    # Instead of using the TemperatureSensor driver, we automagically create
    # a Qt aware version of it. This allows
    QTemperatureSensor = wrap_driver_cls(TemperatureSensor)

    # We initialize the board via the packfile to autodetect it.
    # You can alternative use the COMPORT using the `via_serial`
    # However, notice that using the packfile is superior as it allows you:
    # - to check if the software on the arduino is up to date with the version on your computer.
    #   and update it if necessary.
    # - works even if the comport has changed
    # - you can specify the model and/or serialno of the board to use a particular one
    #   if you have many connected.

    # The `with` syntax as equivalent to:
    # - instantiate the driver
    # - initialize the driver
    # - finalize the driver (even if there was a bug and the software crashes!)
예제 #6
0
    def turn_on_LED_method(self):
        self.board.led = True

    def turn_off_LED_method(self):
        self.board.led = False


class LEDUserInterfase(Frontend):
    gui = 'LED.ui'

    def connect_backend(self):
        super().connect_backend()
        self.widget.turn_on_led_button.clicked.connect(
            self.backend.turn_on_LED_method)
        self.widget.turn_off_led_button.clicked.connect(
            self.backend.turn_off_LED_method)


if __name__ == '__main__':
    from lantz.core.log import log_to_screen, log_to_socket, DEBUG
    from lantz.qt import start_gui_app, wrap_driver_cls

    # ~ log_to_socket(DEBUG) # Uncommment this line to log to socket
    log_to_screen(DEBUG)  # or comment this line to stop logging

    QLED = wrap_driver_cls(LEDDriver)
    with QLED.via_packfile('LEDDriver.pack.yaml', check_update=True) as board:
        app = LEDBackend(board=board)
        start_gui_app(app, LEDUserInterfase)
예제 #7
0
from uc480.core import Camera
from uc480.core import CameraControl, CameraSave, SpectraAnalyzer, SpectraSave, FFTAnalyzer, Main, MainUi

#from lantz.qt.app import build_qapp

if __name__ == '__main__':

    from lantz.core.log import log_to_screen, log_to_socket, DEBUG, ERROR, INFO
    from lantz.qt import start_gui_app, wrap_driver_cls

#    log_to_socket(DEBUG)
    log_to_screen(ERROR)
    
    QCamera = wrap_driver_cls(Camera)

    with QCamera() as camera:
        control_be = CameraControl(camera=camera)
        camera_save_be = CameraSave(camera_control_be=control_be)
        spectra_be = SpectraAnalyzer(camera_control_backend=control_be)
        save_be = SpectraSave(spectra_analyzer_be=spectra_be)
        fft_be = FFTAnalyzer(spectra_analyzer_backend=spectra_be)
        
        app = Main(control_be=control_be, camera_save_be=camera_save_be, spectra_be=spectra_be, save_be=save_be, fft_be=fft_be)
        start_gui_app(app, MainUi)