Skip to content

Commit

Permalink
new plugin features layout
Browse files Browse the repository at this point in the history
  • Loading branch information
seb5g committed Nov 5, 2023
1 parent b344c11 commit 3a45a99
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
10 changes: 9 additions & 1 deletion plugin_info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ license = 'MIT'
[plugin-install]
#packages required for your plugin:
packages-required = ['pydaqmx', 'pymodaq>4.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)
extensions = false # true if plugins contains dashboard extensions
pid_models = false # true if plugins contains pid models
h5exporters = false # true if plugin contains custom h5 file exporters
scanners = false # true if plugin contains custom scan layout (daq_scan extensions)

19 changes: 16 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from pathlib import Path

with open(str(Path(__file__).parent.joinpath(f'src/{PLUGIN_NAME}/VERSION')), 'r') as fvers:
with open(str(Path(__file__).parent.joinpath(f'src/{PLUGIN_NAME}/resources/VERSION')), 'r') as fvers:
version = fvers.read().strip()


Expand Down Expand Up @@ -36,14 +36,27 @@
"Topic :: Software Development :: User Interfaces",
], )

entrypoints = {}
if 'features' in config:
if config['features'].get('instruments', False):
entrypoints['pymodaq.instruments'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'
if config['features'].get('extensions', False):
entrypoints['pymodaq.extensions'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'
if config['features'].get('pid_models', False):
entrypoints['pymodaq.pid_models'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'
if config['features'].get('h5exporters', False):
entrypoints['pymodaq.h5exporters'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'
if config['features'].get('scanners', False):
entrypoints['pymodaq.scanners'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'
else:
entrypoints['pymodaq.instruments'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'

setup(
version=version,
packages=find_packages(where='./src'),
package_dir={'': 'src'},
include_package_data=True,
entry_points={'pymodaq.plugins': f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'},
entry_points=entrypoints,
install_requires=['toml', ]+config['plugin-install']['packages-required'],
**setupOpts
)

2 changes: 1 addition & 1 deletion src/pymodaq_plugins_daqmx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from pymodaq.utils.logger import set_logger # to be imported by other modules.

with open(str(Path(__file__).parent.joinpath('VERSION')), 'r') as fvers:
with open(str(Path(__file__).parent.joinpath('resources/VERSION')), 'r') as fvers:
__version__ = fvers.read().strip()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from qtpy import QtWidgets, QtCore
from qtpy.QtCore import Signal, QThread
from pymodaq.utils.daq_utils import ThreadCommand, getLineInfo
from pymodaq.utils.data import DataFromPlugins, Axis
from pymodaq.utils.data import DataFromPlugins, Axis, DataActuator, DataToExport
import numpy as np
from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base
from pymodaq.control_modules.move_utility_classes import DAQ_Move_base
Expand Down Expand Up @@ -470,7 +470,6 @@ class DAQ_NIDAQmx_Viewer(DAQ_Viewer_base, DAQ_NIDAQmx_base):
refresh_hardware
"""

data_grabed_signal = Signal(list)
live_mode_available = True
params = viewer_params + DAQ_NIDAQmx_base.params

Expand All @@ -487,8 +486,6 @@ def __init__(self, parent=None, params_state=None, control_type="0D"):
elif self.control_type == "Actuator":
self.settings.child('NIDAQ_type').setLimits(['Analog_Output'])



self.settings.child('ao_channels').hide()

#timer used for the counter
Expand All @@ -510,7 +507,6 @@ def commit_settings(self, param):
update_NIDAQ_channels, update_task, DAQ_NIDAQ_source, refresh_hardware
"""


if param.parent() is not None:
if param.parent().name() == 'ai_channels':
device = param.opts['title'].split('/')[0]
Expand All @@ -522,7 +518,6 @@ def commit_settings(self, param):

DAQ_NIDAQmx_base.commit_settings(self, param)


def ini_detector(self, controller=None):
"""
Initialisation procedure of the detector.
Expand Down Expand Up @@ -596,27 +591,24 @@ def emit_data(self, taskhandle, status, callbackdata):
for ind in range(len(self.channels)):
data_tot.append(np.array([np.mean(data[ind*N:(ind+1)*N])]))
self.data_grabed_signal.emit([DataFromPlugins(name='NI AI', data=data_tot, dim='Data0D',
labels=channels_name)])
labels=channels_name)])
else:
for ind in range(len(self.channels)):
data_tot.append(data[ind*N:(ind+1)*N])
self.data_grabed_signal.emit([DataFromPlugins(name='NI AI', data=data_tot, dim='Data1D',
labels=channels_name,
x_axis=Axis(data=np.linspace(0, N / self.clock_settings.frequency, N),
y_axis=Axis(label='Analog Input', units=''),
label='Time', units='s'))])

self.data_grabed_signal.emit([
DataFromPlugins(name='NI AI', data=data_tot, dim='Data1D',
labels=channels_name,
axes=[Axis(data=np.linspace(0, N / self.clock_settings.frequency, N),
index=0)])])
return 0 #mandatory for the PyDAQmx callback



def counter_done(self):
channels_name = [ch.name for ch in self.channels]
data_counter = self.readCounter(len(self.channels),
self.settings['counter_settings', 'counting_time'] * 1e-3)
self.data_grabed_signal.emit([DataFromPlugins(name='NI Counter', data=[data_counter / 1e-3], dim='Data0D',
labels=channels_name,
y_axis=Axis(label='Count Number', units='1/s'))])
labels=channels_name,)])
#y_axis=Axis(label='Count Number', units='1/s'))])
self.task.StopTask()


Expand Down Expand Up @@ -655,9 +647,7 @@ def __init__(self, parent=None, params_state=None, control_type="Actuator"):

self.settings.child('clock_settings', 'Nsamples').setValue(1)



def check_position(self):
def get_actuator_value(self) -> DataActuator:
"""Get the current position from the hardware with scaling conversion.
Returns
Expand Down
File renamed without changes.
Empty file.
2 changes: 2 additions & 0 deletions src/pymodaq_plugins_daqmx/resources/config_template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title = 'Configuration file of the DAQmx plugin'

0 comments on commit 3a45a99

Please sign in to comment.