From 8aa86b0b4c8690b580c58cb0f78d449ad9afe7b2 Mon Sep 17 00:00:00 2001
From: blaakmeer <sdos@astron.nl>
Date: Thu, 14 Sep 2006 07:43:36 +0000
Subject: [PATCH] BugID: 802 Online processing consists of four processes

---
 .../OnlineControl/CEPApplicationManager.cc    |  24 +-
 .../src/OnlineControl/CEPApplicationManager.h |  31 +-
 .../CEPCU/src/OnlineControl/OnlineControl.cc  | 293 +++++++++++-------
 .../CEPCU/src/OnlineControl/OnlineControl.h   |  29 +-
 4 files changed, 227 insertions(+), 150 deletions(-)

diff --git a/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.cc b/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.cc
index d3d89cd9044..89ce40b8011 100644
--- a/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.cc
+++ b/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.cc
@@ -53,7 +53,7 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
       {
         _lastOkCmd = cmd;
       }
-      _interface.appBooted(result);
+      _interface.appBooted(_procName, result);
       break;
 
     case ACCmdQuit:
@@ -61,7 +61,7 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
       {
         _continuePoll = false;
       }
-      _interface.appQuitDone(result);
+      _interface.appQuitDone(_procName, result);
       break;
 
     case ACCmdDefine:
@@ -69,7 +69,7 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
       {
         _lastOkCmd = cmd;
       }
-      _interface.appDefined(result);
+      _interface.appDefined(_procName, result);
       break;
 
     case ACCmdInit:
@@ -77,11 +77,11 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
       {
         _lastOkCmd = cmd;
       }
-      _interface.appInitialized(result);
+      _interface.appInitialized(_procName, result);
       break;
 
     case ACCmdPause:
-      _interface.appPaused(result);
+      _interface.appPaused(_procName, result);
       break;
 
     case ACCmdRun:
@@ -89,23 +89,23 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
       {
         _lastOkCmd = cmd;
       }
-      _interface.appRunDone(result);
+      _interface.appRunDone(_procName, result);
       break;
 
     case ACCmdSnapshot:
-      _interface.appSnapshotDone(result);
+      _interface.appSnapshotDone(_procName, result);
       break;
 
     case ACCmdRecover:
-      _interface.appRecovered(result);
+      _interface.appRecovered(_procName, result);
       break;
 
     case ACCmdReinit:
-      _interface.appReinitialized(result);
+      _interface.appReinitialized(_procName, result);
       break;
 
     case ACCmdReplace:
-      _interface.appReplaced(result);
+      _interface.appReplaced(_procName, result);
       break;
 
     default:
@@ -117,12 +117,12 @@ void  CEPApplicationManager::handleAckMsg(ACCmd         cmd,
 
 void  CEPApplicationManager::handleAnswerMsg   (const string& answer)
 {
-  _interface.appSupplyInfoAnswer(answer);
+  _interface.appSupplyInfoAnswer(_procName, answer);
 }
 
 string  CEPApplicationManager::supplyInfoFunc  (const string& keyList)
 {
-  return _interface.appSupplyInfo(keyList);
+  return _interface.appSupplyInfo(_procName, keyList);
 }
 
   } // namespace CEPCU
diff --git a/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.h b/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.h
index c2c756ed7d5..0a0c45ab36e 100644
--- a/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.h
+++ b/MAC/APL/CEPCU/src/OnlineControl/CEPApplicationManager.h
@@ -46,18 +46,18 @@ class CEPApplicationManagerInterface
     virtual ~CEPApplicationManagerInterface() {}
     
   public:
