Release of 5.1.0 (#237)

* Setting pattern from memory (#218)

* ToString accepts c-style arrays

* fixed patwait time bug in validation

* Introduced pattern class

* compile for servers too

* Python binding for Pattern

* added scanParameters in Python

* slsReceiver: avoid potential memory leak around Implementation::generalData

* additional constructors for scanPrameters in python

* bugfix: avoid potentital memory leak in receiver if called outside constructor context

* added scanParameters in Python

* additional constructors for scanPrameters in python

* M3defaultpattern (#227)

* default pattern for m3 and moench including Python bindings

* M3settings (#228)

* some changes to compile on RH7 and in the server to load the default chip status register at startup

* Updated mythen3DeectorServer_developer executable with correct initialization at startup

Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
Co-authored-by: Anna Bergamaschi <anna.bergamaschi@psi.ch>

* Pattern.h as a public header files (#229)

* fixed buffer overflow but caused by using global instead of local enum

* replacing out of range trimbits with edge values

* replacing dac values that are out of range after interpolation

* updated pybind11 to 2.6.2

* Mythen3 improved synchronization (#231)

Disabling scans for multi module Mythen3, since there is no feedback of the detectors being ready
startDetector first starts the slaves then the master
acquire firs calls startDetector for the slaves then acquire on the master
getMaster to read back from hardware which one is master

* New server for JF to go with the new FW (#232)

* Modified Jungfrau speed settings for HW1.0 - FW fix version 1.1.1, compilation date 210218

* Corrected bug. DBIT clk phase is implemented in both HW version 1.0 and 2.0. Previous version did not update the DBIT phase shift on the configuration of a speed.

* fix for m3 scan with single module

* m3 fw version

* m3 server

* bugfix for bottom when setting quad

* new strategy for finding zmq based on cppzmq



Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
Co-authored-by: Dhanya Thattil <33750417+thattil@users.noreply.github.com>
Co-authored-by: Alejandro Homs Puron <ahoms@esrf.fr>
Co-authored-by: Anna Bergamaschi <anna.bergamaschi@psi.ch>
Co-authored-by: Xiaoqiang Wang <xiaoqiangwang@gmail.com>
Co-authored-by: lopez_c <carlos.lopez-cuenca@psi.ch>
This commit is contained in:
Erik Fröjdh
2021-03-22 14:43:11 +01:00
committed by GitHub
parent 64de9f3ad0
commit 2f2fe4dd47
168 changed files with 3614 additions and 9057 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0)
set(PROJECT_VERSION 5.1.0)
include(CheckIPOSupported)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
@ -157,8 +157,37 @@ set(CMAKE_INSTALL_RPATH $ORIGIN)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
#Adapted from: https://github.com/zeromq/cppzmq/
if (NOT TARGET libzmq)
if(ZeroMQ_HINT)
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
find_package(ZeroMQ 4
NO_DEFAULT_PATH
HINTS ${ZeroMQ_DIR}
)
else()
find_package(ZeroMQ 4)
endif()
# libzmq autotools install: fallback to pkg-config
if(NOT ZeroMQ_FOUND)
message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)")
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
find_package(ZeroMQ 4 REQUIRED)
endif()
# TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work
if(NOT ZeroMQ_FOUND)
message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config")
endif()
if (ZeroMQ_FOUND AND NOT TARGET libzmq)
message(FATAL_ERROR "ZeroMQ version not supported!")
endif()
endif()
if (SLS_USE_TESTS)
enable_testing()

View File

@ -1,13 +1,13 @@
SLS Detector Package 5.0.1 released on 25.11.2020 (Bug Fix Release)
SLS Detector Package 5.1.0 released on 22.03.2020 (Minor Release)
===================================================================
This document describes the differences between 5.0.1 and 5.0.0 releases.
This document describes the differences between 5.1.0 and 5.0.1 releases.
CONTENTS
--------
1. Topics Concerning
1. New Features
2. Resolved Issues
3. Known Issues
4. Firmware Requirements
@ -15,45 +15,62 @@ This document describes the differences between 5.0.1 and 5.0.0 releases.
1. Topics Concerning
====================
- Python bindings
- CMake improvements
1. New Features
===============
Client
------
1. Added settings and threshold features for Mythen3.
2. Internal modification of acquire for Mythen3.
3. Added getMaster for Mythen3
4. Mythen3, API function to set pattern from memory
Mythen3 server
-----------------
1. Setting timing to auto, sets timing to trigger for slaves
2. Resolved Issues
==================
Python bindings
---------------
1. Fixed function signatures for getRxUDPSocketBufferSize,
setRxUDPSocketBufferSize and getRxRealUDPSocketBufferSize.
Receiver
--------
2. Updated pybind11 to v2.6.1 to remove warnings with Python 3.9 and
better handling of C++ standard.
3. Added missing properties in Python.
1. Current code only calls Implementation::setDetectorType from constructor,
but potential memory leak if called out of constructor context. Fixed.
CMake improvements
------------------
Client
------
1. Explicitly state Python 3.6 or greater.
1. Fixed missing scanParameters class in Python
2. cmk.sh refactored to have better option handling
3. Fixed hardcoded path accidentally ending up in the exported CMake package
Server
--------
1. Bottom port not mirrored correctly for Eiger quad
2. Finds the Python of the activated environment when using conda
without having to supply additional arguments.
3. Removed redundant libraries for linking targets.
3. Firmware Requirements
========================
No updates from 5.0.0
Mythen3: 0x210201
Jungfrau: 0x210218 (1.0 pcb)
0x200721 (2.0 pcb, not changed)
Other detectors no updates from 5.0.0

View File

@ -1,112 +0,0 @@
# This file is originally from https://github.com/zeromq/azmq and distributed
# under Boost Software Lincese 1.0
# Boost Software License - Version 1.0 - August 17th, 2003
# Permission is hereby granted, free of charge, to any person or organization
# obtaining a copy of the software and accompanying documentation covered by
# this license (the "Software") to use, reproduce, display, distribute,
# execute, and transmit the Software, and to prepare derivative works of the
# Software, and to permit third-parties to whom the Software is furnished to
# do so, all subject to the following:
# The copyright notices in the Software and this entire statement, including
# the above license grant, this restriction and the following disclaimer,
# must be included in all copies of the Software, in whole or in part, and
# all derivative works of the Software, unless such copies or derivative
# works are solely in the form of machine-executable object code generated by
# a source language processor.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
# --------------------------------------------------------------------------------
# Find ZeroMQ Headers/Libs
# Variables
# ZMQ_ROOT - set this to a location where ZeroMQ may be found
#
# ZeroMQ_FOUND - True of ZeroMQ found
# ZeroMQ_INCLUDE_DIRS - Location of ZeroMQ includes
# ZeroMQ_LIBRARIES - ZeroMQ libraries
include(FindPackageHandleStandardArgs)
if (NOT ZMQ_ROOT)
set(ZMQ_ROOT "$ENV{ZMQ_ROOT}")
endif()
if (NOT ZMQ_ROOT)
find_path(_ZeroMQ_ROOT NAMES include/zmq.h)
else()
set(_ZeroMQ_ROOT "${ZMQ_ROOT}")
endif()
find_path(ZeroMQ_INCLUDE_DIRS NAMES zmq.h HINTS ${_ZeroMQ_ROOT}/include)
if (ZeroMQ_INCLUDE_DIRS)
set(_ZeroMQ_H ${ZeroMQ_INCLUDE_DIRS}/zmq.h)
function(_zmqver_EXTRACT _ZeroMQ_VER_COMPONENT _ZeroMQ_VER_OUTPUT)
set(CMAKE_MATCH_1 "0")
set(_ZeroMQ_expr "^[ \\t]*#define[ \\t]+${_ZeroMQ_VER_COMPONENT}[ \\t]+([0-9]+)$")
file(STRINGS "${_ZeroMQ_H}" _ZeroMQ_ver REGEX "${_ZeroMQ_expr}")
string(REGEX MATCH "${_ZeroMQ_expr}" ZeroMQ_ver "${_ZeroMQ_ver}")
set(${_ZeroMQ_VER_OUTPUT} "${CMAKE_MATCH_1}" PARENT_SCOPE)
endfunction()
_zmqver_EXTRACT("ZMQ_VERSION_MAJOR" ZeroMQ_VERSION_MAJOR)
_zmqver_EXTRACT("ZMQ_VERSION_MINOR" ZeroMQ_VERSION_MINOR)
_zmqver_EXTRACT("ZMQ_VERSION_PATCH" ZeroMQ_VERSION_PATCH)
message(STATUS "ZeroMQ version: ${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}")
# We should provide version to find_package_handle_standard_args in the same format as it was requested,
# otherwise it can't check whether version matches exactly.
if (ZeroMQ_FIND_VERSION_COUNT GREATER 2)
set(ZeroMQ_VERSION "${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}")
else()
# User has requested ZeroMQ version without patch part => user is not interested in specific patch =>
# any patch should be an exact match.
set(ZeroMQ_VERSION "${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}")
endif()
if (NOT ${CMAKE_CXX_PLATFORM_ID} STREQUAL "Windows")
find_library(ZeroMQ_LIBRARIES NAMES zmq HINTS ${_ZeroMQ_ROOT}/lib)
else()
find_library(
ZeroMQ_LIBRARY_RELEASE
NAMES
libzmq
"libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
HINTS
${_ZeroMQ_ROOT}/lib
)
find_library(
ZeroMQ_LIBRARY_DEBUG
NAMES
libzmq_d
"libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}"
HINTS
${_ZeroMQ_ROOT}/lib)
# On Windows we have to use corresponding version (i.e. Release or Debug) of ZeroMQ because of `errno` CRT global variable
# See more at http://www.drdobbs.com/avoiding-the-visual-c-runtime-library/184416623
set(ZeroMQ_LIBRARIES optimized "${ZeroMQ_LIBRARY_RELEASE}" debug "${ZeroMQ_LIBRARY_DEBUG}")
endif()
endif()
find_package_handle_standard_args(ZeroMQ FOUND_VAR ZeroMQ_FOUND
REQUIRED_VARS ZeroMQ_INCLUDE_DIRS ZeroMQ_LIBRARIES
VERSION_VAR ZeroMQ_VERSION)
if (ZeroMQ_FOUND)
mark_as_advanced(ZeroMQ_INCLUDE_DIRS ZeroMQ_LIBRARIES ZeroMQ_VERSION
ZeroMQ_VERSION_MAJOR ZeroMQ_VERSION_MINOR ZeroMQ_VERSION_PATCH)
endif()

View File

@ -25,6 +25,12 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_DIR}
)
install(FILES
"${CMAKE_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake"
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
)
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
install(
EXPORT "${TARGETS_EXPORT_NAME}"

View File

@ -12,8 +12,21 @@ include(CMakeFindDependencyMacro)
set(SLS_USE_HDF5 "@SLS_USE_HDF5@")
# Add optional dependencies here
find_package(ZeroMQ 4 QUIET)
# libzmq autotools install: fallback to pkg-config
if(NOT ZeroMQ_FOUND)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config)
find_package(ZeroMQ 4 REQUIRED)
endif()
if(NOT ZeroMQ_FOUND)
message(FATAL_ERROR "ZeroMQ was NOT found!")
endif()
find_dependency(Threads)
# Add optional dependencies here
if (SLS_USE_HDF5)
find_dependency(HDF5)
endif ()

View File

@ -13,8 +13,9 @@ cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DSLS_USE_HDF5=OFF\
cmake --build . -- -j10
NCORES=$(getconf _NPROCESSORS_ONLN)
echo "Building using: ${NCORES} cores"
cmake --build . -- -j${NCORES}
cmake --build . --target install
CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2

View File

@ -1,3 +1,3 @@
#Copy the GUI
mkdir $PREFIX/bin
cp build/bin/slsDetectorGui $PREFIX/bin/.
mkdir -p $PREFIX/bin
cp build/install/bin/slsDetectorGui $PREFIX/bin/.

View File

@ -1,6 +1,6 @@
mkdir $PREFIX/lib
mkdir $PREFIX/bin
mkdir -p $PREFIX/lib
mkdir -p $PREFIX/bin
mkdir -p $PREFIX/include/sls
# mkdir $PREFIX/include/slsDetectorPackage

View File

@ -59,6 +59,16 @@ outputs:
script: copy_lib.sh
requirements:
build:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- libstdcxx-ng
- libgcc-ng
- zeromq
host:
- zeromq
run:
- libstdcxx-ng
- libgcc-ng
@ -78,6 +88,8 @@ outputs:
host:
- python
- {{ pin_subpackage('slsdetlib', exact=True) }}
run:
- libstdcxx-ng
@ -94,6 +106,13 @@ outputs:
- name: slsdetgui
script: copy_gui.sh
requirements:
build:
- {{ compiler('c') }}
- {{compiler('cxx')}}
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qwt 6.*
run:
- {{ pin_subpackage('slsdetlib', exact=True) }}
- qwt 6.*

View File

@ -0,0 +1,27 @@
#From: https://github.com/zeromq/cppzmq/
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
find_package(PkgConfig)
pkg_check_modules(PC_LIBZMQ QUIET libzmq)
set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION})
find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS})
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
set(ZeroMQ_FOUND ON)
endif()
if (TARGET libzmq)
# avoid errors defining targets twice
return()
endif()
add_library(libzmq SHARED IMPORTED)
set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY})
add_library(libzmq-static STATIC IMPORTED ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS})
set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY})

