From d8e8dbe5181cf292d1a238bac6a45f2b3f4fc05d Mon Sep 17 00:00:00 2001 From: Ruud Overeem <overeem@astron.nl> Date: Fri, 21 Mar 2008 08:35:15 +0000 Subject: [PATCH] Bug 1167: Cleaned up MAC layers. There are less dependancies between the packages now. Observation is moved to LOFAR/Appl/ApplCommon. --- MAC/APL/APLCommon/configure.in | 2 +- .../include/APL/APLCommon/APLUtilities.h | 3 - .../include/APL/APLCommon/ChildControl.h | 7 +- .../include/APL/APLCommon/Makefile.am | 3 +- .../include/APL/APLCommon/Observation.h | 113 ---------- .../include/APL/APLCommon/ParentControl.h | 4 +- MAC/APL/APLCommon/src/APLUtilities.cc | 180 --------------- MAC/APL/APLCommon/src/ChildControl.cc | 15 +- MAC/APL/APLCommon/src/ControllerDefines.cc | 3 +- .../APLCommon/src/Controller_Protocol.prot | 2 +- MAC/APL/APLCommon/src/Makefile.am | 5 +- MAC/APL/APLCommon/src/Observation.cc | 210 ------------------ MAC/APL/APLCommon/src/ParentControl.cc | 9 +- .../APLCommon/src/StartDaemon_Protocol.prot | 2 +- MAC/APL/APLCommon/src/StationInfo.cc | 3 +- MAC/APL/APLCommon/test/Makefile.am | 7 +- MAC/APL/APLCommon/test/tAPLUtilities.cc | 50 ----- MAC/APL/APLCommon/test/tControllerDefines.cc | 7 +- MAC/APL/APLCommon/test/tObservation.cc | 80 ------- MAC/APL/APLCommon/test/tObservation.log_prop | 9 - 20 files changed, 27 insertions(+), 687 deletions(-) delete mode 100644 MAC/APL/APLCommon/include/APL/APLCommon/Observation.h delete mode 100644 MAC/APL/APLCommon/src/Observation.cc delete mode 100644 MAC/APL/APLCommon/test/tObservation.cc delete mode 100644 MAC/APL/APLCommon/test/tObservation.log_prop diff --git a/MAC/APL/APLCommon/configure.in b/MAC/APL/APLCommon/configure.in index 968f4814edd..5c94eaf0e9b 100644 --- a/MAC/APL/APLCommon/configure.in +++ b/MAC/APL/APLCommon/configure.in @@ -57,7 +57,7 @@ lofar_COMPILETOOLS lofar_INTERNAL(LCS/Common, common, , 1, Common/LofarTypes.h,,) lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,) lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Control.h,,) -lofar_INTERNAL(MAC/GCF/GCFCommon, GCFCommon, , 1, GCF/GCF_Defines.h,,) +lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,"",) lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) dnl diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/APLUtilities.h b/MAC/APL/APLCommon/include/APL/APLCommon/APLUtilities.h index 7dcd39d125d..260347095fd 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/APLUtilities.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/APLUtilities.h @@ -82,9 +82,6 @@ public: const string& localFile); static string getTempFileName(const string& format=""); - static string compactedArrayString(const string& orgStr); - static string expandedArrayString (const string& orgStr); - protected: // protected copy constructor APLUtilities(const APLUtilities&); diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ChildControl.h b/MAC/APL/APLCommon/include/APL/APLCommon/ChildControl.h index 5052db52809..e29ea52d4c5 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ChildControl.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ChildControl.h @@ -31,10 +31,7 @@ #include <Common/lofar_string.h> #include <Common/lofar_map.h> #include <Common/lofar_list.h> -#include <GCF/TM/GCF_Task.h> -#include <GCF/TM/GCF_ITCPort.h> -#include <GCF/TM/GCF_TCPPort.h> -#include <GCF/TM/GCF_TimerPort.h> +#include <GCF/TM/GCF_Control.h> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/ControllerAdmin.h> @@ -43,8 +40,8 @@ // Avoid 'using namespace' in headerfiles namespace LOFAR { + using MACIO::GCFEvent; using GCF::TM::GCFTCPPort; - using GCF::TM::GCFEvent; using GCF::TM::GCFTask; using GCF::TM::GCFPortInterface; using GCF::TM::GCFITCPort; diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am b/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am index 41281b83200..ba8e9830e7c 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am +++ b/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am @@ -9,7 +9,6 @@ pkginclude_HEADERS = \ ControllerInfo.h \ ControllerAdmin.h \ ChildControl.h \ - ParentControl.h \ - Observation.h + ParentControl.h include $(top_srcdir)/Makefile.common diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/Observation.h b/MAC/APL/APLCommon/include/APL/APLCommon/Observation.h deleted file mode 100644 index 4d397195907..00000000000 --- a/MAC/APL/APLCommon/include/APL/APLCommon/Observation.h +++ /dev/null @@ -1,113 +0,0 @@ -//# Observation.h: class/struct that holds the Observation information -//# -//# Copyright (C) 2006 -//# 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_APLCOMMON_OBSERVATION_H -#define LOFAR_APLCOMMON_OBSERVATION_H - -// \file -// class/struct that holds the Observation information - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! - -//# Includes -#include <APS/ParameterSet.h> -#include <Common/lofar_bitset.h> -#include <Common/lofar_vector.h> -#include <Common/lofar_string.h> - -namespace LOFAR { - namespace APLCommon { - -// \addtogroup APLCommon -// @{ - -//# Forward Declarations -//class forward; - - -// The Observation class is a public struct that can be used as base-class -// for holding Observation related information. -// It can be instantiated with a parset containing Observation information. -class Observation -{ -public: - Observation(); - ~Observation(); - explicit Observation (ACC::APS::ParameterSet* aParSet); - - // global function for converting filtername to nyquist zone - static uint32 nyquistzoneFromFilter(const string& filterName); - - // get name of a beam (idx starts at 0) - string getBeamName(uint32 beamIdx) const; - - // for operator << - ostream& print (ostream& os) const; - - // data types - typedef bitset<256> RCUset_t; - - class Beam { - public: - Beam() {}; - ~Beam() {}; - - // NOTE: since not other sw in the signal chain supports switching the beam to another direction - // we only support 1 direction per beam for now. - double angle1; - double angle2; - string directionType; -// string angleTimes; - vector<int16> subbands; - vector<int16> beamlets; - }; - - //# Datamembers - string name; - int32 obsID; - time_t startTime; - time_t stopTime; - int16 nyquistZone; - vector<string> stations; - int32 sampleClock; - string filter; - string antennaArray; - RCUset_t RCUset; // set with participating receivers - vector<Beam> beams; - vector<int16> beamlet2beams; // to which beam each beamlet belongs - vector<int16> beamlet2subbands; // which subband each beamlet uses. - -}; - -//# -//# operator << -//# -inline ostream& operator<< (ostream& os, const Observation& anObs) -{ - return (anObs.print(os)); -} - -// @} - } // namespace APLCommon -} // namespace LOFAR - -#endif diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ParentControl.h b/MAC/APL/APLCommon/include/APL/APLCommon/ParentControl.h index f513f62d2f7..8a940481192 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ParentControl.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ParentControl.h @@ -31,7 +31,7 @@ #include <Common/lofar_string.h> #include <Common/lofar_datetime.h> #include <Common/lofar_list.h> -#include <GCF/TM/GCF_Task.h> +#include <GCF/TM/GCF_Control.h> #include <GCF/TM/GCF_TCPPort.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> @@ -41,10 +41,10 @@ // Avoid 'using namespace' in headerfiles namespace LOFAR { + using MACIO::GCFEvent; using GCF::TM::GCFTCPPort; using GCF::TM::GCFITCPort; using GCF::TM::GCFTimerPort; - using GCF::TM::GCFEvent; using GCF::TM::GCFTask; using GCF::TM::GCFPortInterface; using APLCommon::CTState; diff --git a/MAC/APL/APLCommon/src/APLUtilities.cc b/MAC/APL/APLCommon/src/APLUtilities.cc index ea6a4cfe344..b4468715a8f 100644 --- a/MAC/APL/APLCommon/src/APLUtilities.cc +++ b/MAC/APL/APLCommon/src/APLUtilities.cc @@ -302,186 +302,6 @@ string APLUtilities::getTempFileName(const string& format) return string(tempFileName); } -// -// compactedArrayString(string) -// -// Given een array string ( '[ xx, xx, xx ]' ) this utility compacts the string -// by replacing series with range. -// Eg. [ lii001, lii002, lii003, lii005 ] --> [ lii001..lii003, lii005 ] -// -// ----------------------- ATTENTION !!!---------------------------------- -// This routine has been copied to the Navigator software -// (MAC/Navigator/scripts/libs/nav_usr/CS1/CS1_Common.ctl) -// if you change anything struktural change the Navigator part also please -// ----------------------------------------------------------------------- - -string APLUtilities::compactedArrayString(const string& orgStr) -{ - string baseString(orgStr); // destroyable copy - ltrim(baseString, " ["); // strip of brackets - rtrim(baseString, " ]"); - - // and split into a vector - vector<string> strVector = StringUtil::split(baseString, ','); - if (strVector.size() < 2) { - return (orgStr); - } - - // note: we assume that the format of each element is [xxxx]9999 - string::size_type firstDigit(strVector[0].find_first_of("0123456789")); - if (firstDigit == string::npos) { // no digits? then return org string - return (orgStr); - } - string elemName(strVector[0].substr(0,firstDigit)); - string scanMask(elemName+"%ld"); - string outMask (formatString("%s%%0%dld", elemName.c_str(), - strVector[0].length() - elemName.length())); - - string result("["); - long prevValue(-2); - bool firstElem(true); - bool endOfArray(false); - int elemsInRange(0); - int nrElems(strVector.size()); - for (int idx = 0; idx < nrElems; idx++) { - long value; - if (sscanf(strVector[idx].c_str(), scanMask.c_str(), &value) != 1) { - LOG_DEBUG_STR("Element " << strVector[idx] << " does not match mask " - << scanMask << ". Returning orignal string"); - return (orgStr); - } - - if (value == prevValue+1) { // contiquous numbering? - elemsInRange++; - prevValue = value; - if (idx < nrElems-1) { // when elements left - continue; - } - endOfArray = true; - } - - // broken range - if (firstElem) { - result += formatString(outMask.c_str(), value); - firstElem = false; - } - else { - if (elemsInRange == 1) { - result += "," + formatString(outMask.c_str(), value); - } - else { - if (elemsInRange == 2) { - result += "," + formatString(outMask.c_str(), prevValue); - } - else { - result += ".." + formatString(outMask.c_str(), prevValue); - } - if (!endOfArray) { - result += "," + formatString(outMask.c_str(), value); - } - } - } - elemsInRange = 1; - prevValue = value; - } - - return (result+"]"); -} - -// -// expandedArrayString(string) -// -// Given een array string ( '[ xx..xx, xx ]' ) this utility expands the string -// by replacing ranges with the fill series. -// Eg. [ lii001..lii003, lii005 ] --> [ lii001, lii002, lii003, lii005 ] -// -// ----------------------- ATTENTION !!!---------------------------------- -// This routine has been copied to the Navigator software -// (MAC/Navigator/scripts/libs/nav_usr/CS1/CS1_Common.ctl) -// if you change anything struktural change the Navigator part also please -// ----------------------------------------------------------------------- - -string APLUtilities::expandedArrayString(const string& orgStr) -{ - // any ranges in the string? - if (orgStr.find("..",0) == string::npos) { - return (orgStr); // no, just return original - } - - string baseString(orgStr); // destroyable copy - ltrim(baseString, " ["); // strip of brackets - rtrim(baseString, " ]"); - - // and split into a vector - vector<string> strVector = StringUtil::split(baseString, ','); - - // note: we assume that the format of each element is [xxxx]9999 - string::size_type firstDigit(strVector[0].find_first_of("0123456789")); - if (firstDigit == string::npos) { // no digits? then return org string - return (orgStr); - } - - // construct scanmask and outputmask. - string elemName(strVector[0].substr(0,firstDigit)); - string scanMask(elemName+"%ld"); - int nrDigits; - if (strVector[0].find("..",0) != string::npos) { // range element? - nrDigits = ((strVector[0].length() - 2)/2) - elemName.length(); - } - else { - nrDigits = strVector[0].length() - elemName.length(); - } - string outMask (formatString("%s%%0%dld", elemName.c_str(), nrDigits)); - - // handle all elements - string result("["); - bool firstElem(true); - int nrElems(strVector.size()); - for (int idx = 0; idx < nrElems; idx++) { - long firstVal; - long lastVal; - // should match scanmask. - if (sscanf(strVector[idx].c_str(), scanMask.c_str(), &firstVal) != 1) { - LOG_DEBUG_STR("Element " << strVector[idx] << " does not match mask " - << scanMask << ". Returning orignal string"); - return (orgStr); - } - - // range element? - string::size_type rangePos(strVector[idx].find("..",0)); - if (rangePos == string::npos) { - lastVal = firstVal; - } - else { // yes, try to get second element. - if (sscanf(strVector[idx].data()+rangePos+2, scanMask.c_str(), &lastVal) != 1) { - LOG_DEBUG_STR("Second part of element " << strVector[idx] - << " does not match mask " << scanMask - << ". Returning orignal string"); - return (orgStr); - } - // check range - if (lastVal < firstVal) { - LOG_DEBUG_STR("Illegal range specified in " << strVector[idx] << - ". Returning orignal string"); - return (orgStr); - } - } - - // finally construct one or more elements - for (long val = firstVal ; val <= lastVal; val++) { - if (firstElem) { - result += formatString(outMask.c_str(), val); - firstElem = false; - } - else { - result += "," + formatString(outMask.c_str(), val); - } - } - } - - return (result+"]"); -} - // // byteSize // diff --git a/MAC/APL/APLCommon/src/ChildControl.cc b/MAC/APL/APLCommon/src/ChildControl.cc index c7b606e24f1..ad62b767675 100644 --- a/MAC/APL/APLCommon/src/ChildControl.cc +++ b/MAC/APL/APLCommon/src/ChildControl.cc @@ -26,10 +26,10 @@ //# Includes #include <sys/stat.h> #include <Common/LofarLogger.h> +#include <Common/SystemUtil.h> #include <APS/ParameterSet.h> #include <GCF/TM/GCF_Protocols.h> -#include <GCF/GCF_ServiceInfo.h> -#include <GCF/Utils.h> +#include <MACIO/MACServiceInfo.h> #include <APL/APLCommon/APLUtilities.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> @@ -42,7 +42,6 @@ using namespace boost; namespace LOFAR { using namespace Deployment; using namespace GCF::TM; - using namespace GCF::Common; using namespace ACC::APS; namespace APLCommon { @@ -77,8 +76,8 @@ ChildControl::ChildControl() : itsCompletionPort (0) { // Log the protocols I use. - GCF::TM::registerProtocol(CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol(STARTDAEMON_PROTOCOL,STARTDAEMON_PROTOCOL_STRINGS); + registerProtocol(CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); + registerProtocol(STARTDAEMON_PROTOCOL,STARTDAEMON_PROTOCOL_STRINGS); // adopt optional redefinition of startup-retry settings if (globalParameterSet()->isDefined("ChildControl.StartupRetryInterval")) { @@ -219,8 +218,8 @@ bool ChildControl::startChild (uint16 aCntlrType, cntlrSet.writeFile (cntlrSetName); // When program must run on another system scp file to that system - if (hostname != GCF::Common::myHostname(false) && - hostname != GCF::Common::myHostname(true)) { + if (hostname != myHostname(false) && + hostname != myHostname(true)) { APLUtilities::remoteCopy(cntlrSetName, hostname, cntlrSetName); APLUtilities::remoteCopy(baseSetName, hostname, baseSetName); } @@ -661,7 +660,7 @@ void ChildControl::_processActionList() STARTDAEMONCreateEvent startRequest; startRequest.cntlrType = action->cntlrType; startRequest.cntlrName = action->cntlrName; - startRequest.parentHost = GCF::Common::myHostname(true); + startRequest.parentHost = myHostname(true); startRequest.parentService = itsListener->makeServiceName(); startDaemon->second->send(startRequest); diff --git a/MAC/APL/APLCommon/src/ControllerDefines.cc b/MAC/APL/APLCommon/src/ControllerDefines.cc index 31684c43d17..73bd9752799 100644 --- a/MAC/APL/APLCommon/src/ControllerDefines.cc +++ b/MAC/APL/APLCommon/src/ControllerDefines.cc @@ -26,7 +26,7 @@ //# Includes #include <Common/LofarLogger.h> #include <Common/StringUtil.h> // rtrim -#include <GCF/Utils.h> // myHostname +#include <Common/SystemUtil.h> #include <APS/ParameterSet.h> // indexValue #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> @@ -38,7 +38,6 @@ using namespace boost; namespace LOFAR { using namespace Deployment; - using namespace GCF::Common; namespace APLCommon { typedef struct cntlrDefinition { diff --git a/MAC/APL/APLCommon/src/Controller_Protocol.prot b/MAC/APL/APLCommon/src/Controller_Protocol.prot index 3220f18cce1..fa9cd18515f 100644 --- a/MAC/APL/APLCommon/src/Controller_Protocol.prot +++ b/MAC/APL/APLCommon/src/Controller_Protocol.prot @@ -25,7 +25,7 @@ autogen definitions protocol; description = "Protocol for LogicalDevice servers"; prefix = "CONTROL"; // for the signal names -id = "(LOFAR::GCF::TM::F_APL_PROTOCOL+3)"; +id = "(LOFAR::MACIO::F_APL_PROTOCOL+3)"; // specify extra include files // e.g. diff --git a/MAC/APL/APLCommon/src/Makefile.am b/MAC/APL/APLCommon/src/Makefile.am index 75980bf89f5..2008d757180 100644 --- a/MAC/APL/APLCommon/src/Makefile.am +++ b/MAC/APL/APLCommon/src/Makefile.am @@ -1,7 +1,7 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) --writable -L $(datadir)/GCF/TM $< + $(AUTOGEN) --writable -L $(datadir)/MACIO $< %.conf: %.conf.in cp $< $@ @@ -25,8 +25,7 @@ libaplcommon_la_SOURCES = $(DOCHDRS) \ CTState.cc \ ControllerAdmin.cc \ ChildControl.cc \ - ParentControl.cc \ - Observation.cc + ParentControl.cc BUILT_SOURCES = $(ph_HEADERS) swlevel swlevel.conf diff --git a/MAC/APL/APLCommon/src/Observation.cc b/MAC/APL/APLCommon/src/Observation.cc deleted file mode 100644 index 07068d3bfeb..00000000000 --- a/MAC/APL/APLCommon/src/Observation.cc +++ /dev/null @@ -1,210 +0,0 @@ -//# Observation.cc: one line description -//# -//# Copyright (C) 2006 -//# 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 <Common/LofarLogger.h> -#include <Common/lofar_datetime.h> -#include <Common/StreamUtil.h> -#include <APL/APLCommon/APLUtilities.h> -#include <APL/APLCommon/Observation.h> - -namespace LOFAR { - using namespace ACC::APS; - namespace APLCommon { - -Observation::Observation() : - name(), - obsID(0), - startTime(0), - stopTime(0), - nyquistZone(0), - sampleClock(0) -{ -} - -Observation::Observation(ParameterSet* aParSet) : - name(), - obsID(0), - startTime(0), - stopTime(0), - nyquistZone(0), - sampleClock(0) -{ - // analyse ParameterSet. - string prefix = aParSet->locateModule("Observation") + "Observation."; - LOG_TRACE_VAR_STR("'Observation' located at: " << prefix); - - name = aParSet->getString(prefix+"name", ""); - obsID = aParSet->getInt32("_treeID", 0); - - if (aParSet->isDefined(prefix+"startTime")) { - startTime = to_time_t(time_from_string(aParSet->getString(prefix+"startTime"))); - } - if (aParSet->isDefined(prefix+"stopTime")) { - stopTime = to_time_t(time_from_string(aParSet->getString(prefix+"stopTime"))); - } - - if (aParSet->isDefined(prefix+"VirtualInstrument.stationList")) { - string stString("x=" + APLUtilities::expandedArrayString( - aParSet->getString(prefix+"VirtualInstrument.stationList"))); - ParameterSet stParset; - stParset.adoptBuffer(stString); - stations = stParset.getStringVector("x"); - } - - sampleClock = aParSet->getUint32(prefix+"sampleClock", 0); - filter = aParSet->getString(prefix+"bandFilter", ""); - antennaArray= aParSet->getString(prefix+"antennaArray", ""); - nyquistZone = nyquistzoneFromFilter(filter); - - RCUset.reset(); // clear RCUset by default. - if (aParSet->isDefined(prefix+"receiverList")) { - string rcuString("x=" + APLUtilities::expandedArrayString( - aParSet->getString(prefix+"receiverList"))); - ParameterSet rcuParset; - rcuParset.adoptBuffer(rcuString); - vector<uint16> RCUnumbers(rcuParset.getUint16Vector("x")); - if (RCUnumbers.empty()) { // No receivers in the list? - RCUset.set(); // assume all receivers. - } - else { - for (uint i = 0; i < RCUnumbers.size();i++) { - RCUset.set(RCUnumbers[i]); // set mentioned receivers - } - } - } - - // get the beams info - int32 nrBeams; - if (aParSet->isDefined(prefix+"nrBeams")) { - nrBeams = aParSet->getUint32(prefix+"nrBeams"); - } - - // allocate beamlet 2 beam mapping and reset to 0 - beamlet2beams.resize(4*54, 0); - beamlet2subbands.resize(4*54, 0); - - // loop over al beams - for (int32 beam(1) ; beam <= nrBeams; beam++) { - Beam newBeam; - string beamPrefix(prefix+formatString("Beam[%d].", beam)); - // get all fields - newBeam.angle1 = aParSet->getDouble(beamPrefix+"angle1", 0.0); - newBeam.angle2 = aParSet->getDouble(beamPrefix+"angle2", 0.0); - newBeam.directionType = aParSet->getString(beamPrefix+"directionType", ""); -// newBeam.angleTimes = aParSet->get(beamPrefix+"angleTimes", "[]"); - // subbandList - string sbString("x=" + APLUtilities::expandedArrayString(aParSet->getString(beamPrefix+"subbandList","[]"))); - ParameterSet sbParset; - sbParset.adoptBuffer(sbString); - newBeam.subbands = sbParset.getInt16Vector("x"); - // beamletList - string blString("x=" + APLUtilities::expandedArrayString(aParSet->getString(beamPrefix+"beamletList", "[]"))); - ParameterSet blParset; - blParset.adoptBuffer(blString); - newBeam.beamlets = blParset.getInt16Vector("x"); - - // add beam to vector - beams.push_back(newBeam); - - // finally update beamlet 2 beam mapping. - for (int i = newBeam.beamlets.size()-1 ; i >= 0; i--) { - ASSERTSTR (beamlet2beams[newBeam.beamlets[i]] == 0, - "beamlet " << i << " of beam " << beam << " clashes with beamlet of other beam"); - beamlet2beams [newBeam.beamlets[i]] = beam; - beamlet2subbands[newBeam.beamlets[i]] = newBeam.subbands[i]; - } - } -} - - -// -// ~Observation() -// -Observation::~Observation() -{ -} - -// -// getBeamName(beamidx): string -// -string Observation::getBeamName(uint32 beamIdx) const -{ - return (formatString("observation[%d]beam[%d]", obsID, beamIdx+1)); -} - -// -// nyquistzoneFromFilter(filtername) -// -uint32 Observation::nyquistzoneFromFilter(const string& filterName) -{ - if (filterName == "LBL_10_80") { return(1); } - if (filterName == "LBL_30_80") { return(1); } - if (filterName == "LBH_10_80") { return(1); } - if (filterName == "LBH_30_80") { return(1); } - if (filterName == "HB_100_190") { return(2); } - if (filterName == "HB_170_230") { return(3); } - if (filterName == "HB_210_240") { return(3); } - - LOG_ERROR_STR ("filterselection value '" << filterName << - "' not recognized, using LBL_10_80"); - return (1); -} - -// -// print (os) -// -ostream& Observation::print (ostream& os) const -{ - os << endl; - os << "Observation : " << name << endl; - os << "ObsID : " << obsID << endl; - os << "starttime : " << to_simple_string(from_time_t(startTime)) << endl; - os << "stoptime : " << to_simple_string(from_time_t(stopTime)) << endl; -// os << "stations : " << stations << endl; - os << "stations : "; writeVector(os, stations, ",", "[", "]"); os << endl; - os << "antennaArray : " << antennaArray << endl; - os << "receiverList : " << RCUset << endl; - os << "sampleClock : " << sampleClock << endl; - os << "filter : " << filter << endl; - os << "nyquistZone : " << nyquistZone << endl; - os << "nrBeams : " << beams.size() << endl; - for (size_t i(0) ; i < beams.size(); i++) { - os << formatString("Beam[%d].pointing : %f, %f, %s\n", i, beams[i].angle1, beams[i].angle2, beams[i].directionType.c_str()); -// os << "Beam[" << i << "].subbandList: " << beams[i].subbands; -// os << "Beam[" << i << "].beamletList: " << beams[i].beamlets; - os << "Beam[" << i << "].subbandList: "; writeVector(os, beams[i].subbands, ",", "[", "]"); os << endl; - os << "Beam[" << i << "].beamletList: "; writeVector(os, beams[i].beamlets, ",", "[", "]"); os << endl; - } -// os << "beamlet2beams: " << beamlet2beams; - os << "beamlet2beams : "; writeVector(os, beamlet2beams, ",", "[", "]"); os << endl; - os << "beamlet2subbands: "; writeVector(os, beamlet2subbands, ",", "[", "]"); os << endl; - - return (os); -} - - - } // namespace APLCommon -} // namespace LOFAR diff --git a/MAC/APL/APLCommon/src/ParentControl.cc b/MAC/APL/APLCommon/src/ParentControl.cc index e4907cbd415..517ca346815 100644 --- a/MAC/APL/APLCommon/src/ParentControl.cc +++ b/MAC/APL/APLCommon/src/ParentControl.cc @@ -25,10 +25,10 @@ //# Includes #include <Common/LofarLogger.h> +#include <Common/SystemUtil.h> #include <APS/ParameterSet.h> #include <GCF/TM/GCF_Protocols.h> -#include <GCF/GCF_ServiceInfo.h> -#include <GCF/Utils.h> +#include <MACIO/MACServiceInfo.h> #include <APL/APLCommon/APLUtilities.h> #include <APL/APLCommon/ParentControl.h> #include <APL/APLCommon/StationInfo.h> @@ -38,7 +38,6 @@ namespace LOFAR { using namespace Deployment; using namespace GCF::TM; - using namespace GCF::Common; using namespace ACC::APS; namespace APLCommon { @@ -101,8 +100,8 @@ ParentControl::ParentControl() : itsControllerName() { // Log the protocols I use. - GCF::TM::registerProtocol(CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol(STARTDAEMON_PROTOCOL, STARTDAEMON_PROTOCOL_STRINGS); + registerProtocol(CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); + registerProtocol(STARTDAEMON_PROTOCOL, STARTDAEMON_PROTOCOL_STRINGS); } diff --git a/MAC/APL/APLCommon/src/StartDaemon_Protocol.prot b/MAC/APL/APLCommon/src/StartDaemon_Protocol.prot index 3bcefb17972..18da4c7d80f 100644 --- a/MAC/APL/APLCommon/src/StartDaemon_Protocol.prot +++ b/MAC/APL/APLCommon/src/StartDaemon_Protocol.prot @@ -23,7 +23,7 @@ autogen definitions protocol; description = "Protocol for StartDaemons"; prefix = "STARTDAEMON"; // for the signal names -id = "(LOFAR::GCF::TM::F_APL_PROTOCOL+2)"; +id = "(LOFAR::MACIO::F_APL_PROTOCOL+2)"; // specify extra include files // e.g. diff --git a/MAC/APL/APLCommon/src/StationInfo.cc b/MAC/APL/APLCommon/src/StationInfo.cc index a1213d8ed4f..eb69ae35ffd 100644 --- a/MAC/APL/APLCommon/src/StationInfo.cc +++ b/MAC/APL/APLCommon/src/StationInfo.cc @@ -25,7 +25,7 @@ #include <Common/lofar_string.h> #include <Common/LofarTypes.h> #include <Common/StringUtil.h> -#include <GCF/Utils.h> +#include <Common/SystemUtil.h> #include <APL/APLCommon/StationInfo.h> #include <boost/config.hpp> @@ -33,7 +33,6 @@ using namespace boost; namespace LOFAR { - using namespace GCF::Common; namespace Deployment { static char* stationTypeTable[] = { "CS", "RS", "ES" }; diff --git a/MAC/APL/APLCommon/test/Makefile.am b/MAC/APL/APLCommon/test/Makefile.am index 0bf356ab757..a79c1437bfd 100755 --- a/MAC/APL/APLCommon/test/Makefile.am +++ b/MAC/APL/APLCommon/test/Makefile.am @@ -1,4 +1,4 @@ -check_PROGRAMS = tControllerDefines tAPLUtilities tOutOfBand tObservation +check_PROGRAMS = tControllerDefines tAPLUtilities tOutOfBand tControllerDefines_SOURCES = tControllerDefines.cc tControllerDefines_LDADD = ../src/libaplcommon.la @@ -12,10 +12,6 @@ tOutOfBand_SOURCES = tOutOfBand.cc tOutOfBand_LDADD = ../src/libaplcommon.la tOutOfBand_DEPENCIES = ../src/libaplcommon.la $(LOFAR_DEPEND) -tObservation_SOURCES = tObservation.cc -tObservation_LDADD = ../src/libaplcommon.la -tObservation_DEPENCIES = ../src/libaplcommon.la $(LOFAR_DEPEND) - TESTSCRIPTS = tControllerDefines_test.sh @@ -23,7 +19,6 @@ TESTS = $(TESTSCRIPTS) EXTRA_DIST = tControllerDefines.log_prop \ tAPLUtilities.log_prop \ - tObservation.log_prop \ tOutOfBand.log_prop \ ResourceAllocatorTest.log_prop \ $(TESTSCRIPTS) diff --git a/MAC/APL/APLCommon/test/tAPLUtilities.cc b/MAC/APL/APLCommon/test/tAPLUtilities.cc index 7e133c67e12..e7b4a5696b2 100644 --- a/MAC/APL/APLCommon/test/tAPLUtilities.cc +++ b/MAC/APL/APLCommon/test/tAPLUtilities.cc @@ -30,60 +30,10 @@ using namespace LOFAR; using namespace LOFAR::APLCommon; -#define DO_COMPACT_TEST(x) \ - cout << (x) << " ==> " << APLUtilities::compactedArrayString(x) << endl; - -#define DO_EXPAND_TEST(x) \ - cout << (x) << " ==> " << APLUtilities::expandedArrayString(x) << endl; - int main (int argc, char* argv[]) { INIT_LOGGER(argv[0]); - DO_COMPACT_TEST("[ a,b,c ]"); - DO_COMPACT_TEST("[ aa01,aa06 ]"); - DO_COMPACT_TEST("[ aa01,aa02 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03,aa04 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03,aa05 ]"); - DO_COMPACT_TEST("[ aa01, aa02 ,aa03,aa05,aa06 ]"); - DO_COMPACT_TEST("[ aa01, bb02 ,aa03,aa05,aa06 ]"); - DO_COMPACT_TEST("[ aa01, aa02 ,aa0003,aa05,aa06 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03,aa05,aa06,aa7 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03,aa05,a06,aa7 ]"); - DO_COMPACT_TEST("[ aa01,aa02,aa03,aa05,aaa06,aa7 ]"); - - DO_COMPACT_TEST("[22,23,24,25,30,31,33,35]"); - DO_COMPACT_TEST("[22,23,24,25,30,31,33,35,36]"); - DO_COMPACT_TEST("[22,23,24,25,30,31,33,35,36,37]"); - DO_COMPACT_TEST("[22,23,24,25,30,31,33,35,36,37,37]"); - DO_COMPACT_TEST("[22,23,24,25,30,31,33,35,36,37,40]"); - DO_COMPACT_TEST("[22,23,23,25,30,31,30]"); - DO_COMPACT_TEST("[22,23,23,25,30,31,30,31]"); - DO_COMPACT_TEST("[22,23,23,25,30,31,30,31,31]"); - DO_COMPACT_TEST("[22,23,23,23,23,23,25,30,31,30,31,31]"); - - DO_EXPAND_TEST("[ a,b,c ]"); - DO_EXPAND_TEST("[ aa01,aa06 ]"); - DO_EXPAND_TEST("[ aa01,aa02 ]"); - DO_EXPAND_TEST("[ aa01..aa02 ]"); - DO_EXPAND_TEST("[ aa01..aa03 ]"); - DO_EXPAND_TEST("[ aa01..aa03,aa04 ]"); - DO_EXPAND_TEST("[ aa01..aa03,aa05 ]"); - DO_EXPAND_TEST("[ aa02,aa05..aa07]"); - DO_EXPAND_TEST("[ aa02,aa05..aa04]"); - DO_EXPAND_TEST("[ aa02,aa05..aa05]"); - - DO_EXPAND_TEST("[ aa01..ba03,aa05 ]"); - DO_EXPAND_TEST("[ aa01..aa03,ba05 ]"); - DO_EXPAND_TEST("[ aa01,ab03,aa05 ]"); - DO_EXPAND_TEST("[ aa01,ab03..aa05 ]"); - DO_EXPAND_TEST("[ aa01,aa03..ab05 ]"); - DO_EXPAND_TEST("[ aa01,bb03..bb05 ]"); - - DO_EXPAND_TEST("[0..191]"); - DO_EXPAND_TEST("[0,1,2,6,3,4,10..19,16]"); - cout << "16.0GB : " << byteSize(16.0*1024*1024*1024) << endl; cout << " 8.0GB : " << byteSize(8.0*1024*1024*1024) << endl; cout << " 4.0GB : " << byteSize(4.0*1024*1024*1024) << endl; diff --git a/MAC/APL/APLCommon/test/tControllerDefines.cc b/MAC/APL/APLCommon/test/tControllerDefines.cc index 7aa1a42e1f7..73456b9b1de 100644 --- a/MAC/APL/APLCommon/test/tControllerDefines.cc +++ b/MAC/APL/APLCommon/test/tControllerDefines.cc @@ -25,14 +25,13 @@ //# Includes #include <Common/LofarLogger.h> -#include <GCF/Utils.h> // myHostname +#include <Common/SystemUtil.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> using namespace LOFAR; using namespace LOFAR::APLCommon; using namespace LOFAR::Deployment; -using namespace LOFAR::GCF::Common; int main (int argc, char* argv[]) { @@ -87,8 +86,8 @@ int main (int argc, char* argv[]) LOG_INFO_STR("Sharedname of shared name = " << sharedControllerName(sharedName)); - LOG_INFO_STR("myHostname(short) = " << GCF::Common::myHostname(false)); - LOG_INFO_STR("myHostname(long) = " << GCF::Common::myHostname(true)); + LOG_INFO_STR("myHostname(short) = " << myHostname(false)); + LOG_INFO_STR("myHostname(long) = " << myHostname(true)); LOG_INFO_STR("ringNumber = " << stationRingNr()); LOG_INFO_STR("armNumber = " << stationArmNr()); LOG_INFO_STR("PVSSDBname = " << PVSSDatabaseName()); diff --git a/MAC/APL/APLCommon/test/tObservation.cc b/MAC/APL/APLCommon/test/tObservation.cc deleted file mode 100644 index 65fc18c568c..00000000000 --- a/MAC/APL/APLCommon/test/tObservation.cc +++ /dev/null @@ -1,80 +0,0 @@ -//# tObservation.cc -//# -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include <APL/APLCommon/Observation.h> -#include <APS/ParameterSet.h> - -using namespace LOFAR; -using namespace LOFAR::APLCommon; -using namespace LOFAR::ACC::APS; - -int main (int argc, char* argv[]) -{ - INIT_LOGGER(argv[0]); - - string ps1; - ps1 += "_treeID = 25\n"; - ps1 += "Observation.name = observation1\n"; - ps1 += "Observation.startTime = 2007-01-15 12:20:00\n"; - ps1 += "Observation.stopTime = 2007-01-15 13:45:59\n"; - ps1 += "Observation.bandFilter = LBL_10_90\n"; - ps1 += "Observation.antennaArray = CS1_LBA\n"; - ps1 += "Observation.receiverList = [0..21,24,26]\n"; - ps1 += "Observation.sampleClock = 160\n"; - ps1 += "Observation.nrBeams = 1\n"; - ps1 += "Observation.Beam[1].angle1 = 1.57079632679\n"; - // do not specify angle2! - ps1 += "Observation.Beam[1].directionType= J2000\n"; - ps1 += "Observation.Beam[1].subbandList = [5,6,100..103]\n"; - ps1 += "Observation.Beam[1].beamletList = [0..2,20,21,215]\n"; - - ParameterSet parSet1; - parSet1.adoptBuffer(ps1); - - cout << "ParameterSet 1:" << endl; - cout << parSet1; - - Observation obs1(&parSet1); - cout << obs1 << endl; - - // add an extra beam - ps1 += "Observation.nrBeams = 2\n"; - ps1 += "Observation.Beam[2].angle1 = 0.23456789\n"; - ps1 += "Observation.Beam[2].angle2 = 0.123456789\n"; - ps1 += "Observation.Beam[2].directionType= AZEL\n"; - ps1 += "Observation.Beam[2].subbandList = [4,3,102]\n"; - ps1 += "Observation.Beam[2].beamletList = [15,16,18]\n"; - - ParameterSet parSet2; - parSet2.adoptBuffer(ps1); - - Observation obs2(&parSet2); - cout << obs2 << endl; - - return (0); -} - diff --git a/MAC/APL/APLCommon/test/tObservation.log_prop b/MAC/APL/APLCommon/test/tObservation.log_prop deleted file mode 100644 index 668dcbd4406..00000000000 --- a/MAC/APL/APLCommon/test/tObservation.log_prop +++ /dev/null @@ -1,9 +0,0 @@ -# Configure the rootLogger -log4cplus.rootLogger=INFO, STDOUT - -# Define the STDOUT appender -log4cplus.appender.STDOUT=log4cplus::ConsoleAppender -log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout -log4cplus.appender.STDOUT.layout.ConversionPattern=%-5p [%x]%c{3} - %m%n -log4cplus.appender.STDOUT.ImmediateFlush=true - -- GitLab