From bda83f949752cbb55bc57a1ba2bfd2bb951fdf30 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Tue, 22 May 2007 11:05:00 +0000 Subject: [PATCH] BugID: 991 Second large commit. This should be the first "working" version of the global controller. The local (kernel) controller still needs to post its results to the command queue. --- .../BBSControl/include/BBSControl/CommandId.h | 116 ++++++++++++++++++ .../include/BBSControl/LocalControlId.h | 83 +++++++++++++ .../BBSControl/include/BBSControl/Makefile.am | 1 - .../include/BBSControl/RecoverCommand.h | 59 +++++++++ .../include/BBSControl/SynchronizeCommand.h | 59 +++++++++ CEP/BB/BBSControl/src/Makefile.am | 15 ++- CEP/BB/BBSControl/src/RecoverCommand.cc | 83 +++++++++++++ CEP/BB/BBSControl/src/SynchronizeCommand.cc | 83 +++++++++++++ 8 files changed, 490 insertions(+), 9 deletions(-) create mode 100644 CEP/BB/BBSControl/include/BBSControl/CommandId.h create mode 100644 CEP/BB/BBSControl/include/BBSControl/LocalControlId.h create mode 100644 CEP/BB/BBSControl/include/BBSControl/RecoverCommand.h create mode 100644 CEP/BB/BBSControl/include/BBSControl/SynchronizeCommand.h create mode 100644 CEP/BB/BBSControl/src/RecoverCommand.cc create mode 100644 CEP/BB/BBSControl/src/SynchronizeCommand.cc diff --git a/CEP/BB/BBSControl/include/BBSControl/CommandId.h b/CEP/BB/BBSControl/include/BBSControl/CommandId.h new file mode 100644 index 00000000000..b960663077a --- /dev/null +++ b/CEP/BB/BBSControl/include/BBSControl/CommandId.h @@ -0,0 +1,116 @@ +//# CommandId.h: Command identifier +//# +//# Copyright (C) 2002-2004 +//# 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$ + +#ifndef LOFAR_BBSCONTROL_COMMANDID_H +#define LOFAR_BBSCONTROL_COMMANDID_H + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +// \file +// Command identifier + +//# Includes +#include <Common/lofar_string.h> +#include <Common/lofar_iostream.h> +#include <Common/StringUtil.h> + +namespace LOFAR +{ + namespace BBS { + + // \addtogroup BBSControl + // @{ + + // Command identifier. Encapsulates the identifier that is used to + // uniquely identify a command. Internally, this ID is an integer, but + // this may change in the future. + class CommandId + { + public: + // Construct a command-id. + CommandId(int id = -1) : itsId(id) {} + + // Return the command-id as an integer. + // \note This method is provided so that we can later easily change the + // internal format of the ID to something different than \c int. + int asInt() const { return itsId; } + + private: + // Unique id. + int itsId; + + // Comparison operators. + // @{ + friend bool operator<(const CommandId& lhs, const CommandId& rhs); + friend bool operator>(const CommandId& lhs, const CommandId& rhs); + friend bool operator<=(const CommandId& lhs, const CommandId& rhs); + friend bool operator>=(const CommandId& lhs, const CommandId& rhs); + friend bool operator==(const CommandId& lhs, const CommandId& rhs); + friend bool operator!=(const CommandId& lhs, const CommandId& rhs); + // @} + + // Write CommandId \a id in human readable form to output stream \a os. + friend ostream& operator<<(ostream& os, const CommandId& id); + }; + + // @} + + inline bool operator<(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId < rhs.itsId; + } + + inline bool operator>(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId > rhs.itsId; + } + + inline bool operator<=(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId <= rhs.itsId; + } + + inline bool operator>=(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId >= rhs.itsId; + } + + inline bool operator==(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId == rhs.itsId; + } + + inline bool operator!=(const CommandId& lhs, const CommandId& rhs) + { + return lhs.itsId != rhs.itsId; + } + + inline ostream& operator<<(ostream& os, const CommandId& id) + { + return os << id.itsId; + } + + } // namespace BBS + +} // namespace LOFAR + +#endif diff --git a/CEP/BB/BBSControl/include/BBSControl/LocalControlId.h b/CEP/BB/BBSControl/include/BBSControl/LocalControlId.h new file mode 100644 index 00000000000..1df1a8cf126 --- /dev/null +++ b/CEP/BB/BBSControl/include/BBSControl/LocalControlId.h @@ -0,0 +1,83 @@ +//# LocalControlId.h: Identifier for a local controller +//# +//# Copyright (C) 2002-2004 +//# 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$ + +#ifndef LOFAR_BBSCONTROL_LOCALCONTROLID_H +#define LOFAR_BBSCONTROL_LOCALCONTROLID_H + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +// \file +// Identifier for a local controller + +//# Includes +#include <Common/lofar_string.h> +#include <Common/lofar_iostream.h> + +namespace LOFAR +{ + namespace BBS { + + // \addtogroup BBSControl + // @{ + + // Class representing the identifier for a local controller. It is stored + // internally as a string, but this may change in the future. + class LocalControlId + { + public: + // Construct a local controller id. + explicit LocalControlId(const string& id) : itsId(id) {} + + // Get the local controller id as a string. + string asString() const { return itsId; } + + private: + // Internal id. + string itsId; + + // Operator "less-than". Required when using LocalControlId key in a map. + friend bool operator<(const LocalControlId& lhs, + const LocalControlId& rhs); + + // Write LocalControlId \a id in human readable format to output stream + // \a os. + friend ostream& operator<<(ostream& os, const LocalControlId& id); + }; + + // @} + + inline bool operator<(const LocalControlId& lhs, + const LocalControlId& rhs) + { + return lhs.itsId < rhs.itsId; + } + + inline ostream& operator<<(ostream& os, const LocalControlId& id) + { + return os << id.itsId; + } + + } // namespace BBS + +} // namespace LOFAR + +#endif diff --git a/CEP/BB/BBSControl/include/BBSControl/Makefile.am b/CEP/BB/BBSControl/include/BBSControl/Makefile.am index c7a6eb25aec..7246a017728 100644 --- a/CEP/BB/BBSControl/include/BBSControl/Makefile.am +++ b/CEP/BB/BBSControl/include/BBSControl/Makefile.am @@ -28,7 +28,6 @@ pkginclude_HEADERS = \ KernelProcessControl.h \ LocalControlId.h \ NextChunkCommand.h \ - ProcessControlState.h \ RecoverCommand.h \ SolverProcessControl.h \ SynchronizeCommand.h diff --git a/CEP/BB/BBSControl/include/BBSControl/RecoverCommand.h b/CEP/BB/BBSControl/include/BBSControl/RecoverCommand.h new file mode 100644 index 00000000000..7fc96685a23 --- /dev/null +++ b/CEP/BB/BBSControl/include/BBSControl/RecoverCommand.h @@ -0,0 +1,59 @@ +//# RecoverCommand.h: +//# +//# Copyright (C) 2007 +//# 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$ + +#ifndef LOFAR_BBSCONTROL_RECOVERCOMMAND_H +#define LOFAR_BBSCONTROL_RECOVERCOMMAND_H + +#include <BBSControl/Command.h> + +namespace LOFAR +{ + namespace BBS + { + class RecoverCommand : public Command + { + public: + // Destructor. + virtual ~RecoverCommand() {} + + // Return the command type of \c *this as a string. + virtual const string& type() const; + + // Write the contents of \c *this into the ParameterSet \a ps. + virtual void write(ACC::APS::ParameterSet& ps) const; + + // Read the contents from the ParameterSet \a ps into \c *this. + virtual void read(const ACC::APS::ParameterSet& ps); + + // Print the contents of \c *this in human readable form into the output + // stream \a os. + virtual void print(ostream& os) const; + + // Accept a CommandVisitor that wants to process \c *this. + virtual void accept(CommandVisitor &visitor) const; + + }; + + } //# namespace BBS +} //# namespace LOFAR + +#endif diff --git a/CEP/BB/BBSControl/include/BBSControl/SynchronizeCommand.h b/CEP/BB/BBSControl/include/BBSControl/SynchronizeCommand.h new file mode 100644 index 00000000000..409b42cc93c --- /dev/null +++ b/CEP/BB/BBSControl/include/BBSControl/SynchronizeCommand.h @@ -0,0 +1,59 @@ +//# SynchronizeCommand.h: +//# +//# Copyright (C) 2007 +//# 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$ + +#ifndef LOFAR_BBSCONTROL_SYNCHRONIZECOMMAND_H +#define LOFAR_BBSCONTROL_SYNCHRONIZECOMMAND_H + +#include <BBSControl/Command.h> + +namespace LOFAR +{ + namespace BBS + { + class SynchronizeCommand : public Command + { + public: + // Destructor. + virtual ~SynchronizeCommand() {} + + // Return the command type of \c *this as a string. + virtual const string& type() const; + + // Write the contents of \c *this into the ParameterSet \a ps. + virtual void write(ACC::APS::ParameterSet& ps) const; + + // Read the contents from the ParameterSet \a ps into \c *this. + virtual void read(const ACC::APS::ParameterSet& ps); + + // Print the contents of \c *this in human readable form into the output + // stream \a os. + virtual void print(ostream& os) const; + + // Accept a CommandVisitor that wants to process \c *this. + virtual void accept(CommandVisitor &visitor) const; + + }; + + } //# namespace BBS +} //# namespace LOFAR + +#endif diff --git a/CEP/BB/BBSControl/src/Makefile.am b/CEP/BB/BBSControl/src/Makefile.am index b2deccdd429..a311d29d441 100644 --- a/CEP/BB/BBSControl/src/Makefile.am +++ b/CEP/BB/BBSControl/src/Makefile.am @@ -26,24 +26,23 @@ libbbscontrol_la_SOURCES = \ KernelProcessControl.cc \ NextChunkCommand.cc \ pqutil.cc \ - ProcessControlState.cc \ RecoverCommand.cc \ SolverProcessControl.cc \ SynchronizeCommand.cc \ QueryBuilder/AddCommand.cc -bin_PROGRAMS = GlobalControl #KernelControl SolverControl +bin_PROGRAMS = GlobalControl KernelControl SolverControl GlobalControl_SOURCES = GlobalControl.cc GlobalControl_LDADD = libbbscontrol.la GlobalControl_DEPENDENCIES = libbbscontrol.la $(LOFAR_DEPEND) -#KernelControl_SOURCES = KernelControl.cc -#KernelControl_LDADD = libbbscontrol.la -#KernelControl_DEPENDENCIES = libbbscontrol.la $(LOFAR_DEPEND) +KernelControl_SOURCES = KernelControl.cc +KernelControl_LDADD = libbbscontrol.la +KernelControl_DEPENDENCIES = libbbscontrol.la $(LOFAR_DEPEND) -#SolverControl_SOURCES = SolverControl.cc -#SolverControl_LDADD = libbbscontrol.la -#SolverControl_DEPENDENCIES = libbbscontrol.la $(LOFAR_DEPEND) +SolverControl_SOURCES = SolverControl.cc +SolverControl_LDADD = libbbscontrol.la +SolverControl_DEPENDENCIES = libbbscontrol.la $(LOFAR_DEPEND) include $(top_srcdir)/Makefile.common diff --git a/CEP/BB/BBSControl/src/RecoverCommand.cc b/CEP/BB/BBSControl/src/RecoverCommand.cc new file mode 100644 index 00000000000..53ebd5f391b --- /dev/null +++ b/CEP/BB/BBSControl/src/RecoverCommand.cc @@ -0,0 +1,83 @@ +//# RecoverCommand.cc: +//# +//# Copyright (C) 2007 +//# 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> +#include <BBSControl/RecoverCommand.h> +#include <BBSControl/CommandVisitor.h> +#include <Common/LofarLogger.h> +#include <Common/lofar_iostream.h> + +namespace LOFAR +{ + namespace BBS + { + using ACC::APS::ParameterSet; + + // Register RecoverCommand with the CommandFactory. Use an anonymous + // namespace. This ensures that the variable `dummy' gets its own private + // storage area and is only visible in this compilation unit. + namespace + { + bool dummy = CommandFactory::instance(). + registerClass<RecoverCommand>("recover"); + } + + + //##-------- P u b l i c m e t h o d s --------##// + + void RecoverCommand::accept(CommandVisitor &visitor) const + { + visitor.visit(*this); + } + + + const string& RecoverCommand::type() const + { + static const string theType("Recover"); + return theType; + } + + + void RecoverCommand::print(ostream& os) const + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + Command::print(os); + } + + + //##-------- P r i v a t e m e t h o d s --------##// + + void RecoverCommand::write(ParameterSet&) const + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + } + + + void RecoverCommand::read(const ParameterSet&) + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + } + + + } //# namespace BBS + +} //# namespace LOFAR diff --git a/CEP/BB/BBSControl/src/SynchronizeCommand.cc b/CEP/BB/BBSControl/src/SynchronizeCommand.cc new file mode 100644 index 00000000000..beb435712a4 --- /dev/null +++ b/CEP/BB/BBSControl/src/SynchronizeCommand.cc @@ -0,0 +1,83 @@ +//# SynchronizeCommand.cc: +//# +//# Copyright (C) 2007 +//# 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> +#include <BBSControl/SynchronizeCommand.h> +#include <BBSControl/CommandVisitor.h> +#include <Common/LofarLogger.h> +#include <Common/lofar_iostream.h> + +namespace LOFAR +{ + namespace BBS + { + using ACC::APS::ParameterSet; + + // Register SynchronizeCommand with the CommandFactory. Use an anonymous + // namespace. This ensures that the variable `dummy' gets its own private + // storage area and is only visible in this compilation unit. + namespace + { + bool dummy = CommandFactory::instance(). + registerClass<SynchronizeCommand>("synchronize"); + } + + + //##-------- P u b l i c m e t h o d s --------##// + + void SynchronizeCommand::accept(CommandVisitor &visitor) const + { + visitor.visit(*this); + } + + + const string& SynchronizeCommand::type() const + { + static const string theType("Synchronize"); + return theType; + } + + + void SynchronizeCommand::print(ostream& os) const + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + Command::print(os); + } + + + //##-------- P r i v a t e m e t h o d s --------##// + + void SynchronizeCommand::write(ParameterSet&) const + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + } + + + void SynchronizeCommand::read(const ParameterSet&) + { + LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); + } + + + } //# namespace BBS + +} //# namespace LOFAR -- GitLab