Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle MOTPAR:misc_par_1 as PVname suffix #198

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apstools/migration/spec2ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def pop_word(line, int_result=False):
self.mne, self.name = pop_word(r)
self.device = None
self.pvname = None
self.motpar = []
self.motpar = {}
self.macro_prefix = None
self.str_keys = "mne config_line name macro_prefix".split()

Expand Down Expand Up @@ -155,6 +155,11 @@ def setDevice(self, devices):

def ophyd_config(self):
s = f"{self.mne} = EpicsMotor('{self.pvname}', name='{self.mne}')"
suffix = self.motpar.get("misc_par_1")
if suffix is not None:
del self.motpar["misc_par_1"]
pvname = f"{self.device.prefix}{suffix}"
s = f"{self.mne} = EpicsMotor('{pvname}', name='{self.mne}')"
if self.pvname is None:
if self.macro_prefix is not None:
s = f"# Macro Motor: {self}"
Expand All @@ -163,7 +168,8 @@ def ophyd_config(self):
if self.mne != self.name:
s += f" # {self.name}"
if len(self.motpar) > 0:
s += f" # {', '.join(self.motpar)}"
terms = [f"{k}={v}" for k, v in self.motpar.items()]
s += f" # {', '.join(terms)}"
return s


Expand Down Expand Up @@ -269,7 +275,8 @@ def read_config(self, config_file=None):
self.devices[device.name].append(device)
elif word0.startswith("MOTPAR:"):
if motor is not None:
motor.motpar.append(line[len("MOTPAR:"):])
k, v = line[len("MOTPAR:"):].split("=")
motor.motpar[k.strip()] = v.strip()
elif re.match("CNT\d*", line) is not None:
counter = SpecCounter(line)
counter.setDevice(self.devices)
Expand Down