-    virtual void    appBooted(uint16 result) = 0;
-    virtual void    appDefined(uint16 result) = 0;
-    virtual void    appInitialized(uint16 result) = 0;
-    virtual void    appRunDone(uint16 result) = 0;
-    virtual void    appPaused(uint16 result) = 0;
-    virtual void    appQuitDone(uint16 result) = 0;
-    virtual void    appSnapshotDone(uint16 result) = 0;
-    virtual void    appRecovered(uint16 result) = 0;
-    virtual void    appReinitialized(uint16 result) = 0;
-    virtual void    appReplaced(uint16 result) = 0;
-    virtual string  appSupplyInfo(const string& keyList) = 0;
-    virtual void    appSupplyInfoAnswer(const string& answer) = 0;    
+    virtual void    appBooted(const string& procName, uint16 result) = 0;
+    virtual void    appDefined(const string& procName, uint16 result) = 0;
+    virtual void    appInitialized(const string& procName, uint16 result) = 0;
+    virtual void    appRunDone(const string& procName, uint16 result) = 0;
+    virtual void    appPaused(const string& procName, uint16 result) = 0;
+    virtual void    appQuitDone(const string& procName, uint16 result) = 0;
+    virtual void    appSnapshotDone(const string& procName, uint16 result) = 0;
+    virtual void    appRecovered(const string& procName, uint16 result) = 0;
+    virtual void    appReinitialized(const string& procName, uint16 result) = 0;
+    virtual void    appReplaced(const string& procName, uint16 result) = 0;
+    virtual string  appSupplyInfo(const string& procName, const string& keyList) = 0;
+    virtual void    appSupplyInfoAnswer(const string& procName, const string& answer) = 0;    
 
   private:
     // protected copy constructor
@@ -124,6 +124,7 @@ class CEPApplicationManager : public ACC::ALC::ACClientFunctions,
     ACC::ALC::ACAsyncClient         _acClient;
     bool                            _continuePoll;
     ACC::ALC::ACCmd                 _lastOkCmd;
+	string                          _procName;
     
     ALLOC_TRACER_CONTEXT  
 };
@@ -132,10 +133,10 @@ inline CEPApplicationManager::CEPApplicationManager(
                                     CEPApplicationManagerInterface& interface, 
                                     const string& appName) :
       _interface(interface),
-      _acClient(this, appName, 10, 100, 1, 0),
+	  _acClient(this, appName, 10, 100, 1, 0),
       _continuePoll(false),
-      _lastOkCmd(ACC::ALC::ACCmdNone)
-      
+	  _lastOkCmd(ACC::ALC::ACCmdNone),
+      _procName(appName)
 { 
   use(); // to avoid that this object will be deleted in GCFTask::stop;
 }
diff --git a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc
index 0d70222252d..a5c30db5e4a 100644
--- a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc
+++ b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc
@@ -63,7 +63,7 @@ OnlineControl::OnlineControl(const string&	cntlrName) :
 	itsParentControl	(0),
 	itsParentPort		(0),
 	itsTimerPort		(0),
-    itsCepApplication   (*this, cntlrName),
+    itsCepApplications  (),
 	itsCepAppParams     (),
 	itsResultParams     (),
 	itsState			(CTState::NOSTATE),
