From 7af88ee730c30c8587f380253018c31ef9fbe590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Weber?= Date: Fri, 2 Feb 2024 11:47:26 +0100 Subject: [PATCH] remove unused files --- .../extensions/myextension.py | 195 ------------------ .../models/PIDModelTemplate.py | 90 -------- 2 files changed, 285 deletions(-) delete mode 100644 src/pymodaq_plugins_raspberry/extensions/myextension.py delete mode 100644 src/pymodaq_plugins_raspberry/models/PIDModelTemplate.py diff --git a/src/pymodaq_plugins_raspberry/extensions/myextension.py b/src/pymodaq_plugins_raspberry/extensions/myextension.py deleted file mode 100644 index 1f458ad..0000000 --- a/src/pymodaq_plugins_raspberry/extensions/myextension.py +++ /dev/null @@ -1,195 +0,0 @@ -from pymodaq.utils import gui_utils as gutils -from pymodaq.utils import daq_utils as utils -from pyqtgraph.parametertree import Parameter, ParameterTree -from pymodaq.utils.parameter import pymodaq_ptypes -from qtpy import QtWidgets, QtCore - -from pymodaq.utils.plotting.data_viewers.viewer1D import Viewer1D -from pymodaq.utils.plotting.data_viewers.viewer2D import Viewer2D - - -config = utils.load_config() -logger = utils.set_logger(utils.get_module_name(__file__)) - -EXTENSION_NAME = 'MY_EXTENSION_NAME' -CLASS_NAME = 'MyExtension' - - -class MyExtension(gutils.CustomApp): - # list of dicts enabling the settings tree on the user interface - params = [ - {'title': 'Main settings:', 'name': 'main_settings', 'type': 'group', 'children': [ - {'title': 'Save base path:', 'name': 'base_path', 'type': 'browsepath', - 'value': config['data_saving']['h5file']['save_path']}, - {'title': 'File name:', 'name': 'target_filename', 'type': 'str', 'value': "", 'readonly': True}, - {'title': 'Date:', 'name': 'date', 'type': 'date', 'value': QtCore.QDate.currentDate()}, - {'title': 'Do something, such as showing data:', 'name': 'do_something', 'type': 'bool', 'value': False}, - {'title': 'Something done:', 'name': 'something_done', 'type': 'led', 'value': False, 'readonly': True}, - {'title': 'Infos:', 'name': 'info', 'type': 'text', 'value': ""}, - {'title': 'push:', 'name': 'push', 'type': 'bool_push', 'value': False} - ]}, - {'title': 'Other settings:', 'name': 'other_settings', 'type': 'group', 'children': [ - {'title': 'List of stuffs:', 'name': 'list_stuff', 'type': 'list', 'value': 'first', - 'limits': ['first', 'second', 'third'], 'tip': 'choose a stuff from the list'}, - {'title': 'List of integers:', 'name': 'list_int', 'type': 'list', 'value': 0, - 'limits': [0, 256, 512], 'tip': 'choose a stuff from this int list'}, - {'title': 'one integer:', 'name': 'an_integer', 'type': 'int', 'value': 500, }, - {'title': 'one float:', 'name': 'a_float', 'type': 'float', 'value': 2.7, }, - ]}, - ] - - def __init__(self, dockarea, dashboard): - super().__init__(dockarea, dashboard) - self.setup_ui() - - def connect_things(self): - pass - - def setup_docks(self): - """ - to be subclassed to setup the docks layout - for instance: - - self.docks['ADock'] = gutils.Dock('ADock name) - self.dockarea.addDock(self.docks['ADock"]) - self.docks['AnotherDock'] = gutils.Dock('AnotherDock name) - self.dockarea.addDock(self.docks['AnotherDock"], 'bottom', self.docks['ADock"]) - - See Also - ######## - pyqtgraph.dockarea.Dock - """ - self.docks['settings'] = gutils.Dock('Settings') - self.dockarea.addDock(self.docks['settings']) - self.docks['settings'].addWidget(self.settings_tree) - - self.docks['modmanager'] = gutils.Dock('Module Manager') - self.dockarea.addDock(self.docks['modmanager'], 'right', self.docks['settings']) - self.docks['modmanager'].addWidget(self.modules_manager.settings_tree) - - self.docks['viewer1D'] = gutils.Dock('Viewers') - self.dockarea.addDock(self.docks['viewer1D'], 'right', self.docks['modmanager']) - - self.docks['viewer2D'] = gutils.Dock('Viewers') - self.dockarea.addDock(self.docks['viewer2D'], 'bottom', self.docks['viewer1D']) - - widg = QtWidgets.QWidget() - self.viewer1D = Viewer1D(widg) - self.docks['viewer1D'].addWidget(widg) - - widg1 = QtWidgets.QWidget() - self.viewer2D = Viewer2D(widg1) - self.docks['viewer2D'].addWidget(widg1) - - def setup_menu(self): - ''' - to be subclassed - create menu for actions contained into the self.actions_manager, for instance: - - For instance: - - file_menu = self.menubar.addMenu('File') - self.actions_manager.affect_to('load', file_menu) - self.actions_manager.affect_to('save', file_menu) - - file_menu.addSeparator() - self.actions_manager.affect_to('quit', file_menu) - ''' - pass - - def value_changed(self, param): - ''' to be subclassed for actions to perform when one of the param's value in self.settings is changed - - For instance: - if param.name() == 'do_something': - if param.value(): - print('Do something') - self.settings.child('main_settings', 'something_done').setValue(False) - - Parameters - ---------- - param: (Parameter) the parameter whose value just changed - ''' - if param.name() == 'do_something': - if param.value(): - self.modules_manager.det_done_signal.connect(self.show_data) - else: - self.modules_manager.det_done_signal.disconnect() - - def param_deleted(self, param): - ''' to be subclassed for actions to perform when one of the param in self.settings has been deleted - - Parameters - ---------- - param: (Parameter) the parameter that has been deleted - ''' - raise NotImplementedError - - def child_added(self, param): - ''' to be subclassed for actions to perform when a param has been added in self.settings - - Parameters - ---------- - param: (Parameter) the parameter that has been deleted - ''' - raise NotImplementedError - - def setup_actions(self): - pass - - def show_data(self, data_all): - data1D = [] - data2D = [] - labels1D = [] - labels2D = [] - dims = ['data1D', 'data2D'] - for det in data_all: - for dim in dims: - if len(data_all[det][dim]) != 0: - for channel in data_all[det][dim]: - if dim == 'data1D': - labels1D.append(channel) - data1D.append(data_all[det][dim][channel]['data']) - else: - labels2D.append(channel) - data2D.append(data_all[det][dim][channel]['data']) - self.viewer1D.show_data(data1D) - self.viewer2D.setImage(*data2D[:min(3, len(data2D))]) - - - -def main(): - import sys - from pymodaq.dashboard import DashBoard - from pathlib import Path - app = QtWidgets.QApplication(sys.argv) - mainwindow = QtWidgets.QMainWindow() - dockarea = gutils.DockArea() - mainwindow.setCentralWidget(dockarea) - - # init the dashboard - mainwindow_dash = QtWidgets.QMainWindow() - area_dash = gutils.DockArea() - mainwindow_dash.setCentralWidget(area_dash) - dashboard = DashBoard(area_dash) - file = Path(utils.get_set_preset_path()).joinpath(f"{config['presets']['default_preset_for_scan']}.xml") - if file.exists(): - dashboard.set_preset_mode(file) - else: - msgBox = QtWidgets.QMessageBox() - msgBox.setText(f"The default file specified in the configuration file does not exists!\n" - f"{file}\n" - f"Impossible to load the DAQ_Scan Module") - msgBox.setStandardButtons(msgBox.Ok) - ret = msgBox.exec() - - prog = MyExtension(dockarea, dashboard) - - mainwindow.show() - sys.exit(app.exec_()) - - -if __name__ == '__main__': - main() - - diff --git a/src/pymodaq_plugins_raspberry/models/PIDModelTemplate.py b/src/pymodaq_plugins_raspberry/models/PIDModelTemplate.py deleted file mode 100644 index 2f47f13..0000000 --- a/src/pymodaq_plugins_raspberry/models/PIDModelTemplate.py +++ /dev/null @@ -1,90 +0,0 @@ -from pymodaq.extensions.pid.utils import PIDModelGeneric, OutputToActuator, InputFromDetector, main -from pymodaq.utils.data import DataToExport -from typing import List - - -def some_function_to_convert_the_pid_outputs(outputs: List[float], dt: float, stab=True): - """ Should be replaced here or in the model class to process the outputs """ - return outputs - - -def some_function_to_convert_the_data(measurements: DataToExport): - """ Should be replaced here or in the model class to process the measurement """ - a = 0 - b = 1 - return [a, b] - - -class PIDModelTemplate(PIDModelGeneric): - limits = dict(max=dict(state=False, value=100), - min=dict(state=False, value=-100),) - konstants = dict(kp=0.1, ki=0.000, kd=0.0000) - - Nsetpoints = 2 # number of setpoints - setpoint_ini = [128, 128] # number and values of initial setpoints - setpoints_names = ['Xaxis', 'Yaxis'] # number and names of setpoints - - actuators_name = ["Xpiezo", "Ypiezo"] # names of actuator's control modules involved in the PID - detectors_name = ['Camera'] # names of detector's control modules involved in the PID - - params = [] # list of dict to initialize specific Parameters - - def __init__(self, pid_controller): - super().__init__(pid_controller) - - def update_settings(self, param): - """ - Get a parameter instance whose value has been modified by a user on the UI - Parameters - ---------- - param: (Parameter) instance of Parameter object - """ - if param.name() == '': - pass - - def ini_model(self): - super().ini_model() - - # add here other specifics initialization if needed - - def convert_input(self, measurements: DataToExport): - """ - Convert the measurements in the units to be fed to the PID (same dimensionality as the setpoint) - Parameters - ---------- - measurements: DataToExport - Data from the declared detectors from which the model extract a value of the same units as the setpoint - - Returns - ------- - InputFromDetector: the converted input in the setpoints units - - """ - - x, y = some_function_to_convert_the_data(measurements) - return InputFromDetector([y, x]) - - def convert_output(self, outputs: List[float], dt: float, stab=True): - """ - Convert the output of the PID in units to be fed into the actuator - Parameters - ---------- - outputs: List of float - output value from the PID from which the model extract a value of the same units as the actuator - dt: float - Ellapsed time since the last call to this function - stab: bool - - Returns - ------- - OutputToActuator: the converted output - - """ - outputs = some_function_to_convert_the_pid_outputs(outputs, dt, stab) - return OutputToActuator(mode='rel', values=outputs) - - -if __name__ == '__main__': - main("BeamSteeringMockNoModel.xml") # some preset configured with the right actuators and detectors - -