Skip to content
Snippets Groups Projects
__main__.py 3.98 KiB
Newer Older
esarrey's avatar
esarrey committed
# File:         __main__.py
# Author:       Eliott Sarrey
# Date:         June 2023
# Email:        eliott.sarrey@gmail.com
# 
# ███╗   ███╗██╗███╗   ██╗██╗    ███╗   ███╗ ██████╗ ██╗  ██╗███████╗
# ████╗ ████║██║████╗  ██║██║    ████╗ ████║██╔═══██╗██║ ██╔╝██╔════╝
# ██╔████╔██║██║██╔██╗ ██║██║    ██╔████╔██║██║   ██║█████╔╝ █████╗  
# ██║╚██╔╝██║██║██║╚██╗██║██║    ██║╚██╔╝██║██║   ██║██╔═██╗ ██╔══╝  
# ██║ ╚═╝ ██║██║██║ ╚████║██║    ██║ ╚═╝ ██║╚██████╔╝██║  ██╗███████╗
# ╚═╝     ╚═╝╚═╝╚═╝  ╚═══╝╚═╝    ╚═╝     ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝
#
#
esarrey's avatar
esarrey committed
# Description:
#   This is the software for the Mini-MOKE setup of the Spintronics lab at ETHZ
#   The software is based on the pymeasure libraries
#   For the purpose of the software, some classes had to be rewritten and improved, like the UIWindow class
#   In order to keep it clean, the library itself has been left unchanged and the new classes are included in the src folder
esarrey's avatar
esarrey committed
# 
esarrey's avatar
esarrey committed
#   If you have any question regarding this software, please reach out to the author.
import sys
esarrey's avatar
esarrey committed
import qdarkstyle
esarrey's avatar
esarrey committed
from pymeasure.experiment import Results, unique_filename
from pymeasure.display.Qt import QtWidgets
esarrey's avatar
esarrey committed
from PyQt5.QtGui import QIcon
esarrey's avatar
esarrey committed
from src.ui         import UIWindow, UserManualTab, LiveTab, MotorsTab
esarrey's avatar
esarrey committed
from src.procedures import B_Sweep, X_Sweep, Y_Sweep, XY_Sweep
esarrey's avatar
esarrey committed
class MainWindow(UIWindow):
esarrey's avatar
esarrey committed
    """
    Class of for the main window of the sofware, defining the input section, the graph sections and all the tabs
    """
    def __init__(self):
        super().__init__(
esarrey's avatar
esarrey committed
            procedure_class=[B_Sweep, X_Sweep, Y_Sweep, XY_Sweep],
esarrey's avatar
esarrey committed
                ['acq_time','freq','demod','rate','lockin_bw','mod_amp','cst_out1','cst_out2','b_min','b_max','b_step','x','y','full_hyste'],
                ['acq_time','freq','demod','rate','lockin_bw','mod_amp','cst_out1','cst_out2','x_min','x_max','x_step','y','b'],
                ['acq_time','freq','demod','rate','lockin_bw','mod_amp','cst_out1','cst_out2','y_min','y_max','y_step','x','b'],
                ['acq_time','freq','demod','rate','lockin_bw','mod_amp','cst_out1','cst_out2','x_min','x_max','x_step','y_min','y_max','y_step','b']
                ],
            displays=['acq_time', 'freq'],
esarrey's avatar
esarrey committed
            x_axis='Iteration',
esarrey's avatar
esarrey committed
            y_axis='Voltage DC (V)',
esarrey's avatar
esarrey committed
            widget_list=(UserManualTab("User Manual"), MotorsTab("Motor control"), LiveTab("Live measurements")),
esarrey's avatar
esarrey committed
            directory_input=True
        )
        self.setWindowTitle('Mini MOKE')
esarrey's avatar
esarrey committed
        self.setWindowIcon(QIcon('assets/icon.ico'))

    def queue(self, procedure=None):
esarrey's avatar
esarrey committed
        """
        Queue the next experiment and save it to the data folder
        """
esarrey's avatar
esarrey committed
        if procedure is None: procedure = self.make_procedure()
esarrey's avatar
esarrey committed
        file = unique_filename(directory=self.directory,
esarrey's avatar
esarrey committed
                               prefix=self.sample_name_line.text()+"_"+procedure.name+"_",
esarrey's avatar
esarrey committed
                               dated_folder=True,
                               datetimeformat="%Y-%m-%d-%Hh%M"
                               )
esarrey's avatar
esarrey committed
        results = Results(procedure, file)
        experiment = self.new_experiment(results)

esarrey's avatar
esarrey committed
        self.manager.queue(experiment)      # Queue the experiment
if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
esarrey's avatar
esarrey committed
    dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()
    app.setStyleSheet(dark_stylesheet)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())