From ec4f0cff2a34901ba750c9e25abc970a515bbb88 Mon Sep 17 00:00:00 2001 From: Josef Brandt Date: Thu, 10 Sep 2020 10:58:29 +0200 Subject: [PATCH] Fix in importing WITecCom Fixed circular import --- instrumentcom/WITecCOM.py | 11 +++--- instrumentcom/instrumentConfig.py | 61 +++++++++++++++---------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/instrumentcom/WITecCOM.py b/instrumentcom/WITecCOM.py index 69bb5f5..a588640 100644 --- a/instrumentcom/WITecCOM.py +++ b/instrumentcom/WITecCOM.py @@ -32,7 +32,8 @@ from socket import gethostname try: # when running the witectesting, the paths have to be differently, as it is in the same directory as the other raman com modules from .instrumentComBase import InstrumentComBase - from .instrumentConfig import SpecScanParameter + # from .instrumentConfig import SpecScanParameter + from . import instrumentConfig as ic from ..errors import showErrorMessageAsWidget except ImportError: from instrumentComBase import InstrumentComBase @@ -97,8 +98,8 @@ class WITecCOM(InstrumentComBase): CLSID = "{C45E77CE-3D66-489A-B5E2-159F443BD1AA}" magn = 20 - specScanParameters = [SpecScanParameter('IntegrationTime (s)', 'double', default=0.5, minVal=0.01, maxVal=100), - SpecScanParameter('Accumulations', 'int', default=5, minVal=1, maxVal=100)] + specScanParameters = [ic.SpecScanParameter('IntegrationTime (s)', 'double', default=0.5, minVal=0.01, maxVal=100), + ic.SpecScanParameter('Accumulations', 'int', default=5, minVal=1, maxVal=100)] def __init__(self, logger, hostname=None): super().__init__() @@ -259,8 +260,8 @@ class WITecCOM(InstrumentComBase): self.advSpec: SpectraHandler = SpectraHandler(self) if 'Autofocus' not in [param.name for param in self.specScanParameters]: - self.specScanParameters.append(SpecScanParameter('Autofocus', 'checkBox', default=False)) - self.specScanParameters.append(SpecScanParameter('Spectra Batch Size', 'int', default=1000, minVal=1, maxVal=1e6)) + self.specScanParameters.append(ic.SpecScanParameter('Autofocus', 'checkBox', default=False)) + self.specScanParameters.append(ic.SpecScanParameter('Spectra Batch Size', 'int', default=1000, minVal=1, maxVal=1e6)) @comErrorRepeater def getBrightness(self): diff --git a/instrumentcom/instrumentConfig.py b/instrumentcom/instrumentConfig.py index 19466cf..8dca512 100644 --- a/instrumentcom/instrumentConfig.py +++ b/instrumentcom/instrumentConfig.py @@ -23,7 +23,6 @@ import configparser __all__ = ["InstrumentControl", "defaultPath", "simulatedRaman", "SpecScanParameter"] - defaultPath = os.path.dirname(os.path.split(__file__)[0]) config = configparser.ConfigParser() @@ -32,6 +31,36 @@ config.read(os.path.join(defaultPath, 'gepard.cfg')) interface = "SIMULATED_RAMAN_CONTROL" +class SpecScanParameter(object): + def __init__(self, name, dtype, default=None, minVal=None, maxVal=None, valList=None, openFileType=None): + self.name = name + self.dtype = dtype + self.value = default + self.minVal = minVal + self.maxVal = maxVal + self.valList = valList + self.openFileType = openFileType + + if not self.hasValidType(): + print('erroreneous type in setting parameter:', self.dtype) + + def hasValidType(self): + if self.dtype in ['int', 'double', 'checkBox', 'combobox', 'selectBtn']: + return True + else: + return False + + def value_of(self, obj): + if self.dtype in ['int', 'double']: + return obj.value() + elif self.dtype == 'checkBox': + return obj.isChecked() + elif self.dtype == 'combobox': + return obj.currentText() + elif self.dtype == 'selectBtn': + return obj.text() + + try: defaultPath = config["Defaults"]["file_path"] print('default Path is now:', defaultPath) @@ -77,33 +106,3 @@ elif interface == "THERMO_FTIR": from .thermoFTIRCom import ThermoFTIRCom InstrumentControl = ThermoFTIRCom simulatedRaman = False - - -class SpecScanParameter(object): - def __init__(self, name, dtype, default=None, minVal=None, maxVal=None, valList=None, openFileType=None): - self.name = name - self.dtype = dtype - self.value = default - self.minVal = minVal - self.maxVal = maxVal - self.valList = valList - self.openFileType = openFileType - - if not self.hasValidType(): - print('erroreneous type in setting parameter:', self.dtype) - - def hasValidType(self): - if self.dtype in ['int', 'double', 'checkBox', 'combobox', 'selectBtn']: - return True - else: - return False - - def value_of(self, obj): - if self.dtype in ['int', 'double']: - return obj.value() - elif self.dtype == 'checkBox': - return obj.isChecked() - elif self.dtype == 'combobox': - return obj.currentText() - elif self.dtype == 'selectBtn': - return obj.text() \ No newline at end of file -- GitLab