further work on needle valve, pump and lakeshore

This commit is contained in:
l_samenv
2025-03-19 16:37:27 +01:00
parent 19571ab83d
commit 41b51b35fd
10 changed files with 959 additions and 242 deletions

View File

@ -39,6 +39,13 @@ from frappy.extparams import StructParam
from frappy_psi.calcurve import CalCurve
def string_to_num(string):
try:
return int(string)
except ValueError:
return float(string)
class IO(StringIO):
"""IO classes of most LakeShore models will inherit from this"""
end_of_line = '\n'
@ -97,8 +104,9 @@ class HasLscIO(HasIO):
if not args:
self.communicate(f'{msghead};*OPC?')
return None
converters = [type(a) for a in args]
values = [a if issubclass(c, str) else f'{a:g}'
# when an argument is given as integer, it might be that this argument might be a float
converters = [string_to_num if isinstance(a, int) else type(a) for a in args]
values = [a if isinstance(a, str) else f'{a:g}'
for c, a in zip(converters, args)]
if ' ' in msghead:
query = msghead.replace(' ', '? ', 1)
@ -839,7 +847,7 @@ class MainOutput(Output):
}
_htr_range = 1
heater_ranges = {5 - i: 10 ** - i for i in range(5)}
heater_ranges = {5 - i: 10 ** -i for i in range(5)}
sorted_factors = sorted((v, i) for i, v in heater_ranges.items())
def read_status(self):
@ -847,6 +855,9 @@ class MainOutput(Output):
return self.HTRST_MAP[st]
def configure(self):
if self._desired_max_power is None:
self.log.info(f'max_heater {self.writeDict} {self.max_heater}')
self.write_max_heater(self.max_heater)
self._htr_range = irng = self.get_best_power_idx(self._desired_max_power)
user_current = max(0.1, min(self.imax, 2 * math.sqrt(self._desired_max_power /
self.heater_ranges[irng] / self.resistance)))
@ -1180,7 +1191,7 @@ class MainOutput336(MainOutput):
imax = 2
vmax = 50
# 3 ranges only
heater_ranges = {i: 10 ** (3 - i) for i in range(5)}
heater_ranges = {3 - i: 10 ** -i for i in range(3)}
sorted_factors = sorted((v, i) for i, v in heater_ranges.items())