Monolithic design achieved! (jfjoch_broker is NOT up to date!)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user