diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1fd78cc..22f63ef 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,14 @@
-
+
+
+
+
+
+
+
+
@@ -81,7 +88,7 @@
-
+
@@ -126,7 +133,7 @@
-
+
@@ -137,11 +144,11 @@
-
+
-
+
@@ -152,11 +159,11 @@
-
+
-
+
@@ -167,11 +174,11 @@
-
-
+
+
-
+
@@ -182,41 +189,41 @@
-
-
+
+
-
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
@@ -244,7 +251,8 @@
-
+
+
@@ -354,11 +362,6 @@
262
-
- file://$PROJECT_DIR$/hardwarelibrary/devicemanager.py
- 215
-
-
file://$PROJECT_DIR$/hardwarelibrary/tests/testPhysicalDevice.py
298
@@ -369,6 +372,21 @@
293
+
+ file://$PROJECT_DIR$/hardwarelibrary/tests/testIntegraDevice.py
+ 11
+
+
+
+ file://$PROJECT_DIR$/hardwarelibrary/spectrometers/oceaninsight.py
+ 804
+
+
+
+ file://$PROJECT_DIR$/test.py
+ 3
+
+
@@ -383,7 +401,7 @@
-
+
diff --git a/hardwarelibrary/__init__.py b/hardwarelibrary/__init__.py
index 634f582..748570f 100644
--- a/hardwarelibrary/__init__.py
+++ b/hardwarelibrary/__init__.py
@@ -1,7 +1,7 @@
__version__ = "1.0.5"
__author__ = "Daniel Cote "
-__all__ = ["communication","motion","oscilloscope","powermeters","spectrometers"]
+__all__ = ["communication", "motion", "oscilloscope", "powermeters", "spectrometers"]
# We want the modules at the top level
from .devicemanager import *
@@ -14,6 +14,6 @@
import hardwarelibrary.spectrometers
import hardwarelibrary.oscilloscope
import hardwarelibrary.motion
-# import hardwarelibrary.cameras
-#import sources #TODO: Not much to see here yet
\ No newline at end of file
+# import hardwarelibrary.cameras #TODO: Not much to see here yet
+# import hardwarelibrary.sources #TODO: Not much to see here yet
diff --git a/hardwarelibrary/daq/labjackdevice.py b/hardwarelibrary/daq/labjackdevice.py
index 8c762c7..f4a52d7 100644
--- a/hardwarelibrary/daq/labjackdevice.py
+++ b/hardwarelibrary/daq/labjackdevice.py
@@ -5,8 +5,8 @@
class LabjackDevice(PhysicalDevice, AnalogIOProtocol, DigitalIOProtocol):
classIdVendor = 0x0cd5
classIdProduct = 0x003
- def __init__(self, serialNumber="*"):
- super().__init__(serialNumber, idProduct=0x003, idVendor=0x0cd5)
+ def __init__(self, serialNumber="*", idProduct=0x003, idVendor=0x0cd5):
+ super().__init__(serialNumber, idProduct=idProduct, idVendor=idVendor)
self.dev = None
def doInitializeDevice(self):
diff --git a/hardwarelibrary/devicemanager.py b/hardwarelibrary/devicemanager.py
index f31f0fc..05b3c98 100644
--- a/hardwarelibrary/devicemanager.py
+++ b/hardwarelibrary/devicemanager.py
@@ -218,7 +218,7 @@ def usbDeviceConnected(self, usbDevice):
# This may throw if incompat:
# deviceInstanceible
try:
- candidateClass(serialNumber=descriptor.serialNumber,
+ deviceInstance = candidateClass(serialNumber=descriptor.serialNumber,
idProduct=descriptor.idProduct,
idVendor=descriptor.idVendor)
deviceInstance.initializeDevice()
diff --git a/hardwarelibrary/spectrometers/oceaninsight.py b/hardwarelibrary/spectrometers/oceaninsight.py
index 15edc67..b051d94 100644
--- a/hardwarelibrary/spectrometers/oceaninsight.py
+++ b/hardwarelibrary/spectrometers/oceaninsight.py
@@ -815,6 +815,12 @@ class USB2000Plus(USB4000_2000Plus):
def __init__(self, serialNumber=None, idProduct:int = None, idVendor:int = None):
USB4000_2000Plus.__init__(self, serialNumber=serialNumber, idProduct=idProduct, idVendor=idVendor, model="USB2000+")
+class SAS(USB4000_2000Plus):
+ classIdProduct = 0x1006
+
+ def __init__(self, serialNumber=None, idProduct:int = None, idVendor:int = None):
+ USB4000_2000Plus.__init__(self, serialNumber=serialNumber, idProduct=idProduct, idVendor=idVendor)
+
class DebugSpectro:
class Emitter(NamedTuple):
diff --git a/hardwarelibrary/tests/testIntegraDevice.py b/hardwarelibrary/tests/testIntegraDevice.py
index 5bf4280..9246de3 100644
--- a/hardwarelibrary/tests/testIntegraDevice.py
+++ b/hardwarelibrary/tests/testIntegraDevice.py
@@ -12,7 +12,10 @@ class TestIntegraDevice(unittest.TestCase):
def setUp(self):
self.device = IntegraDevice()
self.assertIsNotNone(self.device)
- self.device.initializeDevice()
+ try:
+ self.device.initializeDevice()
+ except Exception as err:
+ self.skipTest("No IntegraDevice connected")
def tearDown(self):
self.device.shutdownDevice()
@@ -39,8 +42,8 @@ def setUp(self):
self.port = USBPort(idVendor=0x1ad5, idProduct=0x0300, interfaceNumber=0, defaultEndPoints=(1,2))
try:
self.port.open()
- except:
- raise (unittest.SkipTest("No devices connected"))
+ except Exception as err:
+ self.skipTest("No IntegraDevice connected")
def tearDown(self):
self.port.close()
diff --git a/hardwarelibrary/tests/testIntellidrive.py b/hardwarelibrary/tests/testIntellidrive.py
index 272419c..c6bd0c7 100644
--- a/hardwarelibrary/tests/testIntellidrive.py
+++ b/hardwarelibrary/tests/testIntellidrive.py
@@ -13,7 +13,7 @@ def setUp(self):
self.portPath = None
ports = serial.tools.list_ports.comports()
for port in ports:
- if port.vid == 0x0403 and port.pid == 0x6001: # Sutter Instruments
+ if port.vid == 0x0403 and port.pid == 0x6001:
self.portPath = "/dev/cu.usbserial-{0}".format(serialNumber)
if self.portPath is None:
diff --git a/hardwarelibrary/tests/testLabjackU3.py b/hardwarelibrary/tests/testLabjackU3.py
index 04c61fc..0b6b848 100644
--- a/hardwarelibrary/tests/testLabjackU3.py
+++ b/hardwarelibrary/tests/testLabjackU3.py
@@ -11,9 +11,12 @@
class TestLabjackDevice(unittest.TestCase):
def setUp(self):
super().setUp()
- self.device = LabjackDevice()
- self.assertIsNotNone(self.device)
- self.device.initializeDevice()
+ try:
+ self.device = LabjackDevice()
+ self.assertIsNotNone(self.device)
+ self.device.initializeDevice()
+ except Exception as err:
+ self.skipTest("No Labjack connected")
def tearDown(self):
super().tearDown()
diff --git a/hardwarelibrary/tests/testLinearMotionDevice.py b/hardwarelibrary/tests/testLinearMotionDevice.py
index 7bdb9e9..f7187b5 100644
--- a/hardwarelibrary/tests/testLinearMotionDevice.py
+++ b/hardwarelibrary/tests/testLinearMotionDevice.py
@@ -174,8 +174,14 @@ def setUp(self):
class TestRealSutterDeviceBase(BaseTestCases.TestLinearMotionDevice):
def setUp(self):
- self.device = SutterDevice()
+
+ try:
+ self.device = SutterDevice()
+ except Exception as err:
+ self.skipTest("No Sutter device connected")
+
super().setUp()
+
if __name__ == '__main__':
unittest.main()
diff --git a/hardwarelibrary/tests/testOscilloscope.py b/hardwarelibrary/tests/testOscilloscope.py
index afedc80..7481788 100644
--- a/hardwarelibrary/tests/testOscilloscope.py
+++ b/hardwarelibrary/tests/testOscilloscope.py
@@ -10,34 +10,26 @@
from hardwarelibrary.oscilloscope import *
class TestTektronik(unittest.TestCase):
-
- def testCreate(self):
+ def setUp(self) -> None:
self.device = OscilloscopeDevice()
self.assertIsNotNone(self.device)
+ try :
+ self.device.initializeDevice()
+ except Exception as err:
+ self.skipTest("No Tektronik connected")
- def testInit(self):
- self.device = OscilloscopeDevice()
- self.device.initializeDevice()
+ def tearDown(self) -> None:
self.device.shutdownDevice()
def testGetWaveform(self):
- self.device = OscilloscopeDevice()
- self.device.initializeDevice()
self.device.getWaveform(Channels.CH1)
self.device.getWaveform(Channels.CH2)
- self.device.shutdownDevice()
def testDisplayWaveform(self):
- self.device = OscilloscopeDevice()
- self.device.initializeDevice()
self.device.displayWaveforms([Channels.CH1, Channels.CH2])
- self.device.shutdownDevice()
def testDisplayWaveform(self):
- self.device = OscilloscopeDevice()
- self.device.initializeDevice()
self.device.displayWaveforms([Channels.CH1, Channels.CH2])
- self.device.shutdownDevice()
@unittest.skip("For understanding earlier on, not necessary anymore")
diff --git a/hardwarelibrary/tests/testPhysicalDevice.py b/hardwarelibrary/tests/testPhysicalDevice.py
index b5d58c8..23d23ad 100644
--- a/hardwarelibrary/tests/testPhysicalDevice.py
+++ b/hardwarelibrary/tests/testPhysicalDevice.py
@@ -33,13 +33,13 @@ class BaseTestCases:
class TestPhysicalDeviceBase(unittest.TestCase):
def setUp(self):
super().setUp()
- DeviceManager().updateConnectedDevices()
+ # DeviceManager().updateConnectedDevices()
self.device = None
self.isRunning = False
self.notificationReceived = None
- DeviceManager().destroy()
+ # DeviceManager().destroy()
NotificationCenter().destroy()
def tearDown(self):
@@ -47,7 +47,7 @@ def tearDown(self):
self.device.shutdownDevice()
self.device = None
- DeviceManager().removeAllDevices()
+ # DeviceManager().removeAllDevices()
super().tearDown()
def testIsRunning(self):
@@ -200,7 +200,7 @@ def setUp(self):
self.device = DeviceManager().anySpectrometerDevice()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No spectrometer connected"))
+ self.skipTest("No Spectro connected")
class TestPowerMeterPhysicalDevice(BaseTestCases.TestPhysicalDeviceBase):
def setUp(self):
@@ -209,7 +209,7 @@ def setUp(self):
self.device = IntegraDevice()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No powermeter connected"))
+ self.skipTest("No powermeter connected")
class TestTektronikPhysicalDevice(BaseTestCases.TestPhysicalDeviceBase):
def setUp(self):
@@ -218,7 +218,7 @@ def setUp(self):
self.device = OscilloscopeDevice()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No oscilloscope connected"))
+ self.skipTest("No Oscilloscope connected")
class TestEchoPhysicalDevice(BaseTestCases.TestPhysicalDeviceBase):
def setUp(self):
@@ -227,7 +227,7 @@ def setUp(self):
self.device = EchoDevice()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No ECHO connected"))
+ self.skipTest("No ECHO connected")
def testEchoCommands(self):
self.device.initializeDevice()
@@ -245,7 +245,7 @@ def setUp(self):
self.device = DebugEchoDevice()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No ECHO connected"))
+ self.skipTest("No ECHO connected")
class TestCameraPhysicalDevice(BaseTestCases.TestPhysicalDeviceBase):
@@ -255,7 +255,7 @@ def setUp(self):
self.device = OpenCVCamera()
self.assertIsNotNone(self.device)
except Exception as err:
- raise (unittest.SkipTest("No Facetime Camera connected"))
+ self.skipTest("No Facetime connected")
class TestPhysicalDeviceCompatibilityClasses(unittest.TestCase):
def testGetDeviceClasses(self):
diff --git a/setup.py b/setup.py
index 31782e9..47d9db2 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,6 @@
"""
-
setuptools.setup(
name="hardwarelibrary",
@@ -17,35 +16,41 @@
author="Daniel Cote",
author_email="dccote@cervo.ulaval.ca",
description="Cross-platform (macOS, Windows, Linux, etc...) library to control various hardware devices mostly for scientific applications.",
- long_description=open('README.md').read(),
- long_description_content_type='text/markdown',
- license='MIT',
- keywords='hardware devices usb communication app control spectrometer powermeter camera',
+ long_description=open("README.md").read(),
+ long_description_content_type="text/markdown",
+ license="MIT",
+ keywords="hardware devices usb communication app control spectrometer powermeter camera",
packages=setuptools.find_packages(),
- install_requires=['numpy','matplotlib','PySerial','PyUSB','pyftdi','LabJackPython'],
- python_requires='>=3.7',
- package_data = {
+ install_requires=[
+ "numpy",
+ "matplotlib",
+ "PySerial",
+ "PyUSB",
+ "pyftdi",
+ "LabJackPython",
+ ],
+ python_requires=">=3.7",
+ include_package_data=True,
+ package_data={
# If any package contains *.txt or *.rst files, include them:
- '': ['*.png'],
- "doc": ['*.html']
+ "": ["*.png"],
+ "doc": ["*.html"],
+ "zip": ["*.zip"],
},
classifiers=[
- 'Development Status :: 4 - Beta',
+ "Development Status :: 4 - Beta",
# Indicate who your project is intended for
- 'Intended Audience :: Science/Research',
- 'Intended Audience :: Education',
- 'Topic :: Scientific/Engineering :: Physics',
- 'Topic :: Education',
-
+ "Intended Audience :: Science/Research",
+ "Intended Audience :: Education",
+ "Topic :: Scientific/Engineering :: Physics",
+ "Topic :: Education",
# Pick your license as you wish (should match "license" above)
- 'License :: OSI Approved :: MIT License',
-
+ "License :: OSI Approved :: MIT License",
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
- 'Programming Language :: Python',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.7',
-
- 'Operating System :: OS Independent'
- ]
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Operating System :: OS Independent",
+ ],
)
diff --git a/test.py b/test.py
index 42243de..f4aee05 100644
--- a/test.py
+++ b/test.py
@@ -1,5 +1,4 @@
-from hardwarelibrary.spectrometers import getAllSubclasses, Spectrometer
+from hardwarelibrary.spectrometers import getAllSubclasses, Spectrometer, SAS
+from hardwarelibrary.utils import *
-devices = getAllSubclasses(Spectrometer)
-for dev in devices:
- print("{0}".format(dev))
+device = SAS()