diff --git a/LCS/ACC/PLC/include/PLC/ProcCtrlProxy.h b/LCS/ACC/PLC/include/PLC/ProcCtrlProxy.h
index 511aff276cf44c9818f95796b69a8ff4c105d715..ab9d1498ea4c1c2024ae5cbb7c0f169a754053b7 100644
--- a/LCS/ACC/PLC/include/PLC/ProcCtrlProxy.h
+++ b/LCS/ACC/PLC/include/PLC/ProcCtrlProxy.h
@@ -76,6 +76,8 @@ namespace LOFAR
         tribool reinit   (const string& configID);
         string  askInfo  (const string& keylist);
 
+		virtual void sendResultParameters(const string&		aKVList);
+
         bool inRunState() const;
         void setRunState();
         void clearRunState();
diff --git a/LCS/ACC/PLC/include/PLC/ProcCtrlRemote.h b/LCS/ACC/PLC/include/PLC/ProcCtrlRemote.h
index f73e9762fc083d2ba6e161b47f98eb57b530a0a6..f663749adf5d915873fd8950ccc3c2c82c1ee468 100644
--- a/LCS/ACC/PLC/include/PLC/ProcCtrlRemote.h
+++ b/LCS/ACC/PLC/include/PLC/ProcCtrlRemote.h
@@ -30,29 +30,38 @@
 #include <PLC/ProcCtrlProxy.h>
 #include <PLC/ProcControlServer.h>
 
