Example #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)
Example #2
0
    # 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!)

    with QTemperatureSensor.via_packfile('TemperatureSensor.pack.yaml',
                                         check_update=True) as board:
        # We then create the backend and provide the driver we have just created
        # This will be bound to the corresponding instrument slot
        app = TemperatureMonitor(interval=5 * ureg.second, board=board)

        # Then we use the start_gui_app. Notice that we provide the class for the Ui, not an instance
        start_gui_app(app, TemperatureMonitorUi)
Example #3
0
from uc480.core.app import SpectraAnalyzer, SpectraAnalyzerUi, SpectraSave, SpectraSaveUi, SpectraViewerUi, SpectraMainUi
from uc480.utilities import enums

from lantz.core import ureg
from lantz.qt.app import Backend, Frontend, InstrumentSlot, QtCore
from lantz.qt.app import BackendSlot

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

#    log_to_socket(DEBUG)
log_to_screen(DEBUG)

spectra_be = SpectraAnalyzer(camera_control_backend=None)

# Then we use the start_gui_app. Notice that we provide the class for the Ui, not an instance
start_gui_app(spectra_be, SpectraAnalyzerUi)
Example #4
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)
Example #5
0
    # 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!)

    with QTemperatureSensor.via_packfile('TemperatureSensor.pack.yaml',
                                         check_update=True) as board:
        # We then create the backend and provide the driver we have just created
        # This will be bound to the corresponding instrument slot
        app = TemperatureMonitor(interval=5 * ureg.second, board=board)

        # Then we use the start_gui_app. Notice that we provide the class for the Ui, not an instance
        start_gui_app(app, TemperaturePlotterUi)
Example #6
0
from uc480.core.app import CameraSave as Backend
from uc480.core.app import CameraSaveUi as Frontend

from lantz.core.log import log_to_screen, DEBUG
from lantz.qt import start_gui_app

log_to_screen(DEBUG)
backend = Backend(None)
start_gui_app(backend, Frontend)
Example #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)
Example #8
0
from uc480.core import Camera
from uc480.core import CameraControl, CameraSave, CameraSaveUi, CameraMain, CameraSaveMainUi
from uc480.utilities import enums

import numpy as np

#from lantz.qt.app import build_qapp

if __name__ == '__main__':

    from lantz.core.log import log_to_screen, log_to_socket, DEBUG, ERROR
    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)
        
        app = CameraMain(control_be=control_be, camera_save_be=camera_save_be)
        start_gui_app(camera_save_be, CameraSaveUi)
Example #9
0
    # 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!)

    with QTemperatureSensor.via_packfile('TemperatureSensor.pack.yaml',
                                         check_update=True) as board:
        # We then create the backend and provide the driver we have just created
        # This will be bound to the corresponding instrument slot
        app = Temperature(board=board)

        # Then we use the start_gui_app. Notice that we provide the class for the Ui, not an instance
        start_gui_app(app, TemperatureUi)
Example #10
0
    def setupUi(self):
        super().setupUi()
        
        # Leftbar
        self.l_leftbar = layout = get_layout0(vertical=True)
        layout.addWidget(self.spectra_analyzer_ui)
        layout.addWidget(self.spectra_save_ui)
        layout.addStretch()
        self.leftbar.setLayout(layout)
        
        # Central, page 1
        self.l_spectrum_page = layout = get_layout0(vertical=False)
        layout.addWidget(self.spectra_viewer_ui)
        self.spectrum_page.setLayout(layout)


log_to_screen(DEBUG)
spectra_analyzer_be = SpectraAnalyzer(None)
spectra_save_be = SpectraSave(None)

main_be = Main(spectra_analyzer_be=spectra_analyzer_be, spectra_save_be=spectra_save_be)

start_gui_app(main_be, MainUi)







Example #11
0
from uc480.core import Camera, CameraControl, CameraControlUi
from uc480.utilities import enums

from lantz.core import ureg
from lantz.qt.app import Backend, Frontend, InstrumentSlot, QtCore
from lantz.qt.app import BackendSlot

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

from pyueye import ueye

#    log_to_socket(DEBUG)
log_to_screen(DEBUG)

QCamera = wrap_driver_cls(Camera)

with QCamera() as camera:
    control_be = CameraControl(camera=camera)
    start_gui_app(control_be, CameraControlUi)