@@ -432,41 +432,62 @@ uint16_t OnlineControl::doClaim(const string& cntlrName)
   uint16_t result = CT_RESULT_NO_ERROR;
   try
   {
-	itsCepAppParams.clear();
-
-	itsCepAppParams.replace("AC.application", cntlrName);
-	itsCepAppParams.replace("AC.resultfile", formatString("./ACC-%s_result.param", cntlrName.c_str()));
-  
 	string processScope("AC.process");
 	string onlineCtrlPrefix(globalParameterSet()->locateModule("OnlineCtrl") + "OnlineCtrl.");
   
-	string procName, startstoptype, executable, hostName;
+	vector<string> procNames, nodes;
+	string executable, hostName, startstoptype;
 	string ldName(getName().c_str());
 	
-	procName = globalParameterSet()->getString(onlineCtrlPrefix+"ApplCtrl.ACCprocess.name");
-	startstoptype = globalParameterSet()->getString(onlineCtrlPrefix+"ApplCtrl.ACCprocess.startstopType");
-	executable = globalParameterSet()->getString(onlineCtrlPrefix+"ApplCtrl.ACCprocess.executable");
-	hostName = globalParameterSet()->getString(onlineCtrlPrefix+"ApplCtrl.ACCprocess.hostname");
+	procNames = globalParameterSet()->getStringVector(onlineCtrlPrefix+"ApplCtrl.ACCprocess.name");
 
-	itsCepAppParams.adoptCollection(globalParameterSet()->makeSubset(onlineCtrlPrefix+"ApplCtrl", "AC"));
-	itsCepAppParams.adoptCollection(globalParameterSet()->makeSubset(onlineCtrlPrefix+procName, procName));
-	  
-	// add some keys to cope with the differences between the OTDB and ACC
-	itsCepAppParams.replace("AC.process[0].count","1");
-	itsCepAppParams.replace("AC.application",procName);
-	itsCepAppParams.replace("AC.process[1].ID",procName);
-	itsCepAppParams.replace("AC.hostname",hostName);
-	itsCepAppParams.replace(formatString("%s.%s[0].startstoptype",procName.c_str(),procName.c_str()),startstoptype);
-	itsCepAppParams.replace(formatString("%s.%s[0].executable",procName.c_str(),procName.c_str()),executable);
-
-	// create nodelist
-	vector<string> nodes = globalParameterSet()->getStringVector("Observation.VirtualInstrument.BGLNodeList");
-	int nodeIndex=1;
-	for(vector<string>::iterator it=nodes.begin();it!=nodes.end();++it)
+	for(size_t i=0;i<procNames.size();i++)
 	{
-	  itsCepAppParams.replace(formatString("AC.%s[%d].node",procName.c_str(),nodeIndex++),*it);
+	  string procName = procNames[i];
+
+	  startstoptype = globalParameterSet()->getString(formatString("%sApplCtrl.%s.startstopType",
+																   onlineCtrlPrefix.c_str(),
+																   procName.c_str()));
+	  executable    = globalParameterSet()->getString(formatString("%sApplCtrl.%s.executable",
+																   onlineCtrlPrefix.c_str(),
+																   procName.c_str()));
+	  hostName      = globalParameterSet()->getString(formatString("%sApplCtrl.%s.hostname",
+																   onlineCtrlPrefix.c_str(),
+																   procName.c_str()));
+	  nodes   = globalParameterSet()->getStringVector(formatString("%sApplCtrl.%s.nodes",
+																   onlineCtrlPrefix.c_str(),
+																   procName.c_str()));
+
+	  CEPApplicationManagerPtr accClient(new CEPApplicationManager(*this, procName));
+	  itsCepApplications[procName] = accClient;
+	  
+	  ACC::APS::ParameterSet params;
+	  params.clear();
+	  params.replace("AC.application", cntlrName);
+	  // import the ApplCtrl section
+	  params.adoptCollection(globalParameterSet()->makeSubset(onlineCtrlPrefix+"ApplCtrl", "AC"));
+	  // import the <procname> section
+	  params.adoptCollection(globalParameterSet()->makeSubset(onlineCtrlPrefix+procName, procName));
+	  // import the OLAP section
+	  params.adoptCollection(globalParameterSet()->makeSubset(onlineCtrlPrefix+"OLAP", "OLAP"));
+	  
+	  // add some keys to cope with the differences between the OTDB and ACC
+	  params.replace("AC.resultfile", formatString("./ACC-%s_%s_result.param", cntlrName.c_str(),procName.c_str()));
+	  params.replace("AC.process[0].count","1");
+	  params.replace("AC.application",procName);
+	  params.replace("AC.process[1].ID",procName);
+	  params.replace("AC.hostname",hostName);
+	  params.replace(formatString("%s.%s[0].startstoptype",procName.c_str(),procName.c_str()),startstoptype);
+	  params.replace(formatString("%s.%s[0].executable",procName.c_str(),procName.c_str()),executable);
+
+	  // create nodelist
+	  int nodeIndex=1;
+	  for(vector<string>::iterator it=nodes.begin();it!=nodes.end();++it)
+	  {
+		params.replace(formatString("AC.%s[%d].node",procName.c_str(),nodeIndex++),*it);
+	  }
+	  itsCepAppParams.push_back(params);
 	}
-		
   }
   catch(APSException &)
   {
@@ -487,54 +508,61 @@ uint16_t OnlineControl::doPrepare(const string&	cntlrName)
   {
 	// TODO use parameterset of 'cntlrname' when being shared controller
 
-	string paramFileName(formatString("ACC-%s.param", cntlrName.c_str()));
-	itsCepAppParams.writeFile(paramFileName);
+	for(size_t i = 0;i < itsCepAppParams.size();i++)
+	{
+	  string procName = itsCepAppParams[i].getString("AC.process[1].ID");
+	  string hostName = itsCepAppParams[i].getString("AC.hostname");
+	  string paramFileName(formatString("ACC-%s_%s.param", cntlrName.c_str(),procName.c_str()));
+	  itsCepAppParams[i].writeFile(paramFileName);
   
-	// schedule all ACC commands
-	time_t startTime  = to_time_t(itsStartTime);
-	time_t initTime   = startTime  - itsCepAppParams.getTime("AC.timeout_init");
-	time_t defineTime = initTime   - itsCepAppParams.getTime("AC.timeout_define") - 
-	                                 itsCepAppParams.getTime("AC.timeout_startup");
-	time_t bootTime   = defineTime - itsCepAppParams.getTime("AC.timeout_createsubsets");
-	time_t now = time(0);
-	time_t stopTime = to_time_t(itsStopTime);
-	LOG_DEBUG(formatString("%d boot %s",        bootTime,   ctime(&bootTime)));
-	LOG_DEBUG(formatString("%d define %s",      defineTime, ctime(&defineTime)));
-	LOG_DEBUG(formatString("%d init %s",        initTime,   ctime(&initTime)));
-	LOG_DEBUG(formatString("%d start %s",       startTime,  ctime(&startTime)));
-	LOG_DEBUG(formatString("%d now %s time %d", now,        ctime(&now), time(0)));
-	LOG_DEBUG(formatString("%d stop %s",        stopTime,   ctime(&stopTime)));
+	  // schedule all ACC commands
+	  time_t startTime  = to_time_t(itsStartTime);
+	  time_t initTime   = startTime  - itsCepAppParams[i].getTime("AC.timeout_init");
+	  time_t defineTime = initTime   - itsCepAppParams[i].getTime("AC.timeout_define") - 
+		                               itsCepAppParams[i].getTime("AC.timeout_startup");
+	  time_t bootTime   = defineTime - itsCepAppParams[i].getTime("AC.timeout_createsubsets");
+	  time_t now = time(0);
+	  time_t stopTime = to_time_t(itsStopTime);
+	  LOG_DEBUG(formatString("%d now %s time %d", now,        ctime(&now), time(0)));
+	  LOG_DEBUG(formatString("%d boot %s",        bootTime,   ctime(&bootTime)));
+	  LOG_DEBUG(formatString("%d define %s",      defineTime, ctime(&defineTime)));
+	  LOG_DEBUG(formatString("%d init %s",        initTime,   ctime(&initTime)));
+	  LOG_DEBUG(formatString("%d start %s",       startTime,  ctime(&startTime)));
+	  LOG_DEBUG(formatString("%d stop %s",        stopTime,   ctime(&stopTime)));
 	
-	string hostName;
-	hostName = itsCepAppParams.getString("AC.hostname");
-	if (now > bootTime)
-	{
-	  APLCommon::APLUtilities::remoteCopy(paramFileName,hostName,LOFAR_SHARE_LOCATION);
-	  LOG_WARN("Cannot guarantee all CEP processes are started in time.");
-	}
-	else
-    {
-	  switch (itsCepApplication.getLastOkCmd())
+	  if (now > bootTime)
 	  {
-	    case ACCmdNone:
-		  itsCepApplication.boot(bootTime, paramFileName);
-		  break;
+		APLCommon::APLUtilities::remoteCopy(paramFileName,hostName,LOFAR_SHARE_LOCATION);
+		LOG_WARN("Cannot guarantee all CEP processes are started in time.");
+	  }
+	  else
+      {
+		CEPApplicationManagerPtr cepAppPtr = itsCepApplications[procName];
+		if(NULL != cepAppPtr)
+		{
+		  switch (cepAppPtr->getLastOkCmd())
+		  {
+	      case ACCmdNone:
+			cepAppPtr->boot(bootTime, paramFileName);
+			break;
         
-        case ACCmdBoot:
-		  itsCepApplication.define(defineTime);
-		  break;
+          case ACCmdBoot:
+			cepAppPtr->define(defineTime);
+			break;
         
-        case ACCmdDefine:
-        case ACCmdInit:
-        case ACCmdRun:
-		  itsCepApplication.recover(0, "snapshot-DB");
-		  break;
+          case ACCmdDefine:
+          case ACCmdInit:
+          case ACCmdRun:
+			cepAppPtr->recover(0, "snapshot-DB");
+			break;
               
-        default:
-		  assert(0);
-		  break;
-	  }    
-	  APLCommon::APLUtilities::remoteCopy(paramFileName,hostName,LOFAR_SHARE_LOCATION);
+          default:
+			assert(0);
+			break;
+		  }   
+		} 
+		APLCommon::APLUtilities::remoteCopy(paramFileName,hostName,LOFAR_SHARE_LOCATION);
+	  }
 	}
   }
   catch(APSException &)
@@ -552,29 +580,37 @@ void OnlineControl::doRelease(void)
 {
   try
   {
-	string hostName, remoteFile, resultFile;
-	hostName = itsCepAppParams.getString("AC.hostname");
-	resultFile = formatString("ACC-%s_result.param", getName().c_str());
-	remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile;
-	APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile);
-	itsResultParams.adoptFile(resultFile);
-	//  itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality()));
-	if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str())))
-    {
-	  itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), "");
+	for(size_t i = 0;i < itsCepAppParams.size();i++)
+	{
+	  string hostName, remoteFile, resultFile, procName;
+	  hostName = itsCepAppParams[i].getString("AC.hostname");
+	  procName = itsCepAppParams[i].getString("AC.process[1].ID");
+	  resultFile = formatString("ACC-%s_%s_result.param", getName().c_str(),procName.c_str());
+	  remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile;
+	  APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile);
+	  itsResultParams.adoptFile(resultFile);
+	  //  itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality()));
+	  if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str())))
+	  {
+		itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), "");
+	  }
+	  itsResultParams.writeFile(formatString("%s_result.param", getName().c_str()));
 	}