-namespace LOFAR
+namespace LOFAR {
+  namespace ACC {
+    namespace PLC {
+
+// \addtogroup PLC
+// @{
+
+// Proxy for the command line process control.
+class ProcCtrlRemote : public ProcCtrlProxy
 {
-  namespace ACC 
-  {
-    namespace PLC 
-    {
-      // \addtogroup PLC
-      // @{
-
-      // Proxy for the command line process control.
-      class ProcCtrlRemote : public ProcCtrlProxy
-      {
-      public:
-        // Constructor. The argument \a aProcCtrl is a pointer to the "real"
-        // Process Control object.
-        ProcCtrlRemote(ProcessControl* aProcCtrl);
-
-        // Start the process controller. Let it run under control of a
-        // ProcControlServer.
-        virtual int operator()(const ParameterSet& arg);
-      };
-
-      // @}
+public:
+	// Constructor. The argument \a aProcCtrl is a pointer to the "real"
+	// Process Control object.
+	ProcCtrlRemote(ProcessControl* aProcCtrl);
+
+	// Start the process controller. Let it run under control of a
+	// ProcControlServer.
+	virtual int operator()(const ParameterSet& arg);
+
+	// Send metadata to the server
+	virtual void sendResultParameters(const string&	aKVlist);
+
+	// Tell how to talk to the ApplController
+	void setServer(ProcControlServer*		aControlServer)
+		{ itsPCServer = aControlServer; }
+
+private:
+	// Pointer to the server so that sendResultParameters can use it.
+	ProcControlServer*		itsPCServer;
+};
+
+// @}
 
     } // namespace PLC
 
diff --git a/LCS/ACC/PLC/include/PLC/ProcessControl.h b/LCS/ACC/PLC/include/PLC/ProcessControl.h
index 0dd30aa098dcc0ad41c25cf7f53a4d2c90461d9f..89d242246b508db15e2d66bc754e5afbce6378d8 100644
--- a/LCS/ACC/PLC/include/PLC/ProcessControl.h
+++ b/LCS/ACC/PLC/include/PLC/ProcessControl.h
@@ -32,9 +32,13 @@
 #include <Common/lofar_tribool.h>
 
 namespace LOFAR {
+  class ParameterSet;
   namespace ACC {
     namespace PLC {
 
+//# Forward declarations
+class ProcCtrlProxy;
+
 // \addtogroup PLC
 // @{
 
@@ -55,7 +59,8 @@ public:
 
 protected:
 	// Default constructor
-	ProcessControl()	: itsRunState(false)	{}
+	explicit ProcessControl(const string&	theProcessID): 
+		itsProcID(theProcessID), itsRunState(false), itsControlProxy(0)	{}
 
 	// \name Commands to control the processes.
 	//
@@ -122,15 +127,22 @@ protected:
 	virtual tribool	reinit	 (const string&		configID)	   = 0;
 	// @}
 
-	// Define a generic way to exchange info between client and server.
+	// Define a generic way to ask questions to the server.
 	virtual string	askInfo   (const string& 	keylist)  = 0;
 
-        // Routines for handling the run state.
-        // @{
-	void setRunState()	{ itsRunState = true; }
+	// Define a generic way to send metadata to the server.
+	void	sendResultParameters (const string& 		keylist);
+	void	sendResultParameters (const ParameterSet& 	aParSet);
+
+    // Routines for handling the run state.
+    // @{
+	void setRunState()		{ itsRunState = true; }
 	void clearRunState()	{ itsRunState = false; }
 	bool inRunState() const	{ return itsRunState; }
-        // @}
+    // @}
+
+	// My unique name (use to communicate with the server).
+	string		itsProcID;
 
 	// The proxy class must be able to set/clear the run state.
 	friend class ProcCtrlProxy;
@@ -140,8 +152,12 @@ private:
 	ProcessControl(const ProcessControl& that);
 	ProcessControl& 	operator=(const ProcessControl& that);
 
-        // Run-state flag.
-        bool	itsRunState;
+	// Run-state flag.
+	bool				itsRunState;
+
+	// Pointer to controlproxy for passing metadata from the process to the server
+	ProcCtrlProxy*		itsControlProxy;
+
 };
 
 // @} addgroup
diff --git a/LCS/ACC/PLC/src/CMakeLists.txt b/LCS/ACC/PLC/src/CMakeLists.txt
index 550e8c2a77f06385e1cb573049ee379891e47acb..a53a67ca9135069fa665b409961ac24692491409 100644
--- a/LCS/ACC/PLC/src/CMakeLists.txt
+++ b/LCS/ACC/PLC/src/CMakeLists.txt
@@ -24,6 +24,7 @@ lofar_add_library(plc
   Package__Version.cc
   DH_ProcControl.cc
   PCCmd.cc
+  ProcessControl.cc
   ProcControlComm.cc
   ProcControlServer.cc
   ProcCtrlProxy.cc
diff --git a/LCS/ACC/PLC/src/Makefile.am b/LCS/ACC/PLC/src/Makefile.am
index 9bcc4e05fd22f4ddb423c68668780b9e77d52a8f..e8bb628370243a1ad0d5ef4b0483dc9239e93486 100644
--- a/LCS/ACC/PLC/src/Makefile.am
+++ b/LCS/ACC/PLC/src/Makefile.am
@@ -2,6 +2,7 @@ lib_LTLIBRARIES           = libplc.la
 
 libplc_la_SOURCES 		  = Package__Version.cc  DH_ProcControl.cc \
 							PCCmd.cc \
+							ProcessControl.cc  \
 							ProcControlComm.cc  \
 							ProcControlServer.cc \
 							ProcCtrlProxy.cc \
diff --git a/LCS/ACC/PLC/src/ProcCtrlProxy.cc b/LCS/ACC/PLC/src/ProcCtrlProxy.cc
index 5831b8825634bd68a46b6e85ae9579b0e84eaee6..f3b6946cdf4c72089b42497c09a676aff148fd8b 100644
--- a/LCS/ACC/PLC/src/ProcCtrlProxy.cc
+++ b/LCS/ACC/PLC/src/ProcCtrlProxy.cc
@@ -28,98 +28,108 @@
 #include <PLC/ProcessControl.h>
 #include <Common/LofarLogger.h>
 
-namespace LOFAR
-{
-  namespace ACC
-  {
-    namespace PLC
-    {
-      //## --------   P u b l i c   m e t h o d s   -------- ##//
-
-      ProcCtrlProxy::~ProcCtrlProxy()
-      {
-        LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
-      }
-
-      tribool ProcCtrlProxy::define()
-      {
-        return itsProcCtrl->define();
-      }
-
-      tribool ProcCtrlProxy::init()
-      {
-        return itsProcCtrl->init();
-      }
-
-      tribool ProcCtrlProxy::run()
-      {
-        setRunState();
-        tribool result = itsProcCtrl->run();
-        if (!result) clearRunState();
-        return result;
-      }
-
-      tribool ProcCtrlProxy::pause(const string& condition)
-      {
-        if (condition == PAUSE_OPTION_NOW) clearRunState();
-        return itsProcCtrl->pause(condition);
-      }
-
-      tribool ProcCtrlProxy::release()
-      {
-        return itsProcCtrl->release();
-      }
-
-      tribool ProcCtrlProxy::quit()
-      {
-        return itsProcCtrl->quit();
-      }
-
-      tribool ProcCtrlProxy::snapshot(const string& destination)
-      {
-        return itsProcCtrl->snapshot(destination);
-      }
-
-      tribool ProcCtrlProxy::recover(const string& source)
-      {
-        return itsProcCtrl->recover(source);
-      }
-
-      tribool ProcCtrlProxy::reinit(const string& configID)
-      {
-        return itsProcCtrl->reinit(configID);
-      }
-
-      string ProcCtrlProxy::askInfo(const string& keylist)
-      {
-        return itsProcCtrl->askInfo(keylist);
-      }
-
-      bool ProcCtrlProxy::inRunState() const
-      {
-        return itsProcCtrl->inRunState();
-      }
-
-      void ProcCtrlProxy::setRunState()
-      {
-        itsProcCtrl->setRunState();
-      }
-
-      void ProcCtrlProxy::clearRunState()
-      {
-        itsProcCtrl->clearRunState();
-      }
-
-      //## -------- P r o t e c t e d   m e t h o d s   -------- ##//
-
-      ProcCtrlProxy::ProcCtrlProxy(ProcessControl* aProcCtrl) :
-        itsProcCtrl(aProcCtrl)
-      {
-        LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
-      }
+namespace LOFAR {
+  namespace ACC {
+    namespace PLC {
 
-    } // namespace PLC
+//## --------   P u b l i c   m e t h o d s   -------- ##//
 
-  } // namespace ACC
+ProcCtrlProxy::~ProcCtrlProxy()
+{
+	LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+}
+
+tribool ProcCtrlProxy::define()
+{
+	return itsProcCtrl->define();
+}
+
+tribool ProcCtrlProxy::init()
+{
+	return itsProcCtrl->init();
+}
+
+tribool ProcCtrlProxy::run()
+{
+	setRunState();
+	tribool result = itsProcCtrl->run();
+	if (!result) { 
+		clearRunState();
+	}
+	return result;
+}
+
+tribool ProcCtrlProxy::pause(const string& condition)
+{
+	if (condition == PAUSE_OPTION_NOW) {
+		clearRunState();
+	}
+	return itsProcCtrl->pause(condition);
+}
+
+tribool ProcCtrlProxy::release()
+{
+	return itsProcCtrl->release();
+}
+
+tribool ProcCtrlProxy::quit()
+{
+	return itsProcCtrl->quit();
+}
+
+tribool ProcCtrlProxy::snapshot(const string& destination)
+{
+	return itsProcCtrl->snapshot(destination);
+}
+
+tribool ProcCtrlProxy::recover(const string& source)
+{
+	return itsProcCtrl->recover(source);
+}
+
+tribool ProcCtrlProxy::reinit(const string& configID)
+{
+	return itsProcCtrl->reinit(configID);
+}
+
+string ProcCtrlProxy::askInfo(const string& keylist)
+{
+	return itsProcCtrl->askInfo(keylist);
+}
+
+bool ProcCtrlProxy::inRunState() const
+{
+	return itsProcCtrl->inRunState();
+}
+
+void ProcCtrlProxy::setRunState()
+{
+	itsProcCtrl->setRunState();
+}
+
+void ProcCtrlProxy::clearRunState()
+{
+	itsProcCtrl->clearRunState();
+}
+
+//## -------- P r o t e c t e d   m e t h o d s   -------- ##//
 
+ProcCtrlProxy::ProcCtrlProxy(ProcessControl* aProcCtrl) :
+	itsProcCtrl(aProcCtrl)
+{
+	LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+
+	itsProcCtrl->itsControlProxy = this;
+}
+
+void ProcCtrlProxy::sendResultParameters(const string&	keyList)
+{
+	LOG_DEBUG_STR("Sending metadata: " << keyList);
+
+	itsProcCtrl->sendResultParameters(keyList);
+}
+
+
+    } // namespace PLC
+  } // namespace ACC
 } // namespace LOFAR
diff --git a/LCS/ACC/PLC/src/ProcCtrlRemote.cc b/LCS/ACC/PLC/src/ProcCtrlRemote.cc
index c33b216c309000cc934c4e6d61324ed4e93c3ccb..e9d85f6cd89d3ed23b6a51e7afde9139387926ab 100644
--- a/LCS/ACC/PLC/src/ProcCtrlRemote.cc
+++ b/LCS/ACC/PLC/src/ProcCtrlRemote.cc
@@ -28,75 +28,89 @@
 #include <Common/ParameterSet.h>
 #include <Common/LofarLogger.h>
 
-namespace LOFAR
+namespace LOFAR {
+  namespace ACC {
+    namespace PLC {
+
+using LOFAR::ParameterSet;
+
+//
+// ProcCtrlRemote(PC*)
+//
+ProcCtrlRemote::ProcCtrlRemote(ProcessControl* aProcCtrl) :
+	ProcCtrlProxy(aProcCtrl),
+	itsPCServer(0)
 {
-  namespace ACC
-  {
-    namespace PLC
-    {
-      using LOFAR::ParameterSet;
-
-      ProcCtrlRemote::ProcCtrlRemote(ProcessControl* aProcCtrl) :
-        ProcCtrlProxy(aProcCtrl)
-      {
-        LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
-      }
-
-      int ProcCtrlRemote::operator()(const ParameterSet& arg)
-      {
-        LOG_TRACE_LIFETIME(TRACE_LEVEL_FLOW, "");
-
-        string prefix = globalParameterSet()->getString("_parsetPrefix");
-
-        // connect to Application Controller
-        ProcControlServer 
-          pcServer(globalParameterSet()->getString(prefix+"_ACnode"),
-                   globalParameterSet()->getUint16(prefix+"_ACport"),
-                   this);
-
-        // Tell AC who we are.
-        string procID = arg.getString("ProcID");
-        LOG_DEBUG_STR("Registering at ApplController as " << procID);
-        sleep(1);
-        pcServer.registerAtAC(procID);
-
-        // Main processing loop
-        bool err(false);
-        bool quiting(false);
-        while (!quiting) {
-
-          LOG_TRACE_STAT("Polling ApplController for message");
-          if (pcServer.pollForMessage()) {
-            LOG_TRACE_COND("Message received from ApplController");
-
-            // get pointer to received data
-            DH_ProcControl* newMsg = pcServer.getDataHolder();
-
-            if (newMsg->getCommand() == PCCmdQuit) {
-              quiting = true;
-            } 
-
-            if (err = err || !pcServer.handleMessage(newMsg)) {
-              LOG_ERROR("ProcControlServer::handleMessage() failed");
-            }
-          } 
-          else  {
-            // no new command received. If we are in the runstate 
-            // call the run-routine again.
-            if (inRunState()) {
-              DH_ProcControl tmpMsg(PCCmdRun);
-              err = err || !pcServer.handleMessage(&tmpMsg);
-            }
-          }
-        }
-        LOG_INFO_STR("Shutting down: ApplicationController");
-        pcServer.unregisterAtAC("");    // send to AC before quiting
-
-        return (err);
-      }
-      
+	LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
+}
+
+//
+// operator()
+//
+int ProcCtrlRemote::operator()(const ParameterSet& arg)
+{
+	LOG_TRACE_LIFETIME(TRACE_LEVEL_FLOW, "");
+
+	string prefix = globalParameterSet()->getString("_parsetPrefix");
+
+	// connect to Application Controller
+	itsPCServer = new ProcControlServer(globalParameterSet()->getString(prefix+"_ACnode"),
+									    globalParameterSet()->getUint16(prefix+"_ACport"),
+									    this);
+	ASSERTSTR(itsPCServer, "Could not establish a connection with the ApplController.");
+
+	// Tell AC who we are.
+	string procID = arg.getString("ProcID");
+	LOG_DEBUG_STR("Registering at ApplController as " << procID);
+	sleep(1);
+	itsPCServer->registerAtAC(procID);
+
+	// Main processing loop
+	bool err(false); 
+	bool quiting(false);
+	while (!quiting) {
+
+		LOG_TRACE_STAT("Polling ApplController for message");
+		if (itsPCServer->pollForMessage()) {
+			LOG_TRACE_COND("Message received from ApplController");
+
+			// get pointer to received data
+			DH_ProcControl* newMsg = itsPCServer->getDataHolder();
+
+			if (newMsg->getCommand() == PCCmdQuit) {
+				quiting = true;
+			} 
+
+			if (err = err || !itsPCServer->handleMessage(newMsg)) {
+				LOG_ERROR("ProcControlServer::handleMessage() failed");
+			}
+		} 
+		else  {
+			// no new command received. If we are in the runstate 
+			// call the run-routine again.
+			if (inRunState()) {
+				DH_ProcControl tmpMsg(PCCmdRun);
+				err = err || !itsPCServer->handleMessage(&tmpMsg);
+			}
+		}
+	}
+
+	LOG_INFO_STR("Shutting down: ApplicationController");
+	itsPCServer->unregisterAtAC("");    // send to AC before quiting
+
+	return (err);
+}
+
+//
+// sendResultParameters(const string&)
+//
+void ProcCtrlRemote::sendResultParameters(const string&	aKVlist)
+{
+	ASSERTSTR(itsPCServer, "Pointer to ProcControlServer is empty!");
+
+	itsPCServer->sendResultParameters(aKVlist);
+}
+
     } // namespace PLC
-    
   } // namespace ACC
-
 } // namespace LOFAR
diff --git a/LCS/ACC/PLC/src/ProcessControl.cc b/LCS/ACC/PLC/src/ProcessControl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ea208bac7f8478ab57638cc484191f066c4c500
--- /dev/null
+++ b/LCS/ACC/PLC/src/ProcessControl.cc
@@ -0,0 +1,54 @@
+//#  ProcessControl.cc: Implements one function of the PC class.
+//#
+//#  Copyright (C) 2009
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id$
+
+#include <lofar_config.h>
+
+//# Includes
+#include <PLC/ProcessControl.h>
+#include <PLC/ProcCtrlProxy.h>
+#include <Common/ParameterSet.h>
+
+namespace LOFAR {
+  namespace ACC {
+    namespace PLC {
+
+//
+// sendResultParameters
+//
+void ProcessControl::sendResultParameters(const string&		keylist)
+{
+	ASSERTSTR(itsControlProxy, "ControlProxy should have been initialized by now!");
+
+	itsControlProxy->sendResultParameters(keylist);
+}
+
+void ProcessControl::sendResultParameters(const ParameterSet&		aParset)
+{
+	string	serializedPS;
+	aParset.writeBuffer(serializedPS);
+	sendResultParameters(serializedPS);
+}
+
+    } // namespace PLC
+  } // namespace ACC
+} // namespace LOFAR
+
diff --git a/MAC/APL/CEPCU/CMakeLists.txt b/MAC/APL/CEPCU/CMakeLists.txt
index 92efefe882e513963299c34e2ebcc7cb6b8a5943..9363d7ce2b0553fb65ad302dad396f198e388803 100644
--- a/MAC/APL/CEPCU/CMakeLists.txt
+++ b/MAC/APL/CEPCU/CMakeLists.txt
@@ -49,4 +49,4 @@ include(LofarConfig)
 ## Subdirectories
 ## ---------------------------------------------------------------------------
 add_subdirectory(src)
-# add_subdirectory(test/ApplController)   # Tests currently do NOT compile 
+add_subdirectory(test/ApplController)   # Tests currently do NOT compile 
diff --git a/MAC/APL/CEPCU/configure.in b/MAC/APL/CEPCU/configure.in
index f559b22c8962a94b6ffd93f122892270ff37bfc6..7ba29a1b118846be9a4874d80747f0b693e8423e 100644
--- a/MAC/APL/CEPCU/configure.in
+++ b/MAC/APL/CEPCU/configure.in
@@ -74,6 +74,7 @@ dnl
 AC_OUTPUT(
 src/Makefile
 src/ApplController/Makefile
+test/ApplController/Makefile
 src/CEPlogProcessor/Makefile
 src/BGPlogProcessor/Makefile
 src/OnlineControl/Makefile
diff --git a/MAC/APL/CEPCU/test/ApplController/APCmdImpl.cc b/MAC/APL/CEPCU/test/ApplController/APCmdImpl.cc
index a96a7cc35e63349981419ba3112b743852fb829d..ff96d7ddfe7af4a097a2ed9ab25b8af967aecafc 100644
--- a/MAC/APL/CEPCU/test/ApplController/APCmdImpl.cc
+++ b/MAC/APL/CEPCU/test/ApplController/APCmdImpl.cc
@@ -32,7 +32,8 @@
 namespace LOFAR {
   namespace ACC {
 
-APCmdImpl::APCmdImpl() :
+APCmdImpl::APCmdImpl(const string&	aProcessID) :
+	ProcessControl(aProcessID),
 	itsRunCounter(0)
 {}
 
@@ -68,6 +69,18 @@ tribool	APCmdImpl::run()
 			clearRunState();
 		}
 	}
+
+	// to test the metadata path we send some metadata when the counter reached 1
+	if (itsRunCounter == 1) {
+		LOG_DEBUG("Sending metadata about runCounter");
+		ParameterSet    resultSet;
+		string          resultBuffer;
+		resultSet.add(KVpair(itsProcID+".runCounter",
+							 string("1"),
+							 true));
+		sendResultParameters(resultSet);
+	}
+
 	return (true);
 }
 
diff --git a/MAC/APL/CEPCU/test/ApplController/APCmdImpl.h b/MAC/APL/CEPCU/test/ApplController/APCmdImpl.h
index 309d5245fbc62369ee3efd875c175ed55ed71e34..51c38e1f4e899aaa58f48464bfa34c8f1c28fce3 100644
--- a/MAC/APL/CEPCU/test/ApplController/APCmdImpl.h
+++ b/MAC/APL/CEPCU/test/ApplController/APCmdImpl.h
@@ -40,7 +40,7 @@ class APCmdImpl : public ProcessControl
 {
 public:
 	// Default constructable
-	APCmdImpl();
+	explicit APCmdImpl(const string&		aProcessID);
 
 	// Destructor
 	virtual ~APCmdImpl();
@@ -59,6 +59,9 @@ public:
 	// Define a generic way to exchange info between client and server.
 	string	askInfo   (const string& 	keylist);
 
+	// Make runstate test available
+	bool inRunState() const { return (ProcessControl::inRunState()); };
+
 protected:
 	// Copying is not allowed
 	APCmdImpl(const APCmdImpl& that);
diff --git a/MAC/APL/CEPCU/test/ApplController/APExample.cc b/MAC/APL/CEPCU/test/ApplController/APExample.cc
deleted file mode 100644
index 8a2507945da09eeaa62c0916c878172d2d083fde..0000000000000000000000000000000000000000
--- a/MAC/APL/CEPCU/test/ApplController/APExample.cc
+++ /dev/null
@@ -1,147 +0,0 @@
-//#  APExample.cc: Example program how a Application Process should respond.
-//#
-//#  Copyright (C) 2002-2005
-//#  ASTRON (Netherlands Foundation for Research in Astronomy)
-//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//#
-//#  This program is free software; you can redistribute it and/or modify
-//#  it under the terms of the GNU General Public License as published by
-//#  the Free Software Foundation; either version 2 of the License, or
-//#  (at your option) any later version.
-//#
-//#  This program is distributed in the hope that it will be useful,
-//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//#  GNU General Public License for more details.
-//#
-//#  You should have received a copy of the GNU General Public License
-//#  along with this program; if not, write to the Free Software
-//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//#
-//#  $Id$
-
-//# Always #include <lofar_config.h> first!
-#include <lofar_config.h>
-
-//# Includes
-#include <time.h>
-#include <libgen.h>
-#include <Common/LofarLogger.h>
-#include <PLC/ProcControlServer.h>
-#include <Common/ParameterSet.h>
-#include <APCmdImpl.h>
-
-using namespace LOFAR;
-using namespace LOFAR::ACC;
-using namespace LOFAR::ACC::PLC;
-
-//
-// This program demonstrates how an Application Process should communicate
-// with the Application Controller. It shows the minimal implementation possible:
-// [A] Connect to the AC.
-// [B] Register at the AC so we receive messages.
-// [C] See if the are new messages arrived.
-// [D] Dispatch the message to the right routine in our APCmdImpl.
-// [E] Unregister at the AC.
-//
-// The places where other program code should be added are marked with
-// IMPLEMENT.
-//
-// Note: The structure of the program is conform the MAIN.cc template.
-//
-int main (int argc, char *argv[]) {
-
-	// Always bring up the logger first
-	string  progName = basename(argv[0]);
-	INIT_VAR_LOGGER(progName.c_str(), progName+"-"+argv[2]);
-
-	// Check invocation syntax
-	if (argc < 2) {
-		LOG_FATAL_STR("Invocation error, syntax: " << progName << 
-					  " parameterfile");
-		return (-1);
-	}
-
-	LOG_INFO_STR("Starting up: " << argv[0] << "(" << argv[1] << ")");
-
-	try {
-		// --- begin of example code ---
-
-		// Read in parameterfile and get my name
-		ParameterSet	itsParamSet(argv[1]);			// may throw
-		string			itsProcID = itsParamSet.getString("process.name");
-
-		// Create a APCmdImpl object. This object contains the real 
-		// implementation of the commands we should support.
-		APCmdImpl		itsAPCmdImpl;
-
-		// [A] Connect to the Application Controller
-		ProcControlServer  itsPCcomm(itsParamSet.getString(itsProcID+".ACnode"),
-									 itsParamSet.getUint16(itsProcID+".ACport"),
-									 &itsAPCmdImpl);
-
-		// IMPLEMENT: do other launch activities like processing the ParamSet
-
-		// [B] Tell AC we are ready for commands
-		LOG_DEBUG_STR("Registering at AC as: " << itsProcID);
-		itsPCcomm.registerAtAC(itsProcID);
-
-		// Main processing loop
-		bool quiting(false);
-		while (!quiting) {
-			// [C] scan AC port to see if a new command was sent.
-			if (itsPCcomm.pollForMessage()) {
-				// get pointer to received data
-				DH_ProcControl* newMsg = itsPCcomm.getDataHolder();
-
-				// we can update our runstate here if we like
-				quiting = (newMsg->getCommand() == PCCmdQuit);
-
-				// [D] let PCcomm dispatch and handle the message
-				LOG_DEBUG_STR("Received messagetype: " << newMsg->getCommand());
-				itsPCcomm.handleMessage(newMsg);
-			}
-			else {
-				// no new message was received, do another run if we are in
-				// the run state.
-				if (itsAPCmdImpl.inRunState()) {
-					itsAPCmdImpl.run();
-				}
-			}
-
-			// IMPLEMENT: do other stuff
-
-			// TEST: simulate we are busy
-			sleep (3);
-		}
-
-		LOG_INFO_STR("Shutting down: " << argv[0]);
-
-		// [E] unregister at AC and send last results
-		// As an example only 1 KV pair is returned but it is allowed to pass
-		// a whole parameterset.
-		ParameterSet	resultSet;
-		string			resultBuffer;
-		resultSet.add(itsProcID+".result", "IMPLEMENT useful information");
-		resultSet.writeBuffer(resultBuffer);		// convert to stringbuffer
-LOG_TRACE_VAR_STR("=====" << resultBuffer << "======");
-		itsPCcomm.unregisterAtAC(resultBuffer);		// send to AC before quiting
-
-		// IMPLEMENT: do other neccesary shutdown actions.
-
-		// TEST: simulate we are busy.
-		sleep (3);
-
-		// --- end of example code ---
-	}
-	catch (Exception&	ex) {
-		LOG_FATAL_STR("Caught exception: " << ex << endl);
-		LOG_FATAL_STR(argv[0] << " terminated by exception!");
-		return(1);
-	}
-
-
-	LOG_INFO_STR(argv[0] << " terminated normally");
-	return (0);
-}
-
diff --git a/MAC/APL/CEPCU/test/ApplController/APTest.cc b/MAC/APL/CEPCU/test/ApplController/APTest.cc
index f73436313e7c03d29b0d34524fcff6ebcde5783a..13f56ded528ab58e76be526171344cdf0452b4a5 100644
--- a/MAC/APL/CEPCU/test/ApplController/APTest.cc
+++ b/MAC/APL/CEPCU/test/ApplController/APTest.cc
@@ -30,6 +30,7 @@
 #include <Common/LofarLogger.h>
 #include <Common/LofarLocators.h>
 #include <PLC/ProcControlServer.h>
+#include <PLC/ProcCtrlRemote.h>
 #include <Common/ParameterSet.h>
 #include <APCmdImpl.h>
 
@@ -62,11 +63,11 @@ int main (int argc, char *argv[]) {
 	ConfigLocator	aCL;
 	string			progName(basename(argv[0]));
 #ifdef HAVE_LOG4CPLUS
-        string			logPropFile(progName + ".log_prop");
+	string			logPropFile(progName + ".log_prop");
 	INIT_VAR_LOGGER (aCL.locate(logPropFile).c_str(), progName + "-" + argv[3]);
 #else
-        string logPropFile(progName + ".debug");
-        INIT_LOGGER (aCL.locate(logPropFile).c_str());	
+	string logPropFile(progName + ".debug");
+	INIT_LOGGER (aCL.locate(logPropFile).c_str());	
 #endif
 	// Check invocation syntax
 	if (argc < 3) {
@@ -87,12 +88,19 @@ int main (int argc, char *argv[]) {
 
 		// Create a APCmdImpl object. This object contains the real 
 		// implementation of the commands we should support.
-		APCmdImpl		itsAPCmdImpl;
+		ProcessControl*		itsAPCmdImpl = new APCmdImpl(itsProcID);
+
+		// Create a proxy to talk to the ApplController.
+		ProcCtrlProxy*	itsProxy = new ProcCtrlRemote(itsAPCmdImpl);
+		ASSERTSTR(itsProxy, "Unable to create a ProcessControlProxy");
 
 		// [A] Connect to the Application Controller
 		ProcControlServer  itsPCcomm(itsParamSet.getString(itsPrefix+"_ACnode"),
 									 itsParamSet.getUint16(itsPrefix+"_ACport"),
-									 &itsAPCmdImpl);
+									 itsProxy);
+
+		// Tell proxy how to talk to the ApplController.
+		((ProcCtrlRemote*)(itsProxy))->setServer(&itsPCcomm);
 
 		// IMPLEMENT: do other launch activities like processing the ParamSet
 		// TEST: init random generator with some value for testing
@@ -126,7 +134,7 @@ int main (int argc, char *argv[]) {
 			else {
 				// no new message was received, do another run if we are in
 				// the run state
-				if (itsAPCmdImpl.inRunState()) {
+				if (((APCmdImpl*)(itsAPCmdImpl))->inRunState()) {
 					itsPCcomm.handleMessage(&DH_ProcControl(PCCmdRun));
 				}
 			}
diff --git a/MAC/APL/CEPCU/test/ApplController/CMakeLists.txt b/MAC/APL/CEPCU/test/ApplController/CMakeLists.txt
index 02d94f91e5f7657b46a38ae80cc7b5f35be13a0a..d98a7c5b4f8d66cf9a690f9d1d996c73ac7d9778 100644
--- a/MAC/APL/CEPCU/test/ApplController/CMakeLists.txt
+++ b/MAC/APL/CEPCU/test/ApplController/CMakeLists.txt
@@ -20,5 +20,4 @@
 
 include(LofarCTest)
 
-lofar_add_test(APExample APExample.cc APCmdImpl.cc)
 lofar_add_test(APTest APTest.cc APCmdImpl.cc)
diff --git a/MAC/APL/CEPCU/test/ApplController/Makefile.am b/MAC/APL/CEPCU/test/ApplController/Makefile.am
index a3fd90e93945a64f44b2dc2ecc13fabdfae578ae..0c035ecfc4557ae79471e07f2827e60f228e8975 100644
--- a/MAC/APL/CEPCU/test/ApplController/Makefile.am
+++ b/MAC/APL/CEPCU/test/ApplController/Makefile.am
@@ -1,16 +1,9 @@
 
-check_PROGRAMS		= APExample
-
 bin_PROGRAMS		= APTest
 sysconf_DATA		= APTest.log_prop
 
 TESTS			= 
 
-### APExample ###
-APExample_SOURCES	= APCmdImpl.cc APExample.cc 
-APExample_DEPENDENCIES	= $(LOFAR_DEPEND) APCmdImpl.h
-APExample_LDADD		= 
-
 ### APTest ###
 APTest_SOURCES		= APCmdImpl.cc APTest.cc
 APTest_DEPENDENCIES	= $(LOFAR_DEPEND) APCmdImpl.h