mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 00:37:12 +02:00
Compare commits
146 Commits
2022.2.23.
...
dacnames
Author | SHA1 | Date | |
---|---|---|---|
13ec32c79a | |||
039e1fd829 | |||
fc41d4313f | |||
4bd4364a3a | |||
4b697dd9db | |||
6470277e43 | |||
2453390cc3 | |||
fa694dbc4c | |||
ea1222ac5b | |||
4cce1dbd7f | |||
1710177af4 | |||
5c79a1a1e8 | |||
83d76267f9 | |||
9ff43efdc5 | |||
21c21a423d | |||
e479b7d4be | |||
8f0398681e | |||
b112cf81c4 | |||
589124845a | |||
1e564a1b33 | |||
5fe10c19a1 | |||
de5c298d99 | |||
2a1f6dc544 | |||
fc21a6763d | |||
fd8e1b2ef7 | |||
0803f1bc1f | |||
9995b74217 | |||
2823451c9d | |||
0f4bcf3a9d | |||
74d55db3f0 | |||
2b35101b17 | |||
f538b8b10b | |||
fb012aa9e9 | |||
82bad7fec6 | |||
717922f380 | |||
3250dda7eb | |||
dffac3014e | |||
586149f3e7 | |||
088dd2c9f8 | |||
89395bd990 | |||
3144f40068 | |||
2fe24c108b | |||
bbfe3b278f | |||
c9fd8ba569 | |||
faa4f09a82 | |||
1ca2e61a85 | |||
7fa51e2a8e | |||
adbd2b853d | |||
0e6d92118f | |||
3796182eb1 | |||
570651a9f8 | |||
afbc414afe | |||
ca0aa7144c | |||
3e5b8840b4 | |||
f1da831e10 | |||
06281ccae9 | |||
509946d964 | |||
95f9da9d70 | |||
4a663e9e50 | |||
b02dec8157 | |||
c361b9517c | |||
78823760b3 | |||
d80006a024 | |||
561777dad6 | |||
c1895c4bc8 | |||
7b66466186 | |||
ef1c52ddc1 | |||
7bd4b9d9d9 | |||
39d3ee2b15 | |||
401467c700 | |||
c9769579e3 | |||
7663d4ef53 | |||
9c1bc262e5 | |||
c17914e0a1 | |||
7d91a15834 | |||
43c46841c1 | |||
fc6c6985e6 | |||
14c63810d6 | |||
6f0eebfbb8 | |||
c8bed64b91 | |||
e1762605e8 | |||
62fff64d87 | |||
7a39822813 | |||
de9e83fd61 | |||
80d31bbb10 | |||
45171d82a4 | |||
9e050060f3 | |||
ed5a1cdf1c | |||
34588356e8 | |||
b6d63a8381 | |||
dd8aebb0ab | |||
261ac78743 | |||
0437bd0584 | |||
46578d1447 | |||
5566cfd24f | |||
5869c25658 | |||
0b7c202f98 | |||
4db34effda | |||
5a5d4eadf1 | |||
b9016fad12 | |||
a1ee681135 | |||
219318a52e | |||
89edf58f41 | |||
ef3df36e55 | |||
6d2302bcc1 | |||
6695b10354 | |||
94adba72bf | |||
1063e8b929 | |||
c9abeace8f | |||
5bfdbf59a2 | |||
1cd347a54d | |||
76eb09eb04 | |||
a936cc26cc | |||
92beb3aa2a | |||
543eb7bb60 | |||
e4b80703ae | |||
2b2533f465 | |||
daa536077d | |||
aa7dee1011 | |||
54313af2f8 | |||
ab302a5160 | |||
7a607c6dd1 | |||
83ff4ab112 | |||
fb631187fa | |||
8770c9f6fb | |||
6e0d7b91bd | |||
6433704086 | |||
aea0efa1b6 | |||
8ffa2c1d65 | |||
47f9ab4027 | |||
0d521b64b6 | |||
0fb6c8b823 | |||
d2731c77a3 | |||
40a9dce7e0 | |||
2ba89b8a45 | |||
4cfb35c176 | |||
4107938921 | |||
8eb5c19187 | |||
a1888bf7c9 | |||
f2cca765be | |||
5b4cc53f8c | |||
251f07a9ae | |||
f228fde6f7 | |||
20f3fb19af | |||
cfe627d348 | |||
753387c34c |
18
RELEASE.txt
18
RELEASE.txt
@ -31,7 +31,7 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
- rx_arping
|
||||
- rx_threadsids max is now 9 (breaking api)
|
||||
- fixed datastream disabling for eiger. Its only available in 10g mode.
|
||||
- m3 server crash (vthrehsold)
|
||||
- m3 server crash (vthrehsold dac names were not provided)
|
||||
- allow vtrim to be interpolated for Eiger settings
|
||||
- m3 setThresholdEnergy and setAllThresholdEnergy was overwriting gaincaps with settings enum
|
||||
- can set localhost with virtual server with minimum configuration: (hostname localhost, rx_hostname localhost, udp_dstip auto)
|
||||
@ -39,10 +39,24 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
- current frame index points to listened frame index (not processed index)
|
||||
- when in discard partial frames or empty mode, the frame number doesnt increase by 1, it increases to that number (so its faster)
|
||||
- file write disabled by default
|
||||
- eiger 12 bit mode
|
||||
- start non blocking acquisition at modular level
|
||||
- connect master commands to api (allow set master for eiger)
|
||||
--ignore-config command line
|
||||
- command line argument 'master' mainly for virtual servers (also master/top for real eiger), only one virtual server for eiger, use command lines for master/top
|
||||
- stop servers also check for errors at startup( in case it was running with an older version)
|
||||
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
||||
- missingpackets signed (negative => extra packets)
|
||||
|
||||
- framescaught and frameindex now returns a vector for each port
|
||||
- progress looks at activated or enabled ports, so progress does not stagnate
|
||||
- (eiger) disable datastreaming also for virtual servers only for 10g
|
||||
- missing packets also takes care of disabled ports
|
||||
- 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)
|
||||
- ctb: can set names for all the dacs
|
||||
- fpga/kernel programming, checks if drive is a special file and not a normal file
|
||||
- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels)
|
||||
|
||||
2. Resolved Issues
|
||||
==================
|
||||
|
@ -6,49 +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
|
||||
|
||||
REDC = '\033[91m'
|
||||
GREENC = '\033[92m'
|
||||
ENDC = '\033[0m'
|
||||
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)
|
||||
|
||||
from parse import system_include_paths
|
||||
|
||||
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):
|
||||
@ -66,7 +74,7 @@ def get_arguments_with_default(node):
|
||||
args = []
|
||||
for arg in node.get_arguments():
|
||||
tokens = [t.spelling for t in arg.get_tokens()]
|
||||
print(tokens)
|
||||
# print(tokens)
|
||||
if '=' in tokens:
|
||||
if arg.type.spelling == "sls::Positions": #TODO! automate
|
||||
args.append("py::arg() = Positions{}")
|
||||
@ -111,33 +119,67 @@ def visit(node):
|
||||
lines.append(
|
||||
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
|
||||
)
|
||||
if cargs.verbose:
|
||||
print(f'&Detector::{child.spelling}{args})')
|
||||
cn.append(child)
|
||||
for child in node.get_children():
|
||||
visit(child)
|
||||
|
||||
# .def("setRxHostname",
|
||||
# (void (Detector::*)(const std::string &, Positions)) &
|
||||
# Detector::setRxHostname,
|
||||
# py::arg(), py::arg() = Positions{})
|
||||
# .def("setRxHostname",
|
||||
# (void (Detector::*)(const std::vector<std::string> &)) &
|
||||
# Detector::setRxHostname,
|
||||
# py::arg())
|
||||
|
||||
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)
|
||||
|
||||
visit(tu.cursor)
|
||||
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')
|
||||
|
||||
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'))
|
||||
|
||||
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)
|
||||
|
||||
# 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'])
|
||||
|
@ -5,6 +5,12 @@ import subprocess
|
||||
from subprocess import PIPE
|
||||
import os
|
||||
|
||||
def clang_format_version():
|
||||
p = subprocess.run(['clang-format', '--version'], capture_output = True)
|
||||
ver = p.stdout.decode().split()[2]
|
||||
major = int(ver.split('.')[0])
|
||||
return major
|
||||
|
||||
|
||||
def remove_comments(text):
|
||||
def replacer(match):
|
||||
|
@ -1,43 +1,45 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
from .detector import Detector
|
||||
from .detector import Detector, freeze
|
||||
from .utils import element_if_equal
|
||||
from .dacs import DetectorDacs
|
||||
from .dacs import DetectorDacs, NamedDacs
|
||||
import _slsdet
|
||||
dacIndex = _slsdet.slsDetectorDefs.dacIndex
|
||||
from .detector_property import DetectorProperty
|
||||
|
||||
class CtbDacs(DetectorDacs):
|
||||
"""
|
||||
Ctb dacs
|
||||
"""
|
||||
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
|
||||
('dac1', dacIndex(1), 0, 4000, 1200),
|
||||
('dac2', dacIndex(2), 0, 4000, 900),
|
||||
('dac3', dacIndex(3), 0, 4000, 1050),
|
||||
('dac4', dacIndex(4), 0, 4000, 1400),
|
||||
('dac5', dacIndex(5), 0, 4000, 655),
|
||||
('dac6', dacIndex(6), 0, 4000, 2000),
|
||||
('dac7', dacIndex(7), 0, 4000, 1400),
|
||||
('dac8', dacIndex(8), 0, 4000, 850),
|
||||
('dac9', dacIndex(9), 0, 4000, 2000),
|
||||
('dac10', dacIndex(10), 0, 4000, 2294),
|
||||
('dac11', dacIndex(11), 0, 4000, 983),
|
||||
('dac12', dacIndex(12), 0, 4000, 1475),
|
||||
('dac13', dacIndex(13), 0, 4000, 1200),
|
||||
('dac14', dacIndex(14), 0, 4000, 1600),
|
||||
('dac15', dacIndex(15), 0, 4000, 1455),
|
||||
('dac16', dacIndex(16), 0, 4000, 0),
|
||||
('dac17', dacIndex(17), 0, 4000, 1000),
|
||||
]
|
||||
_dacnames = [_d[0] for _d in _dacs]
|
||||
# class CtbDacs(DetectorDacs):
|
||||
# """
|
||||
# Ctb dacs
|
||||
# """
|
||||
# _dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
|
||||
# ('dac1', dacIndex(1), 0, 4000, 1200),
|
||||
# ('dac2', dacIndex(2), 0, 4000, 900),
|
||||
# ('dac3', dacIndex(3), 0, 4000, 1050),
|
||||
# ('dac4', dacIndex(4), 0, 4000, 1400),
|
||||
# ('dac5', dacIndex(5), 0, 4000, 655),
|
||||
# ('dac6', dacIndex(6), 0, 4000, 2000),
|
||||
# ('dac7', dacIndex(7), 0, 4000, 1400),
|
||||
# ('dac8', dacIndex(8), 0, 4000, 850),
|
||||
# ('dac9', dacIndex(9), 0, 4000, 2000),
|
||||
# ('dac10', dacIndex(10), 0, 4000, 2294),
|
||||
# ('dac11', dacIndex(11), 0, 4000, 983),
|
||||
# ('dac12', dacIndex(12), 0, 4000, 1475),
|
||||
# ('dac13', dacIndex(13), 0, 4000, 1200),
|
||||
# ('dac14', dacIndex(14), 0, 4000, 1600),
|
||||
# ('dac15', dacIndex(15), 0, 4000, 1455),
|
||||
# ('dac16', dacIndex(16), 0, 4000, 0),
|
||||
# ('dac17', dacIndex(17), 0, 4000, 1000),
|
||||
# ]
|
||||
# _dacnames = [_d[0] for _d in _dacs]
|
||||
|
||||
from .utils import element
|
||||
@freeze
|
||||
class Ctb(Detector):
|
||||
def __init__(self, id = 0):
|
||||
super().__init__(id)
|
||||
self._frozen = False
|
||||
self._dacs = CtbDacs(self)
|
||||
# self._dacs = CtbDacs(self)
|
||||
self._dacs = NamedDacs(self)
|
||||
|
||||
@property
|
||||
def dacs(self):
|
||||
|
@ -36,6 +36,79 @@ class Dac(DetectorProperty):
|
||||
dacstr = ''.join([f'{item:5d}' for item in self.get()])
|
||||
return f'{self.__name__:15s}:{dacstr}'
|
||||
|
||||
class NamedDacs:
|
||||
"""
|
||||
New implementation of the detector dacs. Used at the momen for
|
||||
Ctb but should replace the old one for all detectors
|
||||
"""
|
||||
_frozen = False
|
||||
_direct_access = ['_detector', '_current', '_dacnames']
|
||||
def __init__(self, detector):
|
||||
self._detector = detector
|
||||
self._current = 0
|
||||
|
||||
self._dacnames = [n.replace(" ", "") for n in detector.getDacNames()]
|
||||
# # Populate the dacs
|
||||
for i,name in enumerate(self._dacnames):
|
||||
#name, enum, low, high, default, detector
|
||||
setattr(self, name, Dac(name, dacIndex(i), 0, 4000, 1000, detector))
|
||||
|
||||
self._frozen = True
|
||||
|
||||
# def __getattr__(self, name):
|
||||
# return self.__getattribute__('_' + name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if not self._frozen:
|
||||
#durining init we need to be able to set up the class
|
||||
super().__setattr__(name, value)
|
||||
else:
|
||||
#Later we restrict us to manipulate dacs and a few fields
|
||||
if name in self._direct_access:
|
||||
super().__setattr__(name, value)
|
||||
elif name in self._dacnames:
|
||||
return self.__getattribute__(name).__setitem__(slice(None, None, None), value)
|
||||
else:
|
||||
raise AttributeError(f'Dac not found: {name}')
|
||||
|
||||
def __next__(self):
|
||||
if self._current >= len(self._dacnames):
|
||||
self._current = 0
|
||||
raise StopIteration
|
||||
else:
|
||||
self._current += 1
|
||||
return self.__getattribute__(self._dacnames[self._current-1])
|
||||
# return self.__getattr__(self._dacnames[self._current-1])
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __repr__(self):
|
||||
r_str = ['========== DACS =========']
|
||||
r_str += [repr(dac) for dac in self]
|
||||
return '\n'.join(r_str)
|
||||
def get_asarray(self):
|
||||
"""
|
||||
Read the dacs into a numpy array with dimensions [ndacs, nmodules]
|
||||
"""
|
||||
dac_array = np.zeros((len(self._dacnames), len(self._detector)))
|
||||
for i, _d in enumerate(self):
|
||||
dac_array[i,:] = _d[:]
|
||||
return dac_array
|
||||
|
||||
def to_array(self):
|
||||
return self.get_asarray()
|
||||
|
||||
def set_from_array(self, dac_array):
|
||||
"""
|
||||
Set the dacs from an numpy array with dac values. [ndacs, nmodules]
|
||||
"""
|
||||
dac_array = dac_array.astype(np.int)
|
||||
for i, _d in enumerate(self):
|
||||
_d[:] = dac_array[i]
|
||||
|
||||
def from_array(self, dac_array):
|
||||
self.set_from_array(dac_array)
|
||||
|
||||
class DetectorDacs:
|
||||
_dacs = []
|
||||
@ -50,7 +123,7 @@ class DetectorDacs:
|
||||
# Index to support iteration
|
||||
self._current = 0
|
||||
|
||||
# Populate the dacs
|
||||
# Name the attributes?
|
||||
for _d in self._dacs:
|
||||
setattr(self, '_'+_d[0], Dac(*_d, detector))
|
||||
|
||||
@ -59,7 +132,10 @@ class DetectorDacs:
|
||||
def __getattr__(self, name):
|
||||
return self.__getattribute__('_' + name)
|
||||
|
||||
|
||||
@property
|
||||
def dacnames(self):
|
||||
return [_d[0] for _d in _dacs]
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if name in self._dacnames:
|
||||
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
|
||||
|
@ -287,7 +287,7 @@ class Detector(CppDetectorApi):
|
||||
|
||||
Note
|
||||
-----
|
||||
[Eiger] Options: 4, 8, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
|
||||
[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets clkdivider to 2 (quarter speed), else to 0 (full speed)\n
|
||||
[Mythen3] Options: 8, 16, 32 \n
|
||||
[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
|
||||
"""
|
||||
@ -599,7 +599,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_framescaught(self):
|
||||
"""Number of frames caught by receiver."""
|
||||
"""Number of frames caught by each port in receiver."""
|
||||
return self.getFramesCaught()
|
||||
|
||||
@property
|
||||
@ -1474,6 +1474,19 @@ class Detector(CppDetectorApi):
|
||||
def trimval(self, value):
|
||||
ut.set_using_dict(self.setAllTrimbits, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def master(self):
|
||||
"""
|
||||
[Eiger] Sets half module to master and others to slaves.\n
|
||||
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master.
|
||||
"""
|
||||
return self.getMaster()
|
||||
|
||||
@master.setter
|
||||
def master(self, value):
|
||||
ut.set_using_dict(self.setMaster, value)
|
||||
|
||||
@property
|
||||
@element
|
||||
def lock(self):
|
||||
@ -1558,8 +1571,16 @@ class Detector(CppDetectorApi):
|
||||
|
||||
@property
|
||||
def daclist(self):
|
||||
"""Gets the list of enums for every dac for this detector."""
|
||||
return self.getDacList()
|
||||
"""
|
||||
List of enums for every dac for this detector.
|
||||
:setter: Only implemented for Chiptestboard
|
||||
|
||||
"""
|
||||
return self.getDacNames()
|
||||
|
||||
@daclist.setter
|
||||
def daclist(self, value):
|
||||
self.setDacNames(value)
|
||||
|
||||
@property
|
||||
def dacvalues(self):
|
||||
@ -1905,7 +1926,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_frameindex(self):
|
||||
"""Current frame index received in receiver during acquisition."""
|
||||
"""Current frame index received for each port in receiver during acquisition."""
|
||||
return self.getRxCurrentFrameIndex()
|
||||
|
||||
@property
|
||||
@ -2126,6 +2147,21 @@ class Detector(CppDetectorApi):
|
||||
"""
|
||||
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
||||
|
||||
@property
|
||||
@element
|
||||
def top(self):
|
||||
"""[Eiger] Sets half module to top (1), else bottom.
|
||||
|
||||
Note
|
||||
-----
|
||||
Advanced Function!
|
||||
"""
|
||||
return self.getTop()
|
||||
|
||||
@top.setter
|
||||
def top(self, value):
|
||||
ut.set_using_dict(self.setTop, value)
|
||||
|
||||
"""
|
||||
------------------<<<Jungfrau specific>>>-------------------------
|
||||
"""
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/* WARINING This file is auto generated any edits might be overwritten without
|
||||
* warning */
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include <pybind11/chrono.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
@ -173,6 +173,12 @@ void init_det(py::module &m) {
|
||||
.def("setFlipRows",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getMaster",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getMaster,
|
||||
py::arg() = Positions{})
|
||||
.def("setMaster", (void (Detector::*)(bool, int)) & Detector::setMaster,
|
||||
py::arg(), py::arg())
|
||||
.def("isVirtualDetectorServer",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::isVirtualDetectorServer,
|
||||
@ -487,13 +493,17 @@ void init_det(py::module &m) {
|
||||
Detector::getReceiverStatus,
|
||||
py::arg() = Positions{})
|
||||
.def("getFramesCaught",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFramesCaught,
|
||||
py::arg() = Positions{})
|
||||
.def("getNumMissingPackets",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{})
|
||||
.def("getNextFrameNumber",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNextFrameNumber,
|
||||
@ -766,7 +776,7 @@ void init_det(py::module &m) {
|
||||
Detector::getRxLastClientIP,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxThreadIds",
|
||||
(Result<std::array<pid_t, 8>>(Detector::*)(sls::Positions) const) &
|
||||
(Result<std::array<pid_t, 9>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxThreadIds,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxArping",
|
||||
@ -1005,6 +1015,13 @@ void init_det(py::module &m) {
|
||||
sls::Positions)) &
|
||||
Detector::setDataStream,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("getTop",
|
||||
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getTop,
|
||||
py::arg() = Positions{})
|
||||
.def("setTop",
|
||||
(void (Detector::*)(bool, sls::Positions)) & Detector::setTop,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("getChipVersion",
|
||||
(Result<double>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getChipVersion,
|
||||
@ -1263,10 +1280,6 @@ 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("getChipStatusRegister",
|
||||
(Result<int>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getChipStatusRegister,
|
||||
@ -1414,6 +1427,19 @@ void init_det(py::module &m) {
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
Detector::setLEDEnable,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("setDacNames",
|
||||
(void (Detector::*)(const std::vector<std::string>)) &
|
||||
Detector::setDacNames,
|
||||
py::arg())
|
||||
.def("getDacNames", (std::vector<std::string>(Detector::*)() const) &
|
||||
Detector::getDacNames)
|
||||
.def("getDacIndex",
|
||||
(defs::dacIndex(Detector::*)(const std::string &)) &
|
||||
Detector::getDacIndex,
|
||||
py::arg())
|
||||
.def("getDacName",
|
||||
(std::string(Detector::*)(defs::dacIndex)) & Detector::getDacName,
|
||||
py::arg())
|
||||
.def("setPattern",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
Detector::setPattern,
|
||||
@ -1518,9 +1544,10 @@ void init_det(py::module &m) {
|
||||
Detector::setAdditionalJsonParameter,
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("programFPGA",
|
||||
(void (Detector::*)(const std::string &, sls::Positions)) &
|
||||
(void (Detector::*)(const std::string &, const bool,
|
||||
sls::Positions)) &
|
||||
Detector::programFPGA,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
py::arg(), py::arg(), py::arg() = Positions{})
|
||||
.def("resetFPGA",
|
||||
(void (Detector::*)(sls::Positions)) & Detector::resetFPGA,
|
||||
py::arg() = Positions{})
|
||||
@ -1555,7 +1582,7 @@ void init_det(py::module &m) {
|
||||
Detector::getUpdateMode,
|
||||
py::arg() = Positions{})
|
||||
.def("setUpdateMode",
|
||||
(void (Detector::*)(bool, sls::Positions)) &
|
||||
(void (Detector::*)(const bool, sls::Positions)) &
|
||||
Detector::setUpdateMode,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("readRegister",
|
||||
@ -1647,9 +1674,5 @@ void init_det(py::module &m) {
|
||||
Detector::getMeasurementTime,
|
||||
py::arg() = Positions{})
|
||||
.def("getUserDetails",
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails)
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{});
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails);
|
||||
}
|
||||
|
@ -429,23 +429,28 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
for (ic = -(clusterSize / 2); ic < (clusterSize / 2) + 1;
|
||||
ic++) {
|
||||
|
||||
if ((iy + ir) >= iy && (iy + ir) < ny &&
|
||||
(ix + ic) >= ix && (ix + ic) < nx) {
|
||||
if ((iy + ir) >= 0 && (iy + ir) < ny &&
|
||||
(ix + ic) >= 0 && (ix + ic) < nx) {
|
||||
|
||||
|
||||
if ((iy + ir) >= iy && (ix + ic) >= ix ) {
|
||||
val[(iy + ir) * nx + ix + ic] =
|
||||
subtractPedestal(data, ix + ic, iy + ir, cm);
|
||||
v = &(val[(iy + ir) * nx + ix + ic]);
|
||||
tot += *v;
|
||||
if (ir <= 0 && ic <= 0)
|
||||
bl += *v;
|
||||
if (ir <= 0 && ic >= 0)
|
||||
br += *v;
|
||||
if (ir >= 0 && ic <= 0)
|
||||
tl += *v;
|
||||
if (ir >= 0 && ic >= 0)
|
||||
tr += *v;
|
||||
if (*v > max) {
|
||||
max = *v;
|
||||
}
|
||||
|
||||
}
|
||||
v = &(val[(iy + ir) * nx + ix + ic]);
|
||||
tot += *v;
|
||||
if (ir <= 0 && ic <= 0)
|
||||
bl += *v;
|
||||
if (ir <= 0 && ic >= 0)
|
||||
br += *v;
|
||||
if (ir >= 0 && ic <= 0)
|
||||
tl += *v;
|
||||
if (ir >= 0 && ic >= 0)
|
||||
tr += *v;
|
||||
if (*v > max) //{
|
||||
max = *v;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -513,12 +518,19 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
|
||||
for (ic = -(clusterSize / 2);
|
||||
ic < (clusterSize / 2) + 1; ic++) {
|
||||
if ((iy + ir) >= 0 && (iy + ir) < ny &&
|
||||
(ix + ic) >= 0 && (ix + ic) < nx)
|
||||
(clusters + nph)
|
||||
(ix + ic) >= 0 && (ix + ic) < nx) {
|
||||
(clusters + nph)
|
||||
->set_data(val[(iy + ir) * nx + ix + ic],
|
||||
ic, ir);
|
||||
if (val[(iy + ir) * nx + ix + ic]>max)
|
||||
good=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (good==0) {
|
||||
(clusters + nph)->print();
|
||||
cout << max << " " << val[iy * nx + ix] << endl;
|
||||
}
|
||||
good = 1;
|
||||
if (eMin > 0 && tot < eMin)
|
||||
good = 0;
|
||||
|
@ -216,14 +216,18 @@ class single_photon_hit {
|
||||
|
||||
// int ix, iy;
|
||||
|
||||
printf("***************\n");
|
||||
printf("** %d %d **\n",x,y);
|
||||
for (int iy = 0; iy < dy; iy++) {
|
||||
for (int ix = 0; ix < dx; ix++) {
|
||||
printf("%d \t", data[ix + iy * dx]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("***************\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative
|
||||
coordinates where the center of the cluster is (0,0) \param v value to be
|
||||
|
@ -97,6 +97,11 @@
|
||||
<string>65535</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4095</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
|
@ -91,8 +91,10 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void Update2dPlot();
|
||||
void Update1dXYRange();
|
||||
void Update2dXYRange();
|
||||
void rearrangeGotthard25data(double *data);
|
||||
|
||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||
static const int NUM_GOTTHARD25_CHANS = 1280;
|
||||
sls::Detector *det;
|
||||
slsDetectorDefs::detectorType detType;
|
||||
|
||||
@ -164,4 +166,5 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
uint32_t pixelMask{0};
|
||||
uint32_t gainMask{0};
|
||||
int gainOffset{0};
|
||||
bool gotthard25;
|
||||
};
|
||||
|
@ -69,5 +69,11 @@ class qTabSettings : public QWidget, private Ui::TabSettingsObject {
|
||||
enum { DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2, FIX_G1, FIX_G2, FIX_G0 };
|
||||
bool isVisibleFixG0{false};
|
||||
|
||||
enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
|
||||
enum {
|
||||
DYNAMICRANGE_32,
|
||||
DYNAMICRANGE_16,
|
||||
DYNAMICRANGE_12,
|
||||
DYNAMICRANGE_8,
|
||||
DYNAMICRANGE_4
|
||||
};
|
||||
};
|
||||
|
@ -80,6 +80,10 @@ void qDrawPlot::SetupWidgetWindow() {
|
||||
fileSaveName = "Image";
|
||||
}
|
||||
|
||||
gotthard25 = ((detType == slsDetectorDefs::GOTTHARD2 ||
|
||||
detType == slsDetectorDefs::GOTTHARD) &&
|
||||
det->size() == 2);
|
||||
|
||||
SetupPlots();
|
||||
SetDataCallBack(true);
|
||||
det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),
|
||||
@ -807,6 +811,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
isGainDataExtracted = false;
|
||||
}
|
||||
|
||||
// gotthard25um rearranging
|
||||
if (gotthard25) {
|
||||
rearrangeGotthard25data(rawData);
|
||||
}
|
||||
|
||||
// title and frame index titles
|
||||
plotTitle =
|
||||
plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1);
|
||||
@ -1064,6 +1073,8 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
||||
// mythen3 / gotthard2 debugging
|
||||
int discardBits = numDiscardBits;
|
||||
|
||||
uint16_t temp = 0;
|
||||
uint8_t *src = (uint8_t *)source;
|
||||
switch (dr) {
|
||||
|
||||
case 4:
|
||||
@ -1083,6 +1094,19 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
||||
}
|
||||
break;
|
||||
|
||||
case 12:
|
||||
for (ichan = 0; ichan < size; ++ichan) {
|
||||
temp = (*src++ & 0xFF);
|
||||
temp |= ((*src & 0xF) << 8u);
|
||||
dest[ichan] = (double)temp;
|
||||
++ichan;
|
||||
|
||||
temp = ((*src++ & 0xF0) >> 4u);
|
||||
temp |= ((*src++ & 0xFF) << 4u);
|
||||
dest[ichan] = (double)temp;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
if (detType == slsDetectorDefs::JUNGFRAU ||
|
||||
detType == slsDetectorDefs::GOTTHARD2) {
|
||||
@ -1130,6 +1154,18 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
||||
}
|
||||
}
|
||||
|
||||
void qDrawPlot::rearrangeGotthard25data(double *data) {
|
||||
const int nChans = NUM_GOTTHARD25_CHANS;
|
||||
double temp[nChans * 2] = {0.0};
|
||||
for (int i = 0; i != nChans; ++i) {
|
||||
// master module
|
||||
temp[i * 2] = data[i];
|
||||
// slave module
|
||||
temp[i * 2 + 1] = data[nChans + i];
|
||||
}
|
||||
memcpy(data, temp, nChans * 2 * sizeof(double));
|
||||
}
|
||||
|
||||
void qDrawPlot::UpdatePlot() {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
LOG(logDEBUG) << "Update Plot";
|
||||
|
@ -60,13 +60,19 @@ void qTabSettings::SetupWidgetWindow() {
|
||||
QStandardItemModel *model =
|
||||
qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
|
||||
if (model) {
|
||||
QModelIndex index;
|
||||
QStandardItem *item;
|
||||
index =
|
||||
model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(),
|
||||
comboDynamicRange->rootModelIndex());
|
||||
item = model->itemFromIndex(index);
|
||||
item->setEnabled(false);
|
||||
int dr = DYNAMICRANGE_4;
|
||||
for (int i = 0; i != 2; ++i) {
|
||||
// disable dr 4
|
||||
QModelIndex index =
|
||||
model->index(dr, comboDynamicRange->modelColumn(),
|
||||
comboDynamicRange->rootModelIndex());
|
||||
item = model->itemFromIndex(index);
|
||||
item->setEnabled(false);
|
||||
|
||||
// disable dr 12
|
||||
dr = DYNAMICRANGE_12;
|
||||
}
|
||||
}
|
||||
} else if (detType == slsDetectorDefs::EIGER) {
|
||||
lblDynamicRange->setEnabled(true);
|
||||
@ -305,6 +311,9 @@ void qTabSettings::GetDynamicRange() {
|
||||
case 16:
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_16);
|
||||
break;
|
||||
case 12:
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_12);
|
||||
break;
|
||||
case 8:
|
||||
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_8);
|
||||
break;
|
||||
@ -333,6 +342,9 @@ void qTabSettings::SetDynamicRange(int index) {
|
||||
case DYNAMICRANGE_16:
|
||||
det->setDynamicRange(16);
|
||||
break;
|
||||
case DYNAMICRANGE_12:
|
||||
det->setDynamicRange(12);
|
||||
break;
|
||||
case DYNAMICRANGE_8:
|
||||
det->setDynamicRange(8);
|
||||
break;
|
||||
|
Binary file not shown.
@ -433,16 +433,21 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -702,8 +707,16 @@ void resetPeripheral() {
|
||||
}
|
||||
|
||||
/* set parameters - dr, adcenablemask */
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr == 16)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
||||
int getDynamicRange(int *retval) {
|
||||
*retval = DYNAMIC_RANGE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setADCEnableMask(uint32_t mask) {
|
||||
if (mask == 0u) {
|
||||
|
@ -177,7 +177,7 @@ void Beb_AdjustIPChecksum(struct udp_header_type *ip) {
|
||||
ip->ip_header_checksum[1] = ip_checksum & 0xff;
|
||||
}
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
int Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
*top = 0;
|
||||
*master = 0;
|
||||
// mapping new memory to read master top module configuration
|
||||
@ -187,6 +187,7 @@ void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
// read data
|
||||
ret = Beb_Read32(csp0base, BEB_CONFIG_RD_OFST);
|
||||
@ -202,6 +203,7 @@ void Beb_GetModuleConfiguration(int *master, int *top, int *normal) {
|
||||
// close file pointer
|
||||
Beb_close(fd, csp0base);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay) {
|
||||
@ -862,11 +864,17 @@ void Beb_ResetFrameNumber() {
|
||||
}
|
||||
|
||||
int Beb_SetUpTransferParameters(short the_bit_mode) {
|
||||
if (the_bit_mode != 4 && the_bit_mode != 8 && the_bit_mode != 16 &&
|
||||
the_bit_mode != 32)
|
||||
switch (the_bit_mode) {
|
||||
case 4:
|
||||
case 8:
|
||||
case 12:
|
||||
case 16:
|
||||
case 32:
|
||||
Beb_bit_mode = the_bit_mode;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
Beb_bit_mode = the_bit_mode;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int Beb_StopAcquisition() {
|
||||
@ -1251,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)
|
||||
|
@ -15,7 +15,7 @@ int Beb_SetHeaderData(uint64_t src_mac, uint32_t src_ip, uint16_t src_port,
|
||||
uint64_t dst_mac, uint32_t dst_ip, uint16_t dst_port);
|
||||
void Beb_AdjustIPChecksum(struct udp_header_type *ip);
|
||||
|
||||
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||
int Beb_GetModuleConfiguration(int *master, int *top, int *normal);
|
||||
int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
|
||||
|
||||
void Beb_SetTopVariable(int val);
|
||||
|
@ -16,91 +16,31 @@ include_directories(
|
||||
../../slsSupportLib/include
|
||||
)
|
||||
|
||||
add_executable(eigerDetectorServerMaster_virtual
|
||||
add_executable(eigerDetectorServer_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerMaster_virtual
|
||||
target_include_directories(eigerDetectorServer_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerMaster_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_MASTER
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerMaster_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerMaster_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerMaster_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveTop_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
PUBLIC VIRTUAL_TOP
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveTop_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlaveTop_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
add_executable(eigerDetectorServerSlaveBottom_virtual
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlaveBottom_virtual
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlaveBottom_virtual
|
||||
target_compile_definitions(eigerDetectorServer_virtual
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL #VIRTUAL_9M
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlaveBottom_virtual
|
||||
target_link_libraries(eigerDetectorServer_virtual
|
||||
PUBLIC pthread rt slsProjectCSettings
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
|
||||
set_target_properties(eigerDetectorServer_virtual PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlaveBottom_virtual
|
||||
install(TARGETS eigerDetectorServer_virtual
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
|
||||
configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY)
|
||||
configure_file(detid_eiger.txt ${CMAKE_BINARY_DIR}/bin/detid_eiger.txt COPYONLY)
|
||||
|
@ -18,7 +18,7 @@
|
||||
const unsigned int Feb_Control_leftAddress = 0x100;
|
||||
const unsigned int Feb_Control_rightAddress = 0x200;
|
||||
|
||||
int Feb_Control_master = 0;
|
||||
int Feb_Control_master = -1;
|
||||
int Feb_Control_normal = 0;
|
||||
int Feb_Control_activated = 1;
|
||||
|
||||
@ -50,17 +50,16 @@ double ratemax = -1;
|
||||
// setup
|
||||
void Feb_Control_activate(int activate) { Feb_Control_activated = activate; }
|
||||
|
||||
void Feb_Control_FebControl() {
|
||||
Feb_Control_staticBits = Feb_Control_acquireNReadoutMode =
|
||||
Feb_Control_triggerMode = Feb_Control_externalEnableMode =
|
||||
Feb_Control_subFrameMode = 0;
|
||||
int Feb_Control_FebControl(int normal) {
|
||||
Feb_Control_staticBits = 0;
|
||||
Feb_Control_acquireNReadoutMode = 0;
|
||||
Feb_Control_triggerMode = 0;
|
||||
Feb_Control_externalEnableMode = 0;
|
||||
Feb_Control_subFrameMode = 0;
|
||||
Feb_Control_trimbit_size = 263680;
|
||||
Feb_Control_last_downloaded_trimbits =
|
||||
malloc(Feb_Control_trimbit_size * sizeof(int));
|
||||
}
|
||||
|
||||
int Feb_Control_Init(int master, int normal) {
|
||||
Feb_Control_master = master;
|
||||
Feb_Control_normal = normal;
|
||||
Feb_Interface_SetAddress(Feb_Control_rightAddress, Feb_Control_leftAddress);
|
||||
if (Feb_Control_activated) {
|
||||
@ -931,7 +930,10 @@ unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec) {
|
||||
|
||||
int Feb_Control_PrepareForAcquisition() {
|
||||
LOG(logINFOBLUE, ("Preparing for Acquisition\n"));
|
||||
Feb_Control_PrintAcquisitionSetup();
|
||||
if (!Feb_Control_PrintAcquisitionSetup()) {
|
||||
LOG(logERROR, ("Could not prepare acquisition\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Feb_Control_Reset() == STATUS_ERROR) {
|
||||
LOG(logERROR, ("Trouble reseting daq or data stream\n"));
|
||||
@ -988,20 +990,26 @@ int Feb_Control_PrepareForAcquisition() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Feb_Control_PrintAcquisitionSetup() {
|
||||
int Feb_Control_PrintAcquisitionSetup() {
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
struct tm *timeinfo = localtime(&rawtime);
|
||||
LOG(logINFO,
|
||||
("Starting an exposure: (%s)"
|
||||
"\t Dynamic range nbits: %d\n"
|
||||
"\t Trigger mode: 0x%x\n"
|
||||
"\t Number of exposures: %d\n"
|
||||
"\t Exsposure time (if used): %f seconds.\n"
|
||||
"\t Exsposure period (if used): %f seconds.\n\n",
|
||||
asctime(timeinfo), Feb_Control_GetDynamicRange(),
|
||||
Feb_Control_triggerMode, Feb_Control_GetNExposures(),
|
||||
Feb_Control_exposure_time_in_sec, Feb_Control_exposure_period_in_sec));
|
||||
int dr = 0;
|
||||
if (!Feb_Control_GetDynamicRange(&dr)) {
|
||||
LOG(logERROR, ("Could not print acquisition set up\n"));
|
||||
return 0;
|
||||
}
|
||||
LOG(logINFO, ("Starting an exposure: (%s)"
|
||||
"\t Dynamic range nbits: %d\n"
|
||||
"\t Trigger mode: 0x%x\n"
|
||||
"\t Number of exposures: %d\n"
|
||||
"\t Exsposure time (if used): %f seconds.\n"
|
||||
"\t Exsposure period (if used): %f seconds.\n\n",
|
||||
asctime(timeinfo), dr, Feb_Control_triggerMode,
|
||||
Feb_Control_GetNExposures(), Feb_Control_exposure_time_in_sec,
|
||||
Feb_Control_exposure_period_in_sec));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_StartAcquisition() {
|
||||
@ -1169,49 +1177,106 @@ int Feb_Control_SoftwareTrigger(int block) {
|
||||
}
|
||||
|
||||
// parameters
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo) {
|
||||
int Feb_Control_SetDynamicRange(int dr) {
|
||||
static unsigned int everything_but_bit_mode = DAQ_STATIC_BIT_PROGRAM |
|
||||
DAQ_STATIC_BIT_CHIP_TEST |
|
||||
DAQ_STATIC_BIT_ROTEST;
|
||||
if (four_eight_sixteen_or_thirtytwo == 4) {
|
||||
switch (dr) {
|
||||
case 4:
|
||||
Feb_Control_staticBits =
|
||||
DAQ_STATIC_BIT_M4 |
|
||||
(Feb_Control_staticBits &
|
||||
everything_but_bit_mode); // leave test bits in currernt state
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 8) {
|
||||
break;
|
||||
case 8:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M8 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 16) {
|
||||
break;
|
||||
case 12:
|
||||
case 16:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode &= ~DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else if (four_eight_sixteen_or_thirtytwo == 32) {
|
||||
|
||||
// disable 16 bit conversion if 12 bit mode (enable if 16 bit)
|
||||
if (!Feb_Control_Disable16bitConversion(dr == 12))
|
||||
return 0;
|
||||
break;
|
||||
case 32:
|
||||
Feb_Control_staticBits = DAQ_STATIC_BIT_M12 | (Feb_Control_staticBits &
|
||||
everything_but_bit_mode);
|
||||
Feb_Control_subFrameMode |= DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING;
|
||||
} else {
|
||||
LOG(logERROR, ("dynamic range (%d) not valid, not setting bit mode.\n",
|
||||
four_eight_sixteen_or_thirtytwo));
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR,
|
||||
("dynamic range (%d) not valid, not setting bit mode.\n", dr));
|
||||
LOG(logINFO, ("Set dynamic range int must equal 4,8 16, or 32.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG(logINFO,
|
||||
("Dynamic range set to %d\n", four_eight_sixteen_or_thirtytwo));
|
||||
LOG(logINFO, ("Dynamic range set to %d\n", dr));
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int Feb_Control_GetDynamicRange() {
|
||||
if (Feb_Control_subFrameMode & DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING)
|
||||
return 32;
|
||||
else if (DAQ_STATIC_BIT_M4 & Feb_Control_staticBits)
|
||||
return 4;
|
||||
else if (DAQ_STATIC_BIT_M8 & Feb_Control_staticBits)
|
||||
return 8;
|
||||
int Feb_Control_GetDynamicRange(int *retval) {
|
||||
if (Feb_Control_subFrameMode & DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING) {
|
||||
*retval = 32;
|
||||
} else if (DAQ_STATIC_BIT_M4 & Feb_Control_staticBits) {
|
||||
*retval = 4;
|
||||
} else if (DAQ_STATIC_BIT_M8 & Feb_Control_staticBits) {
|
||||
*retval = 8;
|
||||
} else {
|
||||
int disable16 = 0;
|
||||
if (!Feb_Control_Get16bitConversionDisabled(&disable16)) {
|
||||
LOG(logERROR, ("Could not get dynamic range (12 or 16 bit)\n"));
|
||||
return 0;
|
||||
}
|
||||
if (disable16) {
|
||||
*retval = 12;
|
||||
} else {
|
||||
*retval = 16;
|
||||
}
|
||||
}
|
||||
|
||||
return 16;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_Disable16bitConversion(int disable) {
|
||||
LOG(logINFO, ("%s 16 bit expansion\n", disable ? "Disabling" : "Enabling"));
|
||||
unsigned int regval = 0;
|
||||
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
|
||||
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
|
||||
(disable ? "disable" : "enable")));
|
||||
return 0;
|
||||
}
|
||||
if (disable) {
|
||||
regval |= DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
|
||||
} else {
|
||||
regval &= ~DAQ_REG_HRDWRE_DSBL_16BIT_MSK;
|
||||
}
|
||||
|
||||
if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
|
||||
LOG(logERROR, ("Could not %s 16 bit expansion (bit mode)\n",
|
||||
(disable ? "disable" : "enable")));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_Get16bitConversionDisabled(int *ret) {
|
||||
unsigned int regval = 0;
|
||||
if (!Feb_Control_ReadRegister(DAQ_REG_HRDWRE, ®val)) {
|
||||
LOG(logERROR, ("Could not get 16 bit expansion (bit mode)\n"));
|
||||
return 0;
|
||||
}
|
||||
if (regval & DAQ_REG_HRDWRE_DSBL_16BIT_MSK) {
|
||||
*ret = 1;
|
||||
} else {
|
||||
*ret = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed) {
|
||||
@ -1490,9 +1555,8 @@ int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Feb_Control_SetMasterVariable(int val) { Feb_Control_master = val; }
|
||||
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind) {
|
||||
|
||||
uint32_t offset = DAQ_REG_HRDWRE;
|
||||
unsigned int addr[2] = {Feb_Control_leftAddress, Feb_Control_rightAddress};
|
||||
char *master_names[] = {MASTER_NAMES};
|
||||
@ -1529,9 +1593,31 @@ int Feb_Control_SetMaster(enum MASTERINDEX ind) {
|
||||
LOG(logINFOBLUE, ("%s Master flag to %s Feb\n",
|
||||
(ind == MASTER_HARDWARE ? "Resetting" : "Overwriting"),
|
||||
master_names[ind]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_SetMasterEffects(int master, int controlServer) {
|
||||
int prevMaster = Feb_Control_master;
|
||||
|
||||
Feb_Control_master = master;
|
||||
// change in master for 9m
|
||||
if (controlServer && prevMaster != Feb_Control_master &&
|
||||
!Feb_Control_normal) {
|
||||
if (prevMaster) {
|
||||
Feb_Control_CloseSerialCommunication();
|
||||
}
|
||||
if (Feb_Control_master) {
|
||||
if (!Feb_Control_OpenSerialCommunication()) {
|
||||
LOG(logERROR, ("Could not intitalize feb control serial "
|
||||
"communication\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Feb_Control_SetQuad(int val) {
|
||||
LOG(logINFO, ("Setting Quad to %d in Feb\n", val));
|
||||
Feb_Control_quadMode = val;
|
||||
@ -1554,7 +1640,10 @@ int Feb_Control_SetChipSignalsToTrimQuad(int enable) {
|
||||
regval &= ~(DAQ_REG_HRDWRE_PROGRAM_MSK | DAQ_REG_HRDWRE_M8_MSK);
|
||||
}
|
||||
|
||||
return Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval);
|
||||
if (!Feb_Control_WriteRegister(DAQ_REG_HRDWRE, regval)) {
|
||||
LOG(logERROR, ("Could not set chip signals to trim quad\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1604,7 +1693,7 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
|
||||
for (int iloop = 0; iloop < 2; ++iloop) {
|
||||
if (run[iloop]) {
|
||||
LOG(logINFO,
|
||||
LOG(logDEBUG1,
|
||||
("Writing 0x%x to %s 0x%x\n", data, side[iloop], actualOffset));
|
||||
if (!Feb_Interface_WriteRegister(addr[iloop], actualOffset, data, 0,
|
||||
0)) {
|
||||
@ -1612,6 +1701,18 @@ int Feb_Control_WriteRegister(uint32_t offset, uint32_t data) {
|
||||
side[iloop], actualOffset));
|
||||
return 0;
|
||||
}
|
||||
uint32_t regVal = 0;
|
||||
if (!Feb_Interface_ReadRegister(addr[iloop], actualOffset,
|
||||
®Val)) {
|
||||
LOG(logERROR, ("Could not read %s register\n", addr[iloop]));
|
||||
return 0;
|
||||
}
|
||||
if (regVal != data) {
|
||||
LOG(logERROR,
|
||||
("Could not write %s register. Write 0x%x, read 0x%x\n",
|
||||
addr[iloop], data, regVal));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1648,8 +1749,8 @@ int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval) {
|
||||
side[iloop], actualOffset));
|
||||
return 0;
|
||||
}
|
||||
LOG(logINFO, ("Read 0x%x from %s 0x%x\n", value[iloop], side[iloop],
|
||||
actualOffset));
|
||||
LOG(logDEBUG1, ("Read 0x%x from %s 0x%x\n", value[iloop],
|
||||
side[iloop], actualOffset));
|
||||
*retval = value[iloop];
|
||||
// if not the other (left, not right OR right, not left), return the
|
||||
// value
|
||||
@ -1824,7 +1925,11 @@ int64_t Feb_Control_Get_RateTable_Period_in_nsec() {
|
||||
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec) {
|
||||
// period = exptime if 16bit, period = subexptime if 32 bit
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
int dr = 0;
|
||||
if (!Feb_Control_GetDynamicRange(&dr)) {
|
||||
LOG(logERROR, ("Could not set rate correction tau\n"));
|
||||
return 0;
|
||||
}
|
||||
double period_in_sec =
|
||||
(double)(Feb_Control_GetSubFrameExposureTime()) / (double)1e9;
|
||||
if (dr == 16)
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
// setup
|
||||
void Feb_Control_activate(int activate);
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int normal);
|
||||
int Feb_Control_FebControl(int normal);
|
||||
int Feb_Control_OpenSerialCommunication();
|
||||
void Feb_Control_CloseSerialCommunication();
|
||||
int Feb_Control_CheckSetup();
|
||||
@ -55,7 +54,7 @@ int Feb_Control_ResetChipPartially();
|
||||
int Feb_Control_SendBitModeToBebServer();
|
||||
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
|
||||
int Feb_Control_PrepareForAcquisition();
|
||||
void Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_PrintAcquisitionSetup();
|
||||
int Feb_Control_StartAcquisition();
|
||||
int Feb_Control_StopAcquisition();
|
||||
int Feb_Control_IsReadyForTrigger(int *readyForTrigger);
|
||||
@ -63,8 +62,10 @@ int Feb_Control_SendSoftwareTrigger();
|
||||
int Feb_Control_SoftwareTrigger(int block);
|
||||
|
||||
// parameters
|
||||
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
|
||||
unsigned int Feb_Control_GetDynamicRange();
|
||||
int Feb_Control_SetDynamicRange(int dr);
|
||||
int Feb_Control_GetDynamicRange(int *retval);
|
||||
int Feb_Control_Disable16bitConversion(int disable);
|
||||
int Feb_Control_Get16bitConversionDisabled();
|
||||
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed);
|
||||
int Feb_Control_SetReadoutMode(unsigned int readout_mode);
|
||||
int Feb_Control_SetTriggerMode(unsigned int trigger_mode);
|
||||
@ -86,8 +87,8 @@ int Feb_Control_Get_Counter_Bit();
|
||||
int Feb_Control_SetInterruptSubframe(int val);
|
||||
int Feb_Control_GetInterruptSubframe();
|
||||
int Feb_Control_SetTop(enum TOPINDEX ind, int left, int right);
|
||||
void Feb_Control_SetMasterVariable(int val);
|
||||
int Feb_Control_SetMaster(enum MASTERINDEX ind);
|
||||
int Feb_Control_SetMasterEffects(int master, int controlServer);
|
||||
int Feb_Control_SetQuad(int val);
|
||||
int Feb_Control_SetChipSignalsToTrimQuad(int enable);
|
||||
int Feb_Control_SetReadNRows(int value);
|
||||
|
@ -29,6 +29,8 @@
|
||||
#define DAQ_REG_HRDWRE_OW_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_MASTER_OFST)
|
||||
#define DAQ_REG_HRDWRE_MASTER_OFST (4)
|
||||
#define DAQ_REG_HRDWRE_MASTER_MSK (0x00000001 << DAQ_REG_HRDWRE_MASTER_OFST)
|
||||
#define DAQ_REG_HRDWRE_DSBL_16BIT_OFST (5)
|
||||
#define DAQ_REG_HRDWRE_DSBL_16BIT_MSK (0x00000001 << DAQ_REG_HRDWRE_DSBL_16BIT_OFST)
|
||||
#define DAQ_REG_HRDWRE_PROGRAM_OFST (30)
|
||||
#define DAQ_REG_HRDWRE_PROGRAM_MSK (0x00000001 << DAQ_REG_HRDWRE_PROGRAM_OFST)
|
||||
#define DAQ_REG_HRDWRE_M8_OFST (31)
|
||||
|
Binary file not shown.
@ -26,12 +26,17 @@ extern int updateFlag;
|
||||
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
extern int numUdpDestinations;
|
||||
extern const enum detectorType myDetectorType;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char *cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char *cip, uint32_t ip);
|
||||
|
||||
// Variables that will be exported
|
||||
int masterCommandLine = -1;
|
||||
int topCommandLine = -1;
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -226,6 +231,23 @@ int getModuleId(int *ret, char *mess) {
|
||||
return getModuleIdInFile(ret, mess, ID_FILE);
|
||||
}
|
||||
|
||||
int updateModuleId() {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_module_id = modid;
|
||||
#else
|
||||
if (Beb_SetModuleId(modid) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, ("Could not get module id from the file"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
char mac[255] = "";
|
||||
u_int64_t res = 0;
|
||||
@ -305,46 +327,36 @@ u_int32_t getDetectorIP() {
|
||||
void initControlServer() {
|
||||
LOG(logINFOBLUE, ("Configuring Control server\n"));
|
||||
if (!updateFlag && initError == OK) {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_module_id = modid;
|
||||
#endif
|
||||
if (initError == FAIL) {
|
||||
if (updateModuleConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
getModuleConfiguration();
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
if (!Feb_Control_Init(master, normal)) {
|
||||
if (!Feb_Control_FebControl(normal)) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||
sprintf(initErrorMessage,
|
||||
"Could not intitalize eiger detector sever: feb control\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
// master of 9M, check high voltage serial communication to blackfin
|
||||
if (master && !normal) {
|
||||
if (!Feb_Control_OpenSerialCommunication()) {
|
||||
initError = FAIL;
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not intitalize feb control serial communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize HV for eiger "
|
||||
"detector server: feb control serial "
|
||||
"communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb();
|
||||
Beb_SetModuleId(modid);
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
#endif
|
||||
// also reads config file and deactivates
|
||||
@ -354,73 +366,126 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
if (!updateFlag && initError == OK) {
|
||||
// wait a few s (control server is setting top/master from config file/
|
||||
// command line)
|
||||
usleep(WAIT_STOP_SERVER_START);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (updateModuleConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
getModuleConfiguration();
|
||||
sharedMemory_setStop(0);
|
||||
// get top/master in virtual
|
||||
readConfigFile();
|
||||
sharedMemory_setStop(0);
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
// force top or master if in command line
|
||||
if (checkCommandLineConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// wait a few s (control server is setting top/master from config file)
|
||||
usleep(WAIT_STOP_SERVER_START);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
// exit(-1);
|
||||
getModuleConfiguration();
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
// same addresses for top and bottom
|
||||
Feb_Control_Init(master, normal);
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
// control server read config file and already set up master/top
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Interface_FebInterface();
|
||||
if (!Feb_Control_FebControl(normal)) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize feb control\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not intitalize HV for eiger "
|
||||
"detector server: feb control serial "
|
||||
"communication\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
Beb_SetTopVariable(top);
|
||||
Beb_Beb();
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
#endif
|
||||
// client first connect (from shm) will activate
|
||||
if (setActivate(0) == FAIL) {
|
||||
LOG(logERROR, ("Could not deactivate in stop server\n"));
|
||||
// client first connect (from shm) will activate
|
||||
if (setActivate(0) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, "Could not deactivate\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
}
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
void getModuleConfiguration() {
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
void checkVirtual9MFlag() {
|
||||
#ifdef VIRTUAL
|
||||
#ifdef VIRTUAL_MASTER
|
||||
master = 1;
|
||||
top = 1;
|
||||
#else
|
||||
master = 0;
|
||||
#ifdef VIRTUAL_TOP
|
||||
top = 1;
|
||||
#else
|
||||
top = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VIRTUAL_9M
|
||||
normal = 0;
|
||||
#else
|
||||
normal = 1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
Beb_GetModuleConfiguration(&master, &top, &normal);
|
||||
int updateModuleConfiguration() {
|
||||
if (getModuleConfiguration(&master, &top, &normal) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
checkVirtual9MFlag();
|
||||
#endif
|
||||
if (isControlServer) {
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModuleConfiguration(int *m, int *t, int *n) {
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
*m = master;
|
||||
*t = top;
|
||||
*n = normal;
|
||||
#else
|
||||
if (Beb_GetModuleConfiguration(m, t, n) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, ("Could not get module configuration\n"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logDEBUG,
|
||||
("module config read: master:%d top:%d normal:%d\n", *m, *t, *n));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
return initError;
|
||||
}
|
||||
master = -1;
|
||||
|
||||
if (ignoreConfigFileFlag) {
|
||||
LOG(logWARNING, ("Ignoring Config file\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// if not found in config file, they will be reset to hardware settings
|
||||
top = -1;
|
||||
master = -1;
|
||||
#endif
|
||||
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
@ -471,91 +536,54 @@ int readConfigFile() {
|
||||
|
||||
// top command
|
||||
if (!strncmp(line, "top", strlen("top"))) {
|
||||
int t = -1;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d", command, &top) != 2) {
|
||||
if (sscanf(line, "%s %d", command, &t) != 2) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan top commands from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
enum TOPINDEX ind = (top == 1 ? OW_TOP : OW_BOTTOM);
|
||||
if (!Beb_SetTop(ind)) {
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not overwrite top to %d in Beb from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
top, line);
|
||||
if (t != 0 && t != 1) {
|
||||
sprintf(initErrorMessage,
|
||||
"Invalid top argument from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(ind, 1, 1)) {
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not overwrite top to %d in Feb from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
top, line);
|
||||
sharedMemory_unlockLocalLink();
|
||||
if (setTop(t == 1 ? OW_TOP : OW_BOTTOM) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set top from config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
// validate change
|
||||
int actual_top = -1, temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&temp, &actual_top, &temp2);
|
||||
if (actual_top != top) {
|
||||
sprintf(initErrorMessage, "Could not set top to %d. Read %d\n",
|
||||
top, actual_top);
|
||||
break;
|
||||
}
|
||||
Beb_SetTopVariable(top);
|
||||
#endif
|
||||
}
|
||||
|
||||
// master command
|
||||
else if (!strncmp(line, "master", strlen("master"))) {
|
||||
int m = -1;
|
||||
// cannot scan values
|
||||
if (sscanf(line, "%s %d", command, &master) != 2) {
|
||||
if (sscanf(line, "%s %d", command, &m) != 2) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan master commands from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
enum MASTERINDEX ind = (master == 1 ? OW_MASTER : OW_SLAVE);
|
||||
if (!Beb_SetMaster(ind)) {
|
||||
if (m != 0 && m != 1) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not overwrite master to %d in Beb from on-board "
|
||||
"server "
|
||||
"Invalid master argument from on-board server "
|
||||
"config file. Line:[%s].\n",
|
||||
master, line);
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(ind)) {
|
||||
if (setMaster(m == 1 ? OW_MASTER : OW_SLAVE) == FAIL) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not overwrite master to %d in Feb from on-board "
|
||||
"server "
|
||||
"config file. Line:[%s].\n",
|
||||
master, line);
|
||||
sharedMemory_unlockLocalLink();
|
||||
"Could not set master from config file. Line:[%s].\n",
|
||||
line);
|
||||
break;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
// validate change
|
||||
int actual_master = -1, temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&actual_master, &temp, &temp2);
|
||||
if (actual_master != master) {
|
||||
sprintf(initErrorMessage,
|
||||
"Could not set master to %d. Read %d\n", master,
|
||||
actual_master);
|
||||
break;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
}
|
||||
|
||||
// other commands
|
||||
@ -576,8 +604,10 @@ int readConfigFile() {
|
||||
LOG(logINFO, ("Successfully read config file\n"));
|
||||
}
|
||||
|
||||
#ifndef VIRTUAL
|
||||
// reset to hardware settings if not in config file (if overwritten)
|
||||
resetToHardwareSettings();
|
||||
#endif
|
||||
|
||||
return initError;
|
||||
}
|
||||
@ -589,55 +619,56 @@ void resetToHardwareSettings() {
|
||||
}
|
||||
// top not set in config file
|
||||
if (top == -1) {
|
||||
if (!Beb_SetTop(TOP_HARDWARE)) {
|
||||
LOG(logINFO, ("Resetting Top to hardware settings\n"));
|
||||
if (setTop(TOP_HARDWARE) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Top flag to Beb hardware settings.\n");
|
||||
"Could not reset Top flag to hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(TOP_HARDWARE, 1, 1)) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Top flag to Feb hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
int temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&temp, &top, &temp2);
|
||||
Beb_SetTopVariable(top);
|
||||
}
|
||||
// master not set in config file
|
||||
if (master == -1) {
|
||||
if (!Beb_SetMaster(TOP_HARDWARE)) {
|
||||
LOG(logINFO, ("Resetting Master to hardware settings\n"));
|
||||
if (setMaster(MASTER_HARDWARE) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Master flag to Beb hardware settings.\n");
|
||||
"Could not reset Master flag to hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return;
|
||||
}
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(TOP_HARDWARE)) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Could not reset Master flag to Feb hardware settings.\n");
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
int temp = -1, temp2 = -1;
|
||||
Beb_GetModuleConfiguration(&master, &temp, &temp2);
|
||||
sharedMemory_lockLocalLink();
|
||||
Feb_Control_SetMasterVariable(master);
|
||||
sharedMemory_unlockLocalLink();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int checkCommandLineConfiguration() {
|
||||
if (masterCommandLine != -1) {
|
||||
LOG(logINFO, ("Setting %s from Command Line\n",
|
||||
(masterCommandLine == 1 ? "Master" : "Slave")));
|
||||
if (setMaster(masterCommandLine == 1 ? OW_MASTER : OW_SLAVE) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not set %s from command line.\n",
|
||||
(masterCommandLine == 1 ? "Master" : "Slave"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (topCommandLine != -1) {
|
||||
LOG(logINFO, ("Setting %s from Command Line\n",
|
||||
(topCommandLine == 1 ? "Top" : "Bottom")));
|
||||
if (setTop(topCommandLine == 1 ? OW_TOP : OW_BOTTOM) == FAIL) {
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage, "Could not set %s from command line.\n",
|
||||
(topCommandLine == 1 ? "Top" : "Bottom"));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
|
||||
void allocateDetectorStructureMemory() {
|
||||
@ -671,15 +702,29 @@ void allocateDetectorStructureMemory() {
|
||||
}
|
||||
|
||||
void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL)
|
||||
return;
|
||||
// force top or master if in command line
|
||||
if (checkCommandLineConfiguration() == FAIL)
|
||||
return;
|
||||
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
|
||||
if (updateModuleId() == FAIL)
|
||||
return;
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
resetToDefaultDacs(0);
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStatus(IDLE);
|
||||
setupUDPCommParameters();
|
||||
#endif
|
||||
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
// setting default measurement parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setExpTime(DEFAULT_EXPTIME);
|
||||
@ -719,14 +764,6 @@ void setupDetector() {
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
// force top or master if in config file
|
||||
if (readConfigFile() == FAIL) {
|
||||
return;
|
||||
}
|
||||
LOG(logINFOBLUE,
|
||||
("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL")));
|
||||
|
||||
if (setNumberofDestinations(numUdpDestinations) == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage, "Could not set number of udp destinations\n");
|
||||
@ -821,29 +858,38 @@ int readRegister(uint32_t offset, uint32_t *retval) {
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
// setting dr
|
||||
if (dr > 0) {
|
||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
#ifndef VIRTUAL
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
eiger_dynamicrange = dr;
|
||||
if (dr <= 0) {
|
||||
return FAIL;
|
||||
}
|
||||
// getting dr
|
||||
#ifndef VIRTUAL
|
||||
#ifdef VIRTUAL
|
||||
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
eiger_dynamicrange = Feb_Control_GetDynamicRange();
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
if (!Beb_SetUpTransferParameters(dr)) {
|
||||
LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
sharedMemory_unlockLocalLink();
|
||||
return eiger_dynamicrange;
|
||||
}
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return eiger_dynamicrange;
|
||||
eiger_dynamicrange = dr;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = eiger_dynamicrange;
|
||||
#else
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_GetDynamicRange(retval)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* parameters - readout */
|
||||
@ -1158,6 +1204,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, set M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(1)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1170,6 +1217,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1179,6 +1227,7 @@ int setModule(sls_detector_module myMod, char *mess) {
|
||||
|
||||
// if quad, reset M8 and PROGRAM manually
|
||||
if (!Feb_Control_SetChipSignalsToTrimQuad(0)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1450,7 +1499,120 @@ int setHighVoltage(int val) {
|
||||
|
||||
/* parameters - timing, extsig */
|
||||
|
||||
int isMaster() { return master; }
|
||||
int setMaster(enum MASTERINDEX m) {
|
||||
char *master_names[] = {MASTER_NAMES};
|
||||
LOG(logINFOBLUE, ("Setting up Master flag as %s\n", master_names[m]));
|
||||
#ifdef VIRTUAL
|
||||
switch (m) {
|
||||
case OW_MASTER:
|
||||
master = 1;
|
||||
break;
|
||||
case OW_SLAVE:
|
||||
master = 0;
|
||||
break;
|
||||
default:
|
||||
// hardware settings (do nothing)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// need to set it only once via the control server
|
||||
if (isControlServer) {
|
||||
if (!Beb_SetMaster(m)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetMaster(m)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
}
|
||||
|
||||
// get and update master variable (cannot get from m, could be hardware)
|
||||
if (isMaster(&master) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
// verify for master and slave (not hardware)
|
||||
if ((m == OW_MASTER && master == 0) || (m == OW_SLAVE && master == 1)) {
|
||||
LOG(logERROR,
|
||||
("could not set master/slave. Master value retrieved %d\n",
|
||||
master));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// feb variable and hv comms (9m)
|
||||
sharedMemory_lockLocalLink();
|
||||
if (Feb_Control_SetMasterEffects(master, isControlServer) == FAIL) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int isMaster(int *retval) {
|
||||
int m = -1, t = -1, n = -1;
|
||||
if (getModuleConfiguration(&m, &t, &n) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
*retval = m;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setTop(enum TOPINDEX t) {
|
||||
char *top_names[] = {TOP_NAMES};
|
||||
LOG(logINFOBLUE, ("Setting up Top flag as %s\n", top_names[t]));
|
||||
#ifdef VIRTUAL
|
||||
switch (t) {
|
||||
case OW_TOP:
|
||||
top = 1;
|
||||
break;
|
||||
case OW_BOTTOM:
|
||||
top = 0;
|
||||
break;
|
||||
default:
|
||||
// hardware settings (do nothing)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (!Beb_SetTop(t)) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_SetTop(t, 1, 1)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
|
||||
// get and update top variable(cannot get from t, could be hardware)
|
||||
if (isTop(&top) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
// verify for master and slave (not hardware)
|
||||
if ((t == OW_TOP && top == 0) || (t == OW_BOTTOM && top == 1)) {
|
||||
LOG(logERROR,
|
||||
("could not set top/bottom. Top value retrieved %d\n", top));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
Beb_SetTopVariable(top);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int isTop(int *retval) {
|
||||
int m = -1, t = -1, n = -1;
|
||||
if (getModuleConfiguration(&m, &t, &n) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*retval = t;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setTiming(enum timingMode arg) {
|
||||
int ret = 0;
|
||||
@ -1923,7 +2085,8 @@ int setRateCorrection(
|
||||
else if (custom_tau_in_nsec == -1)
|
||||
custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
int dr = eiger_dynamicrange;
|
||||
|
||||
// get period = subexptime if 32bit , else period = exptime if 16 bit
|
||||
int64_t actual_period =
|
||||
Feb_Control_GetSubFrameExposureTime(); // already in nsec
|
||||
@ -2285,15 +2448,17 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
|
||||
int skipData = 0;
|
||||
int tgEnable = send_to_ten_gig;
|
||||
if (!eiger_virtual_activate ||
|
||||
(!eiger_virtual_left_datastream && !eiger_virtual_right_datastream)) {
|
||||
(tgEnable &&
|
||||
(!eiger_virtual_left_datastream && !eiger_virtual_right_datastream))) {
|
||||
skipData = 1;
|
||||
LOG(logWARNING, ("Not sending Left and Right datastream\n"));
|
||||
}
|
||||
if (!eiger_virtual_left_datastream) {
|
||||
if (tgEnable && !eiger_virtual_left_datastream) {
|
||||
LOG(logWARNING, ("Not sending Left datastream\n"));
|
||||
}
|
||||
if (!eiger_virtual_right_datastream) {
|
||||
if (tgEnable && !eiger_virtual_right_datastream) {
|
||||
LOG(logWARNING, ("Not sending Right datastream\n"));
|
||||
}
|
||||
|
||||
@ -2303,7 +2468,6 @@ void *start_timer(void *arg) {
|
||||
|
||||
int dr = eiger_dynamicrange;
|
||||
double bytesPerPixel = (double)dr / 8.00;
|
||||
int tgEnable = send_to_ten_gig;
|
||||
int datasize = (tgEnable ? 4096 : 1024);
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int maxPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
@ -2321,7 +2485,7 @@ void *start_timer(void *arg) {
|
||||
const int maxRows = MAX_ROWS_PER_READOUT;
|
||||
const int packetsPerFrame = (maxPacketsPerFrame * readNRows) / maxRows;
|
||||
|
||||
LOG(logDEBUG1,
|
||||
LOG(logDEBUG,
|
||||
(" dr:%d\n bytesperpixel:%f\n tgenable:%d\n datasize:%d\n "
|
||||
"packetsize:%d\n maxnumpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, maxPacketsPerFrame,
|
||||
@ -2338,11 +2502,13 @@ void *start_timer(void *arg) {
|
||||
npixels /= 2;
|
||||
}
|
||||
LOG(logDEBUG1,
|
||||
("pixels:%d pixelsperpacket:%d\n", npixels, pixelsPerPacket));
|
||||
("npixels:%d pixelsperpacket:%d\n", npixels, pixelsPerPacket));
|
||||
uint8_t *src = (uint8_t *)imageData;
|
||||
for (int i = 0; i < npixels; ++i) {
|
||||
if (i > 0 && i % pixelsPerPacket == 0) {
|
||||
++pixelVal;
|
||||
}
|
||||
|
||||
switch (dr) {
|
||||
case 4:
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
@ -2357,6 +2523,30 @@ void *start_timer(void *arg) {
|
||||
*((uint8_t *)(imageData + i)) =
|
||||
eiger_virtual_test_mode ? 0xFE : (uint8_t)pixelVal;
|
||||
break;
|
||||
case 12:
|
||||
if (eiger_virtual_test_mode) {
|
||||
// first 12 bit pixel
|
||||
// first 8 byte
|
||||
*src++ = 0xFE;
|
||||
// second 12bit pixel
|
||||
++i;
|
||||
// second 8 byte
|
||||
*src++ = 0xEF;
|
||||
// third byte
|
||||
*src++ = 0xFF;
|
||||
} else {
|
||||
// first 12 bit pixel
|
||||
// first 8 byte
|
||||
*src++ = (uint8_t)(i & 0xFF);
|
||||
// second 8 byte (first nibble)
|
||||
*src = (uint8_t)((i++ >> 8u) & 0xF);
|
||||
// second 12bit pixel
|
||||
// second 8 byte (second nibble)
|
||||
*src++ |= ((uint8_t)(i & 0xF) << 4u);
|
||||
// third byte
|
||||
*src++ = (uint8_t)((i >> 4u) & 0xFF);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
eiger_virtual_test_mode ? 0xFFE : (uint16_t)pixelVal;
|
||||
@ -2433,9 +2623,27 @@ void *start_timer(void *arg) {
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
for (int psize = 0; psize < datasize; psize += npixelsx) {
|
||||
if (dr == 12) {
|
||||
// multiple of 768,1024,4096
|
||||
int copysize = 256;
|
||||
for (int psize = 0; psize < datasize; psize += copysize) {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset,
|
||||
copysize);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2,
|
||||
copysize);
|
||||
srcOffset += copysize;
|
||||
srcOffset2 += copysize;
|
||||
dstOffset += copysize;
|
||||
dstOffset2 += copysize;
|
||||
|
||||
// reached 1 row (quarter module)
|
||||
if ((srcOffset % npixelsx) == 0) {
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int psize = 0; psize < datasize; psize += npixelsx) {
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset,
|
||||
imageData + srcOffset, npixelsx / 2);
|
||||
@ -2465,14 +2673,16 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eiger_virtual_left_datastream && i >= startval &&
|
||||
i <= endval) {
|
||||
if ((!tgEnable ||
|
||||
(tgEnable && eiger_virtual_left_datastream)) &&
|
||||
i >= startval && i <= endval) {
|
||||
usleep(eiger_virtual_transmission_delay_left);
|
||||
sendUDPPacket(iRxEntry, 0, packetData, packetsize);
|
||||
LOG(logDEBUG1, ("Sent left packet: %d\n", i));
|
||||
}
|
||||
if (eiger_virtual_right_datastream && i >= startval &&
|
||||
i <= endval) {
|
||||
if ((!tgEnable ||
|
||||
(tgEnable && eiger_virtual_right_datastream)) &&
|
||||
i >= startval && i <= endval) {
|
||||
usleep(eiger_virtual_transmission_delay_right);
|
||||
sendUDPPacket(iRxEntry, 1, packetData2, packetsize);
|
||||
LOG(logDEBUG1, ("Sent right packet: %d\n", i));
|
||||
@ -2733,9 +2943,9 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
int calculateDataBytes() {
|
||||
if (send_to_ten_gig)
|
||||
return setDynamicRange(-1) * ONE_GIGA_CONSTANT * TEN_GIGA_BUFFER_SIZE;
|
||||
return eiger_dynamicrange * ONE_GIGA_CONSTANT * TEN_GIGA_BUFFER_SIZE;
|
||||
else
|
||||
return setDynamicRange(-1) * TEN_GIGA_CONSTANT * ONE_GIGA_BUFFER_SIZE;
|
||||
return eiger_dynamicrange * TEN_GIGA_CONSTANT * ONE_GIGA_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#define LINKED_SERVER_NAME "eigerDetectorServer"
|
||||
|
||||
#define REQUIRED_FIRMWARE_VERSION (29)
|
||||
#define REQUIRED_FIRMWARE_VERSION (30)
|
||||
// virtual ones renamed for consistency
|
||||
// real ones keep previous name for compatibility (already in production)
|
||||
#ifdef VIRTUAL
|
||||
|
Binary file not shown.
@ -28,12 +28,16 @@ extern int updateFlag;
|
||||
extern int checkModuleFlag;
|
||||
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
extern const enum detectorType myDetectorType;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char *cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char *cip, uint32_t ip);
|
||||
|
||||
// Variables that will be exported
|
||||
int masterCommandLine = -1;
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -69,6 +73,7 @@ int64_t burstPeriodReg = 0;
|
||||
int filterResistor = 0;
|
||||
int cdsGain = 0;
|
||||
int detPos[2] = {};
|
||||
int master = 1;
|
||||
|
||||
int isInitCheckDone() { return initCheckDone; }
|
||||
|
||||
@ -295,6 +300,18 @@ void setModuleId(int modid) {
|
||||
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
|
||||
}
|
||||
|
||||
int updateModuleId() {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_moduleid = modid;
|
||||
#endif
|
||||
setModuleId(modid);
|
||||
return OK;
|
||||
}
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
@ -358,16 +375,27 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
sharedMemory_setStop(0);
|
||||
// not reading config file (nothing of interest to stop server)
|
||||
if (checkCommandLineConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -480,15 +508,13 @@ void setupDetector() {
|
||||
return;
|
||||
}
|
||||
|
||||
// set module id in register
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
#ifdef VIRTUAL
|
||||
virtual_moduleid = modid;
|
||||
#endif
|
||||
if (initError == FAIL) {
|
||||
// master for virtual
|
||||
if (checkCommandLineConfiguration() == FAIL)
|
||||
return;
|
||||
|
||||
if (updateModuleId() == FAIL) {
|
||||
return;
|
||||
}
|
||||
setModuleId(modid);
|
||||
|
||||
setBurstMode(DEFAULT_BURST_MODE);
|
||||
setFilterResistor(DEFAULT_FILTER_RESISTOR);
|
||||
@ -600,6 +626,11 @@ int readConfigFile() {
|
||||
return initError;
|
||||
}
|
||||
|
||||
if (ignoreConfigFileFlag) {
|
||||
LOG(logWARNING, ("Ignoring Config file\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
// require a sleep before and after the rst dac signal
|
||||
usleep(INITIAL_STARTUP_WAIT);
|
||||
|
||||
@ -924,6 +955,21 @@ int readConfigFile() {
|
||||
return initError;
|
||||
}
|
||||
|
||||
int checkCommandLineConfiguration() {
|
||||
if (masterCommandLine != -1) {
|
||||
#ifdef VIRTUAL
|
||||
master = masterCommandLine;
|
||||
#else
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Cannot set Master from command line for this detector. "
|
||||
"Should have been caught before!\n");
|
||||
return FAIL;
|
||||
#endif
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* firmware functions (resets) */
|
||||
|
||||
void cleanFifos() {
|
||||
@ -952,7 +998,16 @@ void resetPeripheral() {
|
||||
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr == 16)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
*retval = DYNAMIC_RANGE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* parameters - timer */
|
||||
void setNumFrames(int64_t val) {
|
||||
@ -1442,6 +1497,11 @@ int setHighVoltage(int val) {
|
||||
|
||||
/* parameters - timing */
|
||||
|
||||
int isMaster(int *retval) {
|
||||
*retval = master;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void updatingRegisters() {
|
||||
LOG(logINFO, ("\tUpdating registers\n"));
|
||||
// burst
|
||||
@ -1921,9 +1981,17 @@ int checkDetectorType() {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if ((abs(type - TYPE_GOTTHARD2_MODULE_VAL) > TYPE_TOLERANCE) &&
|
||||
(abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) > TYPE_TOLERANCE) &&
|
||||
(abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) > TYPE_TOLERANCE)) {
|
||||
if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) <= TYPE_TOLERANCE) {
|
||||
LOG(logINFOBLUE, ("MASTER 25um Module\n"));
|
||||
master = 1;
|
||||
} else if (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) <=
|
||||
TYPE_TOLERANCE) {
|
||||
master = 0;
|
||||
LOG(logINFOBLUE, ("SLAVE 25um Module\n"));
|
||||
} else if (abs(type - TYPE_GOTTHARD2_MODULE_VAL) <= TYPE_TOLERANCE) {
|
||||
master = -1;
|
||||
LOG(logINFOBLUE, ("50um Module\n"));
|
||||
} else {
|
||||
LOG(logERROR,
|
||||
("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got "
|
||||
"%d\n",
|
||||
|
Binary file not shown.
@ -25,9 +25,11 @@ extern int debugflag;
|
||||
extern int updateFlag;
|
||||
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
extern const enum detectorType myDetectorType;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Variables that will be exported
|
||||
int phaseShift = DEFAULT_PHASE_SHIFT;
|
||||
int masterCommandLine = -1;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
@ -359,16 +361,28 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
// to get master from file
|
||||
readConfigFile();
|
||||
// to get master from file
|
||||
if (readConfigFile() == FAIL ||
|
||||
checkCommandLineConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -421,6 +435,13 @@ void setupDetector() {
|
||||
setROI(rois); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
|
||||
setGbitReadout();
|
||||
|
||||
// no config file or not first time server
|
||||
if (readConfigFile() == FAIL)
|
||||
return;
|
||||
|
||||
if (checkCommandLineConfiguration() == FAIL)
|
||||
return;
|
||||
|
||||
// master, slave (25um)
|
||||
setMasterSlaveConfiguration();
|
||||
|
||||
@ -624,6 +645,16 @@ void setGbitReadout() {
|
||||
}
|
||||
|
||||
int readConfigFile() {
|
||||
|
||||
if (initError == FAIL) {
|
||||
return initError;
|
||||
}
|
||||
|
||||
if (ignoreConfigFileFlag) {
|
||||
LOG(logWARNING, ("Ignoring Config file\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
if (getAbsPath(fname, fileNameSize, CONFIG_FILE) == FAIL) {
|
||||
@ -647,7 +678,6 @@ int readConfigFile() {
|
||||
memset(key, 0, keySize);
|
||||
char value[keySize];
|
||||
memset(value, 0, keySize);
|
||||
int scan = OK;
|
||||
|
||||
// keep reading a line
|
||||
while (fgets(line, lineSize, fd)) {
|
||||
@ -667,19 +697,22 @@ int readConfigFile() {
|
||||
master = 0;
|
||||
LOG(logINFOBLUE, ("\tSlave or No Master\n"));
|
||||
} else {
|
||||
LOG(logERROR,
|
||||
("\tCould not scan masterflags %s value from config file\n",
|
||||
value));
|
||||
scan = FAIL;
|
||||
break;
|
||||
initError = FAIL;
|
||||
sprintf(
|
||||
initErrorMessage,
|
||||
"Could not scan masterflags %s value from config file\n",
|
||||
value);
|
||||
LOG(logERROR, (initErrorMessage))
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// not first server since detector power on
|
||||
if (!detectorFirstServer) {
|
||||
LOG(logINFOBLUE, ("\tServer has been started up before. "
|
||||
"Ignoring rest of config file\n"));
|
||||
LOG(logWARNING, ("\tServer has been started up before. "
|
||||
"Ignoring rest of config file\n"));
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,11 +721,14 @@ int readConfigFile() {
|
||||
// convert value to int
|
||||
int ival = 0;
|
||||
if (sscanf(value, "%d", &ival) <= 0) {
|
||||
LOG(logERROR, ("\tCould not scan parameter %s value %s from "
|
||||
"config file\n",
|
||||
key, value));
|
||||
scan = FAIL;
|
||||
break;
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan parameter %s value %s from "
|
||||
"config file\n",
|
||||
key, value);
|
||||
LOG(logERROR, (initErrorMessage))
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
}
|
||||
// set value
|
||||
if (!strcasecmp(key, "masterdefaultdelay"))
|
||||
@ -710,16 +746,16 @@ int readConfigFile() {
|
||||
else if (!strcasecmp(key, "startacqdelay"))
|
||||
startacqdelay = ival;
|
||||
else {
|
||||
LOG(logERROR,
|
||||
("\tCould not scan parameter %s from config file\n", key));
|
||||
scan = FAIL;
|
||||
break;
|
||||
initError = FAIL;
|
||||
sprintf(initErrorMessage,
|
||||
"Could not scan parameter %s from config file\n", key);
|
||||
LOG(logERROR, (initErrorMessage))
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fd);
|
||||
if (scan == FAIL)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
LOG(logINFOBLUE,
|
||||
("\tmasterdefaultdelay:%d\n"
|
||||
@ -734,13 +770,28 @@ int readConfigFile() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int checkCommandLineConfiguration() {
|
||||
if (masterCommandLine != -1) {
|
||||
#ifdef VIRTUAL
|
||||
master = masterCommandLine;
|
||||
#else
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Cannot set Master from command line for this detector. "
|
||||
"Should have been caught before!\n");
|
||||
return FAIL;
|
||||
#endif
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setMasterSlaveConfiguration() {
|
||||
LOG(logINFO, ("Reading Master Slave Configuration\n"));
|
||||
|
||||
// no config file or not first time server
|
||||
if (readConfigFile() == FAIL)
|
||||
// not the first time its being read
|
||||
if (!detectorFirstServer) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(logINFO, ("Reading Master Slave Configuration\n"));
|
||||
// master configuration
|
||||
if (master) {
|
||||
// master default delay set, so reset delay
|
||||
@ -788,7 +839,16 @@ void setMasterSlaveConfiguration() {
|
||||
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr == 16)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
*retval = DYNAMIC_RANGE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setROI(ROI arg) {
|
||||
|
||||
@ -1238,7 +1298,10 @@ int setHighVoltage(int val) {
|
||||
|
||||
/* parameters - timing, extsig */
|
||||
|
||||
int isMaster() { return master; }
|
||||
int isMaster(int *retval) {
|
||||
*retval = master;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setTiming(enum timingMode arg) {
|
||||
u_int32_t addr = EXT_SIGNAL_REG;
|
||||
|
Binary file not shown.
@ -28,6 +28,7 @@ extern int updateFlag;
|
||||
extern udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
extern int numUdpDestinations;
|
||||
extern const enum detectorType myDetectorType;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
@ -392,19 +393,29 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
if (readConfigFile() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
// temp threshold and reset event (read by stop server)
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
sharedMemory_setStop(0);
|
||||
// temp threshold and reset event (read by stop server)
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
#endif
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -643,6 +654,11 @@ int readConfigFile() {
|
||||
return initError;
|
||||
}
|
||||
|
||||
if (ignoreConfigFileFlag) {
|
||||
LOG(logWARNING, ("Ignoring Config file\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
const int fileNameSize = 128;
|
||||
char fname[fileNameSize];
|
||||
if (getAbsPath(fname, fileNameSize, CONFIG_FILE) == FAIL) {
|
||||
@ -796,7 +812,16 @@ void resetPeripheral() {
|
||||
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr == 16)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
*retval = DYNAMIC_RANGE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setADCInvertRegister(uint32_t val) {
|
||||
LOG(logINFO, ("Setting ADC Port Invert Reg to 0x%x\n", val));
|
||||
|
Binary file not shown.
@ -436,16 +436,22 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
sharedMemory_setStop(0);
|
||||
#endif
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -706,7 +712,16 @@ void resetPeripheral() {
|
||||
|
||||
/* set parameters - dr, adcenablemask */
|
||||
|
||||
int setDynamicRange(int dr) { return DYNAMIC_RANGE; }
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr == 16)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
*retval = DYNAMIC_RANGE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setADCEnableMask(uint32_t mask) {
|
||||
if (mask == 0u) {
|
||||
|
Binary file not shown.
@ -35,6 +35,9 @@ extern int isControlServer;
|
||||
extern void getMacAddressinString(char *cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char *cip, uint32_t ip);
|
||||
|
||||
// Variables that will be exported
|
||||
int masterCommandLine = -1;
|
||||
|
||||
int initError = OK;
|
||||
int initCheckDone = 0;
|
||||
char initErrorMessage[MAX_STR_LENGTH];
|
||||
@ -289,6 +292,18 @@ void setModuleId(int modid) {
|
||||
bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK));
|
||||
}
|
||||
|
||||
int updateModuleId() {
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_moduleid = modid;
|
||||
#endif
|
||||
setModuleId(modid);
|
||||
return OK;
|
||||
}
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
@ -352,16 +367,26 @@ void initControlServer() {
|
||||
}
|
||||
|
||||
void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
LOG(logERROR,
|
||||
("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!updateFlag && initError == OK) {
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Stop Server: Map Fail. Dangerous to continue. Goodbye!\n");
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
sharedMemory_setStop(0);
|
||||
sharedMemory_setStop(0);
|
||||
if (checkCommandLineConfiguration() == FAIL) {
|
||||
initCheckDone = 1;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
initCheckDone = 1;
|
||||
}
|
||||
|
||||
/* set up detector */
|
||||
@ -407,6 +432,12 @@ void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
|
||||
if (checkCommandLineConfiguration() == FAIL)
|
||||
return;
|
||||
|
||||
if (updateModuleId() == FAIL)
|
||||
return;
|
||||
|
||||
clkDivider[READOUT_C0] = DEFAULT_READOUT_C0;
|
||||
clkDivider[READOUT_C1] = DEFAULT_READOUT_C1;
|
||||
clkDivider[SYSTEM_C0] = DEFAULT_SYSTEM_C0;
|
||||
@ -447,16 +478,6 @@ void setupDetector() {
|
||||
setASICDefaults();
|
||||
setADIFDefaults();
|
||||
|
||||
// set module id in register
|
||||
int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
#ifdef VIRTUAL
|
||||
virtual_moduleid = modid;
|
||||
#endif
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
setModuleId(modid);
|
||||
|
||||
// set trigger flow for m3 (for all timing modes)
|
||||
bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK);
|
||||
|
||||
@ -480,10 +501,6 @@ void setupDetector() {
|
||||
setInitialExtSignals();
|
||||
// 10G UDP
|
||||
enableTenGigabitEthernet(1);
|
||||
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
|
||||
// check module type attached if not in debug mode
|
||||
@ -700,6 +717,27 @@ void setADIFDefaults() {
|
||||
ADIF_ADDTNL_OFST_MSK)));
|
||||
}
|
||||
|
||||
int checkCommandLineConfiguration() {
|
||||
if (masterCommandLine != -1) {
|
||||
#ifdef VIRTUAL
|
||||
if (masterCommandLine == 1) {
|
||||
bus_w(SYSTEM_STATUS_REG,
|
||||
bus_r(SYSTEM_STATUS_REG) & ~SYSTEM_STATUS_SLV_BRD_DTCT_MSK);
|
||||
} else {
|
||||
bus_w(SYSTEM_STATUS_REG,
|
||||
bus_r(SYSTEM_STATUS_REG) | SYSTEM_STATUS_SLV_BRD_DTCT_MSK);
|
||||
}
|
||||
#else
|
||||
initError = FAIL;
|
||||
strcpy(initErrorMessage,
|
||||
"Cannot set Master from command line for this detector. "
|
||||
"Should have been caught before!\n");
|
||||
return FAIL;
|
||||
#endif
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* firmware functions (resets) */
|
||||
|
||||
void cleanFifos() {
|
||||
@ -729,46 +767,54 @@ void resetPeripheral() {
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
if (dr > 0) {
|
||||
uint32_t regval = 0;
|
||||
switch (dr) {
|
||||
/*case 1: TODO:Not implemented in firmware yet
|
||||
regval = CONFIG_DYNAMIC_RANGE_1_VAL;
|
||||
break;*/
|
||||
case 8:
|
||||
regval = CONFIG_DYNAMIC_RANGE_8_VAL;
|
||||
break;
|
||||
case 16:
|
||||
regval = CONFIG_DYNAMIC_RANGE_16_VAL;
|
||||
break;
|
||||
case 32:
|
||||
regval = CONFIG_DYNAMIC_RANGE_24_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Invalid dynamic range %d\n", dr));
|
||||
return -1;
|
||||
}
|
||||
// set it
|
||||
bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_DYNAMIC_RANGE_MSK);
|
||||
bus_w(CONFIG_REG, bus_r(CONFIG_REG) | regval);
|
||||
updatePacketizing();
|
||||
if (dr <= 0) {
|
||||
return FAIL;
|
||||
}
|
||||
uint32_t regval = 0;
|
||||
switch (dr) {
|
||||
/*case 1: TODO:Not implemented in firmware yet
|
||||
regval = CONFIG_DYNAMIC_RANGE_1_VAL;
|
||||
break;*/
|
||||
case 8:
|
||||
regval = CONFIG_DYNAMIC_RANGE_8_VAL;
|
||||
break;
|
||||
case 16:
|
||||
regval = CONFIG_DYNAMIC_RANGE_16_VAL;
|
||||
break;
|
||||
case 32:
|
||||
regval = CONFIG_DYNAMIC_RANGE_24_VAL;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Invalid dynamic range %d\n", dr));
|
||||
return -1;
|
||||
}
|
||||
// set it
|
||||
bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_DYNAMIC_RANGE_MSK);
|
||||
bus_w(CONFIG_REG, bus_r(CONFIG_REG) | regval);
|
||||
updatePacketizing();
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDynamicRange(int *retval) {
|
||||
uint32_t regval = bus_r(CONFIG_REG) & CONFIG_DYNAMIC_RANGE_MSK;
|
||||
switch (regval) {
|
||||
/*case CONFIG_DYNAMIC_RANGE_1_VAL: TODO:Not implemented in firmware yet
|
||||
return 1;*/
|
||||
case CONFIG_DYNAMIC_RANGE_8_VAL:
|
||||
return 8;
|
||||
*retval = 8;
|
||||
break;
|
||||
case CONFIG_DYNAMIC_RANGE_16_VAL:
|
||||
return 16;
|
||||
*retval = 16;
|
||||
break;
|
||||
case CONFIG_DYNAMIC_RANGE_24_VAL:
|
||||
return 32;
|
||||
*retval = 32;
|
||||
break;
|
||||
default:
|
||||
LOG(logERROR, ("Invalid dynamic range %d read back\n",
|
||||
regval >> CONFIG_DYNAMIC_RANGE_OFST));
|
||||
return -1;
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* set parameters - readout */
|
||||
@ -1091,7 +1137,8 @@ void updatePacketizing() {
|
||||
|
||||
// 10g
|
||||
if (tgEnable) {
|
||||
const int dr = setDynamicRange(-1);
|
||||
int dr = 0;
|
||||
getDynamicRange(&dr);
|
||||
packetsPerFrame = 1;
|
||||
if (dr == 32 && ncounters > 1) {
|
||||
packetsPerFrame = 2;
|
||||
@ -1545,14 +1592,18 @@ int setHighVoltage(int val) {
|
||||
|
||||
/* parameters - timing */
|
||||
|
||||
int isMaster() {
|
||||
return !((bus_r(SYSTEM_STATUS_REG) & SYSTEM_STATUS_SLV_BRD_DTCT_MSK) >>
|
||||
SYSTEM_STATUS_SLV_BRD_DTCT_OFST);
|
||||
int isMaster(int *retval) {
|
||||
int slave = ((bus_r(SYSTEM_STATUS_REG) & SYSTEM_STATUS_SLV_BRD_DTCT_MSK) >>
|
||||
SYSTEM_STATUS_SLV_BRD_DTCT_OFST);
|
||||
*retval = (slave == 0 ? 1 : 0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
void setTiming(enum timingMode arg) {
|
||||
|
||||
if (!isMaster() && arg == AUTO_TIMING)
|
||||
int master = 0;
|
||||
isMaster(&master);
|
||||
if (master && arg == AUTO_TIMING)
|
||||
arg = TRIGGER_EXPOSURE;
|
||||
|
||||
uint32_t addr = CONFIG_REG;
|
||||
@ -2202,7 +2253,8 @@ void *start_timer(void *arg) {
|
||||
|
||||
const int imageSize = calculateDataBytes();
|
||||
const int tgEnable = enableTenGigabitEthernet(-1);
|
||||
const int dr = setDynamicRange(-1);
|
||||
int dr = 0;
|
||||
getDynamicRange(&dr);
|
||||
int ncounters = __builtin_popcount(getCounterMask());
|
||||
int dataSize = 0;
|
||||
int packetsPerFrame = 0;
|
||||
@ -2523,7 +2575,8 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
|
||||
int calculateDataBytes() {
|
||||
int numCounters = __builtin_popcount(getCounterMask());
|
||||
int dr = setDynamicRange(-1);
|
||||
int dr = 0;
|
||||
getDynamicRange(&dr);
|
||||
return (NCHAN_1_COUNTER * NCHIP * numCounters * ((double)dr / 8.00));
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,12 @@ int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
||||
uint64_t fsize);
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *clientChecksum,
|
||||
ssize_t fsize);
|
||||
ssize_t fsize, int forceDeleteNormalFile);
|
||||
int getDrive(char *mess, enum PROGRAM_INDEX index);
|
||||
/** Notify fpga not to touch flash, open src and flash drive to write */
|
||||
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd);
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int forceDeleteNormalFile);
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile);
|
||||
int eraseFlash(char *mess);
|
||||
/* write from tmp file to flash */
|
||||
int writeToFlash(char *mess, ssize_t fsize, FILE *flashfd, FILE *srcfd);
|
||||
|
@ -97,6 +97,9 @@ u_int32_t getDetectorNumber();
|
||||
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D)
|
||||
int getModuleId(int *ret, char *mess);
|
||||
#endif
|
||||
#if defined(EIGERD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
int updateModuleId();
|
||||
#endif
|
||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D)
|
||||
void setModuleId(int modid);
|
||||
#endif
|
||||
@ -110,7 +113,11 @@ u_int32_t getBoardRevision();
|
||||
void initControlServer();
|
||||
void initStopServer();
|
||||
#ifdef EIGERD
|
||||
void getModuleConfiguration();
|
||||
int updateModuleConfiguration();
|
||||
int getModuleConfiguration(int *m, int *t, int *n);
|
||||
#ifdef VIRTUAL
|
||||
void checkVirtual9MFlag();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// set up detector
|
||||
@ -137,6 +144,10 @@ void setADIFDefaults();
|
||||
#if defined(GOTTHARD2D) || defined(EIGERD) || defined(JUNGFRAUD)
|
||||
int readConfigFile();
|
||||
#endif
|
||||
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
|
||||
defined(MYTHEN3D)
|
||||
int checkCommandLineConfiguration();
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
void resetToHardwareSettings();
|
||||
#endif
|
||||
@ -173,6 +184,7 @@ void setMasterSlaveConfiguration();
|
||||
|
||||
// parameters - dr, roi
|
||||
int setDynamicRange(int dr);
|
||||
int getDynamicRange(int *retval);
|
||||
#ifdef GOTTHARDD
|
||||
int setROI(ROI arg);
|
||||
ROI getROI();
|
||||
@ -362,9 +374,16 @@ int getADC(enum ADCINDEX ind);
|
||||
int setHighVoltage(int val);
|
||||
|
||||
// parameters - timing, extsig
|
||||
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD)
|
||||
int isMaster();
|
||||
#ifdef EIGERD
|
||||
int setMaster(enum MASTERINDEX m);
|
||||
int setTop(enum TOPINDEX t);
|
||||
int isTop(int *retval);
|
||||
#endif
|
||||
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \
|
||||
defined(GOTTHARD2D)
|
||||
int isMaster(int *retval);
|
||||
#endif
|
||||
|
||||
#ifdef GOTTHARD2D
|
||||
void updatingRegisters();
|
||||
#endif
|
||||
|
@ -245,6 +245,7 @@ int get_pattern(int);
|
||||
int load_default_pattern(int);
|
||||
int get_all_threshold_energy(int);
|
||||
int get_master(int);
|
||||
int set_master(int);
|
||||
int get_csr();
|
||||
int set_gain_caps(int);
|
||||
int get_gain_caps(int);
|
||||
@ -284,9 +285,12 @@ int update_detector_server(int);
|
||||
int receive_program(int file_des, enum PROGRAM_INDEX index);
|
||||
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName);
|
||||
char *checksum, char *serverName,
|
||||
int forceDeleteNormalFile);
|
||||
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName);
|
||||
int get_update_mode(int);
|
||||
int set_update_mode(int);
|
||||
int set_update_mode(int);
|
||||
int get_top(int);
|
||||
int set_top(int);
|
@ -7,6 +7,7 @@
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
@ -38,6 +39,9 @@
|
||||
|
||||
#define CMD_GET_AMD_FLASH "dmesg | grep Amd"
|
||||
|
||||
#define CMD_CREATE_DEVICE_FILE_PART1 "mknod"
|
||||
#define CMD_CREATE_DEVICE_FILE_PART2 "c 90 6"
|
||||
|
||||
#define FLASH_BUFFER_MEMORY_SIZE (128 * 1024) // 500 KB
|
||||
// clang-format on
|
||||
|
||||
@ -274,7 +278,8 @@ int allowUpdate(char *mess, char *functionType) {
|
||||
getKernelVersion(retvals);
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. Kernel version %s is too old to "
|
||||
"update the Amd flash/ root directory. Most likely, blackfin needs rescue or replacement. Please contact us.\n",
|
||||
"update the Amd flash/ root directory. Most likely, blackfin "
|
||||
"needs rescue or replacement. Please contact us.\n",
|
||||
functionType, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
@ -319,7 +324,7 @@ int preparetoCopyProgram(char *mess, char *functionType, FILE **fd,
|
||||
|
||||
int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
char *functionType, char *clientChecksum,
|
||||
ssize_t fsize) {
|
||||
ssize_t fsize, int forceDeleteNormalFile) {
|
||||
|
||||
memset(messageType, 0, sizeof(messageType));
|
||||
strcpy(messageType, functionType);
|
||||
@ -330,7 +335,8 @@ int eraseAndWriteToFlash(char *mess, enum PROGRAM_INDEX index,
|
||||
|
||||
FILE *flashfd = NULL;
|
||||
FILE *srcfd = NULL;
|
||||
if (openFileForFlash(mess, &flashfd, &srcfd) == FAIL) {
|
||||
if (openFileForFlash(mess, index, &flashfd, &srcfd, forceDeleteNormalFile) ==
|
||||
FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -434,7 +440,8 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd) {
|
||||
int openFileForFlash(char *mess, enum PROGRAM_INDEX index, FILE **flashfd, FILE **srcfd,
|
||||
int forceDeleteNormalFile) {
|
||||
// open src file
|
||||
*srcfd = fopen(TEMP_PROG_FILE_NAME, "r");
|
||||
if (*srcfd == NULL) {
|
||||
@ -447,6 +454,11 @@ int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd) {
|
||||
}
|
||||
LOG(logDEBUG1, ("Temp file ready for reading\n"));
|
||||
|
||||
if (checkNormalFile(mess, index, forceDeleteNormalFile) == FAIL) {
|
||||
fclose(*srcfd);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// open flash drive for writing
|
||||
*flashfd = fopen(flashDriveName, "w");
|
||||
if (*flashfd == NULL) {
|
||||
@ -462,6 +474,95 @@ int openFileForFlash(char *mess, FILE **flashfd, FILE **srcfd) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int checkNormalFile(char *mess, enum PROGRAM_INDEX index, int forceDeleteNormalFile) {
|
||||
#ifndef VIRTUAL
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
// zero = normal file (not char special drive file)
|
||||
if (!S_ISCHR(buf.st_mode)) {
|
||||
// kernel memory is not permanent
|
||||
if (index != PROGRAM_FPGA) {
|
||||
sprintf(mess,
|
||||
"Could not %s. The flash drive found is a normal file. "
|
||||
"Reboot board using 'rebootcontroller' command to load "
|
||||
"proper device tree\n",
|
||||
messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// user does not allow to fix it (default)
|
||||
if (forceDeleteNormalFile == 0) {
|
||||
sprintf(mess,
|
||||
"Could not %s. The flash drive %s found for fpga programming is a normal file. To "
|
||||
"fix this (by deleting this file, creating the flash drive and proceeding with "
|
||||
"programming), re-run the programming command 'programfpga' with parameter "
|
||||
"'--force-delete-normal-file'\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// fpga memory stays after a reboot, user allowed to fix it
|
||||
LOG(logWARNING, ("Flash drive invalidated (normal file). Fixing it...\n"));
|
||||
|
||||
// user allows to fix it, so force delete normal file
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s", flashDriveName) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess,
|
||||
"Could not update %s. Command to delete normal file %s is "
|
||||
"too long\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not delete normal file %s: %s)\n",
|
||||
messageType, flashDriveName, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDeleted Normal File (%s)\n", flashDriveName));
|
||||
|
||||
// create special drive
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "%s %s %s",
|
||||
CMD_CREATE_DEVICE_FILE_PART1, flashDriveName,
|
||||
CMD_CREATE_DEVICE_FILE_PART2) >= MAX_STR_LENGTH) {
|
||||
sprintf(mess,
|
||||
"Could not update %s. Command to create special file %s is "
|
||||
"too long\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(
|
||||
mess, MAX_STR_LENGTH,
|
||||
"Could not update %s. (could not create special file %s: %s)\n",
|
||||
messageType, flashDriveName, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tSpecial File created (%s)\n", flashDriveName));
|
||||
} else {
|
||||
LOG(logINFO, ("\tValidated flash drive (not a normal file)\n"));
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int eraseFlash(char *mess) {
|
||||
LOG(logINFO, ("\tErasing Flash...\n"));
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* global variables */
|
||||
|
||||
@ -146,6 +147,30 @@ int getDrive(char *mess, enum PROGRAM_INDEX index) {
|
||||
}
|
||||
|
||||
int openFileForFlash(char *mess, FILE **flashfd) {
|
||||
#ifndef VIRTUAL
|
||||
// check if its a normal file or special file
|
||||
struct stat buf;
|
||||
if (stat(flashDriveName, &buf) == -1) {
|
||||
sprintf(mess,
|
||||
"Could not %s. Unable to find the flash drive %s\n",
|
||||
messageType, flashDriveName);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
// zero = normal file (not char drive special file)
|
||||
if (!S_ISCHR(buf.st_mode)) {
|
||||
// memory is not permanent
|
||||
sprintf(mess,
|
||||
"Could not %s. The flash drive found is a normal file. "
|
||||
"Reboot board using 'rebootcontroller' command to load "
|
||||
"proper device tree\n",
|
||||
messageType);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tValidated flash drive (not a normal file)\n"));
|
||||
#endif
|
||||
|
||||
*flashfd = fopen(flashDriveName, "w");
|
||||
if (*flashfd == NULL) {
|
||||
sprintf(mess,
|
||||
|
@ -26,11 +26,19 @@ extern int sockfd;
|
||||
extern int debugflag;
|
||||
extern int updateFlag;
|
||||
extern int checkModuleFlag;
|
||||
extern int ignoreConfigFileFlag;
|
||||
|
||||
// Global variables from slsDetectorFunctionList
|
||||
#ifdef GOTTHARDD
|
||||
extern int phaseShift;
|
||||
#endif
|
||||
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
|
||||
defined(MYTHEN3D)
|
||||
extern int masterCommandLine;
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
extern int topCommandLine;
|
||||
#endif
|
||||
|
||||
void error(char *msg) { perror(msg); }
|
||||
|
||||
@ -48,26 +56,57 @@ int main(int argc, char *argv[]) {
|
||||
updateFlag = 0;
|
||||
checkModuleFlag = 1;
|
||||
int version = 0;
|
||||
ignoreConfigFileFlag = 0;
|
||||
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
|
||||
defined(MYTHEN3D)
|
||||
masterCommandLine = -1;
|
||||
#endif
|
||||
#ifdef EIGERD
|
||||
topCommandLine = -1;
|
||||
#endif
|
||||
|
||||
// help message
|
||||
char helpMessage[MAX_STR_LENGTH];
|
||||
memset(helpMessage, 0, MAX_STR_LENGTH);
|
||||
sprintf(
|
||||
helpMessage,
|
||||
"Usage: %s [arguments]\n"
|
||||
"Possible arguments are:\n"
|
||||
"\t-v, --version : Software version\n"
|
||||
"\t-p, --port <port> : TCP communication port with client. \n"
|
||||
"\t-g, --nomodule : [Mythen3][Gotthard2] Generic or No "
|
||||
"Module mode. Skips detector type checks. \n"
|
||||
"\t-f, --phaseshift <value> : [Gotthard] only. Sets phase shift. \n"
|
||||
"\t-d, --devel : Developer mode. Skips firmware checks. \n"
|
||||
"\t-u, --update : Update mode. Skips firmware checks and "
|
||||
"initial detector setup. \n"
|
||||
"\t-s, --stopserver : Stop server. Do not use as it is created "
|
||||
"by "
|
||||
"control server \n\n",
|
||||
argv[0]);
|
||||
const size_t helpMessageSize = 1200;
|
||||
char helpMessage[helpMessageSize];
|
||||
{
|
||||
memset(helpMessage, 0, helpMessageSize);
|
||||
int len = snprintf(
|
||||
helpMessage, helpMessageSize,
|
||||
"Usage: %s [arguments]\n"
|
||||
"Possible arguments are:\n"
|
||||
"\t-v, --version : Software version\n"
|
||||
"\t-p, --port <port> : TCP communication port with client. "
|
||||
"\n"
|
||||
"\t-g, --nomodule : [Mythen3][Gotthard2] \n"
|
||||
"\t Generic or No Module mode. Skips "
|
||||
"detector type checks. \n"
|
||||
"\t-f, --phaseshift <value> : [Gotthard] only. Sets phase shift. \n"
|
||||
"\t-d, --devel : Developer mode. Skips firmware "
|
||||
"checks. \n"
|
||||
"\t-u, --update : Update mode. Skips firmware checks "
|
||||
"and "
|
||||
"initial detector setup. \n"
|
||||
"\t-i, --ignore-config : "
|
||||
"[Eiger][Jungfrau][Gotthard][Gotthard2] \n"
|
||||
"\t Ignore config file. \n"
|
||||
"\t-m, --master <master> : "
|
||||
"[Eiger][Mythen3][Gotthard][Gotthard2] \n"
|
||||
"\t Set Master to 0 or 1. Precedence "
|
||||
"over "
|
||||
"config file. Only for virtual servers except Eiger. \n"
|
||||
"\t-t, --top <top> : [Eiger] Set Top to 0 or 1. "
|
||||
"Precedence "
|
||||
"over config file. \n"
|
||||
"\t-s, --stopserver : Stop server. Do not use as it is "
|
||||
"created "
|
||||
"by control server \n\n",
|
||||
argv[0]);
|
||||
if (len >= (int)helpMessageSize) {
|
||||
LOG(logERROR, ("Help for Server command line arguments size %d "
|
||||
"exceed capacity of %d characters\n",
|
||||
len, helpMessageSize));
|
||||
}
|
||||
}
|
||||
|
||||
// parse command line for config
|
||||
static struct option long_options[] = {
|
||||
@ -80,6 +119,9 @@ int main(int argc, char *argv[]) {
|
||||
{"nomodule", no_argument, NULL, 'g'}, // generic
|
||||
{"devel", no_argument, NULL, 'd'},
|
||||
{"update", no_argument, NULL, 'u'},
|
||||
{"ignore-config", no_argument, NULL, 'i'},
|
||||
{"master", required_argument, NULL, 'm'},
|
||||
{"top", required_argument, NULL, 't'},
|
||||
{"stopserver", no_argument, NULL, 's'},
|
||||
{NULL, 0, NULL, 0}};
|
||||
|
||||
@ -89,7 +131,8 @@ int main(int argc, char *argv[]) {
|
||||
int c = 0;
|
||||
|
||||
while (c != -1) {
|
||||
c = getopt_long(argc, argv, "hvp:f:gdus", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hvp:f:gduim:t:s", long_options,
|
||||
&option_index);
|
||||
|
||||
// Detect the end of the options
|
||||
if (c == -1)
|
||||
@ -160,6 +203,57 @@ int main(int argc, char *argv[]) {
|
||||
isControlServer = 0;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
#if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \
|
||||
defined(JUNGFRAUD)
|
||||
LOG(logINFO, ("Ignoring config file\n"));
|
||||
ignoreConfigFileFlag = 1;
|
||||
#else
|
||||
LOG(logERROR, ("No server config files for this detector\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
#if (defined(MYTHEN3D) || defined(GOTTHARDD) || defined(GOTTHARD2D)) && \
|
||||
!defined(VIRTUAL)
|
||||
LOG(logERROR, ("Cannot set master via the detector server for this "
|
||||
"detector\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
#elif defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
|
||||
defined(MYTHEN3D)
|
||||
if (sscanf(optarg, "%d", &masterCommandLine) != 1) {
|
||||
LOG(logERROR, ("Cannot scan master argument\n%s", helpMessage));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (masterCommandLine == 1) {
|
||||
LOG(logINFO, ("Detector Master mode\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("Detector Slave mode\n"));
|
||||
}
|
||||
#else
|
||||
LOG(logERROR, ("No master implemented for this detector server\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 't':
|
||||
#ifdef EIGERD
|
||||
if (sscanf(optarg, "%d", &topCommandLine) != 1) {
|
||||
LOG(logERROR, ("Cannot scan top argument\n%s", helpMessage));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (topCommandLine == 1) {
|
||||
LOG(logINFO, ("Detector Top mode\n"));
|
||||
} else {
|
||||
LOG(logINFO, ("Detector Bottom mode\n"));
|
||||
}
|
||||
#else
|
||||
LOG(logERROR, ("No top implemented for this detector server\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
printf("%s", helpMessage);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -54,6 +54,7 @@ int sockfd = 0;
|
||||
int debugflag = 0;
|
||||
int updateFlag = 0;
|
||||
int checkModuleFlag = 1;
|
||||
int ignoreConfigFileFlag = 0;
|
||||
|
||||
udpStruct udpDetails[MAX_UDP_DESTINATION];
|
||||
int numUdpDestinations = 1;
|
||||
@ -468,6 +469,9 @@ void function_table() {
|
||||
flist[F_UPDATE_DETECTOR_SERVER] = &update_detector_server;
|
||||
flist[F_GET_UPDATE_MODE] = &get_update_mode;
|
||||
flist[F_SET_UPDATE_MODE] = &set_update_mode;
|
||||
flist[F_SET_MASTER] = &set_master;
|
||||
flist[F_GET_TOP] = &get_top;
|
||||
flist[F_SET_TOP] = &set_top;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -2815,6 +2819,9 @@ int set_dynamic_range(int file_des) {
|
||||
#endif
|
||||
#if defined(EIGERD) || defined(MYTHEN3D)
|
||||
case 8:
|
||||
#ifdef EIGERD
|
||||
case 12:
|
||||
#endif
|
||||
case 16:
|
||||
case 32:
|
||||
#endif
|
||||
@ -2822,14 +2829,25 @@ int set_dynamic_range(int file_des) {
|
||||
defined(MOENCHD) || defined(GOTTHARD2D)
|
||||
case 16:
|
||||
#endif
|
||||
retval = setDynamicRange(dr);
|
||||
LOG(logDEBUG1, ("Dynamic range: %d\n", retval));
|
||||
if (retval == -1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not get dynamic range.\n");
|
||||
LOG(logERROR, (mess));
|
||||
if (dr >= 0) {
|
||||
ret = setDynamicRange(dr);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set dynamic range to %d\n", dr);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
|
||||
// get
|
||||
if (ret == OK) {
|
||||
ret = getDynamicRange(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get dynamic range\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("Dynamic range: %d\n", retval));
|
||||
validate(&ret, mess, dr, retval, "set dynamic range", DEC);
|
||||
}
|
||||
}
|
||||
validate(&ret, mess, dr, retval, "set dynamic range", DEC);
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("Dynamic range", dr);
|
||||
@ -3977,29 +3995,27 @@ int check_version(int file_des) {
|
||||
return printSocketReadError();
|
||||
|
||||
// check software- firmware compatibility and basic tests
|
||||
if (isControlServer) {
|
||||
LOG(logDEBUG1, ("Checking software-firmware compatibility and basic "
|
||||
"test result\n"));
|
||||
LOG(logDEBUG1, ("Checking software-firmware compatibility and basic "
|
||||
"test result\n"));
|
||||
|
||||
// check if firmware check is done
|
||||
// check if firmware check is done
|
||||
if (!isInitCheckDone()) {
|
||||
usleep(3 * 1000 * 1000);
|
||||
if (!isInitCheckDone()) {
|
||||
usleep(3 * 1000 * 1000);
|
||||
if (!isInitCheckDone()) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Firmware Software Compatibility Check (Server "
|
||||
"Initialization) "
|
||||
"still not done done in server. Unexpected.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Server Initialization still not done done in server. "
|
||||
"Unexpected.\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
// check firmware check result
|
||||
if (ret == OK) {
|
||||
char *firmware_message = NULL;
|
||||
if (getInitResult(&firmware_message) == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, firmware_message);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
|
||||
// check firmware check result
|
||||
if (ret == OK) {
|
||||
char *firmware_message = NULL;
|
||||
if (getInitResult(&firmware_message) == FAIL) {
|
||||
ret = FAIL;
|
||||
strcpy(mess, firmware_message);
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4650,11 +4666,17 @@ int set_read_n_rows(int file_des) {
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
#ifdef EIGERD
|
||||
int dr = setDynamicRange(GET_FLAG);
|
||||
int dr = 0;
|
||||
ret = getDynamicRange(&dr);
|
||||
int isTenGiga = enableTenGigabitEthernet(GET_FLAG);
|
||||
unsigned int maxnl = MAX_ROWS_PER_READOUT;
|
||||
unsigned int maxnp = (isTenGiga ? 4 : 16) * dr;
|
||||
if ((arg * maxnp) % maxnl) {
|
||||
// get dr fail
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess,
|
||||
"Could not read n rows (failed to get dynamic range)\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else if ((arg * maxnp) % maxnl) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not set number of rows to %d. For %d bit "
|
||||
@ -4862,6 +4884,7 @@ int is_udp_configured() {
|
||||
LOG(logWARNING, ("%s", configureMessage));
|
||||
return FAIL;
|
||||
}
|
||||
// virtual: no check (can be eth name: lo, ip: 127.0.0.1)
|
||||
#ifndef VIRTUAL
|
||||
if (udpDetails[i].dstmac == 0) {
|
||||
sprintf(configureMessage,
|
||||
@ -7111,7 +7134,10 @@ int get_receiver_parameters(int file_des) {
|
||||
}
|
||||
|
||||
// dynamic range
|
||||
i32 = setDynamicRange(GET_FLAG);
|
||||
ret = getDynamicRange(&i32);
|
||||
if (ret == FAIL) {
|
||||
i32 = 0;
|
||||
}
|
||||
n += sendData(file_des, &i32, sizeof(i32), INT32);
|
||||
if (n < 0)
|
||||
return printSocketReadError();
|
||||
@ -8193,14 +8219,60 @@ int get_master(int file_des) {
|
||||
|
||||
LOG(logDEBUG1, ("Getting master\n"));
|
||||
|
||||
#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD)
|
||||
#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) && \
|
||||
!defined(GOTTHARD2D)
|
||||
functionNotImplemented();
|
||||
#else
|
||||
retval = isMaster();
|
||||
ret = isMaster(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get master\n");
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_master(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting master: %u\n", (int)arg));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if ((check_detector_idle("set master") == OK) &&
|
||||
(arg != 0 && arg != 1)) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set master. Invalid argument %d.\n", arg);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setMaster(arg == 1 ? OW_MASTER : OW_SLAVE);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not set master\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int retval = 0;
|
||||
ret = isMaster(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get master\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("master retval: %u\n", retval));
|
||||
validate(&ret, mess, arg, retval, "set master", DEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_csr(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
@ -9372,6 +9444,15 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
LOG(logINFO, ("\tServer Name: %s\n", serverName));
|
||||
}
|
||||
|
||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
||||
int forceDeleteNormalFile = 0;
|
||||
if (receiveData(file_des, &forceDeleteNormalFile,
|
||||
sizeof(forceDeleteNormalFile), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logINFO,
|
||||
("\tForce Delete Normal File flag? %s\n", (forceDeleteNormalFile ? "Y" : "N")));
|
||||
#endif
|
||||
|
||||
// in same folder as current process (will also work for virtual then
|
||||
// with write permissions)
|
||||
{
|
||||
@ -9396,7 +9477,7 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
checksum, serverName);
|
||||
#else
|
||||
receive_program_via_blackfin(file_des, index, functionType,
|
||||
filesize, checksum, serverName);
|
||||
filesize, checksum, serverName, forceDeleteNormalFile);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -9412,7 +9493,7 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
||||
|
||||
void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
char *functionType, uint64_t filesize,
|
||||
char *checksum, char *serverName) {
|
||||
char *checksum, char *serverName, int forceDeleteNormalFile) {
|
||||
|
||||
#if !defined(JUNGFRAUD) && !defined(CHIPTESTBOARDD) && !defined(MOENCHD) && \
|
||||
!defined(GOTTHARDD)
|
||||
@ -9511,7 +9592,7 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
case PROGRAM_FPGA:
|
||||
case PROGRAM_KERNEL:
|
||||
ret = eraseAndWriteToFlash(mess, index, functionType, checksum,
|
||||
totalsize);
|
||||
totalsize, forceDeleteNormalFile);
|
||||
break;
|
||||
case PROGRAM_SERVER:
|
||||
ret = moveBinaryFile(mess, serverName, TEMP_PROG_FILE_NAME,
|
||||
@ -9673,5 +9754,71 @@ int set_update_mode(int file_des) {
|
||||
}
|
||||
}
|
||||
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
||||
int get_top(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
LOG(logDEBUG1, ("Getting top\n"));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
ret = isTop(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get Top\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("retval top: %d\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
int set_top(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Setting top : %u\n", arg));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (arg != 0 && arg != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not set top mode. Invalid value: %d. Must be 0 or 1\n",
|
||||
arg);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setTop(arg == 1 ? OW_TOP : OW_BOTTOM);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set %s\n",
|
||||
(arg == 1 ? "Top" : "Bottom"));
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int retval = -1;
|
||||
ret = isTop(&retval);
|
||||
if (ret == FAIL) {
|
||||
strcpy(mess, "Could not get Top mode\n");
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
LOG(logDEBUG1, ("retval top: %d\n", retval));
|
||||
validate(&ret, mess, arg, retval, "set top mode", DEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
@ -7,6 +7,7 @@ set(SOURCES
|
||||
src/CmdProxy.cpp
|
||||
src/CmdParser.cpp
|
||||
src/Pattern.cpp
|
||||
src/CtbConfig.cpp
|
||||
)
|
||||
|
||||
add_library(slsDetectorObject OBJECT
|
||||
|
@ -193,6 +193,12 @@ class Detector {
|
||||
*/
|
||||
void setFlipRows(bool value, Positions pos = {});
|
||||
|
||||
/** [Eiger][Mythen3][Gotthard1] via stop server **/
|
||||
Result<bool> getMaster(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger] Set half module to master and the others to slaves */
|
||||
void setMaster(bool value, int pos);
|
||||
|
||||
Result<bool> isVirtualDetectorServer(Positions pos = {}) const;
|
||||
///@}
|
||||
|
||||
@ -284,7 +290,7 @@ class Detector {
|
||||
Result<int> getDynamicRange(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
* [Eiger] Options: 4, 8, 16, 32. If i is 32, also sets clkdivider to 2,
|
||||
* [Eiger] Options: 4, 8, 12, 16, 32. If i is 32, also sets clkdivider to 2,
|
||||
* else sets clkdivider to 1 \n [Mythen3] Options: 8, 16, 32 \n
|
||||
* [Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16
|
||||
*/
|
||||
@ -586,12 +592,17 @@ class Detector {
|
||||
/** Options: IDLE, TRANSMITTING, RUNNING */
|
||||
Result<defs::runStatus> getReceiverStatus(Positions pos = {}) const;
|
||||
|
||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||
/** Gets the number of frames caught for each port in receiver. */
|
||||
Result<std::vector<int64_t>> getFramesCaught(Positions pos = {}) const;
|
||||
|
||||
/** Gets the number of missing packets for each port in receiver. Negative
|
||||
* number denotes extra packets. */
|
||||
Result<std::vector<int64_t>> getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
/** Gets frame index for each port in receiver. */
|
||||
Result<std::vector<int64_t>>
|
||||
getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][CTB] */
|
||||
Result<uint64_t> getNextFrameNumber(Positions pos = {}) const;
|
||||
|
||||
@ -1151,6 +1162,12 @@ class Detector {
|
||||
void setDataStream(const defs::portPosition port, const bool enable,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Eiger] Advanced */
|
||||
Result<bool> getTop(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger] Advanced. Default is hardware default */
|
||||
void setTop(bool value, Positions pos = {});
|
||||
|
||||
///@}
|
||||
|
||||
/** @name Jungfrau Specific */
|
||||
@ -1448,9 +1465,6 @@ class Detector {
|
||||
* (internal gating). Gate index: 0-2, -1 for all */
|
||||
Result<std::array<ns, 3>> getGateDelayForAllGates(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Mythen3][Gotthard1] via stop server **/
|
||||
Result<bool> getMaster(Positions pos = {}) const;
|
||||
|
||||
// TODO! check if we really want to expose this !!!!!
|
||||
Result<int> getChipStatusRegister(Positions pos = {}) const;
|
||||
|
||||
@ -1599,6 +1613,14 @@ class Detector {
|
||||
|
||||
/** [CTB] Default is enabled. */
|
||||
void setLEDEnable(bool enable, Positions pos = {});
|
||||
|
||||
|
||||
void setDacNames(const std::vector<std::string> names);
|
||||
|
||||
std::vector<std::string> getDacNames() const;
|
||||
|
||||
defs::dacIndex getDacIndex(const std::string& name);
|
||||
std::string getDacName(defs::dacIndex i);
|
||||
///@}
|
||||
|
||||
/** @name Pattern */
|
||||
@ -1733,10 +1755,13 @@ class Detector {
|
||||
/** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2]
|
||||
* Advanced user Function!
|
||||
* Program firmware from command line, after which detector controller is
|
||||
* rebooted. [Jungfrau][CTB][Moench] fname is a pof file (full path) \n
|
||||
* [Mythen3][Gotthard2] fname is an rbf file (full path)
|
||||
* rebooted. forceDeleteNormalFile is true, if normal file found
|
||||
* in device tree, it must be deleted, a new device drive created and
|
||||
* programming continued.[Jungfrau][CTB][Moench] fname is a pof file (full
|
||||
* path) \n [Mythen3][Gotthard2] fname is an rbf file (full path)
|
||||
*/
|
||||
void programFPGA(const std::string &fname, Positions pos = {});
|
||||
void programFPGA(const std::string &fname, const bool forceDeleteNormalFile,
|
||||
Positions pos = {});
|
||||
|
||||
/** [Jungfrau][CTB][Moench] Advanced user Function! */
|
||||
void resetFPGA(Positions pos = {});
|
||||
@ -1902,7 +1927,6 @@ class Detector {
|
||||
*/
|
||||
std::string getUserDetails() const;
|
||||
|
||||
Result<uint64_t> getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
@ -1056,11 +1056,10 @@ std::string CmdProxy::TemperatureValues(int action) {
|
||||
std::string CmdProxy::Dac(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
|
||||
auto type = det->getDetectorType().squash();
|
||||
// dac indices only for ctb
|
||||
if (args.size() > 0 && action != defs::HELP_ACTION) {
|
||||
if (is_int(args[0]) &&
|
||||
det->getDetectorType().squash() != defs::CHIPTESTBOARD) {
|
||||
if (is_int(args[0]) && type != defs::CHIPTESTBOARD) {
|
||||
throw sls::RuntimeError(
|
||||
"Dac indices can only be used for chip test board. Use daclist "
|
||||
"to get list of dac names for current detector.");
|
||||
@ -1077,7 +1076,14 @@ std::string CmdProxy::Dac(int action) {
|
||||
if (args.empty())
|
||||
WrongNumberOfParameters(1); // This prints slightly wrong
|
||||
|
||||
defs::dacIndex dacIndex = StringTo<defs::dacIndex>(args[0]);
|
||||
defs::dacIndex dacIndex{};
|
||||
//TODO! Remove if
|
||||
if (type == defs::CHIPTESTBOARD && !is_int(args[0])) {
|
||||
dacIndex = det->getDacIndex(args[0]);
|
||||
} else {
|
||||
dacIndex = StringTo<defs::dacIndex>(args[0]);
|
||||
}
|
||||
|
||||
bool mV = false;
|
||||
|
||||
if (args.size() == 2) {
|
||||
@ -1095,7 +1101,11 @@ std::string CmdProxy::Dac(int action) {
|
||||
if (args.empty())
|
||||
WrongNumberOfParameters(1); // This prints slightly wrong
|
||||
|
||||
defs::dacIndex dacIndex = StringTo<defs::dacIndex>(args[0]);
|
||||
defs::dacIndex dacIndex{};
|
||||
if (type == defs::CHIPTESTBOARD && !is_int(args[0]))
|
||||
dacIndex = det->getDacIndex(args[0]);
|
||||
else
|
||||
dacIndex = StringTo<defs::dacIndex>(args[0]);
|
||||
bool mV = false;
|
||||
if (args.size() == 3) {
|
||||
if ((args[2] != "mv") && (args[2] != "mV")) {
|
||||
@ -1115,6 +1125,41 @@ std::string CmdProxy::Dac(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DacList(const int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == slsDetectorDefs::HELP_ACTION) {
|
||||
os << "\n\t[dacname1 dacname2 .. dacname18] \n\t\t[ChipTestBoard] Set "
|
||||
"the list of dac names for this detector.\n\t\t[All] Gets the "
|
||||
"list "
|
||||
"of "
|
||||
"dac names for every dac for this detector."
|
||||
<< '\n';
|
||||
} else if (action == slsDetectorDefs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getDacNames();
|
||||
os << sls::ToString(t) << '\n';
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) {
|
||||
if (det->getDetectorType().squash() != defs::CHIPTESTBOARD) {
|
||||
throw sls::RuntimeError("This detector already has fixed dac "
|
||||
"names. Cannot change them.");
|
||||
}
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot configure dacnames at module level");
|
||||
}
|
||||
if (args.size() != 18) {
|
||||
WrongNumberOfParameters(18);
|
||||
}
|
||||
det->setDacNames(args);
|
||||
os << ToString(args) << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::DacValues(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -1134,13 +1179,15 @@ std::string CmdProxy::DacValues(int action) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
auto t = det->getDacList();
|
||||
auto names = det->getDacNames();
|
||||
auto name_it = names.begin();
|
||||
os << '[';
|
||||
auto it = t.cbegin();
|
||||
os << ToString(*it) << ' ';
|
||||
os << ToString(*name_it++) << ' ';
|
||||
os << OutString(det->getDAC(*it++, mv, std::vector<int>{det_id}))
|
||||
<< (!args.empty() ? " mV" : "");
|
||||
while (it != t.cend()) {
|
||||
os << ", " << ToString(*it) << ' ';
|
||||
os << ", " << ToString(*name_it++) << ' ';
|
||||
os << OutString(det->getDAC(*it++, mv, std::vector<int>{det_id}))
|
||||
<< (!args.empty() ? " mV" : "");
|
||||
}
|
||||
@ -1274,40 +1321,6 @@ std::string CmdProxy::DetectorStatus(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::RxMissingPackets(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "Number of missing packets for each port in receiver. If "
|
||||
"negative, they are packets in excess. "
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto mp = det->getNumMissingPackets(std::vector<int>{det_id});
|
||||
/*
|
||||
auto tmp = det->getNumMissingPackets(std::vector<int>{det_id});
|
||||
// convert to signed missing packets (to get excess)
|
||||
Result<std::vector<int64_t>> mp(tmp.size());
|
||||
for (unsigned int i = 0; i < mp.size(); ++i) {
|
||||
mp[i] = static_cast<int64_t>(tmp[i]);
|
||||
}
|
||||
OR
|
||||
Result<std::vector<int64_t>> tmp;
|
||||
for (auto val : tmp) {
|
||||
mp.push_back(static_cast<int64_t>(val));
|
||||
}
|
||||
*/
|
||||
os << OutString(mp) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::Scan(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
@ -2866,19 +2879,31 @@ std::string CmdProxy::ProgramFpga(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[fname.pof | fname.rbf (full path)]\n\t[Jungfrau][Ctb][Moench] "
|
||||
"Programs FPGA from pof file (full path). Then, detector "
|
||||
"controller is rebooted \n\t[Mythen3][Gotthard2] Programs FPGA "
|
||||
"from rbf file (full path). Then, detector controller is "
|
||||
"rebooted."
|
||||
os << "[fname.pof | fname.rbf (full "
|
||||
"path)][(opitonal)--force-delete-normal-file]\n\t[Jungfrau][Ctb]["
|
||||
"Moench] Programs FPGA from pof file (full path). Then, detector "
|
||||
"controller is rebooted. \n\t\tUse --force-delete-normal-file "
|
||||
"argument, if normal file found in device tree, it must be "
|
||||
"deleted, a new device drive created and programming "
|
||||
"continued.\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file "
|
||||
"(full path). Then, detector controller is rebooted."
|
||||
<< '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
bool forceDeteleNormalFile = false;
|
||||
if (args.size() == 2) {
|
||||
if (args[1] != "--force-delete-normal-file") {
|
||||
throw sls::RuntimeError(
|
||||
"Could not scan second argument. Did you "
|
||||
"mean --force-delete-normal-file?");
|
||||
}
|
||||
forceDeteleNormalFile = true;
|
||||
} else if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->programFPGA(args[0], std::vector<int>{det_id});
|
||||
det->programFPGA(args[0], forceDeteleNormalFile,
|
||||
std::vector<int>{det_id});
|
||||
os << "successful\n";
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -784,6 +784,7 @@ class CmdProxy {
|
||||
{"trimen", &CmdProxy::TrimEnergies},
|
||||
{"gappixels", &CmdProxy::GapPixels},
|
||||
{"fliprows", &CmdProxy::fliprows},
|
||||
{"master", &CmdProxy::master},
|
||||
|
||||
/* acquisition parameters */
|
||||
{"acquire", &CmdProxy::Acquire},
|
||||
@ -836,7 +837,7 @@ class CmdProxy {
|
||||
|
||||
/* dacs */
|
||||
{"dac", &CmdProxy::Dac},
|
||||
{"daclist", &CmdProxy::daclist},
|
||||
{"daclist", &CmdProxy::DacList},
|
||||
{"dacvalues", &CmdProxy::DacValues},
|
||||
{"resetdacs", &CmdProxy::ResetDacs},
|
||||
{"defaultdac", &CmdProxy::DefaultDac},
|
||||
@ -859,7 +860,8 @@ class CmdProxy {
|
||||
{"rx_status", &CmdProxy::ReceiverStatus},
|
||||
{"status", &CmdProxy::DetectorStatus},
|
||||
{"rx_framescaught", &CmdProxy::rx_framescaught},
|
||||
{"rx_missingpackets", &CmdProxy::RxMissingPackets},
|
||||
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
||||
{"rx_frameindex", &CmdProxy::rx_frameindex},
|
||||
{"nextframenumber", &CmdProxy::nextframenumber},
|
||||
{"trigger", &CmdProxy::Trigger},
|
||||
{"scan", &CmdProxy::Scan},
|
||||
@ -942,6 +944,7 @@ class CmdProxy {
|
||||
{"pulsechip", &CmdProxy::PulseChip},
|
||||
{"quad", &CmdProxy::Quad},
|
||||
{"datastream", &CmdProxy::DataStream},
|
||||
{"top", &CmdProxy::top},
|
||||
|
||||
/* Jungfrau Specific */
|
||||
{"chipversion", &CmdProxy::chipversion},
|
||||
@ -1084,8 +1087,7 @@ class CmdProxy {
|
||||
{"framecounter", &CmdProxy::framecounter},
|
||||
{"runtime", &CmdProxy::runtime},
|
||||
{"frametime", &CmdProxy::frametime},
|
||||
{"user", &CmdProxy::UserDetails},
|
||||
{"rx_frameindex", &CmdProxy::rx_frameindex}
|
||||
{"user", &CmdProxy::UserDetails}
|
||||
|
||||
};
|
||||
|
||||
@ -1109,7 +1111,6 @@ class CmdProxy {
|
||||
/* acquisition parameters */
|
||||
std::string Acquire(int action);
|
||||
std::string Exptime(int action);
|
||||
std::string DynamicRange(int action);
|
||||
std::string ReadoutSpeed(int action);
|
||||
std::string Adcphase(int action);
|
||||
std::string Dbitphase(int action);
|
||||
@ -1123,6 +1124,7 @@ class CmdProxy {
|
||||
std::string TemperatureValues(int action);
|
||||
/* dacs */
|
||||
std::string Dac(int action);
|
||||
std::string DacList(int action);
|
||||
std::string DacValues(int action);
|
||||
std::string ResetDacs(int action);
|
||||
std::string DefaultDac(int action);
|
||||
@ -1281,6 +1283,12 @@ class CmdProxy {
|
||||
"interfaces must be set to 2. slsReceiver and slsDetectorGui "
|
||||
"does not handle.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID_GET(
|
||||
master, getMaster, setMaster, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Sets half module to master and "
|
||||
"others to slaves.\n\t[Gotthard][Gotthard2][Mythen3][Eiger] "
|
||||
"Gets if the current module/ half module is master.");
|
||||
|
||||
/* acquisition parameters */
|
||||
|
||||
INTEGER_COMMAND_SET_NOID_GET_ID(
|
||||
@ -1328,7 +1336,7 @@ class CmdProxy {
|
||||
dr, getDynamicRange, setDynamicRange, StringTo<int>,
|
||||
"[value]\n\tDynamic Range or number of bits per "
|
||||
"pixel in detector.\n\t"
|
||||
"[Eiger] Options: 4, 8, 16, 32. If set to 32, also sets "
|
||||
"[Eiger] Options: 4, 8, 12, 16, 32. If set to 32, also sets "
|
||||
"clkdivider to 2, else to 0.\n\t"
|
||||
"[Mythen3] Options: 8, 16, 32\n\t"
|
||||
"[Jungfrau][Gotthard][Ctb][Moench][Mythen3][Gotthard2] 16");
|
||||
@ -1458,10 +1466,6 @@ class CmdProxy {
|
||||
|
||||
/* dacs */
|
||||
|
||||
GET_COMMAND_NOID(
|
||||
daclist, getDacList,
|
||||
"\n\tGets the list of commands for every dac for this detector.");
|
||||
|
||||
/* on chip dacs */
|
||||
INTEGER_USER_IND_COMMAND(
|
||||
vchip_comp_fe, getOnChipDAC, setOnChipDAC, StringTo<int>,
|
||||
@ -1533,11 +1537,15 @@ class CmdProxy {
|
||||
"to IDLE or STOPPED. Goes to stop server.");
|
||||
|
||||
GET_COMMAND(rx_framescaught, getFramesCaught,
|
||||
"\n\tNumber of frames caught by receiver.");
|
||||
"\n\tNumber of frames caught by each port in receiver.");
|
||||
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver. "
|
||||
"Negative number denotes extra packets.");
|
||||
"\n\tNumber of missing packets for each port in receiver. If "
|
||||
"negative, they are packets in excess. ");
|
||||
|
||||
GET_COMMAND(rx_frameindex, getRxCurrentFrameIndex,
|
||||
"\n\tCurrent frame index received for each port in receiver "
|
||||
"during acquisition.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
nextframenumber, getNextFrameNumber, setNextFrameNumber,
|
||||
@ -1901,6 +1909,10 @@ class CmdProxy {
|
||||
"start of acquisition. 0 complete reset, 1 partial reset. Default is "
|
||||
"complete reset. Advanced function!");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
top, getTop, setTop, StringTo<int>,
|
||||
"[0, 1]\n\t[Eiger] Sets half module to top (1), else bottom.");
|
||||
|
||||
/* Jungfrau Specific */
|
||||
|
||||
GET_COMMAND(chipversion, getChipVersion,
|
||||
@ -2251,10 +2263,6 @@ class CmdProxy {
|
||||
"ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench]["
|
||||
"CTB] Timestamp at a frame start."
|
||||
"\n\t[Gotthard2] not in burst and auto mode.");
|
||||
|
||||
GET_COMMAND(
|
||||
rx_frameindex, getRxCurrentFrameIndex,
|
||||
"\n\tCurrent frame index received in receiver during acquisition.");
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
72
slsDetectorSoftware/src/CtbConfig.cpp
Normal file
72
slsDetectorSoftware/src/CtbConfig.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
#include "CtbConfig.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/string_utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
namespace sls {
|
||||
|
||||
CtbConfig::CtbConfig(){
|
||||
for (size_t i=0; i!=num_dacs; ++i){
|
||||
setDacName(i, "dac"+ToString(i));
|
||||
}
|
||||
}
|
||||
|
||||
void CtbConfig::check_index(size_t i) const {
|
||||
if (!(i < num_dacs)) {
|
||||
std::ostringstream oss;
|
||||
oss << "DAC index is too large needs to be below " << num_dacs;
|
||||
throw RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void CtbConfig::check_size(const std::string &name) const {
|
||||
|
||||
if (name.empty())
|
||||
throw RuntimeError("Name needs to be at least one character");
|
||||
|
||||
// dacname_length -1 to account for \0 termination
|
||||
if (!(name.size() < (name_length - 1))) {
|
||||
std::ostringstream oss;
|
||||
oss << "Length of name needs to be less than " << name_length - 1
|
||||
<< " chars";
|
||||
throw RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
void CtbConfig::setDacName(size_t index, const std::string &name) {
|
||||
|
||||
check_index(index);
|
||||
check_size(name);
|
||||
|
||||
char *dst = &dacnames[index * name_length];
|
||||
memset(dst, '\0', name_length);
|
||||
memcpy(dst, &name[0], name.size());
|
||||
}
|
||||
|
||||
void CtbConfig::setDacNames(const std::vector<std::string>& names){
|
||||
for (size_t i = 0; i!=num_dacs; ++i){
|
||||
setDacName(i, names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CtbConfig::getDacName(size_t index) const {
|
||||
return dacnames + index * name_length;
|
||||
}
|
||||
|
||||
std::vector<std::string> CtbConfig::getDacNames() const {
|
||||
std::vector<std::string> names;
|
||||
for (size_t i = 0; i != num_dacs; ++i)
|
||||
names.push_back(getDacName(i));
|
||||
return names;
|
||||
}
|
||||
|
||||
const char* CtbConfig::shm_tag(){
|
||||
return shm_tag_;
|
||||
}
|
||||
|
||||
} // namespace sls
|
31
slsDetectorSoftware/src/CtbConfig.h
Normal file
31
slsDetectorSoftware/src/CtbConfig.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
namespace sls {
|
||||
|
||||
|
||||
class CtbConfig {
|
||||
static constexpr size_t name_length = 20;
|
||||
static constexpr size_t num_dacs = 18;
|
||||
static constexpr const char* shm_tag_ = "ctbdacs";
|
||||
char dacnames[name_length * num_dacs]{};
|
||||
|
||||
void check_index(size_t i) const;
|
||||
void check_size(const std::string &name) const;
|
||||
|
||||
public:
|
||||
CtbConfig();
|
||||
CtbConfig(const CtbConfig&) = default;
|
||||
CtbConfig(CtbConfig&&) = default;
|
||||
CtbConfig& operator=(const CtbConfig&) = default;
|
||||
~CtbConfig() = default;
|
||||
|
||||
void setDacNames(const std::vector<std::string> &names);
|
||||
void setDacName(size_t index, const std::string &name);
|
||||
std::string getDacName(size_t index) const;
|
||||
std::vector<std::string> getDacNames() const;
|
||||
static const char* shm_tag();
|
||||
};
|
||||
|
||||
|
||||
} // namespace sls
|
@ -7,6 +7,7 @@
|
||||
#include "CmdProxy.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "CtbConfig.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
@ -21,6 +22,7 @@
|
||||
namespace sls {
|
||||
|
||||
void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
||||
|
||||
// single module
|
||||
if (moduleIndex >= 0) {
|
||||
SharedMemory<sharedModule> moduleShm(detectorIndex, moduleIndex);
|
||||
@ -44,6 +46,11 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
|
||||
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
||||
moduleShm.RemoveSharedMemory();
|
||||
}
|
||||
|
||||
// Ctb configuration
|
||||
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
||||
if (ctbShm.IsExisting())
|
||||
ctbShm.RemoveSharedMemory();
|
||||
}
|
||||
|
||||
using defs = slsDetectorDefs;
|
||||
@ -298,6 +305,23 @@ void Detector::setFlipRows(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setFlipRows, pos, value);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getMaster(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::isMaster, pos);
|
||||
}
|
||||
|
||||
void Detector::setMaster(bool master, int pos) {
|
||||
// multi mod, set slaves first
|
||||
if (master && size() > 1) {
|
||||
if (pos == -1) {
|
||||
throw RuntimeError("Master can be set only to a single module");
|
||||
}
|
||||
pimpl->Parallel(&Module::setMaster, {}, false);
|
||||
pimpl->Parallel(&Module::setMaster, {pos}, master);
|
||||
} else {
|
||||
pimpl->Parallel(&Module::setMaster, {pos}, master);
|
||||
}
|
||||
}
|
||||
|
||||
Result<bool> Detector::isVirtualDetectorServer(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::isVirtualDetectorServer, pos);
|
||||
}
|
||||
@ -387,7 +411,7 @@ void Detector::setDynamicRange(int value) {
|
||||
std::vector<int> Detector::getDynamicRangeList() const {
|
||||
switch (getDetectorType().squash()) {
|
||||
case defs::EIGER:
|
||||
return std::vector<int>{4, 8, 16, 32};
|
||||
return std::vector<int>{4, 8, 12, 16, 32};
|
||||
case defs::MYTHEN3:
|
||||
return std::vector<int>{8, 16, 32};
|
||||
default:
|
||||
@ -783,6 +807,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 {
|
||||
@ -793,7 +836,7 @@ Result<defs::runStatus> Detector::getReceiverStatus(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverStatus, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
Result<std::vector<int64_t>> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
@ -802,6 +845,11 @@ Detector::getNumMissingPackets(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
||||
}
|
||||
|
||||
Result<std::vector<int64_t>>
|
||||
Detector::getRxCurrentFrameIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverCurrentFrameIndex, pos);
|
||||
}
|
||||
|
||||
Result<uint64_t> Detector::getNextFrameNumber(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNextFrameNumber, pos);
|
||||
}
|
||||
@ -835,7 +883,7 @@ Result<std::string> Detector::getScanErrorMessage(Positions pos) const {
|
||||
|
||||
Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
||||
// also called by vetostream (for gotthard2)
|
||||
return pimpl->getNumberofUDPInterfaces(pos);
|
||||
return pimpl->Parallel(&Module::getNumberofUDPInterfacesFromShm, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
|
||||
@ -1488,6 +1536,14 @@ void Detector::setDataStream(const defs::portPosition port, const bool enable,
|
||||
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getTop(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getTop, pos);
|
||||
}
|
||||
|
||||
void Detector::setTop(bool value, Positions pos) {
|
||||
pimpl->Parallel(&Module::setTop, pos, value);
|
||||
}
|
||||
|
||||
// Jungfrau Specific
|
||||
Result<double> Detector::getChipVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getChipVersion, pos);
|
||||
@ -1563,7 +1619,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.");
|
||||
}
|
||||
@ -1696,7 +1751,7 @@ Result<defs::streamingInterface> Detector::getVetoStream(Positions pos) const {
|
||||
// 3gbe
|
||||
auto r3 = pimpl->Parallel(&Module::getVetoStream, pos);
|
||||
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
||||
auto r10 = pimpl->getNumberofUDPInterfaces(pos);
|
||||
auto r10 = getNumberofUDPInterfaces(pos);
|
||||
|
||||
Result<defs::streamingInterface> res(r3.size());
|
||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||
@ -1718,7 +1773,7 @@ void Detector::setVetoStream(defs::streamingInterface interface,
|
||||
pimpl->Parallel(&Module::setVetoStream, pos, LOW_LATENCY_LINK);
|
||||
|
||||
// 10gbe (debugging interface) opens 2nd udp interface in receiver
|
||||
int old_numinterfaces = pimpl->getNumberofUDPInterfaces(pos).tsquash(
|
||||
int old_numinterfaces = getNumberofUDPInterfaces(pos).tsquash(
|
||||
"retrieved inconsistent number of udp interfaces");
|
||||
int numinterfaces =
|
||||
(((interface & defs::streamingInterface::ETHERNET_10GB) ==
|
||||
@ -1808,10 +1863,6 @@ Detector::getGateDelayForAllGates(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getGateDelayForAllGates, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getMaster(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::isMaster, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getChipStatusRegister(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getChipStatusRegister, pos);
|
||||
}
|
||||
@ -2023,6 +2074,42 @@ void Detector::setLEDEnable(bool enable, Positions pos) {
|
||||
pimpl->Parallel(&Module::setLEDEnable, pos, enable);
|
||||
}
|
||||
|
||||
void Detector::setDacNames(const std::vector<std::string> names) {
|
||||
if (getDetectorType().squash() != defs::CHIPTESTBOARD)
|
||||
throw RuntimeError("Named dacs only for CTB");
|
||||
pimpl->setCtbDacNames(names);
|
||||
}
|
||||
|
||||
std::vector<std::string> Detector::getDacNames() const {
|
||||
std::vector<std::string> names;
|
||||
auto type = getDetectorType().squash();
|
||||
if (type == defs::CHIPTESTBOARD)
|
||||
return pimpl->getCtbDacNames();
|
||||
|
||||
for (const auto &index : getDacList())
|
||||
names.push_back(ToString(index));
|
||||
return names;
|
||||
}
|
||||
|
||||
defs::dacIndex Detector::getDacIndex(const std::string &name) {
|
||||
auto type = getDetectorType().squash();
|
||||
if (type == defs::CHIPTESTBOARD) {
|
||||
auto names = getDacNames();
|
||||
auto it = std::find(names.begin(), names.end(), name);
|
||||
if (it == names.end())
|
||||
throw RuntimeError("Dacname not found");
|
||||
return static_cast<defs::dacIndex>(it - names.begin());
|
||||
}
|
||||
return StringTo<defs::dacIndex>(name);
|
||||
}
|
||||
|
||||
std::string Detector::getDacName(defs::dacIndex i) {
|
||||
auto type = getDetectorType().squash();
|
||||
if (type == defs::CHIPTESTBOARD)
|
||||
return pimpl->getCtbDacName(i);
|
||||
return ToString(i);
|
||||
}
|
||||
|
||||
// Pattern
|
||||
|
||||
void Detector::setPattern(const std::string &fname, Positions pos) {
|
||||
@ -2143,10 +2230,11 @@ void Detector::setAdditionalJsonParameter(const std::string &key,
|
||||
|
||||
// Advanced
|
||||
|
||||
void Detector::programFPGA(const std::string &fname, Positions pos) {
|
||||
void Detector::programFPGA(const std::string &fname,
|
||||
const bool forceDeleteNormalFile, Positions pos) {
|
||||
LOG(logINFO) << "Updating Firmware...";
|
||||
std::vector<char> buffer = pimpl->readProgrammingFile(fname);
|
||||
pimpl->Parallel(&Module::programFPGA, pos, buffer);
|
||||
pimpl->Parallel(&Module::programFPGA, pos, buffer, forceDeleteNormalFile);
|
||||
rebootController(pos);
|
||||
}
|
||||
|
||||
@ -2191,7 +2279,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
LOG(logINFO) << "Updating Firmware and Detector Server (with tftp)...";
|
||||
LOG(logINFO) << "Updating Detector Server (via tftp)...";
|
||||
pimpl->Parallel(&Module::copyDetectorServer, pos, sname, hostname);
|
||||
programFPGA(fname, pos);
|
||||
programFPGA(fname, false, pos);
|
||||
}
|
||||
|
||||
void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
@ -2202,7 +2290,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
|
||||
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
|
||||
std::string filename = sls::getFileNameFromFilePath(sname);
|
||||
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
|
||||
programFPGA(fname, pos);
|
||||
programFPGA(fname, false, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getUpdateMode(Positions pos) const {
|
||||
@ -2311,12 +2399,8 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
||||
Result<uint64_t> Detector::getRxCurrentFrameIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverCurrentFrameIndex, pos);
|
||||
}
|
||||
|
||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
||||
int num_sockets_per_detector = pimpl->getNumberofUDPInterfaces({}).tsquash(
|
||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||
"Number of UDP Interfaces is not consistent among modules");
|
||||
std::vector<int> res;
|
||||
res.reserve(size());
|
||||
|
@ -32,7 +32,8 @@
|
||||
namespace sls {
|
||||
|
||||
DetectorImpl::DetectorImpl(int detector_index, bool verify, bool update)
|
||||
: detectorIndex(detector_index), shm(detector_index, -1) {
|
||||
: detectorIndex(detector_index), shm(detector_index, -1),
|
||||
ctb_shm(detector_index, -1, CtbConfig::shm_tag()) {
|
||||
setupDetector(verify, update);
|
||||
}
|
||||
|
||||
@ -44,6 +45,9 @@ void DetectorImpl::setupDetector(bool verify, bool update) {
|
||||
if (update) {
|
||||
updateUserdetails();
|
||||
}
|
||||
|
||||
if (ctb_shm.IsExisting())
|
||||
ctb_shm.OpenSharedMemory();
|
||||
}
|
||||
|
||||
void DetectorImpl::setAcquiringFlag(bool flag) { shm()->acquiringFlag = flag; }
|
||||
@ -74,6 +78,10 @@ void DetectorImpl::freeSharedMemory(int detectorIndex, int detPos) {
|
||||
SharedMemory<sharedModule> moduleShm(detectorIndex, i);
|
||||
moduleShm.RemoveSharedMemory();
|
||||
}
|
||||
|
||||
SharedMemory<CtbConfig> ctbShm(detectorIndex, -1, CtbConfig::shm_tag());
|
||||
if (ctbShm.IsExisting())
|
||||
ctbShm.RemoveSharedMemory();
|
||||
}
|
||||
|
||||
void DetectorImpl::freeSharedMemory() {
|
||||
@ -86,6 +94,9 @@ void DetectorImpl::freeSharedMemory() {
|
||||
// clear detector shm
|
||||
shm.RemoveSharedMemory();
|
||||
client_downstream = false;
|
||||
|
||||
if (ctb_shm.IsExisting())
|
||||
ctb_shm.RemoveSharedMemory();
|
||||
}
|
||||
|
||||
std::string DetectorImpl::getUserDetails() {
|
||||
@ -246,13 +257,14 @@ void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
||||
}
|
||||
updateDetectorSize();
|
||||
|
||||
// update zmq port (especially for eiger)
|
||||
int numInterfaces = modules[0]->getNumberofUDPInterfaces();
|
||||
if (numInterfaces == 2) {
|
||||
for (size_t i = 0; i < modules.size(); ++i) {
|
||||
modules[i]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
|
||||
i * numInterfaces);
|
||||
}
|
||||
// Here we know the detector type and can add ctb shared memory
|
||||
// if needed, CTB dac names are only on detector level
|
||||
|
||||
if (shm()->detType == defs::CHIPTESTBOARD) {
|
||||
if (ctb_shm.IsExisting())
|
||||
ctb_shm.OpenSharedMemory();
|
||||
else
|
||||
ctb_shm.CreateSharedMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,6 +293,13 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
||||
|
||||
// get type by connecting
|
||||
detectorType type = Module::getTypeFromDetector(host, port);
|
||||
|
||||
// gotthard cannot have more than 2 modules (50um=1, 25um=2
|
||||
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
|
||||
freeSharedMemory();
|
||||
throw sls::RuntimeError("Gotthard cannot have more than 2 modules");
|
||||
}
|
||||
|
||||
auto pos = modules.size();
|
||||
modules.emplace_back(
|
||||
sls::make_unique<Module>(type, detectorIndex, pos, false));
|
||||
@ -288,11 +307,20 @@ void DetectorImpl::addModule(const std::string &hostname) {
|
||||
modules[pos]->setControlPort(port);
|
||||
modules[pos]->setStopPort(port + 1);
|
||||
modules[pos]->setHostname(host, shm()->initialChecks);
|
||||
|
||||
// module type updated by now
|
||||
shm()->detType = Parallel(&Module::getDetectorType, {})
|
||||
.tsquash("Inconsistent detector types.");
|
||||
// for moench and ctb
|
||||
modules[pos]->updateNumberOfChannels();
|
||||
|
||||
// for eiger, jungfrau, gotthard2
|
||||
modules[pos]->updateNumberofUDPInterfaces();
|
||||
|
||||
// update zmq port in case numudpinterfaces changed
|
||||
int numInterfaces = modules[pos]->getNumberofUDPInterfacesFromShm();
|
||||
modules[pos]->setClientStreamingPort(DEFAULT_ZMQ_CL_PORTNO +
|
||||
pos * numInterfaces);
|
||||
}
|
||||
|
||||
void DetectorImpl::updateDetectorSize() {
|
||||
@ -1142,7 +1170,7 @@ int DetectorImpl::acquire() {
|
||||
if (acquisition_finished != nullptr) {
|
||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||
double progress = (*std::min_element(a.begin(), a.end()));
|
||||
double progress = (*std::max_element(a.begin(), a.end()));
|
||||
acquisition_finished(progress, status, acqFinished_p);
|
||||
}
|
||||
|
||||
@ -1361,10 +1389,6 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
sls::Result<int> DetectorImpl::getNumberofUDPInterfaces(Positions pos) const {
|
||||
return Parallel(&Module::getNumberofUDPInterfaces, pos);
|
||||
}
|
||||
|
||||
sls::Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
|
||||
defs::detectorSettings sett,
|
||||
Positions pos) {
|
||||
@ -1376,4 +1400,16 @@ void DetectorImpl::setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
Parallel(&Module::setDefaultDac, pos, index, defaultValue, sett);
|
||||
}
|
||||
|
||||
std::vector<std::string> DetectorImpl::getCtbDacNames() const {
|
||||
return ctb_shm()->getDacNames();
|
||||
}
|
||||
|
||||
void DetectorImpl::setCtbDacNames(const std::vector<std::string> &names) {
|
||||
ctb_shm()->setDacNames(names);
|
||||
}
|
||||
|
||||
std::string DetectorImpl::getCtbDacName(defs::dacIndex i) const {
|
||||
return ctb_shm()->getDacName(static_cast<int>(i));
|
||||
}
|
||||
|
||||
} // namespace sls
|
@ -7,6 +7,8 @@
|
||||
#include "sls/logger.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
|
||||
#include "CtbConfig.h"
|
||||
class ZmqSocket;
|
||||
class detectorData;
|
||||
|
||||
@ -291,7 +293,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
*/
|
||||
std::vector<char> readProgrammingFile(const std::string &fname);
|
||||
|
||||
sls::Result<int> getNumberofUDPInterfaces(Positions pos) const;
|
||||
void setNumberofUDPInterfaces(int n, Positions pos);
|
||||
sls::Result<int> getDefaultDac(defs::dacIndex index,
|
||||
defs::detectorSettings sett,
|
||||
@ -299,6 +300,11 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
void setDefaultDac(defs::dacIndex index, int defaultValue,
|
||||
defs::detectorSettings sett, Positions pos);
|
||||
|
||||
|
||||
std::vector<std::string> getCtbDacNames() const;
|
||||
std::string getCtbDacName(defs::dacIndex i) const;
|
||||
void setCtbDacNames(const std::vector<std::string>& names);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Creates/open shared memory, initializes detector structure and members
|
||||
@ -382,6 +388,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
|
||||
const int detectorIndex{0};
|
||||
sls::SharedMemory<sharedDetector> shm{0, -1};
|
||||
sls::SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
|
||||
std::vector<std::unique_ptr<sls::Module>> modules;
|
||||
|
||||
/** data streaming (down stream) enabled in client (zmq sckets created) */
|
||||
|
@ -509,6 +509,13 @@ void Module::setFlipRows(bool value) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Module::isMaster() const { return sendToDetectorStop<int>(F_GET_MASTER); }
|
||||
|
||||
void Module::setMaster(const bool master) {
|
||||
sendToDetector(F_SET_MASTER, static_cast<int>(master), nullptr);
|
||||
sendToDetectorStop(F_SET_MASTER, static_cast<int>(master), nullptr);
|
||||
}
|
||||
|
||||
bool Module::isVirtualDetectorServer() const {
|
||||
return sendToDetector<int>(F_IS_VIRTUAL);
|
||||
}
|
||||
@ -866,8 +873,26 @@ double Module::getReceiverProgress() const {
|
||||
return sendToReceiver<double>(F_GET_RECEIVER_PROGRESS);
|
||||
}
|
||||
|
||||
int64_t Module::getFramesCaughtByReceiver() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
std::vector<int64_t> Module::getFramesCaughtByReceiver() const {
|
||||
// TODO!(Erik) Refactor
|
||||
LOG(logDEBUG1) << "Getting frames caught";
|
||||
if (shm()->useReceiverFlag) {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
"Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
std::vector<int64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Frames caught of Receiver" << moduleIndex << ": "
|
||||
<< sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
throw RuntimeError("No receiver to get frames caught.");
|
||||
}
|
||||
|
||||
std::vector<int64_t> Module::getNumMissingPackets() const {
|
||||
@ -892,6 +917,28 @@ std::vector<int64_t> Module::getNumMissingPackets() const {
|
||||
throw RuntimeError("No receiver to get missing packets.");
|
||||
}
|
||||
|
||||
std::vector<int64_t> Module::getReceiverCurrentFrameIndex() const {
|
||||
// TODO!(Erik) Refactor
|
||||
LOG(logDEBUG1) << "Getting frame index";
|
||||
if (shm()->useReceiverFlag) {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_RECEIVER_FRAME_INDEX);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
"Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
std::vector<int64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Frame index of Receiver" << moduleIndex << ": "
|
||||
<< sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
throw RuntimeError("No receiver to get frame index.");
|
||||
}
|
||||
|
||||
uint64_t Module::getNextFrameNumber() const {
|
||||
return sendToDetector<uint64_t>(F_GET_NEXT_FRAME_NUMBER);
|
||||
}
|
||||
@ -929,9 +976,8 @@ int Module::getNumberofUDPInterfacesFromShm() const {
|
||||
return shm()->numUDPInterfaces;
|
||||
}
|
||||
|
||||
int Module::getNumberofUDPInterfaces() const {
|
||||
void Module::updateNumberofUDPInterfaces() {
|
||||
shm()->numUDPInterfaces = sendToDetector<int>(F_GET_NUM_INTERFACES);
|
||||
return shm()->numUDPInterfaces;
|
||||
}
|
||||
|
||||
void Module::setNumberofUDPInterfaces(int n) {
|
||||
@ -1139,7 +1185,7 @@ std::string Module::printReceiverConfiguration() {
|
||||
<< getReceiverHostname();
|
||||
|
||||
if (shm()->detType == JUNGFRAU) {
|
||||
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfaces()
|
||||
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfacesFromShm()
|
||||
<< "\nSelected Interface:\t" << getSelectedUDPInterface();
|
||||
}
|
||||
|
||||
@ -1673,6 +1719,14 @@ void Module::setDataStream(const portPosition port, const bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Module::getTop() const {
|
||||
return (static_cast<bool>(sendToDetector<int>(F_GET_TOP)));
|
||||
}
|
||||
|
||||
void Module::setTop(bool value) {
|
||||
sendToDetector(F_SET_TOP, static_cast<int>(value), nullptr);
|
||||
}
|
||||
|
||||
// Jungfrau Specific
|
||||
double Module::getChipVersion() const {
|
||||
return (sendToDetector<int>(F_GET_CHIP_VERSION)) / 10.00;
|
||||
@ -2197,8 +2251,6 @@ std::array<time::ns, 3> Module::getGateDelayForAllGates() const {
|
||||
return sendToDetector<std::array<time::ns, 3>>(F_GET_GATE_DELAY_ALL_GATES);
|
||||
}
|
||||
|
||||
bool Module::isMaster() const { return sendToDetectorStop<int>(F_GET_MASTER); }
|
||||
|
||||
int Module::getChipStatusRegister() const {
|
||||
return sendToDetector<int>(F_GET_CSR);
|
||||
}
|
||||
@ -2538,12 +2590,14 @@ void Module::setAdditionalJsonParameter(const std::string &key,
|
||||
}
|
||||
|
||||
// Advanced
|
||||
void Module::programFPGA(std::vector<char> buffer) {
|
||||
void Module::programFPGA(std::vector<char> buffer,
|
||||
const bool forceDeleteNormalFile) {
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware");
|
||||
sendProgram(true, buffer, F_PROGRAM_FPGA, "Update Firmware", "",
|
||||
forceDeleteNormalFile);
|
||||
break;
|
||||
case MYTHEN3:
|
||||
case GOTTHARD2:
|
||||
@ -2743,10 +2797,6 @@ int64_t Module::getMeasurementTime() const {
|
||||
return sendToDetectorStop<int64_t>(F_GET_MEASUREMENT_TIME);
|
||||
}
|
||||
|
||||
uint64_t Module::getReceiverCurrentFrameIndex() const {
|
||||
return sendToReceiver<uint64_t>(F_GET_RECEIVER_FRAME_INDEX);
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
void Module::checkArgs(const void *args, size_t args_size, void *retval,
|
||||
@ -3170,10 +3220,10 @@ void Module::initializeModuleStructure(detectorType type) {
|
||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
||||
shm()->useReceiverFlag = false;
|
||||
shm()->numUDPInterfaces = 1;
|
||||
shm()->zmqport =
|
||||
DEFAULT_ZMQ_CL_PORTNO + moduleIndex * shm()->numUDPInterfaces;
|
||||
shm()->zmqip = IpAddr{};
|
||||
shm()->numUDPInterfaces = 1;
|
||||
shm()->stoppedFlag = false;
|
||||
|
||||
// get the Module parameters based on type
|
||||
@ -3534,7 +3584,8 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
const int functionEnum,
|
||||
const std::string &functionType,
|
||||
const std::string serverName) {
|
||||
const std::string serverName,
|
||||
const bool forceDeleteNormalFile) {
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): Sending " << functionType;
|
||||
|
||||
@ -3558,6 +3609,11 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
client.Send(sname);
|
||||
}
|
||||
|
||||
// send forceDeleteNormalFile flag
|
||||
if (blackfin) {
|
||||
client.Send(static_cast<int>(forceDeleteNormalFile));
|
||||
}
|
||||
|
||||
// validate memory allocation etc in detector
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
|
@ -120,6 +120,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
int setTrimEn(const std::vector<int> &energies = {});
|
||||
bool getFlipRows() const;
|
||||
void setFlipRows(bool value);
|
||||
bool isMaster() const;
|
||||
void setMaster(const bool master);
|
||||
|
||||
bool isVirtualDetectorServer() const;
|
||||
|
||||
/**************************************************
|
||||
@ -184,6 +187,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setDBITPipeline(int value);
|
||||
int getReadNRows() const;
|
||||
void setReadNRows(const int value);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
* Acquisition *
|
||||
@ -199,8 +203,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
runStatus getRunStatus() const;
|
||||
runStatus getReceiverStatus() const;
|
||||
double getReceiverProgress() const;
|
||||
int64_t getFramesCaughtByReceiver() const;
|
||||
std::vector<int64_t> getFramesCaughtByReceiver() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
std::vector<int64_t> getReceiverCurrentFrameIndex() const;
|
||||
uint64_t getNextFrameNumber() const;
|
||||
void setNextFrameNumber(uint64_t value);
|
||||
void sendSoftwareTrigger(const bool block);
|
||||
@ -214,7 +219,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
* *
|
||||
* ************************************************/
|
||||
int getNumberofUDPInterfacesFromShm() const;
|
||||
int getNumberofUDPInterfaces() const;
|
||||
void updateNumberofUDPInterfaces();
|
||||
void setNumberofUDPInterfaces(int n);
|
||||
int getSelectedUDPInterface() const;
|
||||
void selectUDPInterface(int n);
|
||||
@ -365,6 +370,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setQuad(const bool enable);
|
||||
bool getDataStream(const portPosition port) const;
|
||||
void setDataStream(const portPosition port, const bool enable);
|
||||
bool getTop() const;
|
||||
void setTop(bool value);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
@ -456,7 +463,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getGateDelay(int gateIndex) const;
|
||||
void setGateDelay(int gateIndex, int64_t value);
|
||||
std::array<time::ns, 3> getGateDelayForAllGates() const;
|
||||
bool isMaster() const;
|
||||
int getChipStatusRegister() const;
|
||||
void setGainCaps(int caps);
|
||||
int getGainCaps();
|
||||
@ -539,7 +545,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
* Advanced *
|
||||
* *
|
||||
* ************************************************/
|
||||
void programFPGA(std::vector<char> buffer);
|
||||
void programFPGA(std::vector<char> buffer,
|
||||
const bool forceDeleteNormalFile);
|
||||
void resetFPGA();
|
||||
void copyDetectorServer(const std::string &fname,
|
||||
const std::string &hostname);
|
||||
@ -576,7 +583,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getNumberOfFramesFromStart() const;
|
||||
int64_t getActualTime() const;
|
||||
int64_t getMeasurementTime() const;
|
||||
uint64_t getReceiverCurrentFrameIndex() const;
|
||||
|
||||
private:
|
||||
void checkArgs(const void *args, size_t args_size, void *retval,
|
||||
@ -755,7 +761,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
bool trimbits = true);
|
||||
void sendProgram(bool blackfin, std::vector<char> buffer,
|
||||
const int functionEnum, const std::string &functionType,
|
||||
const std::string serverName = "");
|
||||
const std::string serverName = "",
|
||||
const bool forceDeleteNormalFile = false);
|
||||
void simulatingActivityinDetector(const std::string &functionType,
|
||||
const int timeRequired);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <fcntl.h> // O_CREAT, O_TRUNC..
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
// #include <stdio.h> // printf
|
||||
#include <sys/mman.h> // shared memory
|
||||
#include <sys/stat.h> // fstat
|
||||
#include <unistd.h>
|
||||
@ -36,11 +35,9 @@ namespace sls {
|
||||
template <typename T> class SharedMemory {
|
||||
|
||||
public:
|
||||
/**
|
||||
* moduleid of -1 creates a detector only shared memory
|
||||
*/
|
||||
SharedMemory(int detectorId, int moduleIndex) {
|
||||
name = ConstructSharedMemoryName(detectorId, moduleIndex);
|
||||
//moduleid of -1 creates a detector only shared memory
|
||||
SharedMemory(int detectorId, int moduleIndex, const std::string& tag = "") {
|
||||
name = ConstructSharedMemoryName(detectorId, moduleIndex, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,11 +100,7 @@ template <typename T> class SharedMemory {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shared memory name
|
||||
*/
|
||||
std::string GetName() const { return name; }
|
||||
|
||||
size_t size() const { return shmSize; }
|
||||
|
||||
/**
|
||||
@ -133,8 +126,8 @@ template <typename T> class SharedMemory {
|
||||
RemoveSharedMemory();
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
shared_struct = MapSharedMemory();
|
||||
new (shared_struct) T{};
|
||||
LOG(logINFO) << "Shared memory created " << name;
|
||||
}
|
||||
|
||||
@ -211,7 +204,7 @@ template <typename T> class SharedMemory {
|
||||
* @param moduleIndex module id, -1 if a detector shared memory
|
||||
* @returns shared memory name
|
||||
*/
|
||||
std::string ConstructSharedMemoryName(int detectorId, int moduleIndex) {
|
||||
std::string ConstructSharedMemoryName(int detectorId, int moduleIndex, const std::string& tag) {
|
||||
|
||||
// using environment path
|
||||
std::string sEnvPath;
|
||||
@ -222,8 +215,12 @@ template <typename T> class SharedMemory {
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
if (moduleIndex < 0)
|
||||
if (moduleIndex < 0){
|
||||
ss << SHM_DETECTOR_PREFIX << detectorId << sEnvPath;
|
||||
if (!tag.empty())
|
||||
ss << "_" << tag;
|
||||
}
|
||||
|
||||
else
|
||||
ss << SHM_DETECTOR_PREFIX << detectorId << SHM_MODULE_PREFIX
|
||||
<< moduleIndex << sEnvPath;
|
||||
@ -293,15 +290,10 @@ template <typename T> class SharedMemory {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Shared memory name */
|
||||
|
||||
std::string name;
|
||||
|
||||
/** File descriptor */
|
||||
int fd{-1};
|
||||
|
||||
/** shm size */
|
||||
size_t shmSize{0};
|
||||
|
||||
T *shared_struct{nullptr};
|
||||
};
|
||||
|
||||
|
@ -18,6 +18,7 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Module.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Pattern.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CtbConfig.cpp
|
||||
)
|
||||
|
||||
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")
|
@ -629,4 +629,32 @@ TEST_CASE("datastream", "[.cmd]") {
|
||||
REQUIRE_THROWS(proxy.Call("datastream", {"1"}, -1, PUT));
|
||||
REQUIRE_THROWS(proxy.Call("datastream", {"left", "1"}, -1, PUT));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("top", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER) {
|
||||
auto prev_val = det.getTop();
|
||||
int numModulesTested = 1;
|
||||
if (det.size() > 1) {
|
||||
numModulesTested = 2;
|
||||
}
|
||||
for (int i = 0; i != numModulesTested; ++i) {
|
||||
std::ostringstream oss1, oss2, oss3;
|
||||
proxy.Call("top", {"1"}, i, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "top 1\n");
|
||||
proxy.Call("top", {}, i, GET, oss2);
|
||||
REQUIRE(oss2.str() == "top 1\n");
|
||||
proxy.Call("top", {"0"}, i, PUT, oss3);
|
||||
REQUIRE(oss3.str() == "top 0\n");
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setTop(prev_val[i], {i});
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("top", {}, -1, GET));
|
||||
REQUIRE_THROWS(proxy.Call("top", {"1"}, -1, PUT));
|
||||
}
|
||||
}
|
@ -93,13 +93,19 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
|
||||
CmdProxy proxy(&det);
|
||||
|
||||
// This ensures 0 caught frames
|
||||
auto prev_val = det.getFileWrite();
|
||||
det.setFileWrite(false); // avoid writing or error on file creation
|
||||
det.startReceiver();
|
||||
det.stopReceiver();
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_framescaught 0\n");
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0, 0]\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Currently disabled may activate if we have a stable env
|
||||
@ -111,10 +117,15 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
|
||||
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||
// }
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFileWrite(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
auto prev_val = det.getFileWrite();
|
||||
det.setFileWrite(false); // avoid writing or error on file creation
|
||||
CmdProxy proxy(&det);
|
||||
{
|
||||
@ -123,8 +134,12 @@ TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
det.stopReceiver();
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_missingpackets", {}, -1, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_missingpackets ["));
|
||||
REQUIRE(std::stoi(s) > 0);
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() != "rx_missingpackets [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
// 0 missing packets (takes into account that acquisition is stopped)
|
||||
@ -133,9 +148,25 @@ TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
det.stopReceiver();
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_missingpackets", {}, -1, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_missingpackets ["));
|
||||
REQUIRE(std::stoi(s) == 0);
|
||||
if (det.getNumberofUDPInterfaces().tsquash(
|
||||
"inconsistent number of interfaces") == 1) {
|
||||
REQUIRE(oss.str() == "rx_missingpackets [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n");
|
||||
}
|
||||
}
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setFileWrite(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
proxy.Call("rx_frameindex", {}, -1, GET);
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
|
||||
}
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
@ -884,16 +915,3 @@ TEST_CASE("rx_jsonpara", "[.cmd][.rx]") {
|
||||
}
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
proxy.Call("rx_frameindex", {}, -1, GET);
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_frameindex", {}, 0, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_frameindex "));
|
||||
REQUIRE(std::stoi(s) >= 0);
|
||||
}
|
||||
|
@ -570,6 +570,46 @@ TEST_CASE("fliprows", "[.cmd]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("master", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
auto det_type = det.getDetectorType().squash();
|
||||
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
|
||||
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
|
||||
if (det_type == defs::EIGER) {
|
||||
// get previous master
|
||||
int prevMaster = 0;
|
||||
{
|
||||
auto previous = det.getMaster();
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
if (previous[i] == 1) {
|
||||
prevMaster = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1;
|
||||
proxy.Call("master", {"0"}, 0, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "master 0\n");
|
||||
}
|
||||
{
|
||||
std::ostringstream oss1;
|
||||
proxy.Call("master", {"1"}, 0, PUT, oss1);
|
||||
REQUIRE(oss1.str() == "master 1\n");
|
||||
}
|
||||
REQUIRE_THROWS(proxy.Call("master", {"1"}, -1, PUT));
|
||||
// set all to slaves, and then master
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setMaster(0, {i});
|
||||
}
|
||||
det.setMaster(1, prevMaster);
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("master", {}, -1, GET));
|
||||
}
|
||||
}
|
||||
|
||||
/* acquisition parameters */
|
||||
|
||||
// acquire: not testing
|
||||
@ -2126,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});
|
||||
}
|
||||
|
59
slsDetectorSoftware/tests/test-CtbConfig.cpp
Normal file
59
slsDetectorSoftware/tests/test-CtbConfig.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "catch.hpp"
|
||||
#include <string>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SharedMemory.h"
|
||||
#include "CtbConfig.h"
|
||||
using namespace sls;
|
||||
#include <fstream>
|
||||
|
||||
|
||||
TEST_CASE("Default construction"){
|
||||
static_assert(sizeof(CtbConfig) == 360); // 18*20
|
||||
|
||||
CtbConfig c;
|
||||
auto names = c.getDacNames();
|
||||
REQUIRE(names.size() == 18);
|
||||
REQUIRE(names[0] == "dac0");
|
||||
REQUIRE(names[1] == "dac1");
|
||||
REQUIRE(names[2] == "dac2");
|
||||
REQUIRE(names[3] == "dac3");
|
||||
}
|
||||
|
||||
TEST_CASE("Set and get a single dac name"){
|
||||
CtbConfig c;
|
||||
c.setDacName(3, "vrf");
|
||||
auto names = c.getDacNames();
|
||||
|
||||
REQUIRE(c.getDacName(3) == "vrf");
|
||||
REQUIRE(names[3] == "vrf");
|
||||
}
|
||||
|
||||
TEST_CASE("Set a name that is too large throws"){
|
||||
CtbConfig c;
|
||||
REQUIRE_THROWS(c.setDacName(3, "somestringthatisreallytolongforadatac"));
|
||||
}
|
||||
|
||||
TEST_CASE("Length of dac name cannot be 0"){
|
||||
CtbConfig c;
|
||||
REQUIRE_THROWS(c.setDacName(1, ""));
|
||||
}
|
||||
|
||||
TEST_CASE("Copy a CTB config"){
|
||||
CtbConfig c1;
|
||||
c1.setDacName(5, "somename");
|
||||
|
||||
auto c2 = c1;
|
||||
//change the name on the first object
|
||||
//to detecto shallow copy
|
||||
c1.setDacName(5, "someothername");
|
||||
REQUIRE(c2.getDacName(5) == "somename");
|
||||
}
|
||||
|
||||
TEST_CASE("Move CtbConfig "){
|
||||
CtbConfig c1;
|
||||
c1.setDacName(3, "yetanothername");
|
||||
CtbConfig c2(std::move(c1));
|
||||
REQUIRE(c2.getDacName(3) == "yetanothername");
|
||||
}
|
@ -134,3 +134,31 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
||||
CHECK(v[i].IsExisting() == false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag"){
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.GetName() == "/slsDetectorPackage_detector_0_ctbdacs");
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
|
||||
|
||||
// if SLSDETNAME is already set we unset it but
|
||||
// save the value
|
||||
std::string old_slsdetname;
|
||||
if (getenv(SHM_ENV_NAME))
|
||||
old_slsdetname = getenv(SHM_ENV_NAME);
|
||||
unsetenv(SHM_ENV_NAME);
|
||||
setenv(SHM_ENV_NAME, "myprefix", 1);
|
||||
|
||||
SharedMemory<int> shm(0, -1, "ctbdacs");
|
||||
REQUIRE(shm.GetName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs");
|
||||
|
||||
// Clean up after us
|
||||
if (old_slsdetname.empty())
|
||||
unsetenv(SHM_ENV_NAME);
|
||||
else
|
||||
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ set(SOURCES
|
||||
src/DataStreamer.cpp
|
||||
src/Fifo.cpp
|
||||
src/Arping.cpp
|
||||
src/MasterAttributes.cpp
|
||||
)
|
||||
|
||||
set(PUBLICHEADERS
|
||||
|
@ -716,6 +716,7 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
|
||||
break;
|
||||
*/
|
||||
case 4:
|
||||
case 12:
|
||||
if (detType == EIGER) {
|
||||
exists = true;
|
||||
}
|
||||
@ -847,9 +848,13 @@ int ClientInterface::get_file_index(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_frame_index(Interface &socket) {
|
||||
uint64_t retval = impl()->getCurrentFrameIndex();
|
||||
LOG(logDEBUG1) << "frame index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
auto retval = impl()->getCurrentFrameIndex();
|
||||
LOG(logDEBUG1) << "frames index:" << sls::ToString(retval);
|
||||
auto size = static_cast<int>(retval.size());
|
||||
socket.Send(OK);
|
||||
socket.Send(size);
|
||||
socket.Send(retval);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
@ -863,9 +868,13 @@ int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_frames_caught(Interface &socket) {
|
||||
int64_t retval = impl()->getFramesCaught();
|
||||
LOG(logDEBUG1) << "frames caught:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
auto retval = impl()->getFramesCaught();
|
||||
LOG(logDEBUG1) << "frames caught:" << sls::ToString(retval);
|
||||
auto size = static_cast<int>(retval.size());
|
||||
socket.Send(OK);
|
||||
socket.Send(size);
|
||||
socket.Send(retval);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::set_file_write(Interface &socket) {
|
||||
|
@ -52,19 +52,7 @@ DataProcessor::~DataProcessor() { DeleteFiles(); }
|
||||
|
||||
/** getters */
|
||||
|
||||
bool DataProcessor::GetStartedFlag() { return startedFlag_; }
|
||||
|
||||
uint64_t DataProcessor::GetNumFramesCaught() { return numFramesCaught_; }
|
||||
|
||||
uint64_t DataProcessor::GetNumCompleteFramesCaught() {
|
||||
return numCompleteFramesCaught_;
|
||||
}
|
||||
|
||||
uint64_t DataProcessor::GetCurrentFrameIndex() { return currentFrameIndex_; }
|
||||
|
||||
uint64_t DataProcessor::GetProcessedIndex() {
|
||||
return currentFrameIndex_ - firstIndex_;
|
||||
}
|
||||
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
||||
|
||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
||||
|
||||
@ -72,7 +60,6 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
startedFlag_ = false;
|
||||
numFramesCaught_ = 0;
|
||||
numCompleteFramesCaught_ = 0;
|
||||
firstIndex_ = 0;
|
||||
currentFrameIndex_ = 0;
|
||||
firstStreamerFrame_ = true;
|
||||
@ -213,12 +200,14 @@ void DataProcessor::CreateVirtualFile(
|
||||
if (virtualFile_) {
|
||||
delete virtualFile_;
|
||||
}
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib);
|
||||
bool gotthard25um =
|
||||
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
|
||||
(numModX * numModY) == 2);
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib, gotthard25um);
|
||||
|
||||
uint64_t numImagesProcessed = GetProcessedIndex() + 1;
|
||||
// maxframesperfile = 0 for infinite files
|
||||
uint32_t framesPerFile =
|
||||
((maxFramesPerFile == 0) ? numImagesProcessed + 1 : maxFramesPerFile);
|
||||
((maxFramesPerFile == 0) ? numFramesCaught_ : maxFramesPerFile);
|
||||
|
||||
// TODO: assumption 1: create virtual file even if no data in other
|
||||
// files (they exist anyway) assumption2: virtual file max frame index
|
||||
@ -228,7 +217,7 @@ void DataProcessor::CreateVirtualFile(
|
||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
modulePos, numUnitsPerReadout, framesPerFile, numImages,
|
||||
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
||||
numImagesProcessed, numModX, numModY, dataFile_->GetPDataType(),
|
||||
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
|
||||
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
|
||||
}
|
||||
|
||||
@ -344,9 +333,6 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
||||
currentFrameIndex_ = fnum;
|
||||
numFramesCaught_++;
|
||||
uint32_t nump = header.packetNumber;
|
||||
if (nump == generalData_->packetsPerFrame) {
|
||||
numCompleteFramesCaught_++;
|
||||
}
|
||||
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
|
||||
|
@ -36,13 +36,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
~DataProcessor() override;
|
||||
|
||||
bool GetStartedFlag();
|
||||
uint64_t GetNumFramesCaught();
|
||||
uint64_t GetNumCompleteFramesCaught();
|
||||
/** (-1 if no frames have been caught */
|
||||
uint64_t GetCurrentFrameIndex();
|
||||
/** (-1 if no frames have been caught) */
|
||||
uint64_t GetProcessedIndex();
|
||||
bool GetStartedFlag() const;
|
||||
|
||||
void SetFifo(Fifo *f);
|
||||
void ResetParametersforNewAcquisition();
|
||||
@ -178,9 +172,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** Number of frames caught */
|
||||
uint64_t numFramesCaught_{0};
|
||||
|
||||
/** Number of complete frames caught */
|
||||
uint64_t numCompleteFramesCaught_{0};
|
||||
|
||||
/** Frame Number of latest processed frame number */
|
||||
std::atomic<uint64_t> currentFrameIndex_{0};
|
||||
|
||||
|
@ -112,6 +112,7 @@ void HDF5DataFile::CreateFirstHDF5DataFile(
|
||||
udpPortNumber_ = udpPortNumber;
|
||||
|
||||
switch (dynamicRange_) {
|
||||
case 12:
|
||||
case 16:
|
||||
dataType_ = PredType::STD_U16LE;
|
||||
break;
|
||||
@ -248,8 +249,30 @@ void HDF5DataFile::WriteToFile(char *buffer, const int buffersize,
|
||||
WriteParameterDatasets(currentFrameNumber, (sls_receiver_header *)(buffer));
|
||||
}
|
||||
|
||||
void HDF5DataFile::Convert12to16Bit(uint16_t *dst, uint8_t *src) {
|
||||
for (int i = 0; i < EIGER_NUM_PIXELS; ++i) {
|
||||
*dst = (uint16_t)(*src++ & 0xFF);
|
||||
*dst++ |= (uint16_t)((*src & 0xF) << 8u);
|
||||
++i;
|
||||
*dst = (uint16_t)((*src++ & 0xF0) >> 4u);
|
||||
*dst++ |= (uint16_t)((*src++ & 0xFF) << 4u);
|
||||
}
|
||||
}
|
||||
|
||||
void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
||||
char *buffer) {
|
||||
// expand 12 bit to 16 bits
|
||||
char *revBuffer = buffer;
|
||||
if (dynamicRange_ == 12) {
|
||||
revBuffer = (char *)malloc(EIGER_16_BIT_IMAGE_SIZE);
|
||||
if (revBuffer == nullptr) {
|
||||
throw sls::RuntimeError("Could not allocate memory for 12 bit to "
|
||||
"16 bit conversion in object " +
|
||||
std::to_string(index_));
|
||||
}
|
||||
Convert12to16Bit((uint16_t *)revBuffer, (uint8_t *)buffer);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(*hdf5Lib_);
|
||||
|
||||
uint64_t nDimx =
|
||||
@ -266,9 +289,15 @@ void HDF5DataFile::WriteDataFile(const uint64_t currentFrameNumber,
|
||||
|
||||
dataSpace_->selectHyperslab(H5S_SELECT_SET, count, start);
|
||||
DataSpace memspace(2, dims2);
|
||||
dataSet_->write(buffer, dataType_, memspace, *dataSpace_);
|
||||
dataSet_->write(revBuffer, dataType_, memspace, *dataSpace_);
|
||||
memspace.close();
|
||||
if (dynamicRange_ == 12) {
|
||||
free(revBuffer);
|
||||
}
|
||||
} catch (const Exception &error) {
|
||||
if (dynamicRange_ == 12) {
|
||||
free(revBuffer);
|
||||
}
|
||||
LOG(logERROR) << "Could not write to file in object " << index_;
|
||||
error.printErrorStack();
|
||||
throw sls::RuntimeError("Could not write to file in object " +
|
||||
|
@ -35,6 +35,7 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
||||
|
||||
private:
|
||||
void CreateFile();
|
||||
void Convert12to16Bit(uint16_t *dst, uint8_t *src);
|
||||
void WriteDataFile(const uint64_t currentFrameNumber, char *buffer);
|
||||
void WriteParameterDatasets(const uint64_t currentFrameNumber,
|
||||
sls_receiver_header *rheader);
|
||||
@ -72,4 +73,7 @@ class HDF5DataFile : private virtual slsDetectorDefs, public File {
|
||||
int detIndex_{0};
|
||||
int numUnitsPerReadout_{0};
|
||||
uint32_t udpPortNumber_{0};
|
||||
|
||||
static const int EIGER_NUM_PIXELS{256 * 2 * 256};
|
||||
static const int EIGER_16_BIT_IMAGE_SIZE{EIGER_NUM_PIXELS * 2};
|
||||
};
|
@ -5,8 +5,8 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib)
|
||||
: File(HDF5), hdf5Lib_(hdf5Lib) {}
|
||||
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib, bool g25)
|
||||
: File(HDF5), hdf5Lib_(hdf5Lib), gotthard25um(g25) {}
|
||||
|
||||
HDF5VirtualFile::~HDF5VirtualFile() { CloseFile(); }
|
||||
|
||||
@ -73,12 +73,10 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||
|
||||
// virtual data dataspace
|
||||
// virtual dataspace
|
||||
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
|
||||
numModZ * nDimz};
|
||||
DataSpace vdsDataSpace(3, vdsDims, nullptr);
|
||||
|
||||
// virtual parameter dataspace
|
||||
hsize_t vdsDimsPara[2] = {numImagesCaught,
|
||||
(unsigned int)numModY * numModZ};
|
||||
DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
|
||||
@ -91,37 +89,54 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
// property list for parameters (datatype)
|
||||
std::vector<DSetCreatPropList> plistPara(paraSize);
|
||||
|
||||
// hyperslab
|
||||
int numMajorHyperslab = numImagesCaught / maxFramesPerFile;
|
||||
// hyperslab (files)
|
||||
int numFiles = numImagesCaught / maxFramesPerFile;
|
||||
if (numImagesCaught % maxFramesPerFile)
|
||||
++numMajorHyperslab;
|
||||
++numFiles;
|
||||
uint64_t framesSaved = 0;
|
||||
// loop through files
|
||||
for (int hyperSlab = 0; hyperSlab < numMajorHyperslab; ++hyperSlab) {
|
||||
for (int iFile = 0; iFile < numFiles; ++iFile) {
|
||||
|
||||
uint64_t nDimx =
|
||||
((numImagesCaught - framesSaved) > maxFramesPerFile)
|
||||
? maxFramesPerFile
|
||||
: (numImagesCaught - framesSaved);
|
||||
hsize_t start[3] = {framesSaved, 0, 0};
|
||||
hsize_t count[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t startPara[2] = {framesSaved, 0};
|
||||
hsize_t countPara[2] = {nDimx, 1};
|
||||
// loop through readouts
|
||||
for (unsigned int i = 0; i < numModY * numModZ; ++i) {
|
||||
|
||||
// setect data hyperslabs
|
||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, count, start);
|
||||
hsize_t startLocation[3] = {framesSaved, 0, 0};
|
||||
hsize_t strideBetweenBlocks[3] = {1, 1, 1};
|
||||
hsize_t numBlocks[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t blockSize[3] = {1, 1, 1};
|
||||
|
||||
// select parameter hyperslabs
|
||||
vdsDataSpacePara.selectHyperslab(H5S_SELECT_SET, countPara,
|
||||
startPara);
|
||||
hsize_t startLocationPara[2] = {framesSaved, 0};
|
||||
hsize_t strideBetweenBlocksPara[3] = {1, 1};
|
||||
hsize_t numBlocksPara[2] = {1, 1};
|
||||
hsize_t blockSizePara[3] = {nDimx, 1};
|
||||
|
||||
// interleaving for g2
|
||||
if (gotthard25um) {
|
||||
strideBetweenBlocks[2] = 2;
|
||||
}
|
||||
|
||||
for (unsigned int iReadout = 0; iReadout < numModY * numModZ;
|
||||
++iReadout) {
|
||||
|
||||
// interleaving for g2 (startLocation is 0 and 1)
|
||||
if (gotthard25um) {
|
||||
startLocation[2] = iReadout;
|
||||
}
|
||||
|
||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, numBlocks,
|
||||
startLocation, strideBetweenBlocks,
|
||||
blockSize);
|
||||
|
||||
vdsDataSpacePara.selectHyperslab(
|
||||
H5S_SELECT_SET, numBlocksPara, startLocationPara,
|
||||
strideBetweenBlocksPara, blockSizePara);
|
||||
|
||||
// source file name
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileNamePrefix << "_d"
|
||||
<< (modulePos * numUnitsPerReadout + i) << "_f" << hyperSlab
|
||||
<< '_' << fileIndex << ".h5";
|
||||
<< (modulePos * numUnitsPerReadout + iReadout) << "_f"
|
||||
<< iFile << '_' << fileIndex << ".h5";
|
||||
std::string srcFileName = os.str();
|
||||
LOG(logDEBUG1) << srcFileName;
|
||||
|
||||
@ -138,25 +153,20 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (numImages > 1)
|
||||
osfn << "_f" << std::setfill('0') << std::setw(12)
|
||||
<< hyperSlab;
|
||||
osfn << "_f" << std::setfill('0') << std::setw(12) << iFile;
|
||||
std::string srcDatasetName = osfn.str();
|
||||
|
||||
// source data dataspace
|
||||
// source dataspace
|
||||
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
DataSpace srcDataSpace(3, srcDims, srcDimsMax);
|
||||
|
||||
// source parameter dataspace
|
||||
hsize_t srcDimsPara[1] = {nDimx};
|
||||
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
|
||||
DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
|
||||
|
||||
// mapping of data property list
|
||||
// mapping of property list
|
||||
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
||||
srcDatasetName.c_str(), srcDataSpace);
|
||||
|
||||
// mapping of parameter property list
|
||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||
plistPara[p].setVirtual(
|
||||
vdsDataSpacePara, relative_srcFileName.c_str(),
|
||||
@ -165,21 +175,23 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
|
||||
// H5Sclose(srcDataspace);
|
||||
// H5Sclose(srcDataspace_para);
|
||||
start[2] += nDimz;
|
||||
if (start[2] >= (numModZ * nDimz)) {
|
||||
start[2] = 0;
|
||||
start[1] += nDimy;
|
||||
|
||||
if (!gotthard25um) {
|
||||
startLocation[2] += nDimz;
|
||||
if (startLocation[2] >= (numModZ * nDimz)) {
|
||||
startLocation[2] = 0;
|
||||
startLocation[1] += nDimy;
|
||||
}
|
||||
}
|
||||
startPara[1]++;
|
||||
startLocationPara[1]++;
|
||||
}
|
||||
framesSaved += nDimx;
|
||||
}
|
||||
// data dataset
|
||||
// datasets
|
||||
dataSetName_ = "data";
|
||||
DataSet vdsDataSet(fd_->createDataSet(dataSetName_.c_str(), dataType,
|
||||
vdsDataSpace, plist));
|
||||
|
||||
// parameter dataset
|
||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||
DataSet vdsDataSetPara(fd_->createDataSet(
|
||||
parameterNames[p].c_str(), parameterDataTypes[p],
|
||||
@ -196,4 +208,4 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Virtual File: " << fileName_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
class HDF5VirtualFile : private virtual slsDetectorDefs, public File {
|
||||
|
||||
public:
|
||||
HDF5VirtualFile(std::mutex *hdf5Lib);
|
||||
HDF5VirtualFile(std::mutex *hdf5Lib, bool g25);
|
||||
~HDF5VirtualFile();
|
||||
|
||||
std::array<std::string, 2> GetFileAndDatasetName() const override;
|
||||
@ -30,4 +30,5 @@ class HDF5VirtualFile : private virtual slsDetectorDefs, public File {
|
||||
H5File *fd_{nullptr};
|
||||
std::string fileName_;
|
||||
std::string dataSetName_;
|
||||
bool gotthard25um;
|
||||
};
|
@ -453,51 +453,51 @@ void Implementation::setFramesPerFile(const uint32_t i) {
|
||||
* ************************************************/
|
||||
slsDetectorDefs::runStatus Implementation::getStatus() const { return status; }
|
||||
|
||||
uint64_t Implementation::getFramesCaught() const {
|
||||
uint64_t min = -1;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (const auto &it : dataProcessor) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
min = std::min(min, it->GetNumCompleteFramesCaught());
|
||||
std::vector<int64_t> Implementation::getFramesCaught() const {
|
||||
std::vector<int64_t> numFramesCaught(numUDPInterfaces);
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
if (it->GetStartedFlag()) {
|
||||
numFramesCaught[index] = it->GetNumCompleteFramesCaught();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != dataProcessor.size())
|
||||
return 0;
|
||||
|
||||
return min;
|
||||
return numFramesCaught;
|
||||
}
|
||||
|
||||
uint64_t Implementation::getCurrentFrameIndex() const {
|
||||
uint64_t max = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
std::vector<int64_t> Implementation::getCurrentFrameIndex() const {
|
||||
std::vector<int64_t> frameIndex(numUDPInterfaces);
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
max = std::max(max, it->GetCurrentFrameIndex());
|
||||
if (it->GetStartedFlag()) {
|
||||
frameIndex[index] = it->GetCurrentFrameIndex();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != listener.size())
|
||||
return 0;
|
||||
return max;
|
||||
return frameIndex;
|
||||
}
|
||||
|
||||
double Implementation::getProgress() const {
|
||||
// get minimum of processed frame indices
|
||||
uint64_t currentFrameIndex = 0;
|
||||
uint32_t flagsum = 0;
|
||||
if (!activated || (!detectorDataStream[0] && !detectorDataStream[1])) {
|
||||
return 100.00;
|
||||
}
|
||||
|
||||
// if disabled, considering only 1 port
|
||||
double totalFrames = (double)(numberOfTotalFrames * listener.size());
|
||||
if (!detectorDataStream[0] || !detectorDataStream[1]) {
|
||||
totalFrames /= 2;
|
||||
}
|
||||
|
||||
double progress = 0;
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
currentFrameIndex = std::max(currentFrameIndex, it->GetListenedIndex());
|
||||
if (detectorDataStream[index] && it->GetStartedFlag()) {
|
||||
progress += (it->GetListenedIndex() + 1) / totalFrames;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != listener.size()) {
|
||||
currentFrameIndex = -1;
|
||||
}
|
||||
|
||||
return (100.00 *
|
||||
((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames));
|
||||
progress *= 100;
|
||||
return progress;
|
||||
}
|
||||
|
||||
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
||||
@ -627,7 +627,7 @@ void Implementation::stopReceiver() {
|
||||
// print summary
|
||||
uint64_t tot = 0;
|
||||
for (int i = 0; i < numUDPInterfaces; i++) {
|
||||
int nf = dataProcessor[i]->GetNumCompleteFramesCaught();
|
||||
int nf = listener[i]->GetNumCompleteFramesCaught();
|
||||
tot += nf;
|
||||
std::string mpMessage = std::to_string(mp[i]);
|
||||
if (mp[i] < 0) {
|
||||
@ -784,6 +784,12 @@ void Implementation::SetupWriter() {
|
||||
}
|
||||
masterAttributes->detType = detType;
|
||||
masterAttributes->timingMode = timingMode;
|
||||
xy nm{numModules.x, numModules.y};
|
||||
if (quadEnable) {
|
||||
nm.x = 1;
|
||||
nm.y = 2;
|
||||
}
|
||||
masterAttributes->geometry = xy(nm.x, nm.y);
|
||||
masterAttributes->imageSize = generalData->imageSize;
|
||||
masterAttributes->nPixels =
|
||||
xy(generalData->nPixelsX, generalData->nPixelsY);
|
||||
@ -1476,10 +1482,10 @@ void Implementation::setTenGigaEnable(const bool b) {
|
||||
detectorDataStream[LEFT] = detectorDataStream10GbE[LEFT];
|
||||
detectorDataStream[RIGHT] = detectorDataStream10GbE[RIGHT];
|
||||
}
|
||||
LOG(logINFO) << "Detector datastream updated [Left: "
|
||||
<< sls::ToString(detectorDataStream[LEFT])
|
||||
<< ", Right: "
|
||||
<< sls::ToString(detectorDataStream[RIGHT]) << "]";
|
||||
LOG(logDEBUG) << "Detector datastream updated [Left: "
|
||||
<< sls::ToString(detectorDataStream[LEFT])
|
||||
<< ", Right: "
|
||||
<< sls::ToString(detectorDataStream[RIGHT]) << "]";
|
||||
}
|
||||
}
|
||||
LOG(logINFO) << "Ten Giga: " << (tengigaEnable ? "enabled" : "disabled");
|
||||
@ -1550,6 +1556,13 @@ void Implementation::setDetectorDataStream(const portPosition port,
|
||||
detectorDataStream10GbE[index] = enable;
|
||||
LOG(logINFO) << "Detector 10GbE datastream (" << sls::ToString(port)
|
||||
<< " Port): " << sls::ToString(detectorDataStream10GbE[index]);
|
||||
// update datastream for 10g
|
||||
if (tengigaEnable) {
|
||||
detectorDataStream[index] = detectorDataStream10GbE[index];
|
||||
LOG(logDEBUG) << "Detector datastream updated ["
|
||||
<< (index == 0 ? "Left" : "Right")
|
||||
<< "] : " << sls::ToString(detectorDataStream[index]);
|
||||
}
|
||||
}
|
||||
|
||||
int Implementation::getReadNRows() const { return readNRows; }
|
||||
|
@ -84,8 +84,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* *
|
||||
* ************************************************/
|
||||
runStatus getStatus() const;
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getCurrentFrameIndex() const;
|
||||
std::vector<int64_t> getFramesCaught() const;
|
||||
std::vector<int64_t> getCurrentFrameIndex() const;
|
||||
double getProgress() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
void setScan(slsDetectorDefs::scanParameters s);
|
||||
|
@ -36,12 +36,22 @@ Listener::~Listener() = default;
|
||||
|
||||
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
|
||||
|
||||
uint64_t Listener::GetNumCompleteFramesCaught() const {
|
||||
return numCompleteFramesCaught;
|
||||
}
|
||||
|
||||
uint64_t Listener::GetLastFrameIndexCaught() const {
|
||||
return lastCaughtFrameIndex;
|
||||
}
|
||||
|
||||
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
uint64_t numPackets) const {
|
||||
if (!activated) {
|
||||
return 0;
|
||||
}
|
||||
if (!(*detectorDataStream)) {
|
||||
return 0;
|
||||
}
|
||||
if (!stoppedFlag) {
|
||||
return (numPackets - numPacketsCaught);
|
||||
}
|
||||
@ -53,11 +63,11 @@ int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
numPacketsCaught;
|
||||
}
|
||||
|
||||
bool Listener::GetStartedFlag() { return startedFlag; }
|
||||
bool Listener::GetStartedFlag() const { return startedFlag; }
|
||||
|
||||
uint64_t Listener::GetCurrentFrameIndex() { return lastCaughtFrameIndex; }
|
||||
uint64_t Listener::GetCurrentFrameIndex() const { return lastCaughtFrameIndex; }
|
||||
|
||||
uint64_t Listener::GetListenedIndex() {
|
||||
uint64_t Listener::GetListenedIndex() const {
|
||||
return lastCaughtFrameIndex - firstIndex;
|
||||
}
|
||||
|
||||
@ -67,6 +77,7 @@ void Listener::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
startedFlag = false;
|
||||
numPacketsCaught = 0;
|
||||
numCompleteFramesCaught = 0;
|
||||
firstIndex = 0;
|
||||
currentFrameIndex = 0;
|
||||
lastCaughtFrameIndex = 0;
|
||||
@ -607,6 +618,9 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
// complete image
|
||||
new_header->detHeader.packetNumber = numpackets; // number of packets caught
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
if (numpackets == pperFrame) {
|
||||
++numCompleteFramesCaught;
|
||||
}
|
||||
++currentFrameIndex;
|
||||
return imageSize;
|
||||
}
|
||||
|
@ -51,53 +51,19 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
~Listener();
|
||||
|
||||
/**
|
||||
* Get Packets caught
|
||||
* @return Packets caught
|
||||
*/
|
||||
uint64_t GetPacketsCaught() const;
|
||||
|
||||
/**
|
||||
* Get Last Frame index caught
|
||||
* @return last frame index caught
|
||||
*/
|
||||
uint64_t GetNumCompleteFramesCaught() const;
|
||||
uint64_t GetLastFrameIndexCaught() const;
|
||||
|
||||
/** Get number of missing packets, returns negative values in case to extra
|
||||
* packet */
|
||||
/** negative values in case of extra packets */
|
||||
int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
|
||||
bool GetStartedFlag() const;
|
||||
uint64_t GetCurrentFrameIndex() const;
|
||||
uint64_t GetListenedIndex() const;
|
||||
|
||||
bool GetStartedFlag();
|
||||
|
||||
uint64_t GetCurrentFrameIndex();
|
||||
/** (-1 if no frames have been caught) */
|
||||
uint64_t GetListenedIndex();
|
||||
|
||||
/**
|
||||
* Set Fifo pointer to the one given
|
||||
* @param f address of Fifo pointer
|
||||
*/
|
||||
void SetFifo(Fifo *f);
|
||||
|
||||
/**
|
||||
* Reset parameters for new acquisition
|
||||
*/
|
||||
void ResetParametersforNewAcquisition();
|
||||
|
||||
/**
|
||||
* Set GeneralData pointer to the one given
|
||||
* @param g address of GeneralData (Detector Data) pointer
|
||||
*/
|
||||
void SetGeneralData(GeneralData *g);
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
*/
|
||||
void CreateUDPSockets();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
*/
|
||||
void ShutDownUDPSocket();
|
||||
|
||||
/**
|
||||
@ -116,10 +82,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetHardCodedPosition(uint16_t r, uint16_t c);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Record First Acquisition Index
|
||||
* @param fnum frame index to record
|
||||
*/
|
||||
void RecordFirstIndex(uint64_t fnum);
|
||||
|
||||
/**
|
||||
@ -146,55 +108,25 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
uint32_t ListenToAnImage(char *buf);
|
||||
|
||||
/**
|
||||
* Print Fifo Statistics
|
||||
*/
|
||||
void PrintFifoStatistics();
|
||||
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
|
||||
/** GeneralData (Detector Data) object */
|
||||
GeneralData *generalData{nullptr};
|
||||
|
||||
/** Fifo structure */
|
||||
Fifo *fifo;
|
||||
|
||||
// individual members
|
||||
/** Detector Type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
/** Receiver Status */
|
||||
std::atomic<runStatus> *status;
|
||||
|
||||
/** UDP Socket - Detector to Receiver */
|
||||
std::unique_ptr<sls::UdpRxSocket> udpSocket{nullptr};
|
||||
|
||||
/** UDP Port Number */
|
||||
uint32_t *udpPortNumber;
|
||||
|
||||
/** ethernet interface */
|
||||
std::string *eth;
|
||||
|
||||
/** UDP Socket Buffer Size */
|
||||
int *udpSocketBufferSize;
|
||||
|
||||
/** actual UDP Socket Buffer Size (double due to kernel bookkeeping) */
|
||||
/** double due to kernel bookkeeping */
|
||||
int *actualUDPSocketBufferSize;
|
||||
|
||||
/** frames per file */
|
||||
uint32_t *framesPerFile;
|
||||
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy *frameDiscardMode;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool *activated;
|
||||
|
||||
/** detector data stream */
|
||||
bool *detectorDataStream;
|
||||
|
||||
/** Silent Mode */
|
||||
bool *silentMode;
|
||||
|
||||
/** row hardcoded as 1D or 2d,
|
||||
@ -209,15 +141,12 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
std::atomic<bool> startedFlag{false};
|
||||
|
||||
/** Frame Number of First Frame */
|
||||
uint64_t firstIndex{0};
|
||||
|
||||
// for acquisition summary
|
||||
/** Number of complete Packets caught */
|
||||
std::atomic<uint64_t> numPacketsCaught{0};
|
||||
|
||||
/** Last Frame Index caught from udp network */
|
||||
std::atomic<uint64_t> numCompleteFramesCaught{0};
|
||||
std::atomic<uint64_t> lastCaughtFrameIndex{0};
|
||||
|
||||
// parameters to acquire image
|
||||
@ -225,25 +154,16 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* ( always check startedFlag for validity first)
|
||||
*/
|
||||
uint64_t currentFrameIndex{0};
|
||||
|
||||
/** True if there is a packet carry over from previous Image */
|
||||
bool carryOverFlag{false};
|
||||
|
||||
/** Carry over packet buffer */
|
||||
std::unique_ptr<char[]> carryOverPacket;
|
||||
|
||||
/** Listening buffer for one packet - might be removed when we can peek and
|
||||
* eiger fnum is in header */
|
||||
std::unique_ptr<char[]> listeningPacket;
|
||||
|
||||
/** if the udp socket is connected */
|
||||
std::atomic<bool> udpSocketAlive{false};
|
||||
|
||||
// for print progress during acquisition
|
||||
/** number of packets for statistic */
|
||||
// for print progress during acquisition*/
|
||||
uint32_t numPacketsStatistic{0};
|
||||
|
||||
/** number of images for statistic */
|
||||
uint32_t numFramesStatistic{0};
|
||||
|
||||
/**
|
||||
|
676
slsReceiverSoftware/src/MasterAttributes.cpp
Normal file
676
slsReceiverSoftware/src/MasterAttributes.cpp
Normal file
@ -0,0 +1,676 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "MasterAttributes.h"
|
||||
|
||||
void MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
LOG(logERROR) << "WriteMasterBinaryAttributes should have been called "
|
||||
"by a child class";
|
||||
}
|
||||
|
||||
std::string MasterAttributes::GetBinaryMasterAttributes() {
|
||||
time_t t = time(nullptr);
|
||||
std::ostringstream oss;
|
||||
oss << "Version : " << std::setprecision(2)
|
||||
<< BINARY_WRITER_VERSION << '\n'
|
||||
<< "TimeStamp : " << ctime(&t) << '\n'
|
||||
<< "Detector Type : " << sls::ToString(detType) << '\n'
|
||||
<< "Timing Mode : " << sls::ToString(timingMode) << '\n'
|
||||
<< "Geometry : " << sls::ToString(geometry) << '\n'
|
||||
<< "Image Size : " << imageSize << " bytes" << '\n'
|
||||
<< "Pixels : " << sls::ToString(nPixels) << '\n'
|
||||
<< "Max Frames Per File : " << maxFramesPerFile << '\n'
|
||||
<< "Frame Discard Policy : " << sls::ToString(frameDiscardMode)
|
||||
<< '\n'
|
||||
<< "Frame Padding : " << framePadding << '\n'
|
||||
<< "Scan Parameters : " << sls::ToString(scanParams) << '\n'
|
||||
<< "Total Frames : " << totalFrames << '\n';
|
||||
return oss.str();
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteBinaryAttributes(FILE *fd, std::string message) {
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteFinalBinaryAttributes(FILE *fd) {
|
||||
// adding few common parameters to the end
|
||||
std::ostringstream oss;
|
||||
|
||||
if (!additionalJsonHeader.empty()) {
|
||||
oss << "Additional Json Header : "
|
||||
<< sls::ToString(additionalJsonHeader) << '\n';
|
||||
}
|
||||
oss << "Frames in File : " << framesInFile << '\n';
|
||||
|
||||
// adding sls_receiver header format
|
||||
oss << '\n'
|
||||
<< "#Frame Header" << '\n'
|
||||
<< "Frame Number : 8 bytes" << '\n'
|
||||
<< "SubFrame Number/ExpLength : 4 bytes" << '\n'
|
||||
<< "Packet Number : 4 bytes" << '\n'
|
||||
<< "Bunch ID : 8 bytes" << '\n'
|
||||
<< "Timestamp : 8 bytes" << '\n'
|
||||
<< "Module Id : 2 bytes" << '\n'
|
||||
<< "Row : 2 bytes" << '\n'
|
||||
<< "Column : 2 bytes" << '\n'
|
||||
<< "Reserved : 2 bytes" << '\n'
|
||||
<< "Debug : 4 bytes" << '\n'
|
||||
<< "Round Robin Number : 2 bytes" << '\n'
|
||||
<< "Detector Type : 1 byte" << '\n'
|
||||
<< "Header Version : 1 byte" << '\n'
|
||||
<< "Packets Caught Mask : 64 bytes" << '\n';
|
||||
|
||||
std::string message = oss.str();
|
||||
|
||||
// writing to file
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void MasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
LOG(logERROR) << "WriteMasterHdf5Attributes should have been called "
|
||||
"by a child class";
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteHDF5Attributes(H5File *fd, Group *group) {
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// clang-format off
|
||||
// version
|
||||
{
|
||||
double version = BINARY_WRITER_VERSION;
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
Attribute attribute = fd->createAttribute(
|
||||
"Version", PredType::NATIVE_DOUBLE, dataspace);
|
||||
attribute.write(PredType::NATIVE_DOUBLE, &version);
|
||||
}
|
||||
// timestamp
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Timestamp", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, std::string(ctime(&t)));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// detector type
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Detector Type", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(detType));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// timing mode
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Timing Mode", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(timingMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
//TODO: make this into an array?
|
||||
// geometry x
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Geometry in x axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&geometry.x, PredType::NATIVE_INT);
|
||||
}
|
||||
// geometry y
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Geometry in y axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&geometry.y, PredType::NATIVE_INT);
|
||||
}
|
||||
// Image Size
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Image Size", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&imageSize, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
sls::strcpy_safe(c, "bytes");
|
||||
attribute.write(strdatatype, c);
|
||||
}
|
||||
//TODO: make this into an array?
|
||||
// npixels x
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in x axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.x, PredType::NATIVE_INT);
|
||||
}
|
||||
// npixels y
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in y axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.y, PredType::NATIVE_INT);
|
||||
}
|
||||
// Maximum frames per file
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Maximum frames per file", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&maxFramesPerFile, PredType::NATIVE_INT);
|
||||
}
|
||||
// Frame Discard Policy
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Frame Discard Policy", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(frameDiscardMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Frame Padding
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Frame Padding", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&framePadding, PredType::NATIVE_INT);
|
||||
}
|
||||
// Scan Parameters
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Scan Parameters", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(scanParams));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Total Frames
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Total Frames", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&totalFrames, PredType::STD_U64LE);
|
||||
}
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteFinalHDF5Attributes(H5File *fd, Group *group) {
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// Total Frames in file
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Frames in File", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&framesInFile, PredType::STD_U64LE);
|
||||
}
|
||||
// additional json header
|
||||
if (!additionalJsonHeader.empty()) {
|
||||
std::string json = sls::ToString(additionalJsonHeader);
|
||||
StrType strdatatype(PredType::C_S1, json.length());
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Additional JSON Header", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(additionalJsonHeader));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteHDF5Exptime(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(exptime));
|
||||
dataset.write(c, strdatatype);
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteHDF5Period(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Acquisition Period", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(period));
|
||||
dataset.write(c, strdatatype);
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteHDF5DynamicRange(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dynamic Range", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dynamicRange, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
char c[1024] = "bits";
|
||||
attribute.write( strdatatype, c);
|
||||
};
|
||||
|
||||
void MasterAttributes::WriteHDF5TenGiga(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Ten Giga Enable", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&tenGiga, PredType::NATIVE_INT);
|
||||
};
|
||||
#endif
|
||||
|
||||
void GotthardMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Roi (xmin, xmax) : " << sls::ToString(roi) << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void GotthardMasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
// Roi xmin
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"roi xmin", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&roi.xmin, PredType::NATIVE_INT);
|
||||
}
|
||||
// Roi xmax
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"roi xmax", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&roi.xmax, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void JungfrauMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Number of UDP Interfaces : " << numUDPInterfaces << '\n'
|
||||
<< "Number of rows : " << readNRows << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void JungfrauMasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of UDP Interfaces", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&numUDPInterfaces, PredType::NATIVE_INT);
|
||||
}
|
||||
// readNRows
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of rows", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&readNRows, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void EigerMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Threshold Energy : " << thresholdEnergyeV << '\n'
|
||||
<< "SubExptime : " << sls::ToString(subExptime)
|
||||
<< '\n'
|
||||
<< "SubPeriod : " << sls::ToString(subPeriod)
|
||||
<< '\n'
|
||||
<< "Quad : " << quad << '\n'
|
||||
<< "Number of rows : " << readNRows << '\n'
|
||||
<< "Rate Corrections : " << sls::ToString(ratecorr)
|
||||
<< '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void EigerMasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// threshold
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Threshold Energy", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&thresholdEnergyeV, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
sls::strcpy_safe(c, "eV");
|
||||
attribute.write(strdatatype, c);
|
||||
}
|
||||
// SubExptime
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset = group->createDataSet("Sub Exposure Time",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(subExptime));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// SubPeriod
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Sub Period", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(subPeriod));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Quad
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Quad", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&quad, PredType::NATIVE_INT);
|
||||
}
|
||||
// readNRows
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of rows", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&readNRows, PredType::NATIVE_INT);
|
||||
}
|
||||
// Rate corrections
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 1024);
|
||||
DataSet dataset = group->createDataSet("Rate Corrections",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(ratecorr));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void Mythen3MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Counter Mask : " << sls::ToStringHex(counterMask)
|
||||
<< '\n'
|
||||
<< "Exptime1 : " << sls::ToString(exptime1)
|
||||
<< '\n'
|
||||
<< "Exptime2 : " << sls::ToString(exptime2)
|
||||
<< '\n'
|
||||
<< "Exptime3 : " << sls::ToString(exptime3)
|
||||
<< '\n'
|
||||
<< "GateDelay1 : " << sls::ToString(gateDelay1)
|
||||
<< '\n'
|
||||
<< "GateDelay2 : " << sls::ToString(gateDelay2)
|
||||
<< '\n'
|
||||
<< "GateDelay3 : " << sls::ToString(gateDelay3)
|
||||
<< '\n'
|
||||
<< "Gates : " << gates << '\n'
|
||||
<< "Threshold Energies : "
|
||||
<< sls::ToString(thresholdAllEnergyeV) << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void Mythen3MasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// Counter Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Counter Mask", PredType::STD_U32LE, dataspace);
|
||||
dataset.write(&counterMask, PredType::STD_U32LE);
|
||||
}
|
||||
// Exptime1
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time1", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime1));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Exptime2
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time2", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime2));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Exptime3
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time3", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime3));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay1
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay1", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay1));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay2
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay2", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay2));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay3
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay3", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay3));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Gates
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gates", PredType::STD_U32LE, dataspace);
|
||||
dataset.write(&gates, PredType::STD_U32LE);
|
||||
}
|
||||
// Threshold Energies
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 1024);
|
||||
DataSet dataset = group->createDataSet("Threshold Energies",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(thresholdAllEnergyeV));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void Gotthard2MasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Burst Mode : " << sls::ToString(burstMode)
|
||||
<< '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void Gotthard2MasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
// burst mode
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Burst Mode", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(burstMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void MoenchMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "ADC Mask : " << sls::ToStringHex(adcmask)
|
||||
<< '\n'
|
||||
<< "Analog Samples : " << analogSamples << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void MoenchMasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
// ADC Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"ADC Mask", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&adcmask, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analogSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void CtbMasterAttributes::WriteMasterBinaryAttributes(FILE *fd) {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "ADC Mask : " << sls::ToStringHex(adcmask)
|
||||
<< '\n'
|
||||
<< "Analog Flag : " << analog << '\n'
|
||||
<< "Analog Samples : " << analogSamples << '\n'
|
||||
<< "Digital Flag : " << digital << '\n'
|
||||
<< "Digital Samples : " << digitalSamples << '\n'
|
||||
<< "Dbit Offset : " << dbitoffset << '\n'
|
||||
<< "Dbit Bitset : " << dbitlist << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
#ifdef HDF5C
|
||||
void CtbMasterAttributes::WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
// ADC Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"ADC mMsk", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&adcmask, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Flag
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Flag", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analog, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analogSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
// Digital Flag
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Digital Flag", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&digital, PredType::NATIVE_INT);
|
||||
}
|
||||
// Digital Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Digital Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&digitalSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
// Dbit Offset
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dbit Offset", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dbitoffset, PredType::NATIVE_INT);
|
||||
}
|
||||
// Dbit List
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dbit Bitset List", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&dbitlist, PredType::STD_U64LE);
|
||||
}
|
||||
};
|
||||
#endif
|
@ -17,10 +17,12 @@ using namespace H5;
|
||||
#include <chrono>
|
||||
using ns = std::chrono::nanoseconds;
|
||||
|
||||
struct MasterAttributes {
|
||||
class MasterAttributes {
|
||||
public:
|
||||
// (before acquisition)
|
||||
slsDetectorDefs::detectorType detType{slsDetectorDefs::GENERIC};
|
||||
slsDetectorDefs::timingMode timingMode{slsDetectorDefs::AUTO_TIMING};
|
||||
slsDetectorDefs::xy geometry{};
|
||||
uint32_t imageSize{0};
|
||||
slsDetectorDefs::xy nPixels{};
|
||||
uint32_t maxFramesPerFile{0};
|
||||
@ -63,701 +65,82 @@ struct MasterAttributes {
|
||||
// Final Attributes (after acquisition)
|
||||
uint64_t framesInFile{0};
|
||||
|
||||
MasterAttributes(){};
|
||||
virtual ~MasterAttributes(){};
|
||||
|
||||
virtual void WriteMasterBinaryAttributes(FILE *fd) {
|
||||
LOG(logERROR) << "WriteMasterBinaryAttributes should have been called "
|
||||
"by a child class";
|
||||
}
|
||||
|
||||
std::string GetBinaryMasterAttributes() {
|
||||
time_t t = time(nullptr);
|
||||
std::ostringstream oss;
|
||||
oss << "Version : " << std::setprecision(2)
|
||||
<< BINARY_WRITER_VERSION << '\n'
|
||||
<< "TimeStamp : " << ctime(&t) << '\n'
|
||||
<< "Detector Type : " << sls::ToString(detType) << '\n'
|
||||
<< "Timing Mode : " << sls::ToString(timingMode)
|
||||
<< '\n'
|
||||
<< "Image Size : " << imageSize << " bytes" << '\n'
|
||||
<< "Pixels : " << sls::ToString(nPixels) << '\n'
|
||||
<< "Max Frames Per File : " << maxFramesPerFile << '\n'
|
||||
<< "Frame Discard Policy : "
|
||||
<< sls::ToString(frameDiscardMode) << '\n'
|
||||
<< "Frame Padding : " << framePadding << '\n'
|
||||
<< "Scan Parameters : " << sls::ToString(scanParams)
|
||||
<< '\n'
|
||||
<< "Total Frames : " << totalFrames << '\n';
|
||||
return oss.str();
|
||||
};
|
||||
|
||||
void WriteBinaryAttributes(FILE *fd, std::string message) {
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
};
|
||||
|
||||
void WriteFinalBinaryAttributes(FILE *fd) {
|
||||
// adding few common parameters to the end
|
||||
std::ostringstream oss;
|
||||
|
||||
if (!additionalJsonHeader.empty()) {
|
||||
oss << "Additional Json Header : "
|
||||
<< sls::ToString(additionalJsonHeader) << '\n';
|
||||
}
|
||||
oss << "Frames in File : " << framesInFile << '\n';
|
||||
|
||||
// adding sls_receiver header format
|
||||
oss << '\n'
|
||||
<< "#Frame Header" << '\n'
|
||||
<< "Frame Number : 8 bytes" << '\n'
|
||||
<< "SubFrame Number/ExpLength : 4 bytes" << '\n'
|
||||
<< "Packet Number : 4 bytes" << '\n'
|
||||
<< "Bunch ID : 8 bytes" << '\n'
|
||||
<< "Timestamp : 8 bytes" << '\n'
|
||||
<< "Module Id : 2 bytes" << '\n'
|
||||
<< "Row : 2 bytes" << '\n'
|
||||
<< "Column : 2 bytes" << '\n'
|
||||
<< "Reserved : 2 bytes" << '\n'
|
||||
<< "Debug : 4 bytes" << '\n'
|
||||
<< "Round Robin Number : 2 bytes" << '\n'
|
||||
<< "Detector Type : 1 byte" << '\n'
|
||||
<< "Header Version : 1 byte" << '\n'
|
||||
<< "Packets Caught Mask : 64 bytes" << '\n';
|
||||
|
||||
std::string message = oss.str();
|
||||
|
||||
// writing to file
|
||||
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
|
||||
message.length()) {
|
||||
throw sls::RuntimeError(
|
||||
"Master binary file incorrect number of bytes written to file");
|
||||
}
|
||||
};
|
||||
|
||||
MasterAttributes() = default;
|
||||
virtual ~MasterAttributes() = default;
|
||||
virtual void WriteMasterBinaryAttributes(FILE *fd);
|
||||
std::string GetBinaryMasterAttributes();
|
||||
void WriteBinaryAttributes(FILE *fd, std::string message);
|
||||
void WriteFinalBinaryAttributes(FILE *fd);
|
||||
#ifdef HDF5C
|
||||
virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group) {
|
||||
LOG(logERROR) << "WriteMasterHdf5Attributes should have been called "
|
||||
"by a child class";
|
||||
};
|
||||
|
||||
void WriteHDF5Attributes(H5File *fd, Group *group) {
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// clang-format off
|
||||
// version
|
||||
{
|
||||
double version = BINARY_WRITER_VERSION;
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
Attribute attribute = fd->createAttribute(
|
||||
"Version", PredType::NATIVE_DOUBLE, dataspace);
|
||||
attribute.write(PredType::NATIVE_DOUBLE, &version);
|
||||
}
|
||||
// timestamp
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Timestamp", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, std::string(ctime(&t)));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// detector type
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Detector Type", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(detType));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// timing mode
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Timing Mode", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(timingMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Image Size
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Image Size", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&imageSize, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
sls::strcpy_safe(c, "bytes");
|
||||
attribute.write(strdatatype, c);
|
||||
}
|
||||
//TODO: make this into an array?
|
||||
// x
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in x axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.x, PredType::NATIVE_INT);
|
||||
}
|
||||
// y
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of pixels in y axis", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&nPixels.y, PredType::NATIVE_INT);
|
||||
}
|
||||
// Maximum frames per file
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Maximum frames per file", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&maxFramesPerFile, PredType::NATIVE_INT);
|
||||
}
|
||||
// Frame Discard Policy
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Frame Discard Policy", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(frameDiscardMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Frame Padding
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Frame Padding", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&framePadding, PredType::NATIVE_INT);
|
||||
}
|
||||
// Scan Parameters
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Scan Parameters", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(scanParams));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Total Frames
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Total Frames", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&totalFrames, PredType::STD_U64LE);
|
||||
}
|
||||
};
|
||||
|
||||
void WriteFinalHDF5Attributes(H5File *fd, Group *group) {
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// Total Frames in file
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Frames in File", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&framesInFile, PredType::STD_U64LE);
|
||||
}
|
||||
// additional json header
|
||||
if (!additionalJsonHeader.empty()) {
|
||||
std::string json = sls::ToString(additionalJsonHeader);
|
||||
StrType strdatatype(PredType::C_S1, json.length());
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Additional JSON Header", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(additionalJsonHeader));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
|
||||
void WriteHDF5Exptime(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(exptime));
|
||||
dataset.write(c, strdatatype);
|
||||
};
|
||||
|
||||
void WriteHDF5Period(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Acquisition Period", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(period));
|
||||
dataset.write(c, strdatatype);
|
||||
};
|
||||
|
||||
void WriteHDF5DynamicRange(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dynamic Range", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dynamicRange, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
char c[1024] = "bits";
|
||||
attribute.write( strdatatype, c);
|
||||
};
|
||||
|
||||
void WriteHDF5TenGiga(H5File *fd, Group *group) {
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Ten Giga Enable", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&tenGiga, PredType::NATIVE_INT);
|
||||
};
|
||||
virtual void WriteMasterHDF5Attributes(H5File *fd, Group *group);
|
||||
void WriteHDF5Attributes(H5File *fd, Group *group);
|
||||
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
|
||||
void WriteHDF5Exptime(H5File *fd, Group *group);
|
||||
void WriteHDF5Period(H5File *fd, Group *group);
|
||||
void WriteHDF5DynamicRange(H5File *fd, Group *group);
|
||||
void WriteHDF5TenGiga(H5File *fd, Group *group);
|
||||
#endif
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
class GotthardMasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
GotthardMasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Roi (xmin, xmax) : " << sls::ToString(roi) << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
GotthardMasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
// Roi xmin
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"roi xmin", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&roi.xmin, PredType::NATIVE_INT);
|
||||
}
|
||||
// Roi xmax
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"roi xmax", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&roi.xmax, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class JungfrauMasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
JungfrauMasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Number of UDP Interfaces : " << numUDPInterfaces << '\n'
|
||||
<< "Number of rows : " << readNRows << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
JungfrauMasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of UDP Interfaces", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&numUDPInterfaces, PredType::NATIVE_INT);
|
||||
}
|
||||
// readNRows
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of rows", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&readNRows, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class EigerMasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
EigerMasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Threshold Energy : " << thresholdEnergyeV << '\n'
|
||||
<< "SubExptime : " << sls::ToString(subExptime)
|
||||
<< '\n'
|
||||
<< "SubPeriod : " << sls::ToString(subPeriod)
|
||||
<< '\n'
|
||||
<< "Quad : " << quad << '\n'
|
||||
<< "Number of rows : " << readNRows << '\n'
|
||||
<< "Rate Corrections : " << sls::ToString(ratecorr)
|
||||
<< '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
EigerMasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// threshold
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Threshold Energy", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&thresholdEnergyeV, PredType::NATIVE_INT);
|
||||
DataSpace dataspaceAttr = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
Attribute attribute =
|
||||
dataset.createAttribute("Unit", strdatatype, dataspaceAttr);
|
||||
sls::strcpy_safe(c, "eV");
|
||||
attribute.write(strdatatype, c);
|
||||
}
|
||||
// SubExptime
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset = group->createDataSet("Sub Exposure Time",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(subExptime));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// SubPeriod
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Sub Period", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(subPeriod));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Quad
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Quad", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&quad, PredType::NATIVE_INT);
|
||||
}
|
||||
// readNRows
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Number of rows", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&readNRows, PredType::NATIVE_INT);
|
||||
}
|
||||
// Rate corrections
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 1024);
|
||||
DataSet dataset = group->createDataSet("Rate Corrections",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(ratecorr));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class Mythen3MasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
Mythen3MasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Dynamic Range : " << dynamicRange << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Counter Mask : " << sls::ToStringHex(counterMask)
|
||||
<< '\n'
|
||||
<< "Exptime1 : " << sls::ToString(exptime1)
|
||||
<< '\n'
|
||||
<< "Exptime2 : " << sls::ToString(exptime2)
|
||||
<< '\n'
|
||||
<< "Exptime3 : " << sls::ToString(exptime3)
|
||||
<< '\n'
|
||||
<< "GateDelay1 : " << sls::ToString(gateDelay1)
|
||||
<< '\n'
|
||||
<< "GateDelay2 : " << sls::ToString(gateDelay2)
|
||||
<< '\n'
|
||||
<< "GateDelay3 : " << sls::ToString(gateDelay3)
|
||||
<< '\n'
|
||||
<< "Gates : " << gates << '\n'
|
||||
<< "Threshold Energies : "
|
||||
<< sls::ToString(thresholdAllEnergyeV) << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
Mythen3MasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5DynamicRange(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
// Counter Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Counter Mask", PredType::STD_U32LE, dataspace);
|
||||
dataset.write(&counterMask, PredType::STD_U32LE);
|
||||
}
|
||||
// Exptime1
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time1", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime1));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Exptime2
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time2", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime2));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Exptime3
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Exposure Time3", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(exptime3));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay1
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay1", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay1));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay2
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay2", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay2));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// GateDelay3
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gate Delay3", strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(gateDelay3));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
// Gates
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Gates", PredType::STD_U32LE, dataspace);
|
||||
dataset.write(&gates, PredType::STD_U32LE);
|
||||
}
|
||||
// Threshold Energies
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 1024);
|
||||
DataSet dataset = group->createDataSet("Threshold Energies",
|
||||
strdatatype, dataspace);
|
||||
sls::strcpy_safe(c, sls::ToString(thresholdAllEnergyeV));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class Gotthard2MasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
Gotthard2MasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Burst Mode : " << sls::ToString(burstMode)
|
||||
<< '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
Gotthard2MasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
// burst mode
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
StrType strdatatype(PredType::C_S1, 256);
|
||||
DataSet dataset =
|
||||
group->createDataSet("Burst Mode", strdatatype, dataspace);
|
||||
char c[1024];
|
||||
memset(c, 0, sizeof(c));
|
||||
sls::strcpy_safe(c, sls::ToString(burstMode));
|
||||
dataset.write(c, strdatatype);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class MoenchMasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
MoenchMasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "ADC Mask : " << sls::ToStringHex(adcmask)
|
||||
<< '\n'
|
||||
<< "Analog Samples : " << analogSamples << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
MoenchMasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
// ADC Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"ADC Mask", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&adcmask, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analogSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
class CtbMasterAttributes : public MasterAttributes {
|
||||
public:
|
||||
CtbMasterAttributes(){};
|
||||
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override {
|
||||
std::ostringstream oss;
|
||||
oss << MasterAttributes::GetBinaryMasterAttributes()
|
||||
<< "Exptime : " << sls::ToString(exptime) << '\n'
|
||||
<< "Period : " << sls::ToString(period) << '\n'
|
||||
<< "Ten Giga : " << tenGiga << '\n'
|
||||
<< "ADC Mask : " << sls::ToStringHex(adcmask)
|
||||
<< '\n'
|
||||
<< "Analog Flag : " << analog << '\n'
|
||||
<< "Analog Samples : " << analogSamples << '\n'
|
||||
<< "Digital Flag : " << digital << '\n'
|
||||
<< "Digital Samples : " << digitalSamples << '\n'
|
||||
<< "Dbit Offset : " << dbitoffset << '\n'
|
||||
<< "Dbit Bitset : " << dbitlist << '\n';
|
||||
std::string message = oss.str();
|
||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||
};
|
||||
|
||||
CtbMasterAttributes() = default;
|
||||
void WriteMasterBinaryAttributes(FILE *fd) override;
|
||||
#ifdef HDF5C
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override {
|
||||
MasterAttributes::WriteHDF5Attributes(fd, group);
|
||||
MasterAttributes::WriteHDF5Exptime(fd, group);
|
||||
MasterAttributes::WriteHDF5Period(fd, group);
|
||||
MasterAttributes::WriteHDF5TenGiga(fd, group);
|
||||
// ADC Mask
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"ADC mMsk", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&adcmask, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Flag
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Flag", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analog, PredType::NATIVE_INT);
|
||||
}
|
||||
// Analog Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Analog Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&analogSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
// Digital Flag
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Digital Flag", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&digital, PredType::NATIVE_INT);
|
||||
}
|
||||
// Digital Samples
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Digital Samples", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&digitalSamples, PredType::NATIVE_INT);
|
||||
}
|
||||
// Dbit Offset
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dbit Offset", PredType::NATIVE_INT, dataspace);
|
||||
dataset.write(&dbitoffset, PredType::NATIVE_INT);
|
||||
}
|
||||
// Dbit List
|
||||
{
|
||||
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||
DataSet dataset = group->createDataSet(
|
||||
"Dbit Bitset List", PredType::STD_U64LE, dataspace);
|
||||
dataset.write(&dbitlist, PredType::STD_U64LE);
|
||||
}
|
||||
};
|
||||
void WriteMasterHDF5Attributes(H5File *fd, Group *group) override;
|
||||
#endif
|
||||
};
|
||||
|
@ -17,8 +17,8 @@
|
||||
// files
|
||||
|
||||
// versions
|
||||
#define HDF5_WRITER_VERSION (6.3) // 1 decimal places
|
||||
#define BINARY_WRITER_VERSION (6.3) // 1 decimal places
|
||||
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
|
||||
#define BINARY_WRITER_VERSION (6.4) // 1 decimal places
|
||||
|
||||
#define MAX_FRAMES_PER_FILE 20000
|
||||
#define SHORT_MAX_FRAMES_PER_FILE 100000
|
||||
|
@ -34,8 +34,8 @@ TEST_CASE("Push pop") {
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
fifo.push(p);
|
||||
++p;
|
||||
CHECK(fifo.getDataValue() == i + 1);
|
||||
CHECK(fifo.getFreeValue() == 4 - i);
|
||||
CHECK(fifo.getDataValue() == (int)(i + 1));
|
||||
CHECK(fifo.getFreeValue() == (int)(4 - i));
|
||||
}
|
||||
|
||||
CHECK(fifo.isEmpty() == false);
|
||||
@ -44,8 +44,8 @@ TEST_CASE("Push pop") {
|
||||
for (size_t i = 0; i != vec.size(); ++i) {
|
||||
fifo.pop(p);
|
||||
CHECK(*p == vec[i]);
|
||||
CHECK(fifo.getDataValue() == 4 - i);
|
||||
CHECK(fifo.getFreeValue() == i + 1);
|
||||
CHECK(fifo.getDataValue() == (int)(4 - i));
|
||||
CHECK(fifo.getFreeValue() == (int)(i + 1));
|
||||
}
|
||||
|
||||
CHECK(fifo.isEmpty() == true);
|
||||
|
@ -258,6 +258,9 @@ enum detFuncs {
|
||||
F_UPDATE_DETECTOR_SERVER,
|
||||
F_GET_UPDATE_MODE,
|
||||
F_SET_UPDATE_MODE,
|
||||
F_SET_MASTER,
|
||||
F_GET_TOP,
|
||||
F_SET_TOP,
|
||||
|
||||
NUM_DET_FUNCTIONS,
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||
@ -619,6 +622,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_UPDATE_DETECTOR_SERVER: return "F_UPDATE_DETECTOR_SERVER";
|
||||
case F_GET_UPDATE_MODE: return "F_GET_UPDATE_MODE";
|
||||
case F_SET_UPDATE_MODE: return "F_SET_UPDATE_MODE";
|
||||
case F_SET_MASTER: return "F_SET_MASTER";
|
||||
case F_GET_TOP: return "F_GET_TOP";
|
||||
case F_SET_TOP: return "F_SET_TOP";
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define APIRECEIVER 0x211124
|
||||
#define APIGUI 0x211124
|
||||
|
||||
#define APICTB 0x220223
|
||||
#define APIGOTTHARD 0x220223
|
||||
#define APIGOTTHARD2 0x220223
|
||||
#define APIJUNGFRAU 0x220223
|
||||
#define APIMYTHEN3 0x220223
|
||||
#define APIMOENCH 0x220223
|
||||
#define APIEIGER 0x220223
|
||||
#define APIEIGER 0x220324
|
||||
#define APICTB 0x220328
|
||||
#define APIGOTTHARD 0x220328
|
||||
#define APIGOTTHARD2 0x220328
|
||||
#define APIJUNGFRAU 0x220328
|
||||
#define APIMYTHEN3 0x220328
|
||||
#define APIMOENCH 0x220328
|
||||
|
Reference in New Issue
Block a user