Merge branch 'developer' into metadataGeometry

This commit is contained in:
Dhanya Thattil 2022-03-17 11:29:15 +01:00 committed by GitHub
commit b02dec8157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 147 additions and 50 deletions

View File

@ -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)
- missingpackets signed (negative => extra packets)
- 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

View File

@ -6,57 +6,57 @@ sls::Detector class. The tool needs the libclang bindings
to be installed.
When the Detector API is updated this file should be run
manually
manually.
"""
from clang import cindex
import subprocess
import argparse
import sys
import time
from pathlib import Path
from parse import system_include_paths, clang_format_version
required_version = 13
RED = '\033[91m'
REDC = '\033[91m'
GREENC = '\033[92m'
ENDC = '\033[0m'
if (ver := clang_format_version()) != required_version:
print(f'{RED}Clang format version {required_version} required, detected: {ver}. Bye!{ENDC}')
sys.exit(1)
def red(msg):
return f'{REDC}{msg}{ENDC}'
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/"
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 = []
ag = []
lines = []
ag2 = []
cn = []
def get_arguments(node):
@ -119,25 +119,67 @@ def visit(node):
lines.append(
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)
for child in node.get_children():
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)
print("Parsing functions in Detector.h - ", end = "", flush = True)
t0 = time.perf_counter()
#parse functions
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)
visit(tu.cursor)
print(green('OK'))
print(f'Parsing took {time.perf_counter()-t0:.3f}s')
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"
with open("../src/detector.cpp", "w") as f:
f.write(warning)
f.write(text)
print("Read detector_in.cpp - ", end = "")
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
subprocess.run(["clang-format", "../src/detector.cpp", "-i"])
# 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'])

View File

@ -1259,20 +1259,20 @@ int Beb_GetNextFrameNumber(uint64_t *retval, int tengigaEnable) {
else {
uint64_t left10g =
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST);
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST);
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST);
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST);
left10g = ((left10g << 32) | temp) >> 16;
++left10g; // increment for firmware
uint64_t right10g =
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST);
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST);
Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST);
temp = Beb_Read32(csp0base, UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST);
right10g = ((right10g << 32) | temp) >> 16;
Beb_close(fd, csp0base);
++right10g; // increment for firmware
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",
(long long int)left10g, (long long int)right10g));
*retval = (left10g > right10g)

View File

@ -800,6 +800,25 @@ void Detector::startDetectorReadout() {
void Detector::stopDetector(Positions 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 {
@ -1588,7 +1607,6 @@ std::vector<defs::gainMode> Detector::getGainModeList() const {
return std::vector<defs::gainMode>{
defs::DYNAMIC, defs::FORCE_SWITCH_G1, defs::FORCE_SWITCH_G2,
defs::FIX_G1, defs::FIX_G2, defs::FIX_G0};
break;
default:
throw RuntimeError("Gain mode is not implemented for this detector.");
}

View File

@ -2166,6 +2166,41 @@ TEST_CASE("nextframenumber", "[.cmd]") {
proxy.Call("nextframenumber", {"1"}, -1, PUT, oss);
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) {
det.setNextFrameNumber(prev_sfnum[i], {i});
}

View File

@ -5,11 +5,11 @@
#define APILIB 0x211125
#define APIRECEIVER 0x211124
#define APIGUI 0x211124
#define APICTB 0x220317
#define APIGOTTHARD 0x220317
#define APIGOTTHARD2 0x220317
#define APIJUNGFRAU 0x220317
#define APIMYTHEN3 0x220317
#define APIMOENCH 0x220317
#define APIEIGER 0x220317