Skip to content

Commit

Permalink
Commit for Thales version 5.9.1
Browse files Browse the repository at this point in the history
Only updated the required Thales version, no other features added.
Enums replaced by IntEnums. Error message if the software version does not fit more specified.
  • Loading branch information
maxkrapp1 committed Oct 16, 2023
1 parent 601f296 commit 6f48d50
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions thales_remote/script_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

from enum import Enum
from enum import Enum, IntEnum
import re
import shutil
import os
Expand All @@ -33,14 +33,14 @@
from thales_remote.error import ThalesRemoteError, TermConnectionError
from thales_remote.connection import ThalesRemoteConnection

MINIMUM_THALES_VERSION = "5.9.0"
MINIMUM_THALES_VERSION = "5.9.1"


def versiontuple(v):
return tuple(map(int, (v.split("."))))


class PotentiostatMode(Enum):
class PotentiostatMode(IntEnum):
"""
working modes for the potentiostat
"""
Expand All @@ -50,7 +50,7 @@ class PotentiostatMode(Enum):
POTMODE_PSEUDOGALVANOSTATIC = 3


class ScanStrategy(Enum):
class ScanStrategy(IntEnum):
"""
options for the EIS scan strategy
Expand All @@ -75,7 +75,7 @@ def stringToEnum(cls, string: str):
return stringEnumMap.get(string)


class ScanDirection(Enum):
class ScanDirection(IntEnum):
"""
set the scan direction for EIS measurements.
Expand All @@ -97,7 +97,7 @@ def stringToEnum(cls, string: str):
return stringEnumMap.get(string)


class FileNaming(Enum):
class FileNaming(IntEnum):
"""
options for the file names in Thales.
Expand All @@ -122,7 +122,7 @@ def stringToEnum(cls, string: str):
return stringEnumMap.get(string)


class Pad4Mode(Enum):
class Pad4Mode(IntEnum):
"""
options for the PAD4 operating mode.
Expand Down Expand Up @@ -150,21 +150,27 @@ def __init__(self, remoteConnection: ThalesRemoteConnection):
try:
versionReply = self.getThalesVersion(timeout=1)
except TermConnectionError as err:
raise ThalesRemoteError("Please update your Thales version.")
raise ThalesRemoteError(
"Please update the Thales software, it is too old for this package version."
)

if "devel" in versionReply:
print("devel version")
elif "" == versionReply:
# timeout
raise ThalesRemoteError("Please update your Thales version.")
raise ThalesRemoteError(
"Please update the Thales software, it is too old for this package version."
)
else:
match = re.search(r"(\d+.\d+.\d+)", versionReply)
versionString = match.group(1)
versionComp = versiontuple(versionString) < versiontuple(
thalesToOld = versiontuple(versionString) < versiontuple(
MINIMUM_THALES_VERSION
)
if versionComp:
raise ThalesRemoteError("Please update your Thales version.")
if thalesToOld:
raise ThalesRemoteError(
f"Please update the Thales software. This package requires at least version {MINIMUM_THALES_VERSION}, but version {versionString} is installed."
)
return

def getCurrent(self) -> float:
Expand All @@ -179,7 +185,7 @@ def getCurrent(self) -> float:

def getPotential(self) -> float:
"""
fead the measured potential from the device
read the measured potential from the device
:returns: the measured potential value
"""
Expand All @@ -189,7 +195,7 @@ def getPotential(self) -> float:

def getVoltage(self) -> float:
"""
fead the measured potential from the device
read the measured potential from the device
:returns: the measured potential value
"""
Expand Down

0 comments on commit 6f48d50

Please sign in to comment.