From 93f7ac210bdc25d7c252b465fd8377be77d81c2f Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Tue, 8 Nov 2016 17:46:48 +0100
Subject: [PATCH] bug fix: when using multiple locations, the application was
 initialised once per location

---
 include/ApplicationCore.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/include/ApplicationCore.h b/include/ApplicationCore.h
index 4eaa1ef9..a0a420dd 100644
--- a/include/ApplicationCore.h
+++ b/include/ApplicationCore.h
@@ -27,12 +27,16 @@
 #include <ControlSystemAdapter-DoocsAdapter/DoocsAdapter.h>
 
   BEGIN_DOOCS_SERVER("Control System Adapter", 10)
-     // set the DOOCS server name to the application name
-     object_name = ChimeraTK::Application::getInstance().getName().c_str();
-     // Create static instances for all applications cores. They must not have overlapping
-     // process variable names ("location/protery" must be unique).
-     ChimeraTK::Application::getInstance().setPVManager(doocsAdapter.getDevicePVManager());
-     ChimeraTK::Application::getInstance().run();
+     static bool isInitialised = false;
+     if(!isInitialised) {
+       // set the DOOCS server name to the application name
+       object_name = ChimeraTK::Application::getInstance().getName().c_str();
+       // Create static instances for all applications cores. They must not have overlapping
+       // process variable names ("location/protery" must be unique).
+       ChimeraTK::Application::getInstance().setPVManager(doocsAdapter.getDevicePVManager());
+       ChimeraTK::Application::getInstance().run();
+       isInitialised = true;
+     }
   END_DOOCS_SERVER()
 
 #else
-- 
GitLab