Commit 6faadb9d authored by Holger Witsch's avatar Holger Witsch

* commit what is on lpellab3 before using this on id15

* black the all stuff at the same time
parent cc1c1344
Pipeline #17526 failed with stages
......@@ -20,7 +20,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
import pel
......@@ -32,22 +33,22 @@ import pel
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = u'PEL project'
project = u"PEL project"
copyright = u"2019, BCU Team"
author = u"BCU Team"
......@@ -70,10 +71,10 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
......@@ -84,7 +85,7 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"
# Theme options are theme-specific and customize the look and feel of a
# theme further. For a list of options available for each theme, see the
......@@ -95,13 +96,13 @@ html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# -- Options for HTMLHelp output ---------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'peldoc'
htmlhelp_basename = "peldoc"
# -- Options for LaTeX output ------------------------------------------
......@@ -110,15 +111,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
......@@ -128,9 +126,7 @@ latex_elements = {
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pel.tex',
u'PEL project Documentation',
u'BCU Team', 'manual'),
(master_doc, "pel.tex", u"PEL project Documentation", u"BCU Team", "manual")
]
......@@ -138,11 +134,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pel',
u'PEL project Documentation',
[author], 1)
]
man_pages = [(master_doc, "pel", u"PEL project Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------
......@@ -151,13 +143,13 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pel',
u'PEL project Documentation',
author,
'pel',
'One line description of project.',
'Miscellaneous'),
(
master_doc,
"pel",
u"PEL project Documentation",
author,
"pel",
"One line description of project.",
"Miscellaneous",
)
]
from bliss.common.scans import *
from bliss.common.plot import *
from bliss.common.standard import umv
import gevent
def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs):
......@@ -29,20 +31,29 @@ def PELscan(mot, p_st, p_en, nbp, t_int, *counters, **kwargs):
pos_start = p_st
pos_end = p_en
print('Move motor "%s" to %g' % (mot.name, pos_bckl))
mot.move(pos_bckl)
print(mot.position())
print('Move motor "%s" to backlash position %g' % (mot.name, pos_bckl))
umv(mot, pos_bckl)
# mot.move(pos_bckl)
print('Move motor "%s" to 1st scan position %g' % (mot.name, pos_start))
umv(mot, pos_start)
# mot.move(pos_start)
print("Waiting time for 1st point %d (s)" % (t_int,))
gevent.sleep(t_int)
print("Scan #%d (/%d) from %g to %g\n\n" % (loop + 1, nbs, pos_start, pos_end))
scan = ascan(mot, pos_start, pos_end, nbp, t_int, *counters, **kwargs)
data = get_data(scan)
# data = scan.get_data()
# plot motor pos vs. counters by default
# do not plot interferometer since it doesn't give a useful result
counters_to_plot = [
name
for name in data.dtype.fields
if name not in ("timestamp", mot.name) and not name.startswith("interf")
]
# counters_to_plot = [
# name
# for name in data.dtype.fields
# if name not in ("timestamp", mot.name) and not name.startswith("interf")
# ]
# Plotting de-activated by CG 6 aug. 2018... causes crash with flint :(
# x = data[mot.name]
......
......@@ -18,16 +18,18 @@ YAML_ configuration example:
counter_number: 1 # CNT 1
"""
import gevent
from bliss.common.measurement import IntegratingCounter
import numpy
from bliss.common.measurement import BaseCounter, IntegratingCounter
from bliss.config.settings import HashSetting
from bliss.scanning.chain import AcquisitionMaster
from bliss.common.measurement import counter_namespace
from bliss.scanning.chain import AcquisitionChain, AcquisitionChannel
class TrigCounter(IntegratingCounter):
def __init__(self, name, config):
IntegratingCounter.__init__(self, name, None, self)
trig_config = config["trigger_device"]
self._opiom_card = trig_config.get("name")
......@@ -84,7 +86,7 @@ class TrigCounter(IntegratingCounter):
def nb_pulses(self, value):
self._counter_config["nb_pulses"] = value
def get_value(self, from_index=0):
def get_values(self, from_index, *counters):
return [self.nb_pulses]
def create_master_device(self, scan_pars, **settings):
......@@ -95,17 +97,15 @@ class TrigCounter(IntegratingCounter):
self, self.name, npoints=npoints, count_time=count_time
)
def __repr__(self):
params = " ".join(
["%s=%s" % (k, v) for k, v in self._counter_config.iteritems()]
)
def __info__(self):
params = " ".join(["%s=%s" % (k, v) for k, v in self._counter_config.items()])
return "TrigCounter %s: %s" % (self.name, params)
class _TrigCounterAcqMaster(AcquisitionMaster):
def __init__(self, device, name, npoints=None, count_time=None):
AcquisitionMaster.__init__(
self, device, name, npoints=npoints, prepare_once=True, start_once=True
self, device, name=name, npoints=npoints, prepare_once=True, start_once=True
)
self._count_time = count_time
......@@ -121,7 +121,8 @@ class _TrigCounterAcqMaster(AcquisitionMaster):
)
def add_counter(self, counter):
pass
self.counter = counter
self.channels.append(AcquisitionChannel(self.counter.name, numpy.float, ()))
def start(self):
if not self.parent:
......@@ -137,6 +138,8 @@ class _TrigCounterAcqMaster(AcquisitionMaster):
opiom = self.device._opiom_card
counter = self.device._opiom_counter
opiom.comm("CNT %d START" % counter)
values = {self.counter.name: self.counter.get_values(0)}
self.channels.update(values)
def wait_ready(self):
opiom = self.device._opiom_card
......
......@@ -3,5 +3,5 @@
"""Top-level package for PEL project."""
__author__ = """BCU Team"""
__email__ = 'bliss@esrf.fr'
__version__ = '0.1.0'
__email__ = "bliss@esrf.fr"
__version__ = "0.1.0"
......@@ -5,42 +5,42 @@
import sys
from setuptools import setup, find_packages
TESTING = any(x in sys.argv for x in ['test', 'pytest'])
TESTING = any(x in sys.argv for x in ["test", "pytest"])
with open('README.rst') as readme_file:
with open("README.rst") as readme_file:
readme = readme_file.read()
requirements = ['bliss']
requirements = ["bliss"]
setup_requirements = ['pytest-runner', 'pytest'] if TESTING else []
setup_requirements = ["pytest-runner", "pytest"] if TESTING else []
test_requirements = ['pytest-cov', 'mock']
test_requirements = ["pytest-cov", "mock"]
setup(
author="BCU Team",
author_email='bliss@esrf.fr',
author_email="bliss@esrf.fr",
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Natural Language :: English",
"Programming Language :: Python :: 2",
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
],
description="PEL software & configuration",
install_requires=requirements,
license="GNU General Public License v3",
long_description=readme,
include_package_data=True,
keywords='pel',
name='pel',
packages=find_packages(include=['pel']),
keywords="pel",
name="pel",
packages=find_packages(include=["pel"]),
setup_requires=setup_requirements,
test_suite='tests',
test_suite="tests",
tests_require=test_requirements,
url='https://gitlab.esrf.fr/PEL/pel',
version='0.1.0',
url="https://gitlab.esrf.fr/PEL/pel",
version="0.1.0",
zip_safe=False,
)
......@@ -21,22 +21,24 @@ from bliss.config.conductor import client
from bliss.config.conductor import connection
from bliss.config.conductor.client import get_default_connection
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
BEACON = [sys.executable, '-m', 'bliss.config.conductor.server']
BEACON_DB_PATH = os.path.join(ROOT, 'tests', 'test_configuration')
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
BEACON = [sys.executable, "-m", "bliss.config.conductor.server"]
BEACON_DB_PATH = os.path.join(ROOT, "tests", "test_configuration")
REDIS_PORT = 7754
BEACON_PORT = 7755
TANGO_PORT = 7756
@pytest.fixture(scope="session")
def beacon():
args = [
'--port=%d' % BEACON_PORT,
'--redis_port=%d' % REDIS_PORT,
'--redis_socket=/tmp/redis_test_pel.sock',
'--db_path=' + BEACON_DB_PATH,
'--posix_queue=0',
'--tango_port=%d' % TANGO_PORT]
"--port=%d" % BEACON_PORT,
"--redis_port=%d" % REDIS_PORT,
"--redis_socket=/tmp/redis_test_pel.sock",
"--db_path=" + BEACON_DB_PATH,
"--posix_queue=0",
"--tango_port=%d" % TANGO_PORT,
]
proc = subprocess.Popen(BEACON + args)
time.sleep(0.5) # wait for beacon to be really started
redis_db = redis.Redis(port=REDIS_PORT)
......@@ -69,8 +71,8 @@ def lima_simulator(beacon):
device_name = "id00/limaccds/simulator1"
device_fqdn = "tango://localhost:%d/%s" % (TANGO_PORT, device_name)
p = subprocess.Popen(['LimaCCDs', 'simulator'])
p = subprocess.Popen(["LimaCCDs", "simulator"])
with gevent.Timeout(3, RuntimeError("Lima simulator is not running")):
while True:
......@@ -94,8 +96,8 @@ def bliss_tango_server(beacon):
device_name = "id00/bliss/test"
device_fqdn = "tango://localhost:%d/%s" % (TANGO_HOST, device_name)
bliss_ds = [sys.executable, '-m', 'bliss.tango.servers.bliss_ds']
p = subprocess.Popen(bliss_ds+["test"])
bliss_ds = [sys.executable, "-m", "bliss.tango.servers.bliss_ds"]
p = subprocess.Popen(bliss_ds + ["test"])
with gevent.Timeout(3, RuntimeError("Bliss tango server is not running")):
while True:
......@@ -111,6 +113,7 @@ def bliss_tango_server(beacon):
yield device_fqdn, dev_proxy
p.terminate()
def motor_fixture(name):
def get_motor(beacon):
m = beacon.get(name)
......@@ -124,6 +127,7 @@ def motor_fixture(name):
for hook in m.motion_hooks:
hook.nb_pre_move = 0
hook.nb_post_move = 0
get_motor.__name__ = name
return pytest.fixture(get_motor)
......@@ -135,11 +139,12 @@ def calc_motor_fixture(name):
yield m
m.stop()
m.wait_move()
get_motor.__name__ = name
return pytest.fixture(get_motor)
m0 = motor_fixture("m0")
m1 = motor_fixture("m1")
# add more fixtures here as needed
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment