Skip to content

Commit

Permalink
Merge pull request #198 from BCDA-APS/196-motpar
Browse files Browse the repository at this point in the history
handle MOTPAR:misc_par_1 as PVname suffix
  • Loading branch information
prjemian authored Jul 25, 2019
2 parents ef3e900 + 772403e commit c5292eb
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit c5292eb

Please sign in to comment.