-	itsResultParams.writeFile(formatString("%s_result.param", getName().c_str()));
   }
   catch(...)
   {
   }
-  itsCepApplication.quit(0);
+  map<string, CEPApplicationManagerPtr>::iterator it;
+  for(it = itsCepApplications.begin();it != itsCepApplications.end();++it)
+  {
+	it->second->quit(0);
+  }
 }
 
 //
 // finishController
 //
-void OnlineControl::finishController(uint16_t result)
+void OnlineControl::finishController(uint16_t /*result*/)
 {
   setState(CTState::RELEASE);
   doRelease();
@@ -598,15 +634,20 @@ void OnlineControl::_disconnectedHandler(GCFPortInterface& port)
 	port.close();
 }
 
-void OnlineControl::appBooted(uint16 result)
+void OnlineControl::appBooted(const string& procName, uint16 result)
 {
+  LOG_INFO_STR("appBooted from " << procName);
   if (result == (AcCmdMaskOk | AcCmdMaskScheduled))  
   {
     time_t startTime  = to_time_t(itsStartTime);
-    time_t initTime   = startTime  - itsCepAppParams.getTime("AC.timeout_init");
-    time_t defineTime = initTime   - itsCepAppParams.getTime("AC.timeout_define") - 
-                                     itsCepAppParams.getTime("AC.timeout_startup");
-    itsCepApplication.define(defineTime);
+    time_t initTime   = startTime  - itsCepAppParams[0].getTime("AC.timeout_init");
+    time_t defineTime = initTime   - itsCepAppParams[0].getTime("AC.timeout_define") - 
+                                     itsCepAppParams[0].getTime("AC.timeout_startup");
+	map<string,CEPApplicationManagerPtr>::iterator it = itsCepApplications.find(procName);
+	if(it != itsCepApplications.end())
+	{
+	  it->second->define(defineTime);
+	}
   }
   else if (result == 0) // Error
   {
@@ -615,14 +656,19 @@ void OnlineControl::appBooted(uint16 result)
   }
 }
 
