Fix bug in detector initialize
This commit is contained in:
@@ -10,31 +10,37 @@ void DetectorWrapper::Initialize(const DiffractionExperiment& experiment,
|
||||
const std::vector<AcquisitionDeviceNetConfig>& net_config) {
|
||||
logger.Info("Initialize detector");
|
||||
try {
|
||||
if (det.size() > 0) {
|
||||
// Only if the detector is already defined
|
||||
auto module_hostname = experiment.GetDetectorModuleHostname();
|
||||
|
||||
if (det.empty()) {
|
||||
if (!module_hostname.empty())
|
||||
det.setHostname(module_hostname);
|
||||
else
|
||||
throw JFJochException(JFJochExceptionCategory::Detector,
|
||||
"Detector not configured and hostname not provided");
|
||||
} else {
|
||||
// Stop the detector
|
||||
InternalStop();
|
||||
|
||||
// Clear synchronization prior to reconfiguring the detector
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
}
|
||||
auto module_hostname = experiment.GetDetectorModuleHostname();
|
||||
auto det_module_hostname = det.getHostname();
|
||||
|
||||
if (!module_hostname.empty()) {
|
||||
bool reset = true;
|
||||
if (module_hostname.size() == det_module_hostname.size()) {
|
||||
reset = false;
|
||||
for (int i = 0; i < module_hostname.size(); i++) {
|
||||
if (module_hostname[i] != det_module_hostname[i])
|
||||
reset = true;
|
||||
if (!module_hostname.empty()) {
|
||||
bool reset = true;
|
||||
auto det_module_hostname = det.getHostname();
|
||||
|
||||
if (module_hostname.size() == det_module_hostname.size()) {
|
||||
reset = false;
|
||||
for (int i = 0; i < module_hostname.size(); i++) {
|
||||
if (module_hostname[i] != det_module_hostname[i])
|
||||
reset = true;
|
||||
}
|
||||
}
|
||||
if (reset) {
|
||||
logger.Info("Resetting detector module host names");
|
||||
det.setHostname(module_hostname);
|
||||
}
|
||||
}
|
||||
if (reset) {
|
||||
logger.Info("Resetting detector module host names");
|
||||
det.setHostname(module_hostname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +167,10 @@ void DetectorWrapper::Deactivate() {
|
||||
det.setHighVoltage(0);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
det.setPowerChip(false);
|
||||
|
||||
det.setMaster(false, 0);
|
||||
det.setSynchronization(false);
|
||||
|
||||
det.freeSharedMemory();
|
||||
} catch (std::exception &e) {
|
||||
logger.ErrorException(e);
|
||||
|
||||
Reference in New Issue
Block a user