Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 077a182b4d | |||
| 3e7e53135c | |||
| 57b567f453 |
@@ -1,12 +1,14 @@
|
|||||||
Node('flamemag.psi.ch',
|
Node('flamemag.psi.ch',
|
||||||
'flame magnet',
|
'flame magnet',
|
||||||
interface='tcp://5000'
|
interface='tcp://5000',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sea_cfg = 'flamemag.config'
|
||||||
|
|
||||||
Mod('cio',
|
Mod('cio',
|
||||||
'frappy_psi.cryoltd.IO',
|
'frappy_psi.cryoltd.IO',
|
||||||
'IO to cryo ltd software',
|
'IO to cryo ltd software',
|
||||||
uri='tcp://flamedil:3128',
|
uri='tcp://flamemag:3128',
|
||||||
)
|
)
|
||||||
|
|
||||||
Mod('main',
|
Mod('main',
|
||||||
@@ -24,7 +26,7 @@ Mod('B',
|
|||||||
target=Param(
|
target=Param(
|
||||||
max=35000.0,
|
max=35000.0,
|
||||||
),
|
),
|
||||||
mode='PERSISTENT',
|
#mode='PERSISTENT',
|
||||||
hw_units='T',
|
hw_units='T',
|
||||||
A_to_G=285.73,
|
A_to_G=285.73,
|
||||||
ramp=Param(
|
ramp=Param(
|
||||||
@@ -32,7 +34,7 @@ Mod('B',
|
|||||||
),
|
),
|
||||||
overshoot={'o': 1.0, 't': 180.0},
|
overshoot={'o': 1.0, 't': 180.0},
|
||||||
degauss={'s': 500.0, 'd': 30.0, 'f': 5.0, 't': 120.0},
|
degauss={'s': 500.0, 'd': 30.0, 'f': 5.0, 't': 120.0},
|
||||||
tolerance=5.0,
|
tolerance=50.0,
|
||||||
wait_switch_on = 30,
|
wait_switch_on = 30,
|
||||||
wait_switch_off = 30,
|
wait_switch_off = 30,
|
||||||
wait_stable_field=180.0,
|
wait_stable_field=180.0,
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ import re
|
|||||||
import time
|
import time
|
||||||
from math import copysign
|
from math import copysign
|
||||||
from frappy.core import HasIO, StringIO, Readable, Drivable, Parameter, Command, \
|
from frappy.core import HasIO, StringIO, Readable, Drivable, Parameter, Command, \
|
||||||
Module, Property, Attached, Enum, IDLE, BUSY, ERROR
|
Module, Property, Attached, Enum, IDLE, BUSY, ERROR, nopoll, PersistentParam, \
|
||||||
|
PersistentMixin
|
||||||
from frappy.errors import ConfigError, BadValueError, HardwareError
|
from frappy.errors import ConfigError, BadValueError, HardwareError
|
||||||
from frappy.datatypes import FloatRange, StringType, EnumType, StructOf
|
from frappy.datatypes import FloatRange, StringType, EnumType, StructOf
|
||||||
from frappy.states import HasStates, status_code, Retry
|
from frappy.states import HasStates, status_code, Retry
|
||||||
@@ -41,7 +42,10 @@ VALUE_UNIT = re.compile(r'([-0-9.E]*\d|inf)([A-Za-z/%]*)$')
|
|||||||
|
|
||||||
def as_float(value):
|
def as_float(value):
|
||||||
"""converts string (with unit) to float"""
|
"""converts string (with unit) to float"""
|
||||||
return float(VALUE_UNIT.match(value).group(1))
|
try:
|
||||||
|
return float(VALUE_UNIT.match(value).group(1))
|
||||||
|
except Exception:
|
||||||
|
raise ValueError(f'can not convert {value!r} to float with unit')
|
||||||
|
|
||||||
|
|
||||||
BOOL_MAP = {'TRUE': True, 'FALSE': False}
|
BOOL_MAP = {'TRUE': True, 'FALSE': False}
|
||||||
@@ -113,6 +117,8 @@ class Main(HasIO, Module):
|
|||||||
# ignore multiline values
|
# ignore multiline values
|
||||||
# if needed, we may collect here and treat with a special key
|
# if needed, we may collect here and treat with a special key
|
||||||
continue
|
continue
|
||||||
|
if not value:
|
||||||
|
continue # silently ignore empty values
|
||||||
obj, pname, cvt = self.params_map.get(key, missing)
|
obj, pname, cvt = self.params_map.get(key, missing)
|
||||||
if obj:
|
if obj:
|
||||||
if not hasattr(obj, pname):
|
if not hasattr(obj, pname):
|
||||||
@@ -268,7 +274,7 @@ class BaseMagfield(HasStates, Channel):
|
|||||||
def cvt_error(self, text):
|
def cvt_error(self, text):
|
||||||
if text != self._last_error:
|
if text != self._last_error:
|
||||||
self._last_error = text
|
self._last_error = text
|
||||||
self.log.error(text)
|
self.log.error(f'{self.channel}_Error: {text}')
|
||||||
return text
|
return text
|
||||||
return self._error_text
|
return self._error_text
|
||||||
|
|
||||||
@@ -287,6 +293,11 @@ class BaseMagfield(HasStates, Channel):
|
|||||||
ramp = Parameter()
|
ramp = Parameter()
|
||||||
target = Parameter()
|
target = Parameter()
|
||||||
|
|
||||||
|
@nopoll
|
||||||
|
def read_setpoint(self):
|
||||||
|
self.main.doPoll()
|
||||||
|
return self.setpoint
|
||||||
|
|
||||||
def write_ramp(self, ramp):
|
def write_ramp(self, ramp):
|
||||||
if self._rate_units != 'A/s':
|
if self._rate_units != 'A/s':
|
||||||
self.sendcmd('Set:<CH>:ChangeRateUnits A/s')
|
self.sendcmd('Set:<CH>:ChangeRateUnits A/s')
|
||||||
@@ -323,9 +334,18 @@ class BaseMagfield(HasStates, Channel):
|
|||||||
return super().start_field_change
|
return super().start_field_change
|
||||||
|
|
||||||
def start_ramp_to_target(self, sm):
|
def start_ramp_to_target(self, sm):
|
||||||
self.start_sweep(sm.target)
|
try:
|
||||||
|
self.start_sweep(sm.target)
|
||||||
|
self.log.info('start_ramp_to_target: start_sweep done')
|
||||||
|
except Exception as e:
|
||||||
|
self.log.error('start_ramp_to_target: start_sweep failed with %r', e)
|
||||||
|
raise
|
||||||
return self.ramp_to_target # -> stabilize_field
|
return self.ramp_to_target # -> stabilize_field
|
||||||
|
|
||||||
|
# def start_ramp_to_target(self, sm):
|
||||||
|
# self.start_sweep(sm.target)
|
||||||
|
# return self.ramp_to_target # -> stabilize_field
|
||||||
|
|
||||||
def stabilize_field(self, sm):
|
def stabilize_field(self, sm):
|
||||||
if self._ready_text == 'FALSE':
|
if self._ready_text == 'FALSE':
|
||||||
# wait for overshoot/degauss/cycle
|
# wait for overshoot/degauss/cycle
|
||||||
@@ -432,7 +452,7 @@ class BaseMagfield(HasStates, Channel):
|
|||||||
self._error_text = ''
|
self._error_text = ''
|
||||||
|
|
||||||
|
|
||||||
class MainField(BaseMagfield, magfield.Magfield):
|
class MainField(PersistentMixin, BaseMagfield, magfield.Magfield):
|
||||||
checked_modules = None
|
checked_modules = None
|
||||||
|
|
||||||
def earlyInit(self):
|
def earlyInit(self):
|
||||||
@@ -456,12 +476,13 @@ class MainField(BaseMagfield, magfield.Magfield):
|
|||||||
super().check_limits(value)
|
super().check_limits(value)
|
||||||
self.check_combined(None, 0, value)
|
self.check_combined(None, 0, value)
|
||||||
|
|
||||||
mode = Parameter(datatype=EnumType(PersistencyMode))
|
mode = PersistentParam(datatype=EnumType(PersistencyMode))
|
||||||
|
|
||||||
def write_mode(self, mode):
|
def write_mode(self, mode):
|
||||||
self.reset_error()
|
self.reset_error()
|
||||||
super().write_mode(mode) # updates mode
|
super().write_mode(mode) # updates mode
|
||||||
return mode
|
self.mode = mode
|
||||||
|
self.saveParameters()
|
||||||
|
|
||||||
@status_code('PREPARING')
|
@status_code('PREPARING')
|
||||||
def start_ramp_to_field(self, sm):
|
def start_ramp_to_field(self, sm):
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class SimpleMagfield(HasStates, Drivable):
|
|||||||
last = self._last_target
|
last = self._last_target
|
||||||
if last is None:
|
if last is None:
|
||||||
try:
|
try:
|
||||||
last = self.setpoint # get read back from HW, if available
|
last = self.read_setpoint() # get read back from HW, if available
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if last is None or abs(last - self.value) > self.tolerance:
|
if last is None or abs(last - self.value) > self.tolerance:
|
||||||
|
|||||||
Reference in New Issue
Block a user