-void OnlineControl::appDefined(uint16 result)
+void OnlineControl::appDefined(const string& procName, uint16 result)
 {
+  LOG_INFO_STR("appDefined from " << procName);
   if (result == (AcCmdMaskOk | AcCmdMaskScheduled))
   {
     time_t startTime  = to_time_t(itsStartTime);
-    time_t initTime   = startTime  - itsCepAppParams.getTime("AC.timeout_init");
+    time_t initTime   = startTime  - itsCepAppParams[0].getTime("AC.timeout_init");
   
-    itsCepApplication.init(initTime);
+	map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+	if(it != itsCepApplications.end())
+	{
+	  it->second->init(initTime);
+	}
   }
   else if (result == 0) // Error
   {
@@ -631,15 +677,20 @@ void OnlineControl::appDefined(uint16 result)
   }
 }
 
-void OnlineControl::appInitialized(uint16 result)
+void OnlineControl::appInitialized(const string& procName, uint16 result)
 {
+  LOG_INFO_STR("appInitialized from " << procName);
   if (result == AcCmdMaskOk)
   {    
 	//    _doStateTransition(LOGICALDEVICE_STATE_SUSPENDED);
   }
   else if (result == (AcCmdMaskOk | AcCmdMaskScheduled))  
   {
-    itsCepApplication.run(to_time_t(itsStartTime));
+	map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+	if(it != itsCepApplications.end())
+	{
+	  it->second->run(to_time_t(itsStartTime));
+	}
   }
   else if (result == 0) // Error
   {
@@ -648,11 +699,16 @@ void OnlineControl::appInitialized(uint16 result)
   }
 }
 
