Modifications necessary for the EIGER test
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
|
||||
const std::vector<AcquisitionDeviceNetConfig>& net_config) {
|
||||
logger.Info("Initialize detector");
|
||||
det_type = experiment.GetDetectorSetup().GetDetectorType();
|
||||
try {
|
||||
auto module_hostname = experiment.GetDetectorModuleHostname();
|
||||
|
||||
@@ -22,9 +23,11 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
|
||||
// Stop the detector
|
||||
InternalStop();
|
||||
|
||||
// Clear synchronization prior to reconfiguring the detector
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
// Clear synchronization prior to reconfiguring the detector
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
}
|
||||
|
||||
if (!module_hostname.empty()) {
|
||||
bool reset = true;
|
||||
@@ -44,69 +47,101 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
det.setNumberofUDPInterfaces(experiment.GetUDPInterfaceCount());
|
||||
|
||||
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 = mod_cfg[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});
|
||||
|
||||
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});
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
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");
|
||||
}
|
||||
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});
|
||||
det.setNumberofUDPInterfaces(experiment.GetUDPInterfaceCount());
|
||||
for (int i = 0; i < mod_cfg.size(); i++) {
|
||||
logger.Info("Configure network for module {}", i);
|
||||
|
||||
auto &cfg = mod_cfg[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});
|
||||
|
||||
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});
|
||||
}
|
||||
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});
|
||||
}
|
||||
|
||||
det.setTemperatureControl(true);
|
||||
det.setThresholdTemperature(THRESHOLD_TEMPERATURE_DEGC);
|
||||
} else if (det_type == DetectorType::EIGER) {
|
||||
|
||||
if (det.size() != 2 * experiment.GetModulesNum()) {
|
||||
logger.Error("Discrepancy in module number between DAQ and detector");
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
}
|
||||
|
||||
det.setTenGiga(true);
|
||||
auto trim_files = experiment.GetDetectorSetup().GetTrimFileNames();
|
||||
|
||||
for (int i = 0; i < mod_cfg.size(); i++) {
|
||||
logger.Info("Configure network for module {}", i);
|
||||
|
||||
auto &cfg = mod_cfg[i];
|
||||
|
||||
det.setDestinationUDPPort(cfg.udp_dest_port_1, 2 * i);
|
||||
det.setDestinationUDPPort2(cfg.udp_dest_port_1, 2 * i + 1);
|
||||
det.setSourceUDPIP(sls::IpAddr(cfg.ipv4_src_addr_1), {2 * i, 2 * i + 1});
|
||||
det.setDestinationUDPIP(sls::IpAddr(cfg.ipv4_dest_addr_1), {2 * i, 2 * i + 1});
|
||||
det.setDestinationUDPMAC(sls::MacAddr(cfg.mac_addr_dest_1), {2 * i, 2 * i + 1});
|
||||
|
||||
if (!trim_files.empty()) {
|
||||
det.loadTrimbits(trim_files[2 * i], {2 * i});
|
||||
det.loadTrimbits(trim_files[2 * i + 1], {2 * i + 1});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
det.setTemperatureControl(true);
|
||||
det.setThresholdTemperature(THRESHOLD_TEMPERATURE_DEGC);
|
||||
|
||||
det.setSynchronization(false);
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
det.setTimingMode(slsDetectorDefs::timingMode::TRIGGER_EXPOSURE);
|
||||
|
||||
det.setTimingMode(slsDetectorDefs::timingMode::TRIGGER_EXPOSURE);
|
||||
auto tx_delay = experiment.GetDetectorSetup().GetTxDelay();
|
||||
if (tx_delay.size() == experiment.GetModulesNum()) {
|
||||
for (int i = 0 ; i < tx_delay.size(); i++)
|
||||
det.setTransmissionDelayFrame(tx_delay[i], {i});
|
||||
}
|
||||
|
||||
det.setMaster(true, 0);
|
||||
det.setSynchronization(true);
|
||||
det.setMaster(true, 0);
|
||||
det.setSynchronization(true);
|
||||
|
||||
auto tx_delay = experiment.GetDetectorSetup().GetTxDelay();
|
||||
if (tx_delay.size() == experiment.GetModulesNum()) {
|
||||
for (int i = 0 ; i < tx_delay.size(); i++)
|
||||
det.setTransmissionDelayFrame(tx_delay[i], {i});
|
||||
if (experiment.GetUDPInterfaceCount() == 2)
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::FULL_SPEED);
|
||||
else
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::HALF_SPEED);
|
||||
|
||||
det.setAutoComparatorDisable(true);
|
||||
if (!det.getPowerChip().squash(false)) {
|
||||
det.setPowerChip(true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
}
|
||||
} else if (det_type == DetectorType::EIGER) {
|
||||
det.setTimingMode(slsDetectorDefs::timingMode::AUTO_TIMING);
|
||||
}
|
||||
|
||||
if (experiment.GetUDPInterfaceCount() == 2)
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::FULL_SPEED);
|
||||
else
|
||||
det.setReadoutSpeed(slsDetectorDefs::speedLevel::HALF_SPEED);
|
||||
|
||||
det.setAutoComparatorDisable(true);
|
||||
if (!det.getPowerChip().squash(false)) {
|
||||
det.setPowerChip(true);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
}
|
||||
|
||||
det.setHighVoltage(HIGH_VOLTAGE);
|
||||
det.setHighVoltage(experiment.GetDetectorSetup().GetHighVoltage());
|
||||
} catch (const std::exception &e) {
|
||||
logger.ErrorException(e);
|
||||
throw JFJochException(JFJochExceptionCategory::Detector, e.what());
|
||||
@@ -117,9 +152,16 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
|
||||
void DetectorWrapper::Start(const DiffractionExperiment& experiment) {
|
||||
logger.Info("Start");
|
||||
|
||||
if (det.size() != experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
if (det.size() != experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
} else if (det_type == DetectorType::EIGER) {
|
||||
if (det.size() != 2 * experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Discrepancy in module number between DAQ and detector");
|
||||
// det.setThresholdEnergy(std::lround(experiment.GetPhotonEnergy_keV() * 1000.0/ 2.0));
|
||||
}
|
||||
|
||||
try {
|
||||
InternalStop();
|
||||
@@ -163,11 +205,11 @@ void DetectorWrapper::Deactivate() {
|
||||
InternalStop();
|
||||
det.setHighVoltage(0);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
det.setPowerChip(false);
|
||||
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
det.setPowerChip(false);
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
}
|
||||
det.freeSharedMemory();
|
||||
} catch (std::exception &e) {
|
||||
logger.ErrorException(e);
|
||||
@@ -280,8 +322,10 @@ std::vector<int64_t> DetectorWrapper::GetHighVoltage() const {
|
||||
try {
|
||||
auto result = det.getHighVoltage();
|
||||
std::vector<int64_t> ret;
|
||||
for (int i = 0; i < result.size(); i++)
|
||||
ret.push_back(result[i]);
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
if (result[i] >= 0)
|
||||
ret.push_back(result[i]);
|
||||
}
|
||||
return ret;
|
||||
} catch (std::exception &e) {
|
||||
throw JFJochException(JFJochExceptionCategory::Detector, e.what());
|
||||
@@ -293,46 +337,54 @@ DetectorStatus DetectorWrapper::GetStatus() const {
|
||||
DetectorStatus status;
|
||||
status.detector_server_version = GetDetectorServerVersion();
|
||||
status.detector_state = GetState();
|
||||
status.power_state = GetPowerState();
|
||||
status.remaining_triggers = GetNumberOfTriggersLeft();
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
status.power_state = GetPowerState();
|
||||
status.remaining_triggers = GetNumberOfTriggersLeft();
|
||||
} else {
|
||||
status.power_state = DetectorPowerState::ON;
|
||||
status.remaining_triggers = -1;
|
||||
}
|
||||
|
||||
status.temperature_fpga_degC = GetFPGATemperatures();
|
||||
status.high_voltage_V = GetHighVoltage();
|
||||
return status;
|
||||
}
|
||||
|
||||
void DetectorWrapper::Configure(const DiffractionExperiment &experiment) {
|
||||
if (experiment.IsFixedGainG1()) {
|
||||
if ((experiment.GetDetectorMode() == DetectorMode::PedestalG0) ||
|
||||
(experiment.GetDetectorMode() == DetectorMode::PedestalG2))
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Pedestal G0/G2 doesn't make sense for fixed G1 mode");
|
||||
det.setGainMode(slsDetectorDefs::FIX_G1);
|
||||
} else {
|
||||
switch (experiment.GetDetectorMode()) {
|
||||
case DetectorMode::PedestalG1:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G1);
|
||||
break;
|
||||
case DetectorMode::PedestalG2:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G2);
|
||||
break;
|
||||
default:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::DYNAMIC);
|
||||
break;
|
||||
if (det_type == DetectorType::JUNGFRAU) {
|
||||
if (experiment.IsFixedGainG1()) {
|
||||
if ((experiment.GetDetectorMode() == DetectorMode::PedestalG0) ||
|
||||
(experiment.GetDetectorMode() == DetectorMode::PedestalG2))
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Pedestal G0/G2 doesn't make sense for fixed G1 mode");
|
||||
det.setGainMode(slsDetectorDefs::FIX_G1);
|
||||
} else {
|
||||
switch (experiment.GetDetectorMode()) {
|
||||
case DetectorMode::PedestalG1:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G1);
|
||||
break;
|
||||
case DetectorMode::PedestalG2:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::FORCE_SWITCH_G2);
|
||||
break;
|
||||
default:
|
||||
det.setGainMode(slsDetectorDefs::gainMode::DYNAMIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
det.setStorageCellStart(experiment.GetStorageCellStart());
|
||||
det.setNumberOfAdditionalStorageCells(experiment.GetStorageCellNumber() - 1);
|
||||
det.setStorageCellDelay(
|
||||
experiment.GetStorageCellDelay() - std::chrono::nanoseconds(MIN_STORAGE_CELL_DELAY_IN_NS));
|
||||
|
||||
if (experiment.IsUsingGainHG0())
|
||||
det.setSettings(slsDetectorDefs::HIGHGAIN0);
|
||||
else
|
||||
det.setSettings(slsDetectorDefs::GAIN0);
|
||||
|
||||
det.setDelayAfterTrigger(experiment.GetDetectorDelay());
|
||||
}
|
||||
|
||||
det.setStorageCellStart(experiment.GetStorageCellStart());
|
||||
det.setNumberOfAdditionalStorageCells(experiment.GetStorageCellNumber() - 1);
|
||||
det.setStorageCellDelay(experiment.GetStorageCellDelay() - std::chrono::nanoseconds(MIN_STORAGE_CELL_DELAY_IN_NS));
|
||||
|
||||
det.setPeriod(experiment.GetDetectorPeriod());
|
||||
|
||||
det.setExptime(std::chrono::microseconds(experiment.GetFrameCountTime()));
|
||||
|
||||
if (experiment.IsUsingGainHG0())
|
||||
det.setSettings(slsDetectorDefs::HIGHGAIN0);
|
||||
else
|
||||
det.setSettings(slsDetectorDefs::GAIN0);
|
||||
|
||||
det.setDelayAfterTrigger(experiment.GetDetectorDelay());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user