Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/pymodaq_plugins_hamamatsu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from pymodaq_utils.utils import get_version, PackageNotFoundError
from pathlib import Path
from pymodaq.utils.logger import set_logger # to be imported by other modules.

from .utils import Config
config = Config()
from pymodaq_utils.utils import get_version, PackageNotFoundError
from pymodaq_utils.logger import set_logger, get_module_name

config = Config()
try:
__version__ = get_version(__package__)
except PackageNotFoundError:
Expand Down
125 changes: 0 additions & 125 deletions src/pymodaq_plugins_hamamatsu/app/custom_app_template.py

This file was deleted.

5 changes: 2 additions & 3 deletions src/pymodaq_plugins_hamamatsu/daq_move_plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import importlib
from pathlib import Path
from pymodaq.daq_utils import daq_utils as utils
logger = utils.set_logger('move_plugins', add_to_console=False)
from .. import set_logger
logger = set_logger('move_plugins', add_to_console=False)

for path in Path(__file__).parent.iterdir():
try:
Expand All @@ -10,4 +10,3 @@
except Exception as e:
logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
pass

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
importlib.import_module('.' + path.stem, __package__)
except Exception as e:
logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
pass
pass
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import numpy as np
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
from pymodaq.control_modules.viewer_utility_classes import (
DAQ_Viewer_base,
comon_parameters,
main,
)
from pymodaq.utils.data import DataFromPlugins
from pymodaq_data.data import Axis, DataToExport
from pymodaq_gui.parameter import Parameter
from pymodaq_utils.utils import ThreadCommand

from pymodaq_plugins_hamamatsu.hardware.minispectro import MiniSpectro
from pymodaq_plugins_hamamatsu.hardware.minispectro import Minispectro


class DAQ_1DViewer_MiniSpectro(DAQ_Viewer_base):
class DAQ_1DViewer_Minispectro(DAQ_Viewer_base):
""" Instrument plugin class for Hamamatsu USB Mini-spectrometers.

This object inherits all functionalities to communicate with PyMoDAQ's DAQ_Viewer module through inheritance via
Expand All @@ -20,12 +25,12 @@ class DAQ_1DViewer_MiniSpectro(DAQ_Viewer_base):
Tested with PyMoDAQ 4.4.7 on Windows 11.

The "specu1b.dll" driver is required and is obtained through the installation of Hamamatsu Tokuspec software. This plugin
should work with the .dll file in its default location (C:\Program Files\Hamamatsu\TokuSpec) but make sure to change its
should work with the .dll file in its default location (C:/Program Files/Hamamatsu/TokuSpec) but make sure to change its
path in the python wrapper "minispectro.py" in the case you place it somewhere else. This .dll file can also be found in
the installation files of the Hamamatsu Evaluation Software originally provided with the device CD.
"""

supported_platforms = ('win32',) # a Windows .NET driver
# supported_platforms = ('win32',) # a Windows .NET driver
params = comon_parameters + [
{'title': 'Device ID', 'name': 'unit_id', 'type': 'str', 'value': '', 'readonly': True},
{'title': 'Sensor name', 'name': 'sensor_name', 'type': 'str', 'value': '', 'readonly': True},
Expand All @@ -43,33 +48,9 @@ class DAQ_1DViewer_MiniSpectro(DAQ_Viewer_base):
]

def ini_attributes(self):
self.controller: MiniSpectro = None
self.controller: Minispectro = None
self.x_axis = None

def commit_settings(self, param: Parameter):
"""Apply the consequences of a change of value in the detector settings

Parameters
----------
param: Parameter
A given parameter (within detector_settings) whose value has been changed by the user
"""
if param.name() == "integration_time":
self.controller.set_parameter(integ_time=int(self.settings['integration_time']*1e3)) # Convert from ms to µs
if param.name() == 'trig_mode':
if param.value() == 'Internal':
self.controller.set_parameter(trigger_mode=0x00)
elif param.value() == 'External (edge)':
self.controller.set_parameter(trigger_mode=0x01)
elif param.value() == 'External (gate)':
self.controller.set_parameter(trigger_mode=0x02)
if param.name() == 'trig_edge':
if param.value() == 'Rising edge':
self.controller.set_parameter(trigger_mode=0x00)
elif param.value() == 'Falling edge':
self.controller.set_parameter(trigger_mode=0x01)