-void OnlineControl::appRunDone(uint16 result)
+void OnlineControl::appRunDone(const string& procName, uint16 result)
 {
+  LOG_INFO_STR("appRunDone from " << procName);
   if (result == (AcCmdMaskOk | AcCmdMaskScheduled))
   {      
-    itsCepApplication.quit(to_time_t(itsStopTime));
+	map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+	if(it != itsCepApplications.end())
+	{
+	  it->second->quit(to_time_t(itsStopTime));
+	}
   }
   else if (result == 0) // Error
   {
@@ -661,12 +717,14 @@ void OnlineControl::appRunDone(uint16 result)
   }
 }
 
-void OnlineControl::appPaused(uint16 /*result*/)
+void OnlineControl::appPaused(const string& procName, uint16 /*result*/)
 {
+  LOG_INFO_STR("appPaused from " << procName);
 }
 
-void OnlineControl::appQuitDone(uint16 result)
+void OnlineControl::appQuitDone(const string& procName, uint16 result)
 {
+  LOG_INFO_STR("appQuitDone from " << procName);
   if (result == (AcCmdMaskOk | AcCmdMaskScheduled))
   {  
     //_qualityGuard.stopMonitoring(); // not in this increment
@@ -677,53 +735,70 @@ void OnlineControl::appQuitDone(uint16 result)
   }
 }
 
-void OnlineControl::appSnapshotDone(uint16 /*result*/)
+void OnlineControl::appSnapshotDone(const string& procName, uint16 /*result*/)
 {
+  LOG_INFO_STR("appSnapshotDone from " << procName);
   time_t rsto(0);
   try 
   {
     rsto = globalParameterSet()->getTime("rescheduleTimeOut");
   }
   catch (...) {}
-  itsCepApplication.pause(0, rsto, "condition");
+  map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+  if(it != itsCepApplications.end())
+  {
+	it->second->pause(0, rsto, "condition");
+  }
 }
 
-void OnlineControl::appRecovered(uint16 /*result*/)
+void OnlineControl::appRecovered(const string& procName, uint16 /*result*/)
 {
+  LOG_INFO_STR("appRecovered from " << procName);
   
   time_t startTime  = to_time_t(itsStartTime);
-  time_t reinitTime = startTime  - itsCepAppParams.getTime("AC.timeout_reinit");
+  time_t reinitTime = startTime  - itsCepAppParams[0].getTime("AC.timeout_reinit");
   
   string paramFileName(formatString("ACC-%s.param", getName().c_str()));
   
-  itsCepApplication.reinit(reinitTime, paramFileName);
+  map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+  if(it != itsCepApplications.end())
+  {
+	it->second->reinit(reinitTime, paramFileName);
+  }
 }
 
