diff --git a/LCS/ACC/ACCbin/configure.in b/LCS/ACC/ACCbin/configure.in index 3d5e860b8c9fc259ae5fee350ca1c5f27c61e81d..eae3e1d38b474e5c87e2b7dfbb24ad439e91d99f 100644 --- a/LCS/ACC/ACCbin/configure.in +++ b/LCS/ACC/ACCbin/configure.in @@ -56,6 +56,10 @@ lofar_INTERNAL(LCS/Transport,Transport,,1,Transport/TransportHolder.h,,) lofar_INTERNAL(LCS/ACC/APS,APS,,1,APS/ParameterSet.h,,) lofar_INTERNAL(LCS/ACC/ALC,ALC,,1,ALC/ApplControl.h,,) lofar_INTERNAL(LCS/ACC/PLC,PLC,,1,PLC/ProcessControl.h,,) +lofar_INTERNAL(MAC/GCF/GCFCommon,GCFCommon,,1,GCF/GCF_ServiceInfo.h,,) +lofar_INTERNAL(MAC/GCF/TM,eventport,,1,GCF/TM/EventPort.h,,) +dnl lofar_INTERNAL(MAC/GCF/TM,gcftm,,1,GCF/TM/GCF_Event.h,,) +lofar_INTERNAL(MAC/APL/APLProtocol,kvt_protocol,,1,APL/APLProtocol/KVT_Protocol.ph,,) dnl Note: only the test programs depend on the tribool functionality lofar_EXTERNAL(boost,1,boost/logic/tribool.hpp,"") diff --git a/LCS/ACC/ACCbin/src/ApplController.cc b/LCS/ACC/ACCbin/src/ApplController.cc index eee717e6e7f46cfb21ef2f842b609d43c774f410..23ca944d9f0b4dd80b5a5d0950b2ba3143ea7dd3 100644 --- a/LCS/ACC/ACCbin/src/ApplController.cc +++ b/LCS/ACC/ACCbin/src/ApplController.cc @@ -28,6 +28,8 @@ #include <Common/LofarLocators.h> #include <ALC/ACCmd.h> #include <PLC/ProcControlComm.h> +#include <GCF/GCF_ServiceInfo.h> +#include <APL/APLProtocol/KVT_Protocol.ph> #include "ApplController.h" #include "PR_Shell.h" // TODO: factory! #include "PR_MPI.h" // TODO: factory! @@ -36,6 +38,7 @@ #include "lofarDirs.h" namespace LOFAR { + using namespace GCF::TM; namespace ACC { // @@ -52,6 +55,7 @@ ApplController::ApplController(const string& configID) : itsAPAPool (0), itsServerStub (0), itsDaemonComm (0), + itsKVLogger (0), itsCurTime (0), itsIsRunning (false), itsStateEngine (new StateEngine), @@ -89,6 +93,7 @@ ApplController::~ApplController() if (itsAPAPool) { delete itsAPAPool; } if (itsServerStub) { delete itsServerStub; } if (itsDaemonComm) { delete itsDaemonComm; } + if (itsKVLogger) { delete itsKVLogger; } if (itsCurACMsg) { delete itsCurACMsg; } if (itsStateEngine) { delete itsStateEngine; } @@ -121,6 +126,11 @@ void ApplController::startupNetwork() itsBootParamSet->getString("AC.pinghost"), itsBootParamSet->getString("AC.pingportnr"), itsBootParamSet->getString("AC.pingID")); + + // client synchrone + itsKVLogger = new EventPort(MAC_SVCMASK_KVTLOGGER, false, KVT_PROTOCOL, "", true); + ASSERTSTR(itsKVLogger, "Can't connect to KeyValueLogger"); + itsIsRunning = true; } @@ -172,9 +182,11 @@ void ApplController::handleProcMessage(APAdmin* anAP) break; case PCCmdParams: { + // TODO: Write this information to the >>>> KeyValueLogger <<<< ParameterSet resultParam; resultParam.adoptBuffer(DHProcPtr->getOptions()); resultParam.writeFile(itsObsParamSet->getString("ApplCtrl.resultfile"), true); + sendToKVLogger(resultParam); break; } @@ -440,6 +452,41 @@ void ApplController::writeResultFile() } } +// +// sendToKVLogger(parSet) +// +// Send the KV pairs to the KeyValueLogger +// +void ApplController::sendToKVLogger(ParameterSet& aResultPS) +{ + // loop over PS and construct a msgpool event. + ParameterSet::iterator iter = aResultPS.begin(); + ParameterSet::iterator end = aResultPS.end(); + KVTSendMsgPoolEvent poolEvent; + poolEvent.seqnr = 1; + poolEvent.msgCount = 0; + while (iter != end) { + poolEvent.keys.theVector.push_back(iter->first); + poolEvent.values.theVector.push_back(iter->second); + poolEvent.msgCount++; + iter++; + } + + // empty PS? + if (!poolEvent.msgCount) { + return; + } + + // send message and wait for answer. + itsKVLogger->send(&poolEvent); + KVTSendMsgPoolAckEvent poolAck(*(itsKVLogger->receive())); + + if (poolAck.result != 0) { + LOG_ERROR_STR("Storing metadata in PVSS resulted in errorcode " << poolAck.result); + } +} + + // // startState (newMsg) // diff --git a/LCS/ACC/ACCbin/src/ApplController.h b/LCS/ACC/ACCbin/src/ApplController.h index 1b86186335f01b8349a6e4d5c9daee3e6299beb4..7b8b16a6bd4e28c48985e05965d8b3a17cc377a3 100644 --- a/LCS/ACC/ACCbin/src/ApplController.h +++ b/LCS/ACC/ACCbin/src/ApplController.h @@ -38,6 +38,7 @@ #include <ALC/ApplControlServer.h> //# communication stub #include <PLC/DH_ProcControl.h> #include <APS/ParameterSet.h> +#include <GCF/TM/EventPort.h> #include "ACCmdImpl.h" //# the real implementation #include "ACDaemonComm.h" #include "CmdStack.h" @@ -80,6 +81,7 @@ private: // it is only meant to avoid code duplication in createParSubsets void writeParSubset(ParameterSet ps, const string& procName, const string& fileName); void writeResultFile (); + void sendToKVLogger (ParameterSet& aResultPS); void checkForACCommands(); void checkForAPMessages(); @@ -101,6 +103,7 @@ private: APAdminPool* itsAPAPool; // Communication with all AP's ApplControlServer* itsServerStub; // Communication with AM ACDaemonComm* itsDaemonComm; // Communication with ACDaemon + GCF::TM::EventPort* itsKVLogger; // Connection to KeyValueLogger time_t itsCurTime; // Current timestamp bool itsIsRunning; // Alive or not