From fc592a938c5618e15d1b89ca2af073720d409fd8 Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Tue, 9 Dec 2025 15:52:58 -0700 Subject: [PATCH 1/8] Changing "." to "1" Having SCC20. causes line 216 to fail if you have a SCC201 device. This is because "SCC20." is not a regex match for "SCC201" --- pylablib/devices/Thorlabs/kinesis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index 9ac8ecf..a7e1fe1 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -196,7 +196,7 @@ def check_background_comm(self, messageID): _device_SN={ 20:"BSC001", 21:"BPC001", 22:"BNT001", 25:"BMS001", 26:"KST101", 27:"KDC101", 28:"KBD101", 29:"KPZ101", 30:"BSC002", 31:"BPC002", 33:"BDC101", 35:"BMS002", 37:"MFF10." , - 40:"(BSC101|SSC20.)", 41:"BPC101", 43:"BDC101", 44:"PPC001", 45:"LTS", 48:"MMR", 49:"MLJ", + 40:"(BSC101|SSC201)", 41:"BPC101", 43:"BDC101", 44:"PPC001", 45:"LTS", 48:"MMR", 49:"MLJ", 50:"MST60" , 51:"MPZ601", 52:"MNA601", 55:"K10CR1", 56:"KLS101", 57:"KNA101", 59:"KSG101", 60:"0ST001", 63:"ODC001", 64:"TLD001", 65:"TIM001", 67:"TBD001", 68:"KSC101", 69:"KPA101", 70:"BSC.03", 71:"BPC.03", 72:"BPS103", 73:"BBD103", @@ -1613,4 +1613,4 @@ def v2i(v, scale=10): open_loop_out=current_parameters.open_loop_out if open_loop_out is None else open_loop_out data=struct.pack(" Date: Tue, 9 Dec 2025 15:55:09 -0700 Subject: [PATCH 2/8] Fix regex matching for model number validation Treats "|" as an actual OR symbol by iterating through the options entered in _device_SN --- pylablib/devices/Thorlabs/kinesis.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index a7e1fe1..d27c977 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -213,8 +213,9 @@ def _model_match(self, model_no, port_model_no): return True if model_no.startswith(port_model_no): return True - if re.match("^"+port_model_no+"$",model_no): - return True + for model in port_model_no.split("|"): + if re.match("^"+port_model_no+"$",model_no): + return True return False def get_device_info(self, dest="host"): """ From c79bbe6dd86614a552700b63301a014e72d26fd5 Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Wed, 10 Dec 2025 13:22:13 -0700 Subject: [PATCH 3/8] Scale handling for BSC20 and SCC20 motor models --- pylablib/devices/Thorlabs/kinesis.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index d27c977..b4b9847 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -1313,10 +1313,14 @@ def _calculate_scale(self, scale): return (ssc,ssc*time_conv*2**16,ssc*time_conv**2*2**16),units if self._model in ["TST001","MST601"] or self._model.startswith("BSC00") or self._model.startswith("BSC10") or self._model.startswith("MPC"): return (ssc,ssc,ssc),units - if self._model in ["TST101","KST101","MST602","K10CR1"] or self._model.startswith("BSC20"): + if self._model in ["TST101","KST101","MST602","K10CR1"]: vpr=53.68 avr=204.94E-6 return (ssc,ssc*vpr,ssc*vpr*avr),units + if self._model.startswith("BSC20") or self._model.startswith("SCC20"): + vpr=8.26 + avr=3.15E-05 + return (ssc,ssc*vpr,ssc*vpr*avr),units warnings.warn("can't recognize motor model {}; setting all scales to internal units".format(self._model)) return (1,1,1),"internal" def _get_scale(self): From 3c2c348c5462618956e7dbe27fde96cf5c81ed6a Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Wed, 10 Dec 2025 13:27:03 -0700 Subject: [PATCH 4/8] Fix AVR value for BSC20 and SCC20 models --- pylablib/devices/Thorlabs/kinesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index b4b9847..71ebc7d 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -1319,7 +1319,7 @@ def _calculate_scale(self, scale): return (ssc,ssc*vpr,ssc*vpr*avr),units if self._model.startswith("BSC20") or self._model.startswith("SCC20"): vpr=8.26 - avr=3.15E-05 + avr=204.94E-6 return (ssc,ssc*vpr,ssc*vpr*avr),units warnings.warn("can't recognize motor model {}; setting all scales to internal units".format(self._model)) return (1,1,1),"internal" From 676707fecd9b628da4a69dd603dea0ada357f460 Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Mon, 5 Jan 2026 14:51:37 -0700 Subject: [PATCH 5/8] Add support for KVS30 and M30 stages in kinesis.py --- pylablib/devices/Thorlabs/kinesis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index 71ebc7d..428fa77 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -1240,6 +1240,8 @@ def _get_step_scale(self, stage): stage=stage.strip().upper() if stage=="STEP": return 1,"step" + if stage in {"M30"}: + return 1E7, "m" if stage in {"MTS25-Z8","MTS50-Z8","Z806","Z812","Z825"}: return 34304E3,"m" if stage in {"Z606","Z612","Z625"}: @@ -1250,7 +1252,7 @@ def _get_step_scale(self, stage): return 12288E3,"m" if stage in {"DDSM50","DDSM100"}: return 2000E3,"m" - if stage in {"DDS220","DDS300","DDS600","MLS203"}: + if stage in {"DDS220","DDS300","DDS600","MLS203", "KVS30"}: return 20000E3,"m" if stage=="DDR100": return 3276800/360,"deg" @@ -1311,7 +1313,7 @@ def _calculate_scale(self, scale): if self._model in ["TBD001","KBD101"] or self._model.startswith("BBD10") or self._model.startswith("BBD20"): time_conv=102.4E-6 return (ssc,ssc*time_conv*2**16,ssc*time_conv**2*2**16),units - if self._model in ["TST001","MST601"] or self._model.startswith("BSC00") or self._model.startswith("BSC10") or self._model.startswith("MPC"): + if self._model in ["TST001","MST601", "M30", "KVS30"] or self._model.startswith("BSC") or self._model.startswith("MPC"): return (ssc,ssc,ssc),units if self._model in ["TST101","KST101","MST602","K10CR1"]: vpr=53.68 From 480e4c27884db7799f8c4dd8b17c33c929721510 Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Mon, 5 Jan 2026 15:09:31 -0700 Subject: [PATCH 6/8] Simplify model name checking --- pylablib/devices/Thorlabs/kinesis.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index 428fa77..6664c0f 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -1240,7 +1240,7 @@ def _get_step_scale(self, stage): stage=stage.strip().upper() if stage=="STEP": return 1,"step" - if stage in {"M30"}: + if self._model.startswith("M30"): return 1E7, "m" if stage in {"MTS25-Z8","MTS50-Z8","Z806","Z812","Z825"}: return 34304E3,"m" @@ -1252,7 +1252,7 @@ def _get_step_scale(self, stage): return 12288E3,"m" if stage in {"DDSM50","DDSM100"}: return 2000E3,"m" - if stage in {"DDS220","DDS300","DDS600","MLS203", "KVS30"}: + if stage in {"DDS220","DDS300","DDS600","MLS203"} or self._model.startswith("KVS30"): return 20000E3,"m" if stage=="DDR100": return 3276800/360,"deg" @@ -1262,7 +1262,7 @@ def _get_step_scale(self, stage): return 1440000/360,"deg" if stage=="HDR50": return 75091/0.99997,"deg" - if self._model in ["TST001","MST601"] or self._model.startswith("BSC00") or self._model.startswith("BSC10"): + if self._model in ["TST001","MST601"] or self._model.startswith(("BSC00", "BSC10")): if stage.startswith("ZST"): return 125540.35E3,"m" if stage.startswith("ZFS"): @@ -1277,7 +1277,7 @@ def _get_step_scale(self, stage): return 25600/360,"deg" if stage=="NR360": return 25600/(360/66),"deg" - if self._model in ["TST101","KST101","MST602","K10CR1"] or self._model.startswith("BSC20") or self._model.startswith("SSC20"): + if self._model in ["TST101","KST101","MST602","K10CR1"] or self._model.startswith(("BSC20", "SSC20")): if stage.startswith("ZST"): return 2008645.63E3,"m" if stage.startswith("ZFS"): @@ -1313,7 +1313,7 @@ def _calculate_scale(self, scale): if self._model in ["TBD001","KBD101"] or self._model.startswith("BBD10") or self._model.startswith("BBD20"): time_conv=102.4E-6 return (ssc,ssc*time_conv*2**16,ssc*time_conv**2*2**16),units - if self._model in ["TST001","MST601", "M30", "KVS30"] or self._model.startswith("BSC") or self._model.startswith("MPC"): + if self._model in ["TST001","MST601"] or self._model.startswith(("BSC", "MPC", "M30", "KVS30")): return (ssc,ssc,ssc),units if self._model in ["TST101","KST101","MST602","K10CR1"]: vpr=53.68 From d04bae0e1f344ef9317b31e2b5273554783ce38b Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Mon, 5 Jan 2026 15:36:48 -0700 Subject: [PATCH 7/8] Update model checks to include M30 and KVS30 --- pylablib/devices/Thorlabs/kinesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylablib/devices/Thorlabs/kinesis.py b/pylablib/devices/Thorlabs/kinesis.py index 6664c0f..43f9a25 100644 --- a/pylablib/devices/Thorlabs/kinesis.py +++ b/pylablib/devices/Thorlabs/kinesis.py @@ -1226,7 +1226,7 @@ def _autodetect_stage(self): stages={2:"Z706",3:"Z712",4:"Z725",5:"CR1-Z7",6:"PRM1-Z8", 7:"MTS25-Z8",8:"MTS50-Z8",9:"Z825",10:"Z812",11:"Z806"} return stages.get(stage_id,None) - if self._model=="K10CR1" or self._model.startswith("MPC"): + if self._model=="K10CR1" or self._model.startswith(("MPC", "M30", "KVS30")): return self._model return None def _get_stage(self, scale): From 446869b51aa204e9da8aaa9d78933d03d1653cca Mon Sep 17 00:00:00 2001 From: bhathawayQNT Date: Fri, 16 Jan 2026 10:25:49 -0700 Subject: [PATCH 8/8] Replace pkg_resources import with importlib.resources depreciated support for pkg_resources --- pylablib/core/utils/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylablib/core/utils/module.py b/pylablib/core/utils/module.py index 2d083dc..4ad9cb2 100644 --- a/pylablib/core/utils/module.py +++ b/pylablib/core/utils/module.py @@ -12,7 +12,7 @@ except ImportError: metadata=None try: - import pkg_resources + import importlib.resources as pkg_resources except ImportError: pkg_resources=None import sys @@ -227,4 +227,4 @@ def install_if_older(pkg, min_ver="", ignore_frozen=True): if get_package_version(pkg) is None or cmp_package_version(pkg,min_ver)=="<": pip_install(pkg,upgrade=True) return True - return False \ No newline at end of file + return False