diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 0000000..0348ec7 --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,10 @@ +from pathlib import Path + +from pymodaq_utils.resources.hatch_build_plugins import PluginInfoTomlHook + +here = Path(__file__).absolute().parent + + +class PluginInfoTomlHook(PluginInfoTomlHook): + def update(self, metadata: dict) -> None: + super().update_custom(metadata, here) diff --git a/plugin_info.toml b/plugin_info.toml index 494300c..6ba6a0e 100644 --- a/plugin_info.toml +++ b/plugin_info.toml @@ -13,7 +13,7 @@ license = 'MIT' [plugin-install] #packages required for your plugin: -packages-required = ['pymodaq>=4.3.0'] +packages-required = ['pymodaq>=5.0.1'] [features] # defines the plugin features contained into this plugin instruments = true # true if plugin contains instrument classes (else false, notice the lowercase for toml files) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7bd0630 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["hatchling>=1.9.0", "hatch-vcs", "toml", "pymodaq_utils"] +build-backend = "hatchling.build" + +[project] +dynamic = ["version", "authors", "dependencies", "description", "urls", "entry-points"] +readme = "README.rst" +license = { file="LICENSE" } +requires-python = ">=3.8" + +name = "pymodaq_plugins_template" + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Other Environment", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering :: Human Machine Interfaces", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: User Interfaces", +] + +[tool.hatch.metadata.hooks.custom] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.targets.sdist] +include = [ + "/src", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index c85f63a..0000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -from pymodaq.resources.setup_plugin import setup -from pathlib import Path - -setup(Path(__file__).parent) diff --git a/src/pymodaq_plugins_template/__init__.py b/src/pymodaq_plugins_template/__init__.py index ca051e5..fc34855 100644 --- a/src/pymodaq_plugins_template/__init__.py +++ b/src/pymodaq_plugins_template/__init__.py @@ -1,5 +1,5 @@ from pathlib import Path -from pymodaq.utils.logger import set_logger # to be imported by other modules. +from pymodaq_utils.logger import set_logger # to be imported by other modules. from .utils import Config config = Config() diff --git a/src/pymodaq_plugins_template/app/custom_app_template.py b/src/pymodaq_plugins_template/app/custom_app_template.py index fdc49bc..ec46ad8 100644 --- a/src/pymodaq_plugins_template/app/custom_app_template.py +++ b/src/pymodaq_plugins_template/app/custom_app_template.py @@ -1,8 +1,8 @@ from qtpy import QtWidgets -from pymodaq.utils import gui_utils as gutils -from pymodaq.utils.config import Config -from pymodaq.utils.logger import set_logger, get_module_name +from pymodaq_gui import utils as gutils +from pymodaq_utils.config import Config +from pymodaq_utils.logger import set_logger, get_module_name # todo: replace here *pymodaq_plugins_template* by your plugin package name from pymodaq_plugins_template.utils import Config as PluginConfig diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index 8ec7754..98874b0 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -1,7 +1,8 @@ -from pymodaq.control_modules.move_utility_classes import DAQ_Move_base, comon_parameters_fun, main, DataActuatorType,\ - DataActuator # common set of parameters for all actuators -from pymodaq.utils.daq_utils import ThreadCommand # object used to send info back to the main thread -from pymodaq.utils.parameter import Parameter +from pymodaq.control_modules.move_utility_classes import (DAQ_Move_base, comon_parameters_fun, + main, DataActuatorType, DataActuator) + +from pymodaq_utils.utils import ThreadCommand # object used to send info back to the main thread +from pymodaq_gui.parameter import Parameter class PythonWrapperOfYourInstrument: @@ -40,7 +41,7 @@ class DAQ_Move_Template(DAQ_Move_base): is_multiaxes = False # TODO for your plugin set to True if this plugin is controlled for a multiaxis controller _axis_names = ['Axis1', 'Axis2'] # TODO for your plugin: complete the list _epsilon = 0.1 # TODO replace this by a value that is correct depending on your controller - data_actuator_type = DataActuatorType['DataActuator'] # wether you use the new data style for actuator otherwise set this + data_actuator_type = DataActuatorType.DataActuator # wether you use the new data style for actuator otherwise set this # as DataActuatorType['float'] (or entirely remove the line) params = [ # TODO for your custom plugin: elements to be added here as dicts in order to control your custom stage diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py index a73ca43..2396226 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py @@ -1,9 +1,11 @@ import numpy as np -from pymodaq.utils.daq_utils import ThreadCommand -from pymodaq.utils.data import DataFromPlugins, DataToExport -from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main -from pymodaq.utils.parameter import Parameter +from pymodaq_utils.utils import ThreadCommand +from pymodaq_data.data import DataToExport +from pymodaq_gui.parameter import Parameter + +from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main +from pymodaq.utils.data import DataFromPlugins class PythonWrapperOfYourInstrument: # TODO Replace this fake class with the import of the real python wrapper of your instrument @@ -15,6 +17,7 @@ class PythonWrapperOfYourInstrument: # for the class name and the file name.) # (3) this file should then be put into the right folder, namely IN THE FOLDER OF THE PLUGIN YOU ARE DEVELOPING: # pymodaq_plugins_my_plugin/daq_viewer_plugins/plugins_0D + class DAQ_0DViewer_Template(DAQ_Viewer_base): """ Instrument plugin class for a OD viewer. diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py index 17e8459..4203070 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py @@ -1,8 +1,11 @@ import numpy as np -from pymodaq.utils.daq_utils import ThreadCommand -from pymodaq.utils.data import DataFromPlugins, Axis, DataToExport + +from pymodaq_utils.utils import ThreadCommand +from pymodaq_data.data import DataToExport, Axis +from pymodaq_gui.parameter import Parameter + from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main -from pymodaq.utils.parameter import Parameter +from pymodaq.utils.data import DataFromPlugins class PythonWrapperOfYourInstrument: @@ -15,6 +18,8 @@ class PythonWrapperOfYourInstrument: # for the class name and the file name.) # (3) this file should then be put into the right folder, namely IN THE FOLDER OF THE PLUGIN YOU ARE DEVELOPING: # pymodaq_plugins_my_plugin/daq_viewer_plugins/plugins_1D + + class DAQ_1DViewer_Template(DAQ_Viewer_base): """ Instrument plugin class for a 1D viewer. diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py index 7f917a5..eef7a22 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py @@ -1,9 +1,11 @@ -from pymodaq.utils.daq_utils import ThreadCommand -from pymodaq.utils.data import DataFromPlugins, Axis, DataToExport -from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main -from pymodaq.utils.parameter import Parameter +import numpy as np +from pymodaq_utils.utils import ThreadCommand +from pymodaq_data.data import DataToExport, Axis +from pymodaq_gui.parameter import Parameter +from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main +from pymodaq.utils.data import DataFromPlugins class PythonWrapperOfYourInstrument: # TODO Replace this fake class with the import of the real python wrapper of your instrument pass diff --git a/src/pymodaq_plugins_template/extensions/custom_extension_template.py b/src/pymodaq_plugins_template/extensions/custom_extension_template.py index 5406107..efc2813 100644 --- a/src/pymodaq_plugins_template/extensions/custom_extension_template.py +++ b/src/pymodaq_plugins_template/extensions/custom_extension_template.py @@ -1,8 +1,12 @@ from qtpy import QtWidgets -from pymodaq.utils import gui_utils as gutils -from pymodaq.utils.config import Config, get_set_preset_path, ConfigError -from pymodaq.utils.logger import set_logger, get_module_name +from pymodaq_gui import utils as gutils +from pymodaq_utils.config import Config, ConfigError +from pymodaq_utils.logger import set_logger, get_module_name + +from pymodaq.utils.config import get_set_preset_path +from pymodaq.extensions.utils import CustomExt + # todo: replace here *pymodaq_plugins_template* by your plugin package name from pymodaq_plugins_template.utils import Config as PluginConfig @@ -20,7 +24,7 @@ # todo: modify the name of this class to reflect its application and change the name in the main # method at the end of the script -class CustomExtensionTemplate(gutils.CustomApp): +class CustomExtensionTemplate(CustomExt): # todo: if you wish to create custom Parameter and corresponding widgets. These will be # automatically added as children of self.settings. Morevover, the self.settings_tree will @@ -131,5 +135,6 @@ def main(): f"preset_for_{CLASS_NAME.lower()} = {'a name for an existing preset'}" ) + if __name__ == '__main__': main() diff --git a/src/pymodaq_plugins_template/models/PIDModelTemplate.py b/src/pymodaq_plugins_template/models/PIDModelTemplate.py index 2f47f13..2b2dce8 100644 --- a/src/pymodaq_plugins_template/models/PIDModelTemplate.py +++ b/src/pymodaq_plugins_template/models/PIDModelTemplate.py @@ -1,5 +1,10 @@ -from pymodaq.extensions.pid.utils import PIDModelGeneric, OutputToActuator, InputFromDetector, main -from pymodaq.utils.data import DataToExport +import numpy as np + +from pymodaq.extensions.pid.utils import PIDModelGeneric, DataToActuatorPID, main +from pymodaq_data.data import DataToExport, DataCalculated + +from pymodaq.utils.data import DataActuator + from typing import List @@ -62,9 +67,12 @@ def convert_input(self, measurements: DataToExport): """ x, y = some_function_to_convert_the_data(measurements) - return InputFromDetector([y, x]) + return DataToExport('pid inputs', + data=[DataCalculated('pid calculated', + data=[np.array([x]), + np.array([y])])]) - def convert_output(self, outputs: List[float], dt: float, stab=True): + def convert_output(self, outputs: List[float], dt: float, stab=True) -> DataToActuatorPID: """ Convert the output of the PID in units to be fed into the actuator Parameters @@ -81,7 +89,9 @@ def convert_output(self, outputs: List[float], dt: float, stab=True): """ outputs = some_function_to_convert_the_pid_outputs(outputs, dt, stab) - return OutputToActuator(mode='rel', values=outputs) + return DataToActuatorPID('pid output', mode='rel', + data=[DataActuator(self.actuators_name[ind], data=outputs[ind]) + for ind in range(len(outputs))]) if __name__ == '__main__': diff --git a/src/pymodaq_plugins_template/resources/config_template.toml b/src/pymodaq_plugins_template/resources/config_template.toml index 3736213..a2604a3 100644 --- a/src/pymodaq_plugins_template/resources/config_template.toml +++ b/src/pymodaq_plugins_template/resources/config_template.toml @@ -1,2 +1,2 @@ -#this is the configuration file of the plugin +title = 'this is the configuration file of the plugin XXX' diff --git a/src/pymodaq_plugins_template/utils.py b/src/pymodaq_plugins_template/utils.py index 1f225ab..4981b95 100644 --- a/src/pymodaq_plugins_template/utils.py +++ b/src/pymodaq_plugins_template/utils.py @@ -6,7 +6,7 @@ """ from pathlib import Path -from pymodaq.utils.config import BaseConfig, USER +from pymodaq_utils.config import BaseConfig, USER class Config(BaseConfig):