-void OnlineControl::appReinitialized(uint16 result)
-{
+void OnlineControl::appReinitialized(const string& procName, uint16 result)
+{ 
+  LOG_INFO_STR("appReinitialized from " << procName);
   if (result == AcCmdMaskOk)
   {    
 	//    _doStateTransition(LOGICALDEVICE_STATE_SUSPENDED);
   }
   else if (result == (AcCmdMaskOk | AcCmdMaskScheduled))  
   {  
-    itsCepApplication.run(to_time_t(itsStartTime));
+	map<string,CEPApplicationManagerPtr>::iterator it =  itsCepApplications.find(procName);
+	if(it != itsCepApplications.end())
+    {
+	  it->second->run(to_time_t(itsStartTime));
+	}
   }
 }
 
-void OnlineControl::appReplaced(uint16 /*result*/)
+void OnlineControl::appReplaced(const string& procName, uint16 /*result*/)
 {
+  LOG_INFO_STR("appReplaced from " << procName);
 }
 
-string OnlineControl::appSupplyInfo(const string& keyList)
+string OnlineControl::appSupplyInfo(const string& procName, const string& keyList)
 {
+  LOG_INFO_STR("appSupplyInfo from " << procName);
   string ret(keyList);
   return ret;
 }
 
-void OnlineControl::appSupplyInfoAnswer(const string& answer)
+void OnlineControl::appSupplyInfoAnswer(const string& procName, const string& answer)
 {
-  LOG_INFO_STR("Answer: " << answer);
+  LOG_INFO_STR("Answer from " << procName << ": " << answer);
 }
 
 
diff --git a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h
index 54ca0367a9d..0b004c8251d 100644
--- a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h
+++ b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h
@@ -91,18 +91,18 @@ public:
 									 GCFPortInterface& port);
 
 protected: // implemenation of abstract CEPApplicationManagerInterface methods
-    void    appBooted(uint16 result);
-    void    appDefined(uint16 result);
-    void    appInitialized(uint16 result);
-    void    appRunDone(uint16 result);
-    void    appPaused(uint16 result);
-    void    appQuitDone(uint16 result);
-    void    appSnapshotDone(uint16 result);
-    void    appRecovered(uint16 result);
-    void    appReinitialized(uint16 result);
-    void    appReplaced(uint16 result);
-    string  appSupplyInfo(const string& keyList);
-    void    appSupplyInfoAnswer(const string& answer);
+    void    appBooted(const string& procName, uint16 result);
+    void    appDefined(const string& procName, uint16 result);
+    void    appInitialized(const string& procName, uint16 result);
+    void    appRunDone(const string& procName, uint16 result);
+    void    appPaused(const string& procName, uint16 result);
+    void    appQuitDone(const string& procName, uint16 result);
+    void    appSnapshotDone(const string& procName, uint16 result);
+    void    appRecovered(const string& procName, uint16 result);
+    void    appReinitialized(const string& procName, uint16 result);
+    void    appReplaced(const string& procName, uint16 result);
+    string  appSupplyInfo(const string& procName, const string& keyList);
+    void    appSupplyInfoAnswer(const string& procName, const string& answer);
   
 private:
 	// avoid defaultconstruction and copying
@@ -119,6 +119,7 @@ private:
 	void	 setState(CTState::CTstateNr     newState);
 
    	typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr;
+	typedef boost::shared_ptr<CEPApplicationManager> CEPApplicationManagerPtr;
 
    	APLCommon::PropertySetAnswer  itsPropertySetAnswer;
    	GCFMyPropertySetPtr           itsPropertySet;
@@ -130,8 +131,8 @@ private:
 
 	GCFTimerPort*			itsTimerPort;
 
-    CEPApplicationManager   itsCepApplication;
-    ACC::APS::ParameterSet  itsCepAppParams;
+    map<string, CEPApplicationManagerPtr>  itsCepApplications;
+    vector<ACC::APS::ParameterSet> itsCepAppParams;
     ACC::APS::ParameterSet  itsResultParams;
 
 	CTState::CTstateNr		itsState;
-- 
GitLab