View File

@ -4,6 +4,8 @@ pybind11_add_module(_slsdet
src/enums.cpp
src/detector.cpp
src/network.cpp
src/pattern.cpp
src/scan.cpp
)
target_link_libraries(_slsdet PUBLIC
@ -28,6 +30,7 @@ set( PYTHON_FILES
enums.py
errors.py
gotthard.py
pattern.py
gotthard2.py
moench.py
proxy.py

View File

@ -0,0 +1,14 @@
from slsdet import Detector, patternParameters
d = Detector()
pat = patternParameters()
#Access to members of the structure using numpy arrays
pat.patlimits = 0x0, 0xa
d.setPattern(pat)
#Load pattern from file
pat.load("/some/dir/some.pat")

View File

@ -6,7 +6,7 @@ d = Detector()
d.fformat = fileFormat.BINARY
# Altough not recommended for convenience all enums
# and some other things can be impored using *
# and some other things can be imported using *
from slsdet import *
d.speed = speedLevel.FULL_SPEED
@ -15,6 +15,6 @@ d.speed = speedLevel.FULL_SPEED
import slsdet.enums
for enum in dir(slsdet.enums):
# filter out special memebers
# filter out special members
if not enum.startswith('_'):
print(enum)

View File

@ -0,0 +1,19 @@
from slsdet import Mythen3, scanParameters, dacIndex
#Configure scan
sp = scanParameters()
sp.enable = 1
sp.dacInd = dacIndex.VTH1
sp.startOffset = 0
sp.stopOffset = 1000
sp.stepSize = 100
sp.dacSettleTime_ns = int(1e9)
# Send scan to detector
d = Mythen3()
d.setScan(sp)

View File

@ -10,6 +10,8 @@ from slsdet.lookup import view, find
import slsdet
d = Detector()
e = Eiger()
c = Ctb()

View File

@ -0,0 +1,80 @@
import subprocess
import os
import sys
from pathlib import Path
import shutil as sh
from argparse import ArgumentParser
class color:
HEADER = "\033[95m"
BLUE = "\033[94m"
CYAN = "\033[96m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
RED = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
MAGENTA = "\033[35m"
@staticmethod
def red(s):
return f"{color.RED}{s}{color.ENDC}"
@staticmethod
def green(s):
return f"{color.GREEN}{s}{color.ENDC}"
def add_to_path():
paths = [
"/opt/uClinux/bfin-uclinux/bin",
"/opt/nios2-gcc/bin",
"/opt/eldk-5.1/powerpc-4xx-softfloat/sysroots/i686-eldk-linux/usr/bin/ppc405-linux",
]
os.environ["PATH"] += os.pathsep + os.pathsep.join(paths)
def rc_to_string(rc):
if rc == 0:
return color.green("OK")
else:
return color.red("FAIL")
parser = ArgumentParser()
parser.add_argument('-t', '--tag', help = 'Tag added to server file name', default='developer')
parser.add_argument('-g', '--git', help='Add new servers to the git repo', action="store_true")
args = parser.parse_args()
servers = [
"eigerDetectorServer",
"jungfrauDetectorServer",
"mythen3DetectorServer",
"gotthard2DetectorServer",
"gotthardDetectorServer",
"ctbDetectorServer",
"moenchDetectorServer",
]
server_root = Path("../../slsDetectorServers/").resolve()
add_to_path()
for server in servers:
bin_name = f"{server}_{args.tag}"
path = server_root / server
print(f"{bin_name} - ", end="")
os.chdir(path)
try:
sh.rmtree(path/'bin')
except FileNotFoundError:
pass
p = subprocess.run(["make"], stdout=subprocess.DEVNULL)
print(rc_to_string(p.returncode))
if p.returncode == 0:
sh.move(f"bin/{server}", f"bin/{bin_name}")
if args.git:
print("Adding to git")
subprocess.run(['git', 'add', 'bin', '-f'])

View File

@ -55,7 +55,7 @@ def generate_enum_string(enums):
data.append('.export_values();\n\n')
return ''.join(data)
with open('../../slsSupportLib/include/sls_detector_defs.h') as f:
with open('../../slsSupportLib/include/sls/sls_detector_defs.h') as f:
data = f.read()
data = remove_comments(data)

View File

@ -2,11 +2,12 @@
Setup file for slsdet
Build upon the pybind11 example found here: https://github.com/pybind/python_example
"""
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
import sys
import setuptools
import os
import sys
sys.path.append('../libs/pybind11')
from setuptools import setup, find_packages
from pybind11.setup_helpers import Pybind11Extension, build_ext
__version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer')
@ -19,109 +20,29 @@ def get_conda_path():
return os.environ['CONDA_PREFIX']
# class get_pybind_include(object):
# """Helper class to determine the pybind11 include path
# The purpose of this class is to postpone importing pybind11
# until it is actually installed, so that the ``get_include()``
# method can be invoked. """
# def __init__(self, user=False):
# self.user = user
# def __str__(self):
# import pybind11
# return pybind11.get_include(self.user)
#TODO migrate to CMake build?
ext_modules = [
Extension(
Pybind11Extension(
'_slsdet',
['src/main.cpp',
'src/enums.cpp',
'src/detector.cpp',
'src/network.cpp'],
'src/network.cpp',
'src/pattern.cpp',
'src/scan.cpp',],
include_dirs=[
# Path to pybind11 headers
# get_pybind_include(),
# get_pybind_include(user=True),
os.path.join('../libs/pybind11/include'),
os.path.join(get_conda_path(), 'include'),
],
libraries=['SlsDetector', 'SlsReceiver', 'zmq'],
libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver', 'zmq'],
library_dirs=[
os.path.join(get_conda_path(), 'lib'),
os.path.join(get_conda_path(), 'bin'),
],
language='c++'
),
]
# As of Python 3.6, CCompiler has a `has_flag` method.
# cf http://bugs.python.org/issue26689
def has_flag(compiler, flagname):
"""Return a boolean indicating whether a flag name is supported on
the specified compiler.
"""
import tempfile
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:
f.write('int main (int argc, char **argv) { return 0; }')
try:
compiler.compile([f.name], extra_postargs=[flagname])
except setuptools.distutils.errors.CompileError:
return False
return True
def cpp_flag(compiler):
"""Return the -std=c++[11/14] compiler flag.
The c++14 is prefered over c++11 (when it is available).
"""
if has_flag(compiler, '-std=c++14'):
return '-std=c++14'
elif has_flag(compiler, '-std=c++11'):
return '-std=c++11'
else:
raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc'],
'unix': [],
}
if sys.platform == 'darwin':
c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
print('**************************************************')
print(ct)
print(opts)
print('**************************************************')
build_ext.build_extensions(self)
def get_shared_lib():
return [f for f in os.listdir('.') if '_slsdet' in f]
setup(
name='slsdet',
version=__version__,
@ -132,6 +53,6 @@ setup(
long_description='',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
ext_modules=ext_modules,
cmdclass={'build_ext': BuildExt},
cmdclass={"build_ext": build_ext},
zip_safe=False,
)

View File

@ -8,6 +8,8 @@ from .mythen3 import Mythen3
from .gotthard2 import Gotthard2
from .gotthard import Gotthard
from .moench import Moench
from .pattern import Pattern, patternParameters
import _slsdet
xy = _slsdet.xy
@ -18,3 +20,4 @@ from .enums import *
IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr
scanParameters = _slsdet.scanParameters

View File

@ -1696,6 +1696,8 @@ class Detector(CppDetectorApi):
To change settings as well or set threshold without trimbits, use setThresholdEnergy.
:setter: It loads trim files from settingspath.
"""
if self.type == detectorType.MYTHEN3:
return self.getAllThresholdEnergy()
return self.getThresholdEnergy()
@threshold.setter

53
python/slsdet/pattern.py Normal file
View File

@ -0,0 +1,53 @@
import _slsdet
from _slsdet import Pattern
class patternParameters(_slsdet.patternParameters):
def __init__(self):
super().__init__()
self.view = self.numpy_view()
self.names = self.view.dtype.names
def __getattr__(self, name):
if name in self.names:
return self.view[name][0]
else:
raise KeyError(f"Key: {name} not found")
def __setattr__(self, name, value):
if name in ["view", "names"]:
self.__dict__[name] = value
elif name in self.names:
self.view[name] = value
else:
raise KeyError(f"Key: {name} not found")
# Provide custom dir for tab completion
def __dir__(self):
return self.names
class Pattern(_slsdet.Pattern):
def __init__(self):
super().__init__()
self.view = self.data().numpy_view()
self.names = self.view.dtype.names
def __getattr__(self, name):
if name in self.names:
return self.view[name][0]
else:
raise KeyError(f"Key: {name} not found")
def __setattr__(self, name, value):
if name in ["view", "names"]:
self.__dict__[name] = value
elif name in self.names:
self.view[name] = value
else:
raise KeyError(f"Key: {name} not found")
# Provide custom dir for tab completion
def __dir__(self):
return self.names

View File

@ -102,6 +102,34 @@ void init_det(py::module &m) {
(void (Detector::*)(defs::detectorSettings, sls::Positions)) &
Detector::setSettings,
py::arg(), py::arg() = Positions{})
.def("getThresholdEnergy",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getThresholdEnergy,
py::arg() = Positions{})
.def("getAllThresholdEnergy",
(Result<std::array<int, 3>>(Detector::*)(sls::Positions) const) &
Detector::getAllThresholdEnergy,
py::arg() = Positions{})
.def("setThresholdEnergy",
(void (Detector::*)(int, defs::detectorSettings, bool,
sls::Positions)) &
Detector::setThresholdEnergy,
py::arg(), py::arg() = defs::STANDARD, py::arg() = true,
py::arg() = Positions{})
.def("setThresholdEnergy",
(void (Detector::*)(std::array<int, 3>, defs::detectorSettings,
bool, sls::Positions)) &
Detector::setThresholdEnergy,
py::arg(), py::arg() = defs::STANDARD, py::arg() = true,
py::arg() = Positions{})
.def("getSettingsPath",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getSettingsPath,
py::arg() = Positions{})
.def("setSettingsPath",
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setSettingsPath,
py::arg(), py::arg() = Positions{})
.def("loadTrimbits",
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::loadTrimbits,
@ -114,6 +142,14 @@ void init_det(py::module &m) {
(void (Detector::*)(int, sls::Positions)) &
Detector::setAllTrimbits,
py::arg(), py::arg() = Positions{})
.def("getTrimEnergies",
(Result<std::vector<int>>(Detector::*)(sls::Positions) const) &
Detector::getTrimEnergies,
py::arg() = Positions{})
.def("setTrimEnergies",
(void (Detector::*)(std::vector<int>, sls::Positions)) &
Detector::setTrimEnergies,
py::arg(), py::arg() = Positions{})
.def("getGapPixelsinCallback",
(bool (Detector::*)() const) & Detector::getGapPixelsinCallback)
.def("setGapPixelsinCallback",
@ -783,24 +819,6 @@ void init_det(py::module &m) {
(void (Detector::*)(sls::ns, sls::Positions)) &
Detector::setSubDeadTime,
py::arg(), py::arg() = Positions{})
.def("getThresholdEnergy",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getThresholdEnergy,
py::arg() = Positions{})
.def("setThresholdEnergy",
(void (Detector::*)(int, defs::detectorSettings, bool,
sls::Positions)) &
Detector::setThresholdEnergy,
py::arg(), py::arg() = defs::STANDARD, py::arg() = true,
py::arg() = Positions{})
.def("getSettingsPath",
(Result<std::string>(Detector::*)(sls::Positions) const) &
Detector::getSettingsPath,
py::arg() = Positions{})
.def("setSettingsPath",
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setSettingsPath,
py::arg(), py::arg() = Positions{})
.def("getOverFlowMode",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getOverFlowMode,
@ -816,14 +834,6 @@ void init_det(py::module &m) {
.def("setBottom",
(void (Detector::*)(bool, sls::Positions)) & Detector::setBottom,
py::arg(), py::arg() = Positions{})
.def("getTrimEnergies",
(Result<std::vector<int>>(Detector::*)(sls::Positions) const) &
Detector::getTrimEnergies,
py::arg() = Positions{})
.def("setTrimEnergies",
(void (Detector::*)(std::vector<int>, sls::Positions)) &
Detector::setTrimEnergies,
py::arg(), py::arg() = Positions{})
.def("getRateCorrection",
(Result<sls::ns>(Detector::*)(sls::Positions) const) &
Detector::getRateCorrection,
@ -1122,6 +1132,10 @@ void init_det(py::module &m) {
(Result<std::array<ns, 3>>(Detector::*)(sls::Positions) const) &
Detector::getGateDelayForAllGates,
py::arg() = Positions{})
.def("getMaster",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getMaster,
py::arg() = Positions{})
.def("getNumberOfAnalogSamples",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getNumberOfAnalogSamples,
@ -1271,9 +1285,17 @@ void init_det(py::module &m) {
(void (Detector::*)(const std::string &, sls::Positions)) &
Detector::setPattern,
py::arg(), py::arg() = Positions{})
.def("setPattern",
(void (Detector::*)(const sls::Pattern &, sls::Positions)) &
Detector::setPattern,
py::arg(), py::arg() = Positions{})
.def("savePattern",
(void (Detector::*)(const std::string &)) & Detector::savePattern,
py::arg())
.def("loadDefaultPattern",
(void (Detector::*)(sls::Positions)) &
Detector::loadDefaultPattern,
py::arg() = Positions{})
.def("getPatternIOControl",
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
Detector::getPatternIOControl,

View File

@ -2,10 +2,12 @@
* warning */
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "sls/Pattern.h"
#include "sls/sls_detector_defs.h"
namespace py = pybind11;
void init_enums(py::module &m) {

View File

@ -1,9 +1,11 @@
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "sls/sls_detector_defs.h"
#include "sls/Pattern.h"
namespace py = pybind11;
void init_enums(py::module &m) {
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
@ -14,5 +16,4 @@ void init_enums(py::module &m) {
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
[[ENUMS]]
}

View File

@ -19,6 +19,8 @@ void init_enums(py::module &);
void init_experimental(py::module &);
void init_det(py::module &);
void init_network(py::module &);
void init_pattern(py::module &);
void init_scan(py::module &);
PYBIND11_MODULE(_slsdet, m) {
m.doc() = R"pbdoc(
C/C++ API
@ -33,6 +35,8 @@ PYBIND11_MODULE(_slsdet, m) {
init_enums(m);
init_det(m);
init_network(m);
init_pattern(m);
init_scan(m);
// init_experimental(m);

29
python/src/pattern.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "sls/Pattern.h"
#include "sls/sls_detector_defs.h"
namespace py = pybind11;
void init_pattern(py::module &m) {
using pat = sls::patternParameters;
py::class_<pat> patternParameters(m, "patternParameters");
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop, wait,
waittime);
patternParameters.def(py::init());
patternParameters.def("numpy_view", [](py::object &obj) {
pat &o = obj.cast<pat &>();
return py::array_t<pat>(1, &o, obj);
});
py::class_<sls::Pattern> Pattern(m, "Pattern");
Pattern.def(py::init());
Pattern.def("load", &sls::Pattern::load);
Pattern.def("data", (pat * (sls::Pattern::*)()) & sls::Pattern::data,
py::return_value_policy::reference);
}

39
python/src/scan.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <sstream>
#include "sls/sls_detector_defs.h"
namespace py = pybind11;
void init_scan(py::module &m) {
using sp = slsDetectorDefs::scanParameters;
py::class_<sp> scanParameters(m, "scanParameters");
scanParameters.def(py::init());
scanParameters.def(py::init<slsDetectorDefs::dacIndex, int, int, int>());
scanParameters.def(py::init<slsDetectorDefs::dacIndex, int, int, int, std::chrono::nanoseconds>());
scanParameters.def_readwrite("enable", &sp::enable);
scanParameters.def_readwrite("dacInd", &sp::dacInd);
scanParameters.def_readwrite("startOffset", &sp::startOffset);
scanParameters.def_readwrite("stopOffset", &sp::stopOffset);
scanParameters.def_readwrite("stepSize", &sp::stepSize);
scanParameters.def_readwrite("dacSettleTime_ns", &sp::dacSettleTime_ns);
scanParameters.def("__repr__", [](const sp &a){
std::ostringstream oss;
auto indent = " ";
oss << "<scanParameters>\n";
oss << indent << "enable: " << a.enable << '\n';
oss << indent << "dacInd: " << a.dacInd << '\n';
oss << indent << "startOffset: " << a.startOffset << '\n';
oss << indent << "stopOffset: " << a.stopOffset << '\n';
oss << indent << "stepSize: " << a.stepSize << '\n';
oss << indent << "dacSettleTime_ns: " << a.dacSettleTime_ns;
return oss.str();
});
}

View File

@ -0,0 +1 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv5.0.0

View File

@ -0,0 +1 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer

View File

@ -1 +0,0 @@
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv5.0.0

View File

@ -1 +0,0 @@
800 10

View File

@ -1 +0,0 @@
829 9.3

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
800 10

View File

@ -1 +0,0 @@
804 15.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
800 10

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
817 11.6

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -91,7 +91,6 @@ target_include_directories(slsDetectorGui PUBLIC
target_link_libraries(slsDetectorGui PUBLIC
slsProjectOptions
slsProjectWarnings
slsDetectorStatic
${QT_QTCORE_LIBRARIES}
${QT_QTGUI_LIBRARIES}
@ -101,6 +100,9 @@ target_link_libraries(slsDetectorGui PUBLIC
Qt4::QtOpenGL
Qt4::QtSvg
expat
PRIVATE
slsProjectWarnings
)
set_target_properties(slsDetectorGui PROPERTIES
@ -111,7 +113,7 @@ if(SLS_LTO_AVAILABLE)
endif()
install(TARGETS slsDetectorGui
EXPORT "${TARGETS_EXPORT_NAME}"
# EXPORT "${TARGETS_EXPORT_NAME}" #do not export gui
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -32,17 +32,23 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="2">
<widget class="QSpinBox" name="spinThreshold">
<item row="1" column="4">
<widget class="QSpinBox" name="spinThreshold3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
@ -63,10 +69,69 @@
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<item row="1" column="2">
<widget class="QSpinBox" name="spinThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Dynamic Range:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
@ -74,7 +139,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
<height>190</height>
</size>
</property>
</spacer>
@ -86,10 +151,16 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1.67772e+07</string>
@ -112,21 +183,102 @@
</item>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="6">
<widget class="QPushButton" name="btnSetThreshold">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
<width>100</width>
<height>30</height>
</size>
</property>
</spacer>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="text">
<string>Set</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/rightArrow.png</normaloff>:/icons/images/rightArrow.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Settings:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboSettings">
@ -141,10 +293,16 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Settings of the detector.
#settings#</string>
@ -266,40 +424,10 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblDynamicRange">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Dynamic Range:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Settings:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="verticalSpacer">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
@ -307,7 +435,82 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>190</height>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblThreshold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="spinThreshold2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>16777215</height>
</size>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string> eV</string>
</property>
<property name="minimum">
<number>-100000</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="1" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
@ -317,6 +520,9 @@
<tabstops>
<tabstop>comboSettings</tabstop>
<tabstop>spinThreshold</tabstop>
<tabstop>spinThreshold2</tabstop>
<tabstop>spinThreshold3</tabstop>
<tabstop>btnSetThreshold</tabstop>
<tabstop>comboDynamicRange</tabstop>
</tabstops>
<resources>

View File

@ -14,6 +14,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void SetSettings(int index);
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
void SetThresholdEnergies();
private:
void SetupWidgetWindow();
@ -23,6 +24,7 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
void GetSettings();
void GetDynamicRange();
void GetThresholdEnergy();
void GetThresholdEnergies();
sls::Detector *det;
enum {

View File

@ -14,14 +14,24 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
spinThreshold2->hide();
spinThreshold3->hide();
btnSetThreshold->hide();
btnSetThreshold->setEnabled(false);
// enabling according to det type
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) {
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
spinThreshold2->show();
spinThreshold3->show();
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
spinThreshold2->setEnabled(true);
spinThreshold3->setEnabled(true);
btnSetThreshold->setEnabled(true);
btnSetThreshold->show();
// disable dr
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
@ -34,7 +44,6 @@ void qTabSettings::SetupWidgetWindow() {
item = model->itemFromIndex(index);
item->setEnabled(false);
}
} else if (detType == slsDetectorDefs::EIGER) {
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
@ -48,6 +57,10 @@ void qTabSettings::SetupWidgetWindow() {
SetupDetectorSettings();
}
spinThreshold->setValue(-1);
if (detType == slsDetectorDefs::MYTHEN3) {
spinThreshold2->setValue(-1);
spinThreshold3->setValue(-1);
}
Initialization();
// default for the disabled
GetDynamicRange();
@ -104,6 +117,11 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)G4_HIGHGAIN]->setEnabled(true);
item[(int)G4_LOWGAIN]->setEnabled(true);
break;
case slsDetectorDefs::MYTHEN3:
item[(int)STANDARD]->setEnabled(true);
item[(int)FAST]->setEnabled(true);
item[(int)HIGHGAIN]->setEnabled(true);
break;
default:
LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL,
@ -126,7 +144,13 @@ void qTabSettings::Initialization() {
SLOT(SetDynamicRange(int)));
// Threshold
if (spinThreshold->isEnabled())
// m3
if (btnSetThreshold->isEnabled()) {
connect(btnSetThreshold, SIGNAL(clicked()), this,
SLOT(SetThresholdEnergies()));
}
// eiger
else if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
}
@ -169,7 +193,7 @@ void qTabSettings::SetSettings(int index) {
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
&qTabSettings::GetSettings)
// threshold
if (spinThreshold->isEnabled()) {
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
SetThresholdEnergy(spinThreshold->value());
}
}
@ -233,6 +257,23 @@ void qTabSettings::SetDynamicRange(int index) {
&qTabSettings::GetDynamicRange)
}
void qTabSettings::GetThresholdEnergies() {
LOG(logDEBUG) << "Getting theshold energies";
disconnect(btnSetThreshold, SIGNAL(clicked()), this,
SLOT(SetThresholdEnergies()));
try {
auto retval = det->getAllThresholdEnergy().tsquash(
"Inconsistent threhsold energies for all detectors.");
spinThreshold->setValue(retval[0]);
spinThreshold2->setValue(retval[1]);
spinThreshold3->setValue(retval[2]);
}
CATCH_DISPLAY("Could not get threshold energy.",
"qTabDataOutput::GetThresholdEnergies")
connect(btnSetThreshold, SIGNAL(clicked()), this,
SLOT(SetThresholdEnergies()));
}
void qTabSettings::GetThresholdEnergy() {
LOG(logDEBUG) << "Getting theshold energy";
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
@ -248,6 +289,23 @@ void qTabSettings::GetThresholdEnergy() {
SLOT(SetThresholdEnergy(int)));
}
void qTabSettings::SetThresholdEnergies() {
std::array<int, 3> eV = {spinThreshold->value(), spinThreshold2->value(),
spinThreshold3->value()};
slsDetectorDefs::detectorSettings sett =
static_cast<slsDetectorDefs::detectorSettings>(
comboSettings->currentIndex());
LOG(logINFO) << "Setting Threshold Energies to " << sls::ToString(eV)
<< " (eV)";
try {
det->setThresholdEnergy(eV, sett);
}
CATCH_DISPLAY("Could not get threshold energies.",
"qTabSettings::SetThresholdEnergies")
// set the right value anyway (due to tolerance)
GetThresholdEnergies();
}
void qTabSettings::SetThresholdEnergy(int index) {
LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try {
@ -270,8 +328,14 @@ void qTabSettings::Refresh() {
GetDynamicRange();
}
if (spinThreshold->isEnabled())
// m3
if (btnSetThreshold->isEnabled())
GetThresholdEnergies();
// eiger
else if (spinThreshold->isEnabled()) {
LOG(logINFOBLUE) << "calling it!";
GetThresholdEnergy();
}
LOG(logDEBUG) << "**Updated Settings Tab";
}

View File

@ -22,6 +22,7 @@ add_executable(ctbDetectorServer_virtual
include_directories(
../slsDetectorServer/include
../../slsSupportLib/include
../../slsDetectorSoftware/include/sls/
)
target_include_directories(ctbDetectorServer_virtual

View File

@ -2,10 +2,11 @@ current_dir = $(shell pwd)
main_inc = ../slsDetectorServer/include/
main_src = ../slsDetectorServer/src/
support_lib = ../../slsSupportLib/include/
det_lib = ../../slsDetectorSoftware/include/sls/
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lrt -pthread
PROGS = ctbDetectorServer
DESTDIR ?= bin

View File

@ -1395,7 +1395,7 @@ int Feb_Control_SetMaster(enum MASTERINDEX ind) {
int Feb_Control_SetQuad(int val) {
LOG(logINFO, ("Setting Quad to %d in Feb\n", val));
// only setting on the right feb if quad
return Feb_Control_SetTop(val == 0 ? TOP_HARDWARE : OW_TOP, 0, 1);
return Feb_Control_SetTop(val == 0 ? TOP_HARDWARE : OW_BOTTOM, 0, 1);
}
int Feb_Control_SetReadNLines(int value) {

View File

@ -0,0 +1,2 @@
top 1
master 1

Some files were not shown because too many files have changed in this diff Show More