mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
Merge branch 'developer' into metadataGeometry
This commit is contained in:
commit
b02dec8157
@ -48,6 +48,8 @@ This document describes the differences between v7.0.0 and v6.x.x
|
|||||||
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
||||||
- missingpackets signed (negative => extra packets)
|
- missingpackets signed (negative => extra packets)
|
||||||
- added geometry to metadata
|
- added geometry to metadata
|
||||||
|
- 10g eiger nextframenumber get fixed.
|
||||||
|
- stop, able to set nextframenumber to a consistent (max + 1) for all modules if different (eiger/ctb/jungfrau/moench)
|
||||||
|
|
||||||
|
|
||||||
2. Resolved Issues
|
2. Resolved Issues
|
||||||
|
@ -6,57 +6,57 @@ sls::Detector class. The tool needs the libclang bindings
|
|||||||
to be installed.
|
to be installed.
|
||||||
|
|
||||||
When the Detector API is updated this file should be run
|
When the Detector API is updated this file should be run
|
||||||
manually
|
manually.
|
||||||
"""
|
"""
|
||||||
from clang import cindex
|
from clang import cindex
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
from parse import system_include_paths, clang_format_version
|
from parse import system_include_paths, clang_format_version
|
||||||
|
|
||||||
required_version = 13
|
REDC = '\033[91m'
|
||||||
RED = '\033[91m'
|
GREENC = '\033[92m'
|
||||||
ENDC = '\033[0m'
|
ENDC = '\033[0m'
|
||||||
if (ver := clang_format_version()) != required_version:
|
def red(msg):
|
||||||
print(f'{RED}Clang format version {required_version} required, detected: {ver}. Bye!{ENDC}')
|
return f'{REDC}{msg}{ENDC}'
|
||||||
sys.exit(1)
|
|
||||||
|
def green(msg):
|
||||||
|
return f'{GREENC}{msg}{ENDC}'
|
||||||
|
|
||||||
|
def check_clang_format_version(required_version):
|
||||||
|
if (ver := clang_format_version()) != required_version:
|
||||||
|
msg = red(f'Clang format version {required_version} required, detected: {ver}. Bye!')
|
||||||
|
print(msg)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
msg = green(f'Found clang-format version {ver}')
|
||||||
|
print(msg)
|
||||||
|
|
||||||
|
def check_for_compile_commands_json(path):
|
||||||
|
# print(f"Looking for compile data base in: {path}")
|
||||||
|
compile_data_base_file = path/'compile_commands.json'
|
||||||
|
if not compile_data_base_file.exists():
|
||||||
|
msg = red(f"No compile_commands.json file found in {path}. Bye!")
|
||||||
|
print(msg)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
msg = green(f'Found: {compile_data_base_file}')
|
||||||
|
print(msg)
|
||||||
|
|
||||||
|
|
||||||
default_build_path = "/home/l_frojdh/sls/build/"
|
default_build_path = "/home/l_frojdh/sls/build/"
|
||||||
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
|
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument(
|
|
||||||
"-p",
|
|
||||||
"--build_path",
|
|
||||||
help="Path to the build database",
|
|
||||||
type=str,
|
|
||||||
default=default_build_path,
|
|
||||||
)
|
|
||||||
cargs = parser.parse_args()
|
|
||||||
|
|
||||||
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
|
|
||||||
index = cindex.Index.create()
|
|
||||||
args = db.getCompileCommands(fpath)
|
|
||||||
args = list(iter(args).__next__().arguments)[0:-1]
|
|
||||||
args = args + "-x c++ --std=c++11".split()
|
|
||||||
syspath = system_include_paths("clang++")
|
|
||||||
incargs = ["-I" + inc for inc in syspath]
|
|
||||||
args = args + incargs
|
|
||||||
|
|
||||||
|
|
||||||
tu = index.parse(fpath, args=args)
|
|
||||||
|
|
||||||
|
|
||||||
m = []
|
m = []
|
||||||
ag = []
|
ag = []
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
ag2 = []
|
ag2 = []
|
||||||
|
|
||||||
cn = []
|
cn = []
|
||||||
|
|
||||||
def get_arguments(node):
|
def get_arguments(node):
|
||||||
@ -119,25 +119,67 @@ def visit(node):
|
|||||||
lines.append(
|
lines.append(
|
||||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||||
)
|
)
|
||||||
print(f'&Detector::{child.spelling}{args})')
|
if cargs.verbose:
|
||||||
|
print(f'&Detector::{child.spelling}{args})')
|
||||||
cn.append(child)
|
cn.append(child)
|
||||||
for child in node.get_children():
|
for child in node.get_children():
|
||||||
visit(child)
|
visit(child)
|
||||||
|
|
||||||
|
|
||||||
visit(tu.cursor)
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"-p",
|
||||||
|
"--build_path",
|
||||||
|
help="Path to the build database",
|
||||||
|
type=Path,
|
||||||
|
default=default_build_path,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v",
|
||||||
|
"--verbose",
|
||||||
|
help="more output",
|
||||||
|
action='store_true',
|
||||||
|
)
|
||||||
|
cargs = parser.parse_args()
|
||||||
|
|
||||||
|
check_clang_format_version(12)
|
||||||
|
check_for_compile_commands_json(cargs.build_path)
|
||||||
|
|
||||||
with open("../src/detector_in.cpp") as f:
|
print("Parsing functions in Detector.h - ", end = "", flush = True)
|
||||||
data = f.read()
|
t0 = time.perf_counter()
|
||||||
s = "".join(lines)
|
#parse functions
|
||||||
s += ";"
|
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
|
||||||
text = data.replace("[[FUNCTIONS]]", s)
|
index = cindex.Index.create()
|
||||||
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
|
args = db.getCompileCommands(fpath)
|
||||||
with open("../src/detector.cpp", "w") as f:
|
args = list(iter(args).__next__().arguments)[0:-1]
|
||||||
f.write(warning)
|
args = args + "-x c++ --std=c++11".split()
|
||||||
f.write(text)
|
syspath = system_include_paths("clang++")
|
||||||
|
incargs = ["-I" + inc for inc in syspath]
|
||||||
|
args = args + incargs
|
||||||
|
tu = index.parse(fpath, args=args)
|
||||||
|
visit(tu.cursor)
|
||||||
|
print(green('OK'))
|
||||||
|
print(f'Parsing took {time.perf_counter()-t0:.3f}s')
|
||||||
|
|
||||||
# run clang format on the output
|
print("Read detector_in.cpp - ", end = "")
|
||||||
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
with open("../src/detector_in.cpp") as f:
|
||||||
|
data = f.read()
|
||||||
|
s = "".join(lines)
|
||||||
|
s += ";"
|
||||||
|
text = data.replace("[[FUNCTIONS]]", s)
|
||||||
|
warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
|
||||||
|
print(green("OK"))
|
||||||
|
print("Writing to detector.cpp - ", end = "")
|
||||||
|
with open("../src/detector.cpp", "w") as f:
|
||||||
|
f.write(warning)
|
||||||
|
f.write(text)
|
||||||
|
print(green('OK'))
|
||||||
|
|
||||||
|
# run clang format on the output
|
||||||
|
print('Running clang format on generated source -', end = "")
|
||||||
|
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
|
||||||
|
print(green(" OK"))
|
||||||
|
|
||||||
|
print("Changes since last commit:")
|
||||||
|
subprocess.run(['git', 'diff', '../src/detector.cpp'])
|
||||||
|
@ -1259,20 +1259,20 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
uint64_t left10g =
|
uint64_t left10g =
|
||||||
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST);
|
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST);
|
||||||
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST);
|
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST);
|
||||||
left10g = ((left10g << 32) | temp) >> 16;
|
left10g = ((left10g << 32) | temp) >> 16;
|
||||||
++left10g; // increment for firmware
|
++left10g; // increment for firmware
|
||||||
|
|
||||||
uint64_t right10g =
|
uint64_t right10g =
|
||||||
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST);
|
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST);
|
||||||
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST);
|
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST);
|
||||||
right10g = ((right10g << 32) | temp) >> 16;
|
right10g = ((right10g << 32) | temp) >> 16;
|
||||||
Beb_close(fd, csp0base);
|
Beb_close(fd, csp0base);
|
||||||
++right10g; // increment for firmware
|
++right10g; // increment for firmware
|
||||||
|
|
||||||
if (left10g != right10g) {
|
if (left10g != right10g) {
|
||||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left "
|
LOG(logERROR, ("Retrieved inconsistent frame numbers from 10g left "
|
||||||
"%llu and right %llu\n",
|
"%llu and right %llu\n",
|
||||||
(long long int)left10g, (long long int)right10g));
|
(long long int)left10g, (long long int)right10g));
|
||||||
*retval = (left10g > right10g)
|
*retval = (left10g > right10g)
|
||||||
|
Binary file not shown.
@ -800,6 +800,25 @@ void Detector::startDetectorReadout() {
|
|||||||
|
|
||||||
void Detector::stopDetector(Positions pos) {
|
void Detector::stopDetector(Positions pos) {
|
||||||
pimpl->Parallel(&Module::stopAcquisition, pos);
|
pimpl->Parallel(&Module::stopAcquisition, pos);
|
||||||
|
|
||||||
|
// validate consistent frame numbers
|
||||||
|
switch (getDetectorType().squash()) {
|
||||||
|
case defs::EIGER:
|
||||||
|
case defs::JUNGFRAU:
|
||||||
|
case defs::MOENCH:
|
||||||
|
case defs::CHIPTESTBOARD: {
|
||||||
|
auto res = getNextFrameNumber(pos);
|
||||||
|
if (!res.equal()) {
|
||||||
|
uint64_t maxVal = 0;
|
||||||
|
for (auto it : res) {
|
||||||
|
maxVal = std::max(maxVal, it);
|
||||||
|
}
|
||||||
|
setNextFrameNumber(maxVal + 1);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
||||||
@ -1588,7 +1607,6 @@ std::vector<defs::gainMode> Detector::getGainModeList() const {
|
|||||||
return std::vector<defs::gainMode>{
|
return std::vector<defs::gainMode>{
|
||||||
defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2,
|
defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2,
|
||||||
defs::FIX_G1, defs::FIX_G2, defs::FIX_G0};
|
defs::FIX_G1, defs::FIX_G2, defs::FIX_G0};
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw RuntimeError("Gain mode is not implemented for this detector.");
|
throw RuntimeError("Gain mode is not implemented for this detector.");
|
||||||
}
|
}
|
||||||
|
@ -2166,6 +2166,41 @@ TEST_CASE("nextframenumber", "[.cmd]") {
|
|||||||
proxy.Call("nextframenumber", {"1"}, -1, PUT, oss);
|
proxy.Call("nextframenumber", {"1"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "nextframenumber 1\n");
|
REQUIRE(oss.str() == "nextframenumber 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto prev_timing =
|
||||||
|
det.getTimingMode().tsquash("inconsistent timing mode in test");
|
||||||
|
auto prev_frames =
|
||||||
|
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
|
||||||
|
auto prev_exptime =
|
||||||
|
det.getExptime().tsquash("inconsistent exptime in test");
|
||||||
|
auto prev_period =
|
||||||
|
det.getPeriod().tsquash("inconsistent period in test");
|
||||||
|
det.setTimingMode(defs::AUTO_TIMING);
|
||||||
|
det.setNumberOfFrames(1);
|
||||||
|
det.setExptime(std::chrono::microseconds(200));
|
||||||
|
det.setPeriod(std::chrono::milliseconds(1));
|
||||||
|
det.startDetector();
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
auto currentfnum =
|
||||||
|
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
|
||||||
|
REQUIRE(currentfnum == 2);
|
||||||
|
if (det_type == defs::EIGER) {
|
||||||
|
auto prev_tengiga =
|
||||||
|
det.getTenGiga().tsquash("inconsistent ten giga enable");
|
||||||
|
det.setTenGiga(true);
|
||||||
|
det.setNextFrameNumber(1);
|
||||||
|
det.startDetector();
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
auto currentfnum = det.getNextFrameNumber().tsquash(
|
||||||
|
"inconsistent frame nr in test");
|
||||||
|
REQUIRE(currentfnum == 2);
|
||||||
|
det.setTenGiga(prev_tengiga);
|
||||||
|
}
|
||||||
|
|
||||||
|
det.setTimingMode(prev_timing);
|
||||||
|
det.setNumberOfFrames(prev_frames);
|
||||||
|
det.setExptime(prev_exptime);
|
||||||
|
det.setPeriod(prev_period);
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setNextFrameNumber(prev_sfnum[i], {i});
|
det.setNextFrameNumber(prev_sfnum[i], {i});
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
#define APILIB 0x211125
|
#define APILIB 0x211125
|
||||||
#define APIRECEIVER 0x211124
|
#define APIRECEIVER 0x211124
|
||||||
#define APIGUI 0x211124
|
#define APIGUI 0x211124
|
||||||
|
|
||||||
#define APICTB 0x220317
|
#define APICTB 0x220317
|
||||||
#define APIGOTTHARD 0x220317
|
#define APIGOTTHARD 0x220317
|
||||||
#define APIGOTTHARD2 0x220317
|
#define APIGOTTHARD2 0x220317
|
||||||
#define APIJUNGFRAU 0x220317
|
#define APIJUNGFRAU 0x220317
|
||||||
#define APIMYTHEN3 0x220317
|
#define APIMYTHEN3 0x220317
|
||||||
#define APIMOENCH 0x220317
|
#define APIMOENCH 0x220317
|
||||||
|
|
||||||
#define APIEIGER 0x220317
|
#define APIEIGER 0x220317
|
||||||
|
Loading…
x
Reference in New Issue
Block a user