Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/pymodaq_plugins_daqmx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
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 pymodaq_utils.utils import get_version, PackageNotFoundError

try:
__version__ = get_version(__package__)
except PackageNotFoundError:
__version__ = '0.0.0dev'

from .utils import Config
config = Config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DAQ_NIDAQmx_Actuator(DAQ_Move_base, DAQ_NIDAQmx_base):
*params* dictionnary
=============== ==============
"""
_controller_units = 'Volts'
_controller_units = 'V'
is_multiaxes = False # set to True if this plugin is controlled for a multiaxis controller (with a unique communication link)
stage_names = [] # "list of strings of the multiaxes

Expand Down Expand Up @@ -163,6 +163,12 @@ def move_Home(self):
## TODO: Reimplement in your daq_move with NIDAQmx library
raise NotImplementedError

def close(self):
"""Terminate the communication protocol: close the current task of the controller"""
controller = getattr(self, 'controller', None)
if controller is not None:
controller.close()

def stop_motion(self):
"""
Call the specific move_done function (depending on the hardware).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DAQ_NIDAQmx_Viewer(DAQ_Viewer_base, DAQ_NIDAQmx_base):
param_devices = NIDAQmx.get_NIDAQ_devices().device_names
params = viewer_params + [
{'title': 'Devices :', 'name': 'devices', 'type': 'list', 'limits': param_devices,
'value': param_devices[0]
'value': param_devices[0] if param_devices else ''
},
] + DAQ_NIDAQmx_base.params

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,31 @@
from nidaqmx.system import System as niSystem
from nidaqmx.system.device import Device as niDevice
from nidaqmx import Task as niTask
from nidaqmx.errors import DaqError, DAQmxErrors
from nidaqmx.errors import DaqError, DAQmxErrors, DaqNotFoundError
from pymodaq_plugins_daqmx import config


logger = set_logger(get_module_name(__file__))


class _NoDevices:
"""Stands for the collection of devices when the NI-DAQmx driver is not installed: no device at all.

The modules of the plugin build their settings when they are imported, which then must not fail on a computer
without the driver (for instance a continuous integration runner).
"""
device_names = []

def __iter__(self):
return iter(())

def __len__(self):
return 0

def __contains__(self, item):
return False


class ClockSettingsBase:
def __init__(self, Nsamples=1000, repetition=False):

Expand Down Expand Up @@ -202,6 +220,9 @@ def get_NIDAQ_devices(cls):
if devices == ['']:
devices = []
return devices
except DaqNotFoundError: # the NI-DAQmx driver is not installed
logger.warning('The NI-DAQmx driver is not installed: no NI device can be listed')
return _NoDevices()
except DaqError as e:
return e.error_code

Expand Down
Loading