Skip to content

Commit

Permalink
Merge pull request #18 from dls-controls/virtac-fix
Browse files Browse the repository at this point in the history
Virtac fix
  • Loading branch information
willrogers committed Jan 2, 2020
2 parents 25c80b3 + d353aee commit b566903
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
10 changes: 10 additions & 0 deletions virtac/atip_ioc_entry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys

Expand All @@ -19,6 +20,15 @@
at the top of the file as they must be below the requires and the path editing.
"""

LOG_FORMAT = '%(asctime)s %(message)s'

if '-v' in sys.argv:
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
sys.argv.remove('-v')
else:
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)


# Determine the ring mode
if sys.argv[1:]:
ring_mode = sys.argv[1]
Expand Down
17 changes: 5 additions & 12 deletions virtac/atip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,15 @@ def _create_records(self, limits_csv):
PREC=precision, MDEL="-1",
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, 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,
on_update_name=self._on_update,
always_update=True)
self._in_records[in_record] = ([element.index], 'b0')
self._out_records[out_record] = in_record
Expand All @@ -199,18 +196,15 @@ def on_update(value, name=set_pv): # noqa E306
except HandleException:
self._rb_only_records.append(in_record)
else:
def on_update(value, name=set_pv):
self._on_update(name, value)
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,
on_update_name=self._on_update,
always_update=True)
self._out_records[out_record] = in_record
# Now for lattice fields.
Expand All @@ -228,26 +222,25 @@ def on_update(value, name=set_pv):
self._rb_only_records.append(in_record)
print("~*~*Woah, we're halfway there, Wo-oah...*~*~")

def _on_update(self, name, value):
def _on_update(self, value, name):
"""The callback function passed to out records, it is called after
successful record processing has been completed. It updates the out
record's corresponding in record with the value that has been set and
then sets the value to the centralised Pytac lattice.
Args:
name (str): The name of record object that has just been set to.
value (number): The value that has just been set to the record.
name (str): The name of record object that has just been set to.
"""
in_record = self._out_records[self.all_record_names[name]]
in_record.set(value)
index, field = self._in_records[in_record]
if self.tune_feedback_status is True:
try:
offset_record = self._offset_pvs[name]
value += offset_record.get()
except KeyError:
pass
else:
value += offset_record.get()
if isinstance(index, list):
for i in index:
self.lattice[i - 1].set_value(field, value, units=pytac.ENG,
Expand Down
3 changes: 2 additions & 1 deletion virtac/start-virtac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# The launch method for this is entirely Diamond-specific as it relies on
# the internal pythonSoftIoc installation.

PYIOC_VERSION=2-15
PYIOC_VERSION=2-16
EPICS_VERSION=R3.14.12.7
PYIOC=/dls_sw/prod/$EPICS_VERSION/support/pythonIoc/$PYIOC_VERSION/pythonIoc
export HERE=$(dirname $PYIOC)
Expand All @@ -18,5 +18,6 @@ fi

export EPICS_CA_SERVER_PORT=6064
export EPICS_CAS_SERVER_PORT=6064
export EPICS_CA_REPEATER_PORT=6065

exec pipenv run python atip_ioc_entry.py "$@"

0 comments on commit b566903

Please sign in to comment.