Skip to content

Commit

Permalink
Add record precision setting to limits csv.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Nicholls committed Apr 26, 2019
1 parent 3cc8c5b commit 2c64607
Show file tree
Hide file tree
Showing 4 changed files with 2,194 additions and 2,180 deletions.
4 changes: 2 additions & 2 deletions ioc/SOFT-IOC.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ port 6064 to avoid conflict with the same PVs on the live machine.
Initialisation:
---------------

Before starting please ensure you have working up to date versions of Pytac,
AT, and ATIP.
Before starting please ensure you have working and up to date versions of AT,
Pytac, and ATIP.

Inside the top-level atip directory::

Expand Down
25 changes: 19 additions & 6 deletions ioc/atip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def _create_records(self, limits_csv):
csv_reader = csv.DictReader(open(limits_csv))
for line in csv_reader:
limits_dict[line['pv']] = (float(line['upper']),
float(line['lower']))
float(line['lower']),
int(line['precision']))
bend_set = False
for element in self.lattice:
if element.type_ == 'BEND':
Expand All @@ -109,19 +110,25 @@ def _create_records(self, limits_csv):
value = element.get_value('b0', units=pytac.ENG,
data_source=pytac.SIM)
get_pv = element.get_pv_name('b0', pytac.RB)
upper, lower = limits_dict.get(get_pv, (None, None))
upper, lower, precision = limits_dict.get(get_pv, (None,
None,
None))
builder.SetDeviceName(get_pv.split(':', 1)[0])
in_record = builder.aIn(get_pv.split(':', 1)[1],
LOPR=lower, HOPR=upper,
PREC=precision,
initial_value=value)
set_pv = element.get_pv_name('b0', pytac.SP)
def on_update(value, name=set_pv): # noqa E306
self._on_update(name, value)
upper, lower = limits_dict.get(set_pv, (None, None))
upper, lower, precision = limits_dict.get(set_pv, (None,
None,
None))
builder.SetDeviceName(set_pv.split(':', 1)[0])
out_record = builder.aOut(set_pv.split(':', 1)[1],
LOPR=lower, HOPR=upper,
DRVL=lower, DRVH=upper,
PREC=precision,
initial_value=value,
on_update=on_update)
# how to solve the index problem?
Expand All @@ -134,10 +141,13 @@ def on_update(value, name=set_pv): # noqa E306
value = element.get_value(field, units=pytac.ENG,
data_source=pytac.SIM)
get_pv = element.get_pv_name(field, pytac.RB)
upper, lower = limits_dict.get(get_pv, (None, None))
upper, lower, precision = limits_dict.get(get_pv, (None,
None,
None))
builder.SetDeviceName(get_pv.split(':', 1)[0])
in_record = builder.aIn(get_pv.split(':', 1)[1],
LOPR=lower, HOPR=upper,
PREC=precision,
initial_value=value)
self._in_records[in_record] = (element.index, field)
try:
Expand All @@ -147,11 +157,14 @@ def on_update(value, name=set_pv): # noqa E306
else:
def on_update(value, name=set_pv):
self._on_update(name, value)
upper, lower = limits_dict.get(set_pv, (None, None))
upper, lower, precision = limits_dict.get(set_pv,
(None, None,
None))
builder.SetDeviceName(set_pv.split(':', 1)[0])
out_record = builder.aOut(set_pv.split(':', 1)[1],
LOPR=lower, HOPR=upper,
DRVL=lower, DRVH=upper,
PREC=precision,
initial_value=value,
on_update=on_update)
self._out_records[out_record.name] = in_record
Expand All @@ -164,7 +177,7 @@ def on_update(value, name=set_pv):
value = self.lattice.get_value(field, units=pytac.ENG,
data_source=pytac.SIM)
builder.SetDeviceName(get_pv.split(':', 1)[0])
in_record = builder.aIn(get_pv.split(':', 1)[1],
in_record = builder.aIn(get_pv.split(':', 1)[1], PREC=4,
initial_value=value)
self._in_records[in_record] = (0, field)
self._rb_only_records.append(in_record)
Expand Down
7 changes: 4 additions & 3 deletions ioc/create_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ def generate_feedback_pvs():


def generate_pv_limits():
data = [("pv", "upper", "lower")]
data = [("pv", "upper", "lower", "precision")]
lattice = atip.utils.loader()
for element in lattice:
for field in element.get_fields()[pytac.SIM]:
pv = element.get_pv_name(field, pytac.RB)
ctrl = caget(pv, format=FORMAT_CTRL)
data.append((pv, ctrl.upper_ctrl_limit, ctrl.lower_ctrl_limit))
data.append((pv, ctrl.upper_ctrl_limit, ctrl.lower_ctrl_limit,
ctrl.precision))
try:
pv = element.get_pv_name(field, pytac.SP)
except pytac.exceptions.HandleException:
pass
else:
ctrl = caget(pv, format=FORMAT_CTRL)
data.append((pv, ctrl.upper_ctrl_limit,
ctrl.lower_ctrl_limit))
ctrl.lower_ctrl_limit, ctrl.precision))
return data


Expand Down

0 comments on commit 2c64607

Please sign in to comment.