Monolithic design achieved! (jfjoch_broker is NOT up to date!)
This commit is contained in:
+1
-6
@@ -25,7 +25,6 @@ IF (CMAKE_CUDA_COMPILER)
|
||||
ENDIF()
|
||||
|
||||
SET(JFJOCH_COMPILE_WRITER ON CACHE BOOL "Compile HDF5 writer")
|
||||
SET(JFJOCH_COMPILE_DETECTOR ON CACHE BOOL "Compile detector control")
|
||||
SET(JFJOCH_COMPILE_INDEXER ON CACHE BOOL "Compile indexer")
|
||||
SET(JFJOCH_COMPILE_TESTS OFF CACHE BOOL "Compile tests")
|
||||
|
||||
@@ -50,14 +49,10 @@ ADD_SUBDIRECTORY(fpga)
|
||||
ADD_SUBDIRECTORY(acquisition_device)
|
||||
ADD_SUBDIRECTORY(receiver)
|
||||
ADD_SUBDIRECTORY(image_analysis)
|
||||
ADD_SUBDIRECTORY(detector_control)
|
||||
|
||||
SET(jfjoch_executables jfjoch_broker)
|
||||
|
||||
IF (JFJOCH_COMPILE_DETECTOR)
|
||||
ADD_SUBDIRECTORY(detector_control)
|
||||
LIST(APPEND jfjoch_executables jfjoch_detector)
|
||||
ENDIF()
|
||||
|
||||
IF (JFJOCH_COMPILE_TESTS OR JFJOCH_COMPILE_WRITER)
|
||||
ADD_SUBDIRECTORY(writer)
|
||||
LIST(APPEND jfjoch_executables jfjoch_writer jfjoch_writer_multi)
|
||||
|
||||
@@ -3,7 +3,7 @@ ADD_LIBRARY(JFJochBroker STATIC
|
||||
JFJochServices.cpp JFJochServices.h
|
||||
JFJochBroker.cpp JFJochBroker.h JFJochBrokerParser.cpp JFJochBrokerParser.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JFJochBroker JFJochReceiver gRPCClients CommonFunctions)
|
||||
TARGET_LINK_LIBRARIES(JFJochBroker JFJochReceiver JFJochDetector gRPCClients CommonFunctions JFJochProtoBuf)
|
||||
|
||||
ADD_EXECUTABLE(jfjoch_broker jfjoch_broker.cpp)
|
||||
TARGET_LINK_LIBRARIES(jfjoch_broker JFJochBroker)
|
||||
|
||||
@@ -240,8 +240,8 @@ void ParseBrokerConfiguration(const nlohmann::json &input, const std::string& ta
|
||||
}
|
||||
}
|
||||
|
||||
if (j.contains("detector_addr"))
|
||||
broker.Services().Detector(GET_STR(j, "detector_addr"));
|
||||
if (j.contains("detector"))
|
||||
broker.Services().Detector();
|
||||
} else
|
||||
throw JFJochException(JFJochExceptionCategory::JSON, "Service configuration not found");
|
||||
}
|
||||
+24
-19
@@ -23,24 +23,24 @@ void JFJochServices::Start(const DiffractionExperiment& experiment, const JFCali
|
||||
receiver->Start(experiment, nullptr);
|
||||
}
|
||||
|
||||
if (!experiment.IsUsingInternalPacketGen()) {
|
||||
if (detector && !experiment.IsUsingInternalPacketGen()) {
|
||||
logger.Info(" ... detector start");
|
||||
detector.Start(experiment);
|
||||
detector->Start(experiment);
|
||||
}
|
||||
logger.Info(" Done!");
|
||||
}
|
||||
|
||||
void JFJochServices::Off() {
|
||||
detector.Off();
|
||||
if (detector)
|
||||
detector->Deactivate();
|
||||
}
|
||||
|
||||
void JFJochServices::On(const DiffractionExperiment &x) {
|
||||
logger.Info("Detector on");
|
||||
|
||||
if (receiver != nullptr) {
|
||||
JFJochProtoBuf::DetectorConfig config = x.DetectorConfig(receiver->GetNetworkConfig());
|
||||
detector.On(config);
|
||||
}
|
||||
if (detector && (receiver != nullptr))
|
||||
detector->Configure(x, receiver->GetNetworkConfig());
|
||||
|
||||
logger.Info(" ... done");
|
||||
}
|
||||
|
||||
@@ -86,13 +86,16 @@ JFJochServicesOutput JFJochServices::Stop(const JFCalibration &calibration) {
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("Stopping detector");
|
||||
try {
|
||||
detector.Stop();
|
||||
logger.Info(" ... done");
|
||||
} catch (JFJochException &e) {
|
||||
logger.Error(" ... finished with error {}",e.what());
|
||||
exception = std::make_unique<JFJochException>(e);
|
||||
if (detector) {
|
||||
logger.Info("Stopping detector");
|
||||
try {
|
||||
|
||||
detector->Stop();
|
||||
logger.Info(" ... done");
|
||||
} catch (JFJochException &e) {
|
||||
logger.Error(" ... finished with error {}", e.what());
|
||||
exception = std::make_unique<JFJochException>(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (exception)
|
||||
@@ -113,7 +116,8 @@ void JFJochServices::Abort() {
|
||||
}
|
||||
|
||||
void JFJochServices::Cancel() {
|
||||
detector.Stop();
|
||||
if (detector)
|
||||
detector->Stop();
|
||||
if (receiver != nullptr)
|
||||
receiver->Cancel();
|
||||
}
|
||||
@@ -130,9 +134,9 @@ JFJochServices &JFJochServices::Writer(const std::string &addr, const std::strin
|
||||
return *this;
|
||||
}
|
||||
|
||||
JFJochServices &JFJochServices::Detector(const std::string &addr) {
|
||||
detector.Connect(addr);
|
||||
logger.Info("Using detector service with gRPC {}", addr);
|
||||
JFJochServices &JFJochServices::Detector() {
|
||||
detector = std::make_unique<DetectorWrapper>();
|
||||
logger.Info("Using detector service");
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -170,7 +174,8 @@ void JFJochServices::SetDataProcessingSettings(const DataProcessingSettings &set
|
||||
}
|
||||
|
||||
void JFJochServices::Trigger() {
|
||||
detector.Trigger();
|
||||
if (detector)
|
||||
detector->Trigger();
|
||||
}
|
||||
|
||||
size_t JFJochServices::WriterZMQCount() const {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../common/Logger.h"
|
||||
#include "../receiver/JFJochReceiverService.h"
|
||||
#include "../grpc/JFJochWriterGroupClient.h"
|
||||
#include "../grpc/JFJochDetectorClient.h"
|
||||
#include "../detector_control/DetectorWrapper.h"
|
||||
|
||||
struct JFJochServicesOutput {
|
||||
JFJochReceiverOutput receiver_output;
|
||||
@@ -17,7 +17,7 @@ struct JFJochServicesOutput {
|
||||
class JFJochServices {
|
||||
JFJochReceiverService *receiver = nullptr;
|
||||
JFJochWriterGroupClient writer;
|
||||
JFJochDetectorClient detector;
|
||||
std::unique_ptr<DetectorWrapper> detector;
|
||||
|
||||
Logger &logger;
|
||||
bool writer_running = false;
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
void SetDataProcessingSettings(const DataProcessingSettings &settings);
|
||||
JFJochServices& Receiver(JFJochReceiverService *input);
|
||||
JFJochServices& Writer(const std::string &addr, const std::string &zmq_push_addr);
|
||||
JFJochServices& Detector(const std::string &addr);
|
||||
JFJochServices& Detector();
|
||||
|
||||
size_t WriterZMQCount() const;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ ADD_LIBRARY( CommonFunctions STATIC
|
||||
RawToConvertedGeometryCore.h
|
||||
Plot.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(CommonFunctions Compression FrameSerialize libzmq JFCalibration JFJochProtoBuf -lrt)
|
||||
TARGET_LINK_LIBRARIES(CommonFunctions Compression FrameSerialize libzmq JFCalibration -lrt)
|
||||
|
||||
IF (CMAKE_CUDA_COMPILER)
|
||||
TARGET_SOURCES(CommonFunctions PRIVATE CUDAWrapper.cu )
|
||||
|
||||
@@ -7,14 +7,11 @@
|
||||
#include "GitInfo.h"
|
||||
#include "DiffractionExperiment.h"
|
||||
#include "JFJochException.h"
|
||||
#include "../compression/MaxCompressedSize.h"
|
||||
|
||||
#define check_max(param, val, max) if ((val) > (max)) throw JFJochException(JFJochExceptionCategory::InputParameterAboveMax, param)
|
||||
#define check_min(param, val, min) if ((val) < (min)) throw JFJochException(JFJochExceptionCategory::InputParameterBelowMin, param)
|
||||
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment() : DiffractionExperiment(DetectorGeometry(8, 2))
|
||||
{}
|
||||
DiffractionExperiment::DiffractionExperiment() : DiffractionExperiment(DetectorGeometry(8, 2)) {}
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup) : detector(det_setup) {
|
||||
dataset.photon_energy_keV = WVL_1A_IN_KEV;
|
||||
@@ -691,92 +688,6 @@ std::string DiffractionExperiment::GetSampleName() const {
|
||||
return dataset.sample_name;
|
||||
}
|
||||
|
||||
// Create ProtoBuf structures
|
||||
|
||||
DiffractionExperiment::operator JFJochProtoBuf::DetectorInput() const {
|
||||
JFJochProtoBuf::DetectorInput ret;
|
||||
|
||||
ret.set_modules_num(GetModulesNum());
|
||||
switch (GetDetectorMode()) {
|
||||
case DetectorMode::Conversion:
|
||||
ret.set_mode(JFJochProtoBuf::CONVERSION);
|
||||
break;
|
||||
case DetectorMode::Raw:
|
||||
ret.set_mode(JFJochProtoBuf::RAW);
|
||||
break;
|
||||
case DetectorMode::PedestalG0:
|
||||
ret.set_mode(JFJochProtoBuf::PEDESTAL_G0);
|
||||
break;
|
||||
case DetectorMode::PedestalG1:
|
||||
ret.set_mode(JFJochProtoBuf::PEDESTAL_G1);
|
||||
break;
|
||||
case DetectorMode::PedestalG2:
|
||||
ret.set_mode(JFJochProtoBuf::PEDESTAL_G2);
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetNumTriggers() == 1) {
|
||||
ret.set_num_frames(GetFrameNumPerTrigger() + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
ret.set_num_triggers(1);
|
||||
} else {
|
||||
// More than 1 trigger - detector needs one trigger or few more trigger
|
||||
if (GetStorageCellNumber() > 1)
|
||||
ret.set_num_frames(1);
|
||||
else
|
||||
ret.set_num_frames(GetFrameNumPerTrigger());
|
||||
|
||||
if (GetFrameNumPerTrigger() < DELAY_FRAMES_STOP_AND_QUIT)
|
||||
ret.set_num_triggers(GetNumTriggers() + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
else
|
||||
ret.set_num_triggers(GetNumTriggers() + 1);
|
||||
}
|
||||
ret.set_storage_cell_start(GetStorageCellStart());
|
||||
ret.set_storage_cell_number(GetStorageCellNumber());
|
||||
ret.set_storage_cell_delay_ns(GetStorageCellDelay().count());
|
||||
|
||||
if (GetStorageCellNumber() > 1) {
|
||||
ret.set_period_us((GetFrameTime().count() +10) * GetStorageCellNumber());
|
||||
} else
|
||||
ret.set_period_us(GetFrameTime().count());
|
||||
|
||||
ret.set_count_time_us(GetFrameCountTime().count());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
JFJochProtoBuf::DetectorConfig DiffractionExperiment::DetectorConfig(const std::vector<AcquisitionDeviceNetConfig> &net_config) const {
|
||||
JFJochProtoBuf::DetectorConfig ret;
|
||||
if (net_config.size() < GetDataStreamsNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds,
|
||||
"Number of FPGA boards in the receiver is less then necessary");
|
||||
|
||||
if (!detector.GetDetectorModuleHostname().empty() && (detector.GetDetectorModuleHostname().size() != GetModulesNum()))
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds,
|
||||
"Inconsistent number of modules and detector module host names");
|
||||
|
||||
if (!detector.GetDetectorModuleHostname().empty())
|
||||
*ret.mutable_module_hostname() = {detector.GetDetectorModuleHostname().begin(),
|
||||
detector.GetDetectorModuleHostname().end()};
|
||||
|
||||
ret.set_udp_interface_count(detector.GetUDPInterfaceCount());
|
||||
|
||||
for (int d = 0; d < GetDataStreamsNum(); d++) {
|
||||
for (int m = 0; m < GetModulesNum(d); m++) {
|
||||
auto mod_cfg = ret.add_modules();
|
||||
mod_cfg->set_udp_dest_port_1(net_config[d].udp_port);
|
||||
mod_cfg->set_udp_dest_port_2(net_config[d].udp_port);
|
||||
mod_cfg->set_ipv4_src_addr_1(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m)));
|
||||
mod_cfg->set_ipv4_src_addr_2(IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m + 1)));
|
||||
mod_cfg->set_ipv4_dest_addr_1(net_config[d].ipv4_addr);
|
||||
mod_cfg->set_ipv4_dest_addr_2(net_config[d].ipv4_addr);
|
||||
mod_cfg->set_mac_addr_dest_1(net_config[d].mac_addr);
|
||||
mod_cfg->set_mac_addr_dest_2(net_config[d].mac_addr);
|
||||
mod_cfg->set_module_id_in_data_stream(m);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DiffractionExperiment::CheckDataProcessingSettings(const DataProcessingSettings &settings) {
|
||||
check_min("Signal to noise threshold", settings.signal_to_noise_threshold, 1);
|
||||
check_min("Photon count threshold", settings.photon_count_threshold, 0);
|
||||
@@ -931,9 +842,8 @@ int64_t DiffractionExperiment::GetModuleSlowDirectionStep(uint16_t module_number
|
||||
return detector.GetGeometry().GetSlowDirectionStep(module_number);
|
||||
}
|
||||
|
||||
void DiffractionExperiment::GetDetectorModuleHostname(std::vector<std::string> &output) const {
|
||||
for (const auto &iter: detector.GetDetectorModuleHostname())
|
||||
output.push_back(iter);
|
||||
std::vector<std::string> DiffractionExperiment::GetDetectorModuleHostname() const {
|
||||
return detector.GetDetectorModuleHostname();
|
||||
}
|
||||
|
||||
std::string DiffractionExperiment::GetDetectorDescription() const {
|
||||
@@ -1020,3 +930,28 @@ DiffractionExperiment &DiffractionExperiment::FPGAOutputMode(FPGAPixelOutput inp
|
||||
FPGAPixelOutput DiffractionExperiment::GetFPGAOutputMode() const {
|
||||
return dataset.fpga_pixel_output;
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetUDPInterfaceCount() const {
|
||||
return detector.GetUDPInterfaceCount();
|
||||
}
|
||||
|
||||
std::vector<DetectorModuleConfig>
|
||||
DiffractionExperiment::GetDetectorModuleConfig(const std::vector<AcquisitionDeviceNetConfig> &net_config) const{
|
||||
std::vector<DetectorModuleConfig> ret;
|
||||
for (int d = 0; d < GetDataStreamsNum(); d++) {
|
||||
for (int m = 0; m < GetModulesNum(d); m++) {
|
||||
DetectorModuleConfig mod_cfg;
|
||||
mod_cfg.udp_dest_port_1 = net_config[d].udp_port;
|
||||
mod_cfg.udp_dest_port_2 = net_config[d].udp_port;
|
||||
mod_cfg.ipv4_src_addr_1 = IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m));
|
||||
mod_cfg.ipv4_src_addr_2 = IPv4AddressToStr(GetSrcIPv4Address(d, 2 * m + 1));
|
||||
mod_cfg.ipv4_dest_addr_1 = net_config[d].ipv4_addr;
|
||||
mod_cfg.ipv4_dest_addr_2 = net_config[d].ipv4_addr;
|
||||
mod_cfg.mac_addr_dest_1 = net_config[d].mac_addr;
|
||||
mod_cfg.mac_addr_dest_2 = net_config[d].mac_addr;
|
||||
mod_cfg.module_id_in_data_stream = m;
|
||||
ret.emplace_back(std::move(mod_cfg));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <exception>
|
||||
#include <mutex>
|
||||
|
||||
#include <jfjoch.pb.h>
|
||||
#include <optional>
|
||||
|
||||
#include "../compression/CompressionAlgorithmEnum.h"
|
||||
|
||||
@@ -17,7 +15,6 @@
|
||||
#include "../frame_serialize/CBORMessages.h"
|
||||
#include "DetectorSetup.h"
|
||||
#include "../image_analysis/DataProcessingSettings.h"
|
||||
#include <optional>
|
||||
|
||||
enum class DetectorMode {
|
||||
Conversion, Raw, PedestalG0, PedestalG1, PedestalG2
|
||||
@@ -33,6 +30,19 @@ struct AcquisitionDeviceNetConfig {
|
||||
uint64_t udp_port;
|
||||
};
|
||||
|
||||
struct DetectorModuleConfig {
|
||||
uint64_t udp_dest_port_1;
|
||||
uint64_t udp_dest_port_2;
|
||||
std::string ipv4_src_addr_1;
|
||||
std::string ipv4_src_addr_2;
|
||||
std::string ipv4_dest_addr_1;
|
||||
std::string ipv4_dest_addr_2;
|
||||
std::string mac_addr_dest_1;
|
||||
std::string mac_addr_dest_2;
|
||||
uint64_t module_id_in_data_stream;
|
||||
};
|
||||
|
||||
|
||||
class DiffractionExperiment {
|
||||
// Internal detector settings
|
||||
std::chrono::microseconds frame_time_pedestalG1G2;
|
||||
@@ -160,9 +170,6 @@ public:
|
||||
|
||||
void FillMessage(StartMessage &message) const;
|
||||
|
||||
operator JFJochProtoBuf::DetectorInput() const;
|
||||
JFJochProtoBuf::DetectorConfig DetectorConfig(const std::vector<AcquisitionDeviceNetConfig>& net_config) const;
|
||||
|
||||
static void CheckDataProcessingSettings(const DataProcessingSettings& settings);
|
||||
static DataProcessingSettings DefaultDataProcessingSettings();
|
||||
DetectorMode GetDetectorMode() const;
|
||||
@@ -258,7 +265,7 @@ public:
|
||||
std::string GetInstrumentNameShort() const;
|
||||
std::string GetDetectorDescription() const;
|
||||
|
||||
void GetDetectorModuleHostname(std::vector<std::string>& output) const;
|
||||
std::vector<std::string> GetDetectorModuleHostname() const;
|
||||
bool GetPedestalWithExternalTrigger() const;
|
||||
|
||||
DiffractionExperiment& ApplySolidAngleCorr(bool input);
|
||||
@@ -276,6 +283,9 @@ public:
|
||||
|
||||
DiffractionExperiment& FPGAOutputMode(FPGAPixelOutput input);
|
||||
FPGAPixelOutput GetFPGAOutputMode() const;
|
||||
|
||||
int64_t GetUDPInterfaceCount() const;
|
||||
std::vector<DetectorModuleConfig> GetDetectorModuleConfig(const std::vector<AcquisitionDeviceNetConfig>& net_config) const;
|
||||
};
|
||||
|
||||
inline int64_t CalculateStride(const std::chrono::microseconds &frame_time, const std::chrono::microseconds &preview_time) {
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef JUNGFRAUJOCH_ZMQIMAGEPUSHER_H
|
||||
#define JUNGFRAUJOCH_ZMQIMAGEPUSHER_H
|
||||
|
||||
#include <jfjoch.pb.h>
|
||||
|
||||
#include "ImagePusher.h"
|
||||
#include "ThreadSafeFIFO.h"
|
||||
#include "ZMQWrappers.h"
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#ifndef JUNGFRAUJOCH_ZMQPREVIEWPUBLISHER_H
|
||||
#define JUNGFRAUJOCH_ZMQPREVIEWPUBLISHER_H
|
||||
|
||||
#include <jfjoch.pb.h>
|
||||
|
||||
#include "ZMQWrappers.h"
|
||||
#include "DiffractionExperiment.h"
|
||||
#include "../jungfrau/JFCalibration.h"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
ADD_SUBDIRECTORY(slsDetectorPackage)
|
||||
INSTALL(TARGETS sls_detector_put sls_detector_get RUNTIME)
|
||||
|
||||
ADD_EXECUTABLE(jfjoch_detector jfjoch_detector.cpp JFJochDetector.cpp JFJochDetector.h DetectorWrapper.cpp DetectorWrapper.h)
|
||||
ADD_LIBRARY(JFJochDetector STATIC DetectorWrapper.cpp DetectorWrapper.h)
|
||||
TARGET_LINK_LIBRARIES(JFJochDetector CommonFunctions slsSupportShared slsDetectorShared)
|
||||
|
||||
TARGET_LINK_LIBRARIES(jfjoch_detector CommonFunctions slsSupportShared slsDetectorShared)
|
||||
|
||||
INSTALL(TARGETS sls_detector_put sls_detector_get jfjoch_detector RUNTIME)
|
||||
SET_PROPERTY(TARGET jfjoch_detector PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
@@ -6,7 +6,8 @@
|
||||
#include "../common/JFJochException.h"
|
||||
#include "../common/Definitions.h"
|
||||
|
||||
void DetectorWrapper::Configure(const JFJochProtoBuf::DetectorConfig &request) {
|
||||
void DetectorWrapper::Configure(const DiffractionExperiment& experiment,
|
||||
const std::vector<AcquisitionDeviceNetConfig>& net_config) {
|
||||
logger.Info("Configure");
|
||||
try {
|
||||
if (det.size() > 0) {
|
||||
@@ -19,45 +20,43 @@ void DetectorWrapper::Configure(const JFJochProtoBuf::DetectorConfig &request) {
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
}
|
||||
auto module_hostname = experiment.GetDetectorModuleHostname();
|
||||
|
||||
if (request.module_hostname_size() > 0) {
|
||||
std::vector<std::string> module_hostname;
|
||||
for (const auto &iter: request.module_hostname())
|
||||
module_hostname.push_back(iter);
|
||||
if (!module_hostname.empty() > 0) {
|
||||
logger.Info("Resetting detector module host names");
|
||||
det.setHostname(module_hostname);
|
||||
}
|
||||
if (det.size() != request.modules_size()) {
|
||||
|
||||
if (det.size() != experiment.GetModulesNum()) {
|
||||
logger.Error("Discrepancy in module number between DAQ and detector");
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
}
|
||||
|
||||
if ((request.udp_interface_count() != 1) && (request.udp_interface_count() != 2))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Only 1 and 2 are supported as UDP interface count");
|
||||
det.setNumberofUDPInterfaces(request.udp_interface_count());
|
||||
det.setNumberofUDPInterfaces(experiment.GetUDPInterfaceCount());
|
||||
|
||||
for (int i = 0; i < request.modules_size(); i++) {
|
||||
auto mod_cfg = experiment.GetDetectorModuleConfig(net_config);
|
||||
|
||||
for (int i = 0; i < mod_cfg.size(); i++) {
|
||||
logger.Info("Configure network for module {}", i);
|
||||
|
||||
auto &cfg = request.modules(i);
|
||||
auto &cfg = mod_cfg[i];
|
||||
|
||||
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1()), {i});
|
||||
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1), {i});
|
||||
det.setSourceUDPMAC(sls::MacAddr(BASE_DETECTOR_MAC + i * 2), {i});
|
||||
|
||||
det.setDestinationUDPPort (cfg.udp_dest_port_1(), i);
|
||||
det.setDestinationUDPIP( sls::IpAddr(cfg.ipv4_dest_addr_1()), {i});
|
||||
det.setDestinationUDPMAC( sls::MacAddr(cfg.mac_addr_dest_1()), {i});
|
||||
det.setDestinationUDPPort (cfg.udp_dest_port_1, i);
|
||||
det.setDestinationUDPIP( sls::IpAddr(cfg.ipv4_dest_addr_1), {i});
|
||||
det.setDestinationUDPMAC( sls::MacAddr(cfg.mac_addr_dest_1), {i});
|
||||
|
||||
if (request.udp_interface_count() == 2) {
|
||||
det.setSourceUDPIP2(sls::IpAddr(cfg.ipv4_src_addr_2()), {i});
|
||||
if (experiment.GetUDPInterfaceCount() == 2) {
|
||||
det.setSourceUDPIP2(sls::IpAddr(cfg.ipv4_src_addr_2), {i});
|
||||
det.setSourceUDPMAC2(sls::MacAddr(BASE_DETECTOR_MAC + i * 2 + 1), {i});
|
||||
det.setDestinationUDPPort2(cfg.udp_dest_port_2(), i);
|
||||
det.setDestinationUDPIP2( sls::IpAddr(cfg.ipv4_dest_addr_2()), {i});
|
||||
det.setDestinationUDPMAC2(sls::MacAddr(cfg.mac_addr_dest_2()), {i});
|
||||
det.setDestinationUDPPort2(cfg.udp_dest_port_2, i);
|
||||
det.setDestinationUDPIP2( sls::IpAddr(cfg.ipv4_dest_addr_2), {i});
|
||||
det.setDestinationUDPMAC2(sls::MacAddr(cfg.mac_addr_dest_2), {i});
|
||||
}
|
||||
uint32_t tmp = (cfg.module_id_in_data_stream() * 2) % UINT16_MAX;
|
||||
uint32_t tmp = (cfg.module_id_in_data_stream * 2) % UINT16_MAX;
|
||||
uint32_t column_id_register = ((tmp + 1) << 16) | tmp;
|
||||
|
||||
det.writeRegister(0x7C, column_id_register, {i});
|
||||
@@ -87,20 +86,20 @@ void DetectorWrapper::Configure(const JFJochProtoBuf::DetectorConfig &request) {
|
||||
logger.Info(" ... done");
|
||||
}
|
||||
|
||||
void DetectorWrapper::Start(const JFJochProtoBuf::DetectorInput &request) {
|
||||
void DetectorWrapper::Start(const DiffractionExperiment& experiment) {
|
||||
logger.Info("Start");
|
||||
|
||||
if (det.size() != request.modules_num())
|
||||
if (det.size() != experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
|
||||
try {
|
||||
InternalStop();
|
||||
switch (request.mode()) {
|
||||
case JFJochProtoBuf::PEDESTAL_G1:
|
||||
switch (experiment.GetDetectorMode()) {
|
||||
case DetectorMode::PedestalG1:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G1);
|
||||
break;
|
||||
case JFJochProtoBuf::PEDESTAL_G2:
|
||||
case DetectorMode::PedestalG2:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G2);
|
||||
break;
|
||||
default:
|
||||
@@ -109,19 +108,38 @@ void DetectorWrapper::Start(const JFJochProtoBuf::DetectorInput &request) {
|
||||
}
|
||||
|
||||
det.setNextFrameNumber(1);
|
||||
det.setNumberOfFrames(request.num_frames());
|
||||
det.setNumberOfTriggers(request.num_triggers());
|
||||
det.setStorageCellStart(request.storage_cell_start());
|
||||
det.setNumberOfAdditionalStorageCells(request.storage_cell_number() - 1);
|
||||
det.setStorageCellDelay(std::chrono::nanoseconds(request.storage_cell_delay_ns() - MIN_STORAGE_CELL_DELAY_IN_NS));
|
||||
|
||||
if (request.period_us() < MIN_FRAME_TIME_HALF_SPEED_IN_US)
|
||||
if (experiment.GetNumTriggers() == 1) {
|
||||
det.setNumberOfFrames(experiment.GetFrameNumPerTrigger() + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
det.setNumberOfTriggers(1);
|
||||
} else {
|
||||
// More than 1 trigger - detector needs one trigger or few more trigger
|
||||
if (experiment.GetStorageCellNumber() > 1)
|
||||
det.setNumberOfFrames(1);
|
||||
else
|
||||
det.setNumberOfFrames(experiment.GetFrameNumPerTrigger());
|
||||
|
||||
if (experiment.GetFrameNumPerTrigger() < DELAY_FRAMES_STOP_AND_QUIT)
|
||||
det.setNumberOfTriggers(experiment.GetNumTriggers() + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
else
|
||||
det.setNumberOfTriggers(experiment.GetNumTriggers() + 1);
|
||||
}
|
||||
|
||||
det.setStorageCellStart(experiment.GetStorageCellStart());
|
||||
det.setNumberOfAdditionalStorageCells(experiment.GetStorageCellNumber() - 1);
|
||||
det.setStorageCellDelay(experiment.GetStorageCellDelay() - std::chrono::nanoseconds(MIN_STORAGE_CELL_DELAY_IN_NS));
|
||||
|
||||
if ((experiment.GetStorageCellNumber() > 1) || (experiment.GetFrameTime().count() < MIN_FRAME_TIME_HALF_SPEED_IN_US))
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::FULL_SPEED);
|
||||
else
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::HALF_SPEED);
|
||||
|
||||
det.setPeriod(std::chrono::microseconds(request.period_us()));
|
||||
det.setExptime(std::chrono::microseconds(request.count_time_us()));
|
||||
if (experiment.GetStorageCellNumber() > 1) {
|
||||
det.setPeriod((experiment.GetFrameTime() + std::chrono::microseconds(10)) * experiment.GetStorageCellNumber() );
|
||||
} else
|
||||
det.setPeriod(experiment.GetFrameTime());
|
||||
|
||||
det.setExptime(std::chrono::microseconds(experiment.GetFrameCountTime()));
|
||||
|
||||
det.startDetector();
|
||||
} catch (std::exception &e) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define JUNGFRAUJOCH_DETECTORWRAPPER_H
|
||||
|
||||
#include <sls/Detector.h>
|
||||
#include <jfjoch.pb.h>
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
#define BASE_DETECTOR_MAC 0xAABBCCDDEE10 // little-endian!
|
||||
@@ -18,8 +18,8 @@ class DetectorWrapper {
|
||||
public:
|
||||
enum class DetectorState {IDLE, ERROR, BUSY};
|
||||
[[nodiscard]] DetectorState GetState() const;
|
||||
void Configure(const JFJochProtoBuf::DetectorConfig &config);
|
||||
void Start(const JFJochProtoBuf::DetectorInput &request);
|
||||
void Configure(const DiffractionExperiment& experiment, const std::vector<AcquisitionDeviceNetConfig>& net_config);
|
||||
void Start(const DiffractionExperiment& experiment);
|
||||
void Stop();
|
||||
void Trigger();
|
||||
void Deactivate();
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#include "JFJochDetector.h"
|
||||
#include "../common/JFJochException.h"
|
||||
|
||||
grpc::Status JFJochDetector::Start(grpc::ServerContext *context, const JFJochProtoBuf::DetectorInput *request,
|
||||
JFJochProtoBuf::Empty *response) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
|
||||
try {
|
||||
detector.Start(*request);
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
grpc::Status JFJochDetector::Stop(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
|
||||
try {
|
||||
detector.Stop();
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
grpc::Status JFJochDetector::On(grpc::ServerContext *context, const JFJochProtoBuf::DetectorConfig *request,
|
||||
JFJochProtoBuf::Empty *response) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
try {
|
||||
detector.Configure(*request);
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
grpc::Status JFJochDetector::Off(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
try {
|
||||
detector.Deactivate();
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
grpc::Status JFJochDetector::Status(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::DetectorStatus *response) {
|
||||
try {
|
||||
switch(detector.GetState()) {
|
||||
case DetectorWrapper::DetectorState::IDLE:
|
||||
response->set_state(JFJochProtoBuf::IDLE);
|
||||
break;
|
||||
case DetectorWrapper::DetectorState::ERROR:
|
||||
response->set_state(JFJochProtoBuf::ERROR);
|
||||
break;
|
||||
case DetectorWrapper::DetectorState::BUSY:
|
||||
response->set_state(JFJochProtoBuf::BUSY);
|
||||
break;
|
||||
}
|
||||
response->set_fw_version(detector.GetFirmwareVersion());
|
||||
response->set_server_version(detector.GetDetectorServerVersion());
|
||||
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
|
||||
grpc::Status JFJochDetector::Trigger(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) {
|
||||
std::unique_lock<std::mutex> ul(m);
|
||||
try {
|
||||
detector.Trigger();
|
||||
return grpc::Status::OK;
|
||||
} catch (JFJochException &e) {
|
||||
return {grpc::StatusCode::ABORTED, e.what()};
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#ifndef DETECTORWRAPPER_H
|
||||
#define DETECTORWRAPPER_H
|
||||
|
||||
#include <sls/Detector.h>
|
||||
#include "jfjoch.grpc.pb.h"
|
||||
#include "DetectorWrapper.h"
|
||||
|
||||
#include "../common/Logger.h"
|
||||
|
||||
class JFJochDetector final : public JFJochProtoBuf::gRPC_JFJochDetector::Service {
|
||||
std::mutex m;
|
||||
DetectorWrapper detector;
|
||||
public:
|
||||
grpc::Status Start(grpc::ServerContext *context, const JFJochProtoBuf::DetectorInput *request,
|
||||
JFJochProtoBuf::Empty *response) override;
|
||||
grpc::Status Stop(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) override;
|
||||
grpc::Status Status(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::DetectorStatus *response) override;
|
||||
grpc::Status On(grpc::ServerContext *context, const JFJochProtoBuf::DetectorConfig *request,
|
||||
JFJochProtoBuf::Empty *response) override;
|
||||
grpc::Status Off(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) override;
|
||||
grpc::Status Trigger(grpc::ServerContext *context, const JFJochProtoBuf::Empty *request,
|
||||
JFJochProtoBuf::Empty *response) override;
|
||||
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_DETECTORWRAPPER_H
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#include <fstream>
|
||||
#include <grpcpp/server.h>
|
||||
#include <grpcpp/server_builder.h>
|
||||
#include <grpcpp/security/server_credentials.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "JFJochDetector.h"
|
||||
#include "../common/Logger.h"
|
||||
#include "../grpc/gRPCServer_Template.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Logger logger("jfjoch_detector");
|
||||
|
||||
nlohmann::json input;
|
||||
|
||||
std::string grpc_addr = "unix:/opt/jfjoch/.jfjoch-detector";
|
||||
if (argc == 2) grpc_addr = "0.0.0.0:" + std::string(argv[1]);
|
||||
|
||||
JFJochDetector service;
|
||||
|
||||
auto server = gRPCServer(grpc_addr, service);
|
||||
logger.Info("gRPC configuration listening on " + grpc_addr);
|
||||
server->Wait();
|
||||
}
|
||||
@@ -47,7 +47,6 @@ TARGET_INCLUDE_DIRECTORIES(JFJochProtoBuf PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
TARGET_LINK_LIBRARIES(JFJochProtoBuf ${_GRPC_GRPCPP})
|
||||
|
||||
ADD_LIBRARY(gRPCClients STATIC
|
||||
JFJochDetectorClient.cpp JFJochDetectorClient.h
|
||||
JFJochWriterClient.cpp JFJochWriterClient.h
|
||||
JFJochWriterGroupClient.cpp JFJochWriterGroupClient.h)
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include "JFJochDetectorClient.h"
|
||||
#include "../common/JFJochException.h"
|
||||
|
||||
void JFJochDetectorClient::Connect(const std::string &addr) {
|
||||
if (addr.empty()) _stub.reset();
|
||||
else {
|
||||
_stub = std::make_unique<JFJochProtoBuf::gRPC_JFJochDetector::Stub>(
|
||||
grpc::CreateChannel(addr, grpc::InsecureChannelCredentials()));
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochDetectorClient::Start(const DiffractionExperiment &in_experiment) {
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::DetectorInput request = in_experiment;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->Start(&context, request, &empty);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochDetectorClient::Stop() {
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->Stop(&context, empty, &empty);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochDetectorClient::On(const JFJochProtoBuf::DetectorConfig &request) {
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->On(&context, request, &empty);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochDetectorClient::Off() {
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->Off(&context, empty, &empty);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochDetectorClient::Trigger() {
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->Trigger(&context, empty, &empty);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
}
|
||||
}
|
||||
|
||||
JFJochProtoBuf::DetectorStatus JFJochDetectorClient::GetStatus() {
|
||||
JFJochProtoBuf::DetectorStatus ret;
|
||||
if (_stub) {
|
||||
grpc::ClientContext context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
auto status = _stub->Status(&context, empty, &ret);
|
||||
if (!status.ok()) throw JFJochException(JFJochExceptionCategory::gRPCError,
|
||||
"JFJochDetector: " + status.error_message());
|
||||
} else {
|
||||
ret.set_state(JFJochProtoBuf::NOT_INITIALIZED);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#ifndef JUNGFRAUJOCH_JFJOCHDETECTORCLIENT_H
|
||||
#define JUNGFRAUJOCH_JFJOCHDETECTORCLIENT_H
|
||||
|
||||
#include <string>
|
||||
#include <jfjoch.grpc.pb.h>
|
||||
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
|
||||
class JFJochDetectorClient {
|
||||
std::unique_ptr<JFJochProtoBuf::gRPC_JFJochDetector::Stub> _stub;
|
||||
public:
|
||||
void Connect(const std::string &addr);
|
||||
void Start(const DiffractionExperiment &request);
|
||||
void Stop();
|
||||
JFJochProtoBuf::DetectorStatus GetStatus();
|
||||
void On(const JFJochProtoBuf::DetectorConfig &request);
|
||||
void Off();
|
||||
void Trigger();
|
||||
};
|
||||
|
||||
|
||||
#endif //JUNGFRAUJOCH_JFJOCHDETECTORCLIENT_H
|
||||
@@ -19,12 +19,6 @@ enum DetectorMode {
|
||||
PEDESTAL_G2 = 4;
|
||||
};
|
||||
|
||||
enum FPGAFIFOStatusEnum {
|
||||
EMPTY = 0;
|
||||
FULL = 1;
|
||||
PARTIAL = 2;
|
||||
}
|
||||
|
||||
enum State {
|
||||
NOT_INITIALIZED = 0;
|
||||
IDLE = 1;
|
||||
@@ -181,52 +175,6 @@ message WriterOutput {
|
||||
repeated DataFileStatistics file_statistics = 4;
|
||||
}
|
||||
|
||||
// Detector
|
||||
message DetectorModuleConfig {
|
||||
uint64 udp_dest_port_1 = 1;
|
||||
uint64 udp_dest_port_2 = 2;
|
||||
string ipv4_src_addr_1 = 3;
|
||||
string ipv4_src_addr_2 = 4;
|
||||
string ipv4_dest_addr_1 = 5;
|
||||
string ipv4_dest_addr_2 = 6;
|
||||
string mac_addr_dest_1 = 7;
|
||||
string mac_addr_dest_2 = 8;
|
||||
uint64 module_id_in_data_stream = 9;
|
||||
}
|
||||
|
||||
message DetectorConfig {
|
||||
repeated DetectorModuleConfig modules = 1;
|
||||
repeated string module_hostname = 2;
|
||||
int64 udp_interface_count = 3;
|
||||
}
|
||||
|
||||
message DetectorInput {
|
||||
int64 modules_num = 1;
|
||||
DetectorMode mode = 2;
|
||||
int64 num_frames = 3;
|
||||
int64 num_triggers = 4;
|
||||
int64 storage_cell_number = 5;
|
||||
int64 storage_cell_start = 6;
|
||||
int64 storage_cell_delay_ns = 7;
|
||||
int64 period_us = 9;
|
||||
int64 count_time_us = 10;
|
||||
}
|
||||
|
||||
message DetectorOutput {
|
||||
|
||||
}
|
||||
|
||||
message DetectorStatus {
|
||||
State state = 1;
|
||||
int64 fw_version = 2;
|
||||
string server_version = 3;
|
||||
}
|
||||
|
||||
message FPGAFIFOStatus {
|
||||
string name = 1;
|
||||
FPGAFIFOStatusEnum value = 2;
|
||||
}
|
||||
|
||||
message DataProcessingSettings {
|
||||
float signal_to_noise_threshold = 1; // STRONG_PIXEL in XDS
|
||||
int64 photon_count_threshold = 2; // Threshold in photon counts
|
||||
@@ -302,15 +250,6 @@ service gRPC_JFJochWriter {
|
||||
rpc Stop (Empty) returns (WriterOutput) {}
|
||||
}
|
||||
|
||||
service gRPC_JFJochDetector {
|
||||
rpc Start (DetectorInput) returns (Empty) {}
|
||||
rpc Stop (Empty) returns (Empty) {}
|
||||
rpc Status (Empty) returns (DetectorStatus) {}
|
||||
rpc On (DetectorConfig) returns (Empty) {}
|
||||
rpc Off (Empty) returns (Empty) {}
|
||||
rpc Trigger (Empty) returns (Empty) {}
|
||||
}
|
||||
|
||||
service gRPC_JFJochBroker {
|
||||
rpc Start (DatasetSettings) returns (Empty) {}
|
||||
rpc Stop (Empty) returns (Empty) {}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "JFCalibration.h"
|
||||
|
||||
#include "../compression/JFJochCompressor.h"
|
||||
#include <cstring>
|
||||
|
||||
JFCalibration::JFCalibration(size_t in_nmodules, size_t in_nstorage_cells) :
|
||||
nmodules(in_nmodules),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "JFConversionFloatingPoint.h"
|
||||
|
||||
JFConversionFloatingPoint::JFConversionFloatingPoint()
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <jfjoch.pb.h>
|
||||
|
||||
#include "../common/Definitions.h"
|
||||
|
||||
|
||||
+31
-47
File diff suppressed because one or more lines are too long
@@ -132,232 +132,6 @@ class gRPC_JFJochWriter(object):
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
|
||||
class gRPC_JFJochDetectorStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.Start = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/Start',
|
||||
request_serializer=jfjoch__pb2.DetectorInput.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
)
|
||||
self.Stop = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/Stop',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
)
|
||||
self.Status = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/Status',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.DetectorStatus.FromString,
|
||||
)
|
||||
self.On = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/On',
|
||||
request_serializer=jfjoch__pb2.DetectorConfig.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
)
|
||||
self.Off = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/Off',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
)
|
||||
self.Trigger = channel.unary_unary(
|
||||
'/JFJochProtoBuf.gRPC_JFJochDetector/Trigger',
|
||||
request_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
response_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
)
|
||||
|
||||
|
||||
class gRPC_JFJochDetectorServicer(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
def Start(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Stop(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Status(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def On(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Off(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Trigger(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_gRPC_JFJochDetectorServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'Start': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Start,
|
||||
request_deserializer=jfjoch__pb2.DetectorInput.FromString,
|
||||
response_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'Stop': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Stop,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'Status': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Status,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.DetectorStatus.SerializeToString,
|
||||
),
|
||||
'On': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.On,
|
||||
request_deserializer=jfjoch__pb2.DetectorConfig.FromString,
|
||||
response_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'Off': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Off,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
),
|
||||
'Trigger': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Trigger,
|
||||
request_deserializer=jfjoch__pb2.Empty.FromString,
|
||||
response_serializer=jfjoch__pb2.Empty.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'JFJochProtoBuf.gRPC_JFJochDetector', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
# This class is part of an EXPERIMENTAL API.
|
||||
class gRPC_JFJochDetector(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
@staticmethod
|
||||
def Start(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/Start',
|
||||
jfjoch__pb2.DetectorInput.SerializeToString,
|
||||
jfjoch__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Stop(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/Stop',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Status(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/Status',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.DetectorStatus.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def On(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/On',
|
||||
jfjoch__pb2.DetectorConfig.SerializeToString,
|
||||
jfjoch__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Off(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/Off',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Trigger(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/JFJochProtoBuf.gRPC_JFJochDetector/Trigger',
|
||||
jfjoch__pb2.Empty.SerializeToString,
|
||||
jfjoch__pb2.Empty.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
|
||||
class gRPC_JFJochBrokerStub(object):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
|
||||
|
||||
@@ -585,58 +585,6 @@ TEST_CASE("DiffractionExperiment_StorageCells_Pedestal","[DiffractionExperiment]
|
||||
REQUIRE(x.GetFrameNumPerTrigger() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_MultiTriggger","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(700us).ImagesPerTrigger(350).NumTriggers(7);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
REQUIRE(ret.period_us() == x.GetFrameTime().count());
|
||||
REQUIRE(ret.count_time_us() == x.GetFrameCountTime().count());
|
||||
REQUIRE(ret.num_triggers() == 8);
|
||||
REQUIRE(ret.num_frames() == 350);
|
||||
REQUIRE(ret.storage_cell_number() == 1);
|
||||
REQUIRE(ret.mode() == JFJochProtoBuf::CONVERSION);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_NoTriggger","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).ImagesPerTrigger(350).NumTriggers(1);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
REQUIRE(ret.period_us() == x.GetFrameTime().count());
|
||||
REQUIRE(ret.count_time_us() == x.GetFrameCountTime().count());
|
||||
REQUIRE(ret.num_triggers() == 1);
|
||||
REQUIRE(ret.num_frames() == 350 + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
REQUIRE(ret.storage_cell_number() == 1);
|
||||
REQUIRE(ret.mode() == JFJochProtoBuf::CONVERSION);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_PedestalG2","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).PedestalG2Frames(4560).NumTriggers(1).Mode(DetectorMode::PedestalG2);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
REQUIRE(ret.period_us() == x.GetFrameTime().count());
|
||||
REQUIRE(ret.count_time_us() == x.GetFrameCountTime().count());
|
||||
REQUIRE(ret.num_triggers() == 1);
|
||||
REQUIRE(ret.num_frames() == 4560 + DELAY_FRAMES_STOP_AND_QUIT);
|
||||
REQUIRE(ret.storage_cell_number() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_StorageCell","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).NumTriggers(4560).StorageCells(8).StorageCellDelay(7000ns);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
REQUIRE(ret.period_us() == 8 * (x.GetFrameTime().count() + 10));
|
||||
REQUIRE(ret.count_time_us() == x.GetFrameCountTime().count());
|
||||
REQUIRE(ret.num_triggers() == 4560 + 1);
|
||||
REQUIRE(ret.num_frames() == 1);
|
||||
REQUIRE(ret.storage_cell_number() == 8);
|
||||
REQUIRE(ret.storage_cell_delay_ns() == 7000);
|
||||
REQUIRE(ret.storage_cell_start() == x.GetStorageCellStart());
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DefaultDataProcessingSettings","[DiffractionExperiment]") {
|
||||
REQUIRE_NOTHROW(DiffractionExperiment::CheckDataProcessingSettings(
|
||||
DiffractionExperiment::DefaultDataProcessingSettings()));
|
||||
@@ -680,7 +628,6 @@ TEST_CASE("DiffractionExperiment_FPGA_Summation_output","[DiffractionExperiment]
|
||||
TEST_CASE("DiffractionExperiment_DetectorModuleHostname","[DiffractionExperiment]") {
|
||||
std::vector<std::string> h = {"mx1", "mx2", "mx3"};
|
||||
DiffractionExperiment x(DetectorSetup(3, "X", h));
|
||||
JFJochProtoBuf::DetectorConfig det_cfg;
|
||||
|
||||
std::vector<AcquisitionDeviceNetConfig> net_cfg;
|
||||
|
||||
@@ -695,9 +642,10 @@ TEST_CASE("DiffractionExperiment_DetectorModuleHostname","[DiffractionExperiment
|
||||
.udp_port = 1234});
|
||||
|
||||
std::vector<std::string> h_out;
|
||||
REQUIRE_NOTHROW(x.GetDetectorModuleHostname(h_out));
|
||||
REQUIRE_NOTHROW(h_out = x.GetDetectorModuleHostname());
|
||||
REQUIRE(h == h_out);
|
||||
|
||||
REQUIRE_NOTHROW(det_cfg = x.DetectorConfig(net_cfg));
|
||||
auto det_cfg = x.GetDetectorModuleConfig(net_cfg);
|
||||
REQUIRE(det_cfg.size() == x.GetModulesNum());
|
||||
}
|
||||
|
||||
|
||||
@@ -147,13 +147,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
logger.Info("Write HDF5 master file");
|
||||
|
||||
JFJochProtoBuf::ReceiverOutput receiver_output;
|
||||
|
||||
receiver_output.set_start_time_ms(1640995200000);
|
||||
receiver_output.set_end_time_ms(1640995210000);
|
||||
receiver_output.set_images_sent(nimages);
|
||||
receiver_output.set_max_image_number_sent(nimages - 1);
|
||||
|
||||
EndMessage end_message;
|
||||
end_message.number_of_images = x.GetImageNum();
|
||||
HDF5Metadata::NXmx(start_message, end_message);
|
||||
|
||||
@@ -15,7 +15,7 @@ ADD_LIBRARY(JFJochWriter STATIC
|
||||
StreamWriter.cpp StreamWriter.h
|
||||
JFJochWriterService.cpp JFJochWriterService.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JFJochWriter HDF5Wrappers CommonFunctions)
|
||||
TARGET_LINK_LIBRARIES(JFJochWriter HDF5Wrappers CommonFunctions JFJochProtoBuf)
|
||||
|
||||
TARGET_LINK_LIBRARIES(jfjoch_writer JFJochWriter)
|
||||
TARGET_LINK_LIBRARIES(jfjoch_writer_multi JFJochWriter)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#define JUNGFRAUJOCH_JFJOCHWRITERSERVICE_H
|
||||
|
||||
#include <shared_mutex>
|
||||
#include "jfjoch.grpc.pb.h"
|
||||
#include <jfjoch.grpc.pb.h>
|
||||
#include "StreamWriter.h"
|
||||
|
||||
class JFJochWriterService final : public JFJochProtoBuf::gRPC_JFJochWriter::Service {
|
||||
|
||||
Reference in New Issue
Block a user