def ini_detector(self, controller=None):
"""Detector communication initialization

Expand All @@ -85,10 +66,15 @@ def ini_detector(self, controller=None):
initialized: bool
False if initialization failed otherwise True
"""
self.ini_detector_init(slave_controller=controller)
# self.ini_detector_init(slave_controller=controller)

if self.is_master:
self.controller = MiniSpectro()
self.controller = Minispectro()
self.controller.connect()
initialized = self.controller.check_connection()
else:
self.controller = controller
initialized = True

self.settings.child('unit_id').setValue(self.controller.unit_id)
self.settings.child('sensor_name').setValue(self.controller.sensor_name)
Expand All @@ -106,7 +92,7 @@ def ini_detector(self, controller=None):
self.settings.child('gain').setValue('None')
self.settings.child('gain').setReadonly()

data_x_axis = self.controller.get_sensor_data()[1]*1e-9
data_x_axis = np.array(self.controller.wl)*1e-9 # Axis' axes needs array + conversion to nm
self.x_axis = Axis(data=data_x_axis, label='Wavelength', units='m', index=0)

# Initialize viewers panel with the future type of data
Expand All @@ -116,13 +102,13 @@ def ini_detector(self, controller=None):
dim='Data1D', labels=['Spectrometer'],
axes=[self.x_axis])]))

info = "Whatever info you want to log"
info = "Minispectrometer initialized"
initialized = True
return info, initialized

def close(self):
"""Terminate the communication protocol"""
if self.controller is not None:
if self.is_master and self.controller is not None:
self.controller.close()

def grab_data(self, Naverage=1, **kwargs):
Expand All @@ -137,8 +123,8 @@ def grab_data(self, Naverage=1, **kwargs):
others optionals arguments
"""
# Synchrone version (blocking function)
data_tot = self.controller.get_sensor_data()[2]
self.dte_signal.emit(DataToExport(name='MiniSpectro',
data_tot = self.controller.get_sensor_data()
self.dte_signal.emit(DataToExport(name='minispectro',
data=[DataFromPlugins(name='Mini-spectrometer',
data=data_tot,
dim='Data1D',
Expand All @@ -147,10 +133,32 @@ def grab_data(self, Naverage=1, **kwargs):

def stop(self):
"""
Stop the current grab by emitting a status. Works by stopping to call get_sensor_data() function)
Stop the current grab by emitting a status.
"""
self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log']))
self.emit_status(ThreadCommand('Update_Status', ['Useless for mini-spectrometers (no existing stop function)']))

def commit_settings(self, param: Parameter):
"""Apply the consequences of a change of value in the detector settings

Parameters
----------
param: Parameter
A given parameter (within detector_settings) whose value has been changed by the user
"""
if param.name() == "integration_time":
self.controller.set_parameter(integ_time=int(self.settings['integration_time']*1e3)) # Convert from ms to µs
if param.name() == 'trig_mode':
if param.value() == 'Internal':
self.controller.set_parameter(trigger_mode=0x00)
elif param.value() == 'External (edge)':
self.controller.set_parameter(trigger_mode=0x01)
elif param.value() == 'External (gate)':
self.controller.set_parameter(trigger_mode=0x02)
if param.name() == 'trig_edge':
if param.value() == 'Rising edge':
self.controller.set_parameter(trigger_mode=0x00)
elif param.value() == 'Falling edge':
self.controller.set_parameter(trigger_mode=0x01)

if __name__ == '__main__':
main(__file__)
Loading
Loading