Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Nicholls committed May 7, 2019
1 parent 9f61e1b commit 5ae354c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"

install:
- pip install virtualenv
- python -m virtualenv venv
- source venv/bin/activate
- |
if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then
pip install "cothread==2.16"
fi
- pip install -r requirements.txt
- pip install git+https://github.com/dls-controls/pytac.git
- pip install -e "git+https://github.com/atcollab/at.git#egg=at-python&subdirectory=pyat"
Expand Down
22 changes: 13 additions & 9 deletions ioc/atip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from pytac.exceptions import HandleException, FieldException
from softioc import builder

from solution import callback_set, callback_refresh, caget_mask, caput_mask
from solution import summate, collate, transform
from masks import callback_set, callback_refresh, caget_mask, caput_mask
from mirror_objects import summate, collate, transform


class ATIPServer(object):
Expand Down Expand Up @@ -75,7 +75,6 @@ def _all_record_names(self):
return {record.name: record for record in self._in_records.keys() +
self._out_records.keys() + self._feedback_records.values()}


def update_pvs(self):
"""The callback function passed to ATSimulator during lattice creation,
it is called each time a calculation of physics data is completed. It
Expand All @@ -91,7 +90,7 @@ def update_pvs(self):
else:
value = self.lattice[index - 1].get_value(
field, units=pytac.ENG, data_source=pytac.SIM
)
)
rb_record.set(value)

def _create_records(self, limits_csv):
Expand Down Expand Up @@ -214,9 +213,13 @@ def _on_update(self, name, value):
index, field = self._in_records[in_record]

if self.tune_feedback_status is True:
offset_pv = self._offset_pvs[name]
offset = caget(offset_pv)
value = value + offset
try:
offset_pv = self._offset_pvs[name]
except KeyError:
pass
else:
offset = caget(offset_pv)
value = value + offset
self.lattice[index - 1].set_value(field, value, units=pytac.ENG,
data_source=pytac.SIM)

Expand Down Expand Up @@ -339,13 +342,14 @@ def refresh_record(self, pv_name):
def start_tune_feedback(self, tune_csv=None):
if tune_csv is not None:
self._tune_fb_csv_path = tune_csv
if self.tune_fb_csv_path is None:
if self._tune_fb_csv_path is None:
raise ValueError("No tune feedback csv file was given at start-up,"
" please provide one now; i.e. server.start_tune_"
"feedback(path_to_csv)")
csv_reader = csv.DictReader(open(tune_csv))
csv_reader = csv.DictReader(open(self._tune_fb_csv_path))
if not self._pv_monitoring:
self.monitor_mirrored_pvs()
self.tune_feedback_status = True
for line in csv_reader:
quad_pv = line['quad_set_pv']
offset_pv = line['offset_pv']
Expand Down
35 changes: 35 additions & 0 deletions ioc/masks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from cothread.catools import caget, caput


class callback_set(object):
def __init__(self, output):
self.output = output

def callback(self, value, index=None):
for record in self.output:
record.set(value)


class callback_refresh(object):
def __init__(self, server, output_pv):
self.server = server
self.output_pv = output_pv

def callback(self, value, index=None):
self.server.refresh_record(self.output_pv)


class caget_mask(object):
def __init__(self, pv):
self.pv = pv

def get(self):
return caget(self.pv)


class caput_mask(object):
def __init__(self, pv):
self.pv = pv

def set(self, value):
return caput(self.pv, value)
35 changes: 0 additions & 35 deletions ioc/solution.py → ioc/mirror_objects.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
import numpy
from cothread.catools import caget, caput


class callback_set(object):
def __init__(self, output):
self.output = output

def callback(self, value, index=None):
for record in self.output:
record.set(value)


class callback_refresh(object):
def __init__(self, server, output_pv):
self.server = server
self.output_pv = output_pv

def callback(self, value, index=None):
self.server.refresh_record(self.output_pv)


class caget_mask(object):
def __init__(self, pv):
self.pv = pv

def get(self):
return caget(self.pv)


class caput_mask(object):
def __init__(self, pv):
self.pv = pv

def set(self, value):
return caput(self.pv, value)


class summate(object):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
numpy>=1.10
scipy>=0.16
pytest>=2.9
cothread
pytest-cov
coveralls
mock
flake8
sphinx
sphinx-rtd-theme
cothread

0 comments on commit 5ae354c

Please sign in to comment.