From 781421a647d7020175faea6f4b7104fdad608825 Mon Sep 17 00:00:00 2001
From: Ruud Overeem <overeem@astron.nl>
Date: Mon, 9 Feb 2015 08:50:50 +0000
Subject: [PATCH] Task #7342: Using derived class from 'Message' in the
 MACScheduler.

---
 .gitattributes                                |  1 +
 .../MessageBus/Protocols/CMakeLists.txt       |  1 +
 .../Protocols/TaskSpecificationSystem.h       | 84 +++++++++++++++++++
 .../MainCU/src/MACScheduler/MACScheduler.cc   |  6 ++
 4 files changed, 92 insertions(+)
 create mode 100644 LCS/MessageBus/include/MessageBus/Protocols/TaskSpecificationSystem.h

diff --git a/.gitattributes b/.gitattributes
index d753a085d06..49f6abdee94 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2431,6 +2431,7 @@ LCS/MessageBus/data/task_spec_system_78958.txt -text
 LCS/MessageBus/data/task_spec_system_empty.txt -text
 LCS/MessageBus/data/task_spec_system_no_ids.txt -text
 LCS/MessageBus/data/task_spec_system_xml_error.txt -text
+LCS/MessageBus/include/MessageBus/Protocols/TaskSpecificationSystem.h -text
 LCS/MessageBus/src/LofarMsgTemplate.txt -text
 LCS/MessageBus/src/Message.cc -text
 LCS/MessageBus/src/Routing.conf -text
diff --git a/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt b/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt
index 0ef4a186445..3b735c1b282 100644
--- a/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt
+++ b/LCS/MessageBus/include/MessageBus/Protocols/CMakeLists.txt
@@ -10,4 +10,5 @@ install(FILES
   TaskFeedbackDataproducts.h
   TaskFeedbackProcessing.h
   TaskFeedbackStatus.h
+  TaskSpecificationSystem.h
   DESTINATION include/${PACKAGE_NAME}/Protocols)
diff --git a/LCS/MessageBus/include/MessageBus/Protocols/TaskSpecificationSystem.h b/LCS/MessageBus/include/MessageBus/Protocols/TaskSpecificationSystem.h
new file mode 100644
index 00000000000..c67b9c8fc4e
--- /dev/null
+++ b/LCS/MessageBus/include/MessageBus/Protocols/TaskSpecificationSystem.h
@@ -0,0 +1,84 @@
+//# TaskSpecificationSystem.h: Protocol for emission of status feedback information
+//#
+//# Copyright (C) 2015
+//# ASTRON (Netherlands Institute for Radio Astronomy)
+//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+//#
+//# This file is part of the LOFAR software suite.
+//# The LOFAR software suite 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 3 of the License, or
+//# (at your option) any later version.
+//#
+//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
+//#
+//# $Id: TaskSpecificationSystem.h 30864 2015-02-03 16:07:56Z mol $
+
+#ifndef LOFAR_MESSAGEBUS_TASK_SPECIFICATION_SYSTEM_H
+#define LOFAR_MESSAGEBUS_TASK_SPECIFICATION_SYSTEM_H
+
+#ifdef HAVE_QPID
+#include <MessageBus/Message.h>
+#include <Common/ParameterSet.h>
+#include <Common/StringUtil.h>
+
+namespace LOFAR {
+namespace Protocols {
+
+class TaskSpecificationSystem: public Message
+{
+public:
+    TaskSpecificationSystem(
+						// Name of the service or process producing this message
+						const std::string &from,
+
+						// End-user responsible for this request (if applicable)
+						const std::string &forUser,
+
+						// Human-readable summary describing this request
+						const std::string &summary,
+
+						// Identifiers for the context of this message
+						const std::string &momID,
+						const std::string &sasID,
+
+						// Payload: a parset containing the generated feedback
+						const ParameterSet &feedback
+					  ): 
+		Message( from, forUser, summary, "task.specification.system", "1.0.0", momID, sasID)
+	{
+   		std::string buffer;
+		feedback.writeBuffer(buffer);
+		setTXTPayload(buffer);
+	}
+
+	// Parse a message
+	TaskSpecificationSystem(const qpid::messaging::Message qpidMsg) :
+	    Message(qpidMsg)
+	{ }
+
+	// Read a message from disk (header + payload)
+	TaskSpecificationSystem(const std::string &rawContent) :
+		Message(rawContent)
+	{ }
+
+	ParameterSet specfications() const {
+		ParameterSet result;
+		result.adoptBuffer(payload());
+		return result;
+	}
+};
+
+  } // namespace Protocols
+} // namespace LOFAR
+
+#endif
+
+#endif
+
diff --git a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc
index 6dea75d6cfa..aa1bb8ebd60 100644
--- a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc
+++ b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc
@@ -28,6 +28,7 @@
 #include <Common/ParameterSet.h>
 #include <GCF/TM/GCF_Protocols.h>
 #include <MACIO/MACServiceInfo.h>
+#include <MessageBus/Protocols/TaskSpecificationSystem.h>
 #include <GCF/PVSS/GCF_PVTypes.h>
 #include <APL/APLCommon/APL_Defines.h>
 #include <APL/APLCommon/ControllerDefines.h>
@@ -47,6 +48,7 @@ using namespace LOFAR::GCF::PVSS;
 using namespace LOFAR::GCF::TM;
 using namespace LOFAR::GCF::RTDB;
 using namespace LOFAR::OTDB;
+using namespace LOFAR::Protocols;
 using namespace boost::posix_time;
 using namespace std;
 
@@ -834,10 +836,14 @@ void MACScheduler::_setParsetOnMsgBus(const string&	filename) const
 	string			sasID = obsSpecs.getString(obsPrefix + ".otdbID");
 
     //                      from, forUser, summary, protocol, protocolVersion, momID, sasID
+#if 1	
+	TaskSpecificationSystem	outMsg("LOFAR.MACScheduler", "", "", momID, sasID, obsSpecs);
+#else
 	Message			outMsg("LOFAR.MACScheduler", "", "", "task.specification.system", "1.0", momID, sasID);
 	stringstream	ss;
 	obsSpecs.writeStream(ss);
 	outMsg.setTXTPayload(ss.str());
+#endif
 	cout << outMsg << endl;
 	itsMsgQueue->send(outMsg);
 }
-- 
GitLab