diff --git a/MAC/APL/APLCommon/CMakeLists.txt b/MAC/APL/APLCommon/CMakeLists.txt index 1a0ad98001ab418eec0e02a79efaea51add18c72..9dbf80c0a74509bd14c24794984d3886fe33922a 100644 --- a/MAC/APL/APLCommon/CMakeLists.txt +++ b/MAC/APL/APLCommon/CMakeLists.txt @@ -4,6 +4,7 @@ lofar_package(APLCommon 3.1 DEPENDS Common ApplCommon GCFTM MACIO) include(LofarFindPackage) lofar_find_package(Boost REQUIRED COMPONENTS regex) +lofar_find_package(Blitz REQUIRED) add_definitions(-DBOOST_DISABLE_THREADS) diff --git a/MAC/APL/APLCommon/configure.in b/MAC/APL/APLCommon/configure.in index a96d89b014ef793271f71ca46d80075ca1c8bfa2..49800cfa5d9dc03a82d71e4dce09b7b729a5e82d 100644 --- a/MAC/APL/APLCommon/configure.in +++ b/MAC/APL/APLCommon/configure.in @@ -58,7 +58,7 @@ lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,) lofar_INTERNAL(LCS/ApplCommon, ApplCommon, , 1, ApplCommon/StationInfo.h,,) lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Control.h,,) lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,"",) -dnl lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) +lofar_EXTERNAL(BLITZ, 1, blitz/blitz.h,,,,'gnu3:-Wno-unused gnu3:-ftemplate-depth-30',, -lm) lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, "boost_date_time boost_regex") dnl diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/AntennaPos.h b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaPos.h new file mode 100644 index 0000000000000000000000000000000000000000..fb109e6cefcd1a133d6da0302d7e44b08b0e6566 --- /dev/null +++ b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaPos.h @@ -0,0 +1,100 @@ +//# AntennaPos.h: Class to manage the antenna subsets. +//# +//# 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$ + +#ifndef LOFAR_APLCOMMON_ANTENNAPOS_H +#define LOFAR_APLCOMMON_ANTENNAPOS_H + +// \file AntennaPos.h +// Class to manage the antenna subsets. + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! +//# Includes +#include <blitz/array.h> + +// Avoid 'using namespace' in headerfiles + +namespace LOFAR { + namespace APLCommon { + +// \addtogroup package +// @{ + +//# --- Forward Declarations --- +//# classes mentioned as parameter or returntype without virtual functions. + + +// This class represents an antenna array. The LOFAR remote station will initially +// have two anntena arrays. One for the low-band antennas, and one for the high-band +// antennas. Alternative configurations of the antennas are described in AntennaSets. +class AntennaPos +{ +public: + explicit AntennaPos (const string& filename); + virtual ~AntennaPos(); + + // all about the bits + // [antNr, pol, xyz] + const blitz::Array<double, 3>& LBAAntPos() const { return itsLBAAntPos; } + const blitz::Array<double, 3>& HBAAntPos() const { return itsHBAAntPos; } + + // [rcu, xyz] + const blitz::Array<double, 2>& LBARCUPos() const { return itsLBARCUPos; } + const blitz::Array<double, 2>& HBARCUPos() const { return itsHBARCUPos; } + + // [xyz] + const blitz::Array<double, 1>& LBACentre() const { return itsLBACentre; } + const blitz::Array<double, 1>& HBACentre() const { return itsHBACentre; } + + // [rcu, xyz] + const blitz::Array<double, 1>& LBARCULengths() const { return itsLBARCULengths; } + const blitz::Array<double, 1>& HBARCULengths() const { return itsHBARCULengths; } + + int nrLBAs() const { return itsLBAAntPos.extent(blitz::firstDim); } + int nrHBAs() const { return itsHBAAntPos.extent(blitz::firstDim); } + +private: + // Copying is not allowed + AntennaPos(); + AntennaPos(const AntennaPos& that); + AntennaPos& operator=(const AntennaPos& that); + + //# --- Datamembers --- + blitz::Array<double,1> itsLBACentre; // [ (x,y,z) ] + blitz::Array<double,1> itsHBACentre; // [ (x,y,z) ] + + blitz::Array<double,2> itsLBARCUPos; // [ rcuNr, (x,y,z) ] + blitz::Array<double,2> itsHBARCUPos; // [ rcuNr, (x,y,z) ] + + blitz::Array<double,3> itsLBAAntPos; // [ antNr, pol, (x,y,z) ] + blitz::Array<double,3> itsHBAAntPos; // [ antNr, pol, (x,y,z) ] + + // during calculations we often need the length of the vectors. + blitz::Array<double,1> itsLBARCULengths; // [ len ] + blitz::Array<double,1> itsHBARCULengths; // [ len ] +}; + + +// @} + } // namespace APLCommon +} // namespace LOFAR + +#endif diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/AntennaSets.h b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaSets.h new file mode 100644 index 0000000000000000000000000000000000000000..3f99a6ba59e9247a52ec9ed23c93f5103990b211 --- /dev/null +++ b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaSets.h @@ -0,0 +1,122 @@ +//# AntennaSets.h: Class to manage the antenna subsets. +//# +//# 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$ + +#ifndef LOFAR_APLCOMMON_ANTENNASET_H +#define LOFAR_APLCOMMON_ANTENNASET_H + +// \file AntennaSets.h +// Class to manage the antenna subsets. + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! +//# Includes +#include <Common/LofarConstants.h> +#include <Common/lofar_bitset.h> +#include <Common/lofar_map.h> +#include <ApplCommon/StationInfo.h> + +// Avoid 'using namespace' in headerfiles + +namespace LOFAR { + namespace APLCommon { + +// \addtogroup package +// @{ + +//# --- Forward Declarations --- +//# classes mentioned as parameter or returntype without virtual functions. + + +// class_description +// ... +class AntennaSets +{ +public: + explicit AntennaSets (const string& filename); + virtual ~AntennaSets(); + + // all about the bits + string RCUinputs (const string& setName, uint stnType = stationTypeValue()) const; + bitset<MAX_RCUS> LBAallocation(const string& setName, uint stnType = stationTypeValue()) const; + bitset<MAX_RCUS> HBAallocation(const string& setName, uint stnType = stationTypeValue()) const; + + // all about the names + bool isAntennaSet (const string& setName) const; + vector<string> antennaSetList() const; + + // type of antennas used in the set + bool usesLBAfield (const string& setName, uint stnType = stationTypeValue()) const; + + // ... example + ostream& print (ostream& os) const + { return (os); } + +private: + // Copying is not allowed + AntennaSets(); + AntennaSets(const AntennaSets& that); + AntennaSets& operator=(const AntennaSets& that); + + // internal datastructures + class singleSet { + public: + string RCUinputs; + bitset<MAX_RCUS> LBAallocation; + bitset<MAX_RCUS> HBAallocation; + + singleSet() { RCUinputs.resize(MAX_RCUS,'.'); } + }; + class setTriple { + public: + singleSet europe; + singleSet remote; + singleSet core; + }; + + // internal functions + bool _adoptSelector(const string& selector, singleSet& triple, uint rcuCount); + + //# --- Datamembers --- + // name of the file that contains the antennaSets. + string itsAntennaSetFile; + + typedef map<string, setTriple>::const_iterator AntSetIter; + + map<string, setTriple> itsDefinitions; +}; + +//# --- Inline functions --- + +// ... example +//# +//# operator<< +//# +inline ostream& operator<< (ostream& os, const AntennaSets& anSet) +{ + return (anSet.print(os)); +} + + +// @} + } // namespace APLCommon +} // namespace LOFAR + +#endif diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/CMakeLists.txt b/MAC/APL/APLCommon/include/APL/APLCommon/CMakeLists.txt index 44e035d62f55f2f812cfc4816f058e033162a087..089642e31cbc0b8805988fe1db84fe613d693bbe 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/CMakeLists.txt +++ b/MAC/APL/APLCommon/include/APL/APLCommon/CMakeLists.txt @@ -3,6 +3,8 @@ # List of header files that will be installed. set(inst_HEADERS AntennaMapper.h + AntennaPos.h + AntennaSets.h APLCommonExceptions.h APL_Defines.h APLUtilities.h diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am b/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am index 553db0832b85fccb0d06059a54d743e4385bac40..61d4cb55a2e37693b2156c703715717d744b0095 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am +++ b/MAC/APL/APLCommon/include/APL/APLCommon/Makefile.am @@ -1,6 +1,8 @@ pkgincludedir = $(includedir)/APL/APLCommon pkginclude_HEADERS = Package__Version.h \ AntennaMapper.h \ + AntennaPos.h \ + AntennaSets.h \ APLCommonExceptions.h \ APL_Defines.h \ APLUtilities.h \ diff --git a/MAC/APL/APLCommon/src/AntennaPos.cc b/MAC/APL/APLCommon/src/AntennaPos.cc new file mode 100644 index 0000000000000000000000000000000000000000..06155f50d1d346d66bb9493bcea5a8470554ab0c --- /dev/null +++ b/MAC/APL/APLCommon/src/AntennaPos.cc @@ -0,0 +1,152 @@ +//# AntennaPos.cc: one_line_description +//# +//# 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$ + +//# Always #include <lofar_config.h> first! +#include <lofar_config.h> + +//# Includes +#include <Common/LofarLogger.h> +#include <Common/LofarLocators.h> +#include <Common/LofarConstants.h> +#include <Common/lofar_fstream.h> +#include <APL/APLCommon/AntennaPos.h> + +using namespace blitz; + +namespace LOFAR { + namespace APLCommon { + +const int IDX_CORE = 0; +const int IDX_REMOTE = 1; +const int IDX_EUROPE = 2; + +// +// AntennaPos(fileName) +// +// Name +// 3 [ x y z ] +// Nant x Npol x 3 [ ... ] +// +// The info is stored in itsxxxAntPos[ant,pol,xyz] and in itsxxxRCUPos[rcu,xyz] because +// some programs are antenna based while others are rcu based. +// +AntennaPos::AntennaPos(const string& filename) +{ + ConfigLocator cl; + string fullFilename(cl.locate(filename)); + ifstream inputStream; + inputStream.open(fullFilename.c_str()); + + ASSERTSTR(inputStream.good(), "File " << fullFilename << " cannot be opened succesfully."); + + string line; + string AntTypeName; + // read file and skip lines that start with '#' or are empty + while(getline(inputStream, line)) { + if (line.empty() || line[0] == '\0' || line[0] == ']') { + continue; + } + + // expect name + ASSERTSTR(line=="LBA" || line=="HBA" || line=="HBA0" || line=="HBA1", + "Only 'LBA','HBA','HBA0' and 'HBA1' allowed for antenna types (not '" << line << "')"); + AntTypeName = line; + + // expect centre position + blitz::Array<double,1> centrePos; + inputStream >> centrePos; + ASSERTSTR(centrePos.dimensions() == 1 && centrePos.extent(firstDim) == 3, + "Position of the centre should be a 1 dimensional array with 3 values ,not " << centrePos); + LOG_DEBUG_STR(AntTypeName << " centre is at " << centrePos); + + // ignore positions of the HBA subfields + if (line != "LBA" && line != "HBA") { + continue; + } + + // expect positions + blitz::Array<double,3> antennaPos; + inputStream >> antennaPos; + inputStream.ignore(80, '\n'); + ASSERTSTR(antennaPos.dimensions() == 3 && + antennaPos.extent(firstDim) <= MAX_ANTENNAS && + antennaPos.extent(secondDim) == N_POL && + antennaPos.extent(thirdDim) <= 3, + "Expected an array of size NrAntennas x nrPol x (x,y,z)"); + LOG_DEBUG_STR(AntTypeName << " dimensions = " << antennaPos.shape()); + + // copy the info to the right data members + if (AntTypeName == "LBA") { + itsLBACentre.resize(centrePos.shape()); + itsLBACentre = centrePos; + itsLBAAntPos.resize(antennaPos.shape()); + itsLBAAntPos = antennaPos; + // store info also in the rcu format + itsLBARCUPos.resize(itsLBAAntPos.extent(firstDim) * N_POL, itsLBAAntPos.extent(thirdDim)); + for (int antNr = 0; antNr < itsLBAAntPos.extent(firstDim); antNr++) { + for (int pol = 0; pol < N_POL; pol++) { + itsLBARCUPos(antNr*2+pol, Range::all()) = itsLBAAntPos(antNr, pol, Range::all()); + } + } + itsLBARCULengths.resize(itsLBARCUPos.extent(firstDim)); + itsLBARCULengths(Range::all()) = sqrt(itsLBARCUPos(Range::all(),0)*itsLBARCUPos(Range::all(),0) + + itsLBARCUPos(Range::all(),1)*itsLBARCUPos(Range::all(),1) + + itsLBARCUPos(Range::all(),2)*itsLBARCUPos(Range::all(),2)); + } + else { // handle the HBA positions + itsHBACentre.resize(centrePos.shape()); + itsHBACentre = centrePos; + itsHBAAntPos.resize(antennaPos.shape()); + itsHBAAntPos = antennaPos; + // store info also in the rcu format + itsHBARCUPos.resize(itsHBAAntPos.extent(firstDim) * N_POL, itsHBAAntPos.extent(thirdDim)); + for (int antNr = 0; antNr < itsHBAAntPos.extent(firstDim); antNr++) { + for (int pol = 0; pol < N_POL; pol++) { + itsHBARCUPos(antNr*2+pol, Range::all()) = itsHBAAntPos(antNr, pol, Range::all()); + } + } + itsHBARCULengths.resize(itsHBARCUPos.extent(firstDim)); + itsHBARCULengths(Range::all()) = sqrt(itsHBARCUPos(Range::all(),0)*itsHBARCUPos(Range::all(),0) + + itsHBARCUPos(Range::all(),1)*itsHBARCUPos(Range::all(),1) + + itsHBARCUPos(Range::all(),2)*itsHBARCUPos(Range::all(),2)); + } + } // while not EOF + + ASSERTSTR(itsLBAAntPos.extent(firstDim) != 0 && itsHBAAntPos.extent(firstDim) != 0, + "File should contain definitions for both LBA and HBA antennafields"); + + LOG_INFO_STR("Antenna positionfile " << fullFilename << " read in succesfully"); + + inputStream.close(); +} + +// +// ~AntennaPos() +// +AntennaPos::~AntennaPos() +{ +} + + + + } // namespace APLCommon +} // namespace LOFAR diff --git a/MAC/APL/APLCommon/src/AntennaSets.cc b/MAC/APL/APLCommon/src/AntennaSets.cc new file mode 100644 index 0000000000000000000000000000000000000000..930c02e15635b47945abc12b5f17dc05086f7b06 --- /dev/null +++ b/MAC/APL/APLCommon/src/AntennaSets.cc @@ -0,0 +1,276 @@ +//# AntennaSets.cc: one_line_description +//# +//# 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$ + +//# Always #include <lofar_config.h> first! +#include <lofar_config.h> + +//# Includes +#include <Common/LofarLogger.h> +#include <Common/LofarLocators.h> +#include <Common/lofar_fstream.h> +#include <APL/APLCommon/AntennaSets.h> + +namespace LOFAR { + namespace APLCommon { + +const int IDX_CORE = 0; +const int IDX_REMOTE = 1; +const int IDX_EUROPE = 2; + +// +// AntennaSets(fileName) +// +AntennaSets::AntennaSets(const string& filename) : + itsAntennaSetFile(filename) +{ + ConfigLocator cl; + itsAntennaSetFile = cl.locate(filename); + ifstream inputStream; + inputStream.open(itsAntennaSetFile.c_str()); + + ASSERTSTR(inputStream.good(), "File " << itsAntennaSetFile << " cannot be opened succesfully."); + + char line [2048]; + char setName [1024]; + char stnType [1024]; + char selector[1024]; + string curName; + int lineNr(0); + setTriple* newTriple(0); + bitset<3> stnTypeMask; + stnTypeMask.reset(); + // read file and skip lines that start with '#' or are empty + while(inputStream.getline(line, 2048)) { + lineNr++; + if (line[0] == '#' || line[0] == '\0') { + continue; + } + + ASSERTSTR (sscanf(line, "%s%s%s", setName, stnType, selector) == 3, + "Line " << lineNr << " (" << line << ") has the wrong format"); + + if (stnTypeMask.count() == 0) { + newTriple = new setTriple(); + curName = setName; + ASSERTSTR(newTriple, "Cannot get memory for storing the antennaSets"); + } + else { + ASSERTSTR(curName.compare(setName) == 0, + lineNr << ": Definition of antennaSet '" << curName << "' is not yet complete."); + } + + if ((!strcmp(stnType,"Europe") && stnTypeMask[IDX_EUROPE]) || + (!strcmp(stnType,"Remote") && stnTypeMask[IDX_REMOTE]) || + (!strcmp(stnType,"Core") && stnTypeMask[IDX_CORE])) { + ASSERTSTR(false, lineNr << ": StationType '" << stnType << "' already defined for antennaSet '" << setName << "'"); + } + + ASSERTSTR(!strcmp(stnType,"Europe") || !strcmp(stnType,"Remote") || !strcmp(stnType,"Core"), + lineNr << ": Unknown stationType '" << stnType << "'"); + + try { + if (!strcmp(stnType,"Europe") && _adoptSelector(selector, newTriple->europe, 192)) { + stnTypeMask.set(IDX_EUROPE); + } + if (!strcmp(stnType,"Remote") && _adoptSelector(selector, newTriple->remote, 96)) { + stnTypeMask.set(IDX_REMOTE); + } + if (!strcmp(stnType,"Core") && _adoptSelector(selector, newTriple->core, 96)) { + stnTypeMask.set(IDX_CORE); + } + } + catch (Exception& ex) { + ASSERTSTR(false, lineNr << ex.what()); + } + + if (stnTypeMask.count() == 3) { + LOG_DEBUG_STR("Storing definition for antennaSet '" << setName << "'"); + ASSERTSTR(itsDefinitions.find(setName) == itsDefinitions.end(), + lineNr << ": AntennaSet '" << setName << "' already defined"); + itsDefinitions[setName] = *newTriple; + delete newTriple; + newTriple = 0; + stnTypeMask.reset(); + } + } // while not EOF + + ASSERTSTR(itsDefinitions.size() != 0, "File '" << itsAntennaSetFile << "' does not contain antennaSet definitions"); + ASSERTSTR(stnTypeMask.count() == 0 || stnTypeMask.count() == 3, "Last definition '" << setName << "' is not complete."); + + LOG_INFO_STR("Found " << itsDefinitions.size() << " antennaSet definitions in " << itsAntennaSetFile); + +} + +// +// ~AntennaSets() +// +AntennaSets::~AntennaSets() +{ +} + +// +// _adoptSelector(selector, singleSet, rcuCount) +// +bool AntennaSets::_adoptSelector(const string& selector, singleSet& antSet, uint rcuCount) +{ + ASSERTSTR(!selector.empty(), "SelectorString may not be empty"); + ASSERTSTR(rcuCount, "rcuCount must be > 0"); + + uint strLen(selector.length()); + uint rcuNr(0); + uint sIdx(0); + while (sIdx < strLen) { + // first get the loopcount if any + uint loopCnt(0); + while (sIdx < strLen && isdigit(selector[sIdx])) { + loopCnt = loopCnt * 10 + (selector[sIdx] - '0'); + sIdx++; + } + if (!loopCnt) { + loopCnt = 1; + } + + // next get the pattern + string pattern; + uint patLen(0); + while (sIdx < strLen && !isdigit(selector[sIdx])) { + pattern[patLen] = selector[sIdx]; + patLen++; + sIdx++; + } + ASSERTSTR(patLen, "Expected a pattern at position " << sIdx << " of selector " << selector); + + // now we have both the loopcount and the pattern, apply it to Set. + for (uint l = 0; l < loopCnt; l++) { + for (uint p = 0; p < patLen; p++) { + char input = pattern[p]; + ASSERTSTR(input=='l' || input=='h' || input=='H' || input=='.', + "character '" << input << + "' not allowed for selecting an RCUinput, only lhH. are allowed."); + ASSERTSTR(rcuNr < MAX_RCUS, + "selector:'"<< selector << "' specified more than " << MAX_RCUS << " RCUs"); + + if (input=='l' || input=='h') { + antSet.LBAallocation.set(rcuNr); + } + else if (input=='H') { + antSet.HBAallocation.set(rcuNr); + } + antSet.RCUinputs[rcuNr] = input; + rcuNr++; + } // pattern len + } // pattern count + } // for whole string + + ASSERTSTR(rcuNr == rcuCount, "selector '" << selector << "' specifies " << rcuNr << " inputs, while " << rcuCount << " inputs are required."); + + return (true); + +} + +// +// RCUinputs(setName) +// +string AntennaSets::RCUinputs (const string& setName, uint stationType) const +{ + AntSetIter iter = itsDefinitions.find(setName); + ASSERTSTR(iter != itsDefinitions.end(), setName << " is not defined in " << itsAntennaSetFile); + switch (stationType) { + case 0: return (iter->second.core.RCUinputs); + case 1: return (iter->second.remote.RCUinputs); + case 2: return (iter->second.europe.RCUinputs); + default: ASSERT(false); // satisfy compiler. + } +} + +// +// LBAallocation(setName) +// +bitset<MAX_RCUS> AntennaSets::LBAallocation(const string& setName, uint stationType) const +{ + AntSetIter iter = itsDefinitions.find(setName); + ASSERTSTR(iter != itsDefinitions.end(), setName << " is not defined in " << itsAntennaSetFile); + switch (stationType) { + case 0: return (iter->second.core.LBAallocation); + case 1: return (iter->second.remote.LBAallocation); + case 2: return (iter->second.europe.LBAallocation); + default: ASSERT(false); // satisfy compiler. + } +} + +// +// HBAallocation(setName) +// +bitset<MAX_RCUS> AntennaSets::HBAallocation(const string& setName, uint stationType) const +{ + AntSetIter iter = itsDefinitions.find(setName); + ASSERTSTR(iter != itsDefinitions.end(), setName << " is not defined in " << itsAntennaSetFile); + switch (stationType) { + case 0: return (iter->second.core.HBAallocation); + case 1: return (iter->second.remote.HBAallocation); + case 2: return (iter->second.europe.HBAallocation); + default: ASSERT(false); // satisfy compiler. + } +} + +// +// isAntennaSet(setName) +// +bool AntennaSets::isAntennaSet (const string& setName) const +{ + return(itsDefinitions.find(setName) != itsDefinitions.end()); +} + +// +// antennaSetList() +// +vector<string> AntennaSets::antennaSetList() const +{ + vector<string> result; + + AntSetIter iter = itsDefinitions.begin(); + AntSetIter end = itsDefinitions.end(); + while (iter != end) { + result.push_back(iter->first); + iter++; + } + return (result); +} + +// +// usesLBAfield(setName) +// +bool AntennaSets::usesLBAfield(const string& setName, uint stationType) const +{ + AntSetIter iter = itsDefinitions.find(setName); + ASSERTSTR(iter != itsDefinitions.end(), setName << " is not defined in " << itsAntennaSetFile); + switch (stationType) { + case 0: return (iter->second.core.LBAallocation.count()); + case 1: return (iter->second.remote.HBAallocation.count()); + case 2: return (iter->second.europe.HBAallocation.count()); + default: ASSERT(false); // satisfy compiler. + } +} + + + } // namespace APLCommon +} // namespace LOFAR diff --git a/MAC/APL/APLCommon/src/CMakeLists.txt b/MAC/APL/APLCommon/src/CMakeLists.txt index e9023faab3c1ffd5f6f55de9707fed6039ce0eaa..a79b5789defda81e44a5ef6ca8164407f88301c6 100644 --- a/MAC/APL/APLCommon/src/CMakeLists.txt +++ b/MAC/APL/APLCommon/src/CMakeLists.txt @@ -11,6 +11,8 @@ lofar_add_library(aplcommon Package__Version.cc StartDaemon_Protocol.cc Controller_Protocol.cc + AntennaPos.cc + AntennaSets.cc APLUtilities.cc ControllerDefines.cc CTState.cc diff --git a/MAC/APL/APLCommon/src/ChildControl.cc b/MAC/APL/APLCommon/src/ChildControl.cc index 499dd9af10861309096c0732f53da3b70de8f12e..3ca22fa01e82604dc9dfb136fc5bec1f34f000e7 100644 --- a/MAC/APL/APLCommon/src/ChildControl.cc +++ b/MAC/APL/APLCommon/src/ChildControl.cc @@ -141,7 +141,7 @@ void ChildControl::openService(const string& aServiceName, ASSERTSTR(itsListener, "Can't create a listener port for my children"); itsListener->setInstanceNr (instanceNr); - itsListener->open(); + itsListener->autoOpen(5,0,1); // 5 tries with 1 second interval. } // @@ -955,7 +955,6 @@ void ChildControl::_doGarbageCollection() GCFEvent::TResult ChildControl::initial (GCFEvent& event, GCFPortInterface& port) { -// LOG_DEBUG_STR ("initial:" << evtstr(event) << "@" << port.getName()); LOG_DEBUG_STR ("initial:" << eventName(event) << "@" << port.getName()); GCFEvent::TResult status = GCFEvent::HANDLED; @@ -978,16 +977,9 @@ GCFEvent::TResult ChildControl::initial (GCFEvent& event, case F_DISCONNECTED: port.close(); if (&port == itsListener) { - port.setTimer(1.0); + ASSERTSTR(false, "Unable to open the listener, bailing out."); } - else { -// _handleDisconnectEvent(event, port); - } - break; - - case F_TIMER: - // is this always the reconnect timer? - itsListener->open(); + ASSERTSTR(false, "Programming error, unexpected port closed"); break; default: diff --git a/MAC/APL/APLCommon/src/Makefile.am b/MAC/APL/APLCommon/src/Makefile.am index 6236b1ad214ff2ec3ff7d909ddeccdcf8763b26c..10ea7ce373fafbc278d4fe3ff0effa14cc2643ca 100644 --- a/MAC/APL/APLCommon/src/Makefile.am +++ b/MAC/APL/APLCommon/src/Makefile.am @@ -24,8 +24,9 @@ libaplcommon_la_SOURCES = Package__Version.cc \ CTState.cc \ ControllerAdmin.cc \ ChildControl.cc \ - ParentControl.cc - + ParentControl.cc \ + AntennaSets.cc \ + AntennaPos.cc BUILT_SOURCES = $(ph_HEADERS) swlevel swlevel.conf diff --git a/MAC/APL/APLCommon/test/AntennaSets1.conf b/MAC/APL/APLCommon/test/AntennaSets1.conf new file mode 100644 index 0000000000000000000000000000000000000000..dc5c371d90ded401be0cdaf3d300cd1cfac292bc --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets1.conf @@ -0,0 +1,78 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Remote 96h +LBA_INNER Core 96h +# +# Use outer half of the LBAs on Core and Remote +LBA_OUTER Europe 192h +LBA_OUTER Remote 96l +LBA_OUTER Core 96l +# +# Use half of inner and outer LBAs on Core and Remote [TBC] +LBA_SPARSE Europe 192h +LBA_SPARSE Remote 24llhh +LBA_SPARSE Core 24llhh +# +# Use X dipole of all LBAs +LBA_X Europe 96h. +LBA_X Remote 48hl +LBA_X Core 48hl +# +# Use Y dipole of all LBAs +LBA_Y Europe 96.h +LBA_Y Remote 48lh +LBA_Y Core 48lh + +# Note: On Core stations the Serdes splitter is always on for HBA + +# Use 'ear' 0 in Core stations (antennas 0-23) +HBA_ONE Europe 192H +HBA_ONE Remote 96H +HBA_ONE Core 48H48. +# +# Use 'ear' 1 in Core stations (antennas 24-47) +HBA_TWO Europe 192H +HBA_TWO Remote 96H +HBA_TWO Core 48.48H +# +# Use both 'ears' in the Core (microstationmode for EOR) +HBA_BOTH Europe 192H +HBA_BOTH Remote 96H +HBA_BOTH Core 96H + + diff --git a/MAC/APL/APLCommon/test/AntennaSets2.conf b/MAC/APL/APLCommon/test/AntennaSets2.conf new file mode 100644 index 0000000000000000000000000000000000000000..029da83f4a66895882496f62324a992bdb6a794b --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets2.conf @@ -0,0 +1,40 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Remote +LBA_INNER Core 96h +# diff --git a/MAC/APL/APLCommon/test/AntennaSets3.conf b/MAC/APL/APLCommon/test/AntennaSets3.conf new file mode 100644 index 0000000000000000000000000000000000000000..0cc67527daf3acd692dfac500bf4d51bb17c2fc7 --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets3.conf @@ -0,0 +1,44 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Core 96h +# +# Use outer half of the LBAs on Core and Remote +LBA_OUTER Europe 192h +LBA_OUTER Remote 96l +LBA_OUTER Core 96l +# diff --git a/MAC/APL/APLCommon/test/AntennaSets4.conf b/MAC/APL/APLCommon/test/AntennaSets4.conf new file mode 100644 index 0000000000000000000000000000000000000000..471251bdc25bb1c93b485c0f9114ad53192ff99f --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets4.conf @@ -0,0 +1,41 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Remote 96h +LBA_INNER Europe 192h +LBA_INNER Core 96h +# diff --git a/MAC/APL/APLCommon/test/AntennaSets5.conf b/MAC/APL/APLCommon/test/AntennaSets5.conf new file mode 100644 index 0000000000000000000000000000000000000000..a16d7a9868e8f7651bed1156a9005528a9f84d5a --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets5.conf @@ -0,0 +1,54 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Remote 96h +LBA_INNER Core 96h +# +# Use outer half of the LBAs on Core and Remote +LBA_OUTER Europe 192h +LBA_OUTER Remote 96l +LBA_OUTER Core 96l +# +# Use half of inner and outer LBAs on Core and Remote [TBC] +LBA_SPARSE Europe 192h +LBA_SPARSE Remote 24llhh +LBA_SPARSE Core 24llhh +# +# Use X dipole of all LBAs +LBA_OUTER Europe 192h +LBA_OUTER Remote 96l +LBA_OUTER Core 96l diff --git a/MAC/APL/APLCommon/test/AntennaSets6.conf b/MAC/APL/APLCommon/test/AntennaSets6.conf new file mode 100644 index 0000000000000000000000000000000000000000..9305463c540cf73d3f4b27d2dfab4b307686a05f --- /dev/null +++ b/MAC/APL/APLCommon/test/AntennaSets6.conf @@ -0,0 +1,48 @@ +# +# AntennaSet.conf +# +# This file defines subsets of the (physical) antennafields that can be used +# in observations as 'the' antennafield. +# +# Since there are 3 different station layout each subset must be defined for +# each stationtype (Core, Remote and Europe). +# +# A Subset is defined for specifying for each stationtypes for each RCU which +# input is used. +# +# Allowed values for the RCU input selection are: +# H : HBA input +# h : LBH input +# l : LBL input +# . : RCU not included +# +# To diminish the typing-work to syntax of an rcu definition is: +# input-selector ::= H | h | l | . +# rcu_definition ::= number input-selector [ number inputselector ...] +# +# E.g. when on a station on all RCUs the HBA input must be used this can be defined as +# 192H in stead of 192 'H' after each other. +# +# Or when all even RCUs should use LBL and all even RCUs shoud use LBH: +# 96hl +# +# The total number of assigned RCUs MUST match the total number for each station: +# +# RCU counts LBA HBA +# Europe 192 192 +# Remote 96 96 +# Core 96 96 +# +# Use inner half of the LBAs on Core and Remote +LBA_INNER Europe 192h +LBA_INNER Remote 96h +LBA_INNER Core 96h +# +# Use outer half of the LBAs on Core and Remote +LBA_OUTER Europe 192h +LBA_OUTER Remote 96l +LBA_OUTER Core 96l +# +# Use half of inner and outer LBAs on Core and Remote [TBC] +LBA_SPARSE Europe 192h +LBA_SPARSE Core 24llhh diff --git a/MAC/APL/APLCommon/test/CMakeLists.txt b/MAC/APL/APLCommon/test/CMakeLists.txt index 61223202cab33b656b20200680f1614979ccbb56..3e983c81b7cb3d21a63af9528d0745ff1406dc4d 100644 --- a/MAC/APL/APLCommon/test/CMakeLists.txt +++ b/MAC/APL/APLCommon/test/CMakeLists.txt @@ -10,6 +10,8 @@ lofar_add_test(tAPLUtilities tAPLUtilities.cc) lofar_add_test(tbitsetUtil tbitsetUtil.cc) lofar_add_test(tOutOfBand tOutOfBand.cc) lofar_add_test(tAntennaMapper tAntennaMapper.cc) +lofar_add_test(tAntennaSet tAntennaSet.cc) +lofar_add_test(tAntennaPos tAntennaPos.cc) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/ResourceAllocatorTest.log_prop.in diff --git a/MAC/APL/APLCommon/test/Makefile.am b/MAC/APL/APLCommon/test/Makefile.am index 205b67513c19744dd02824ccd4b1400041c3397b..5658eb0938accf5503c9a43c86d219cb92ecdbae 100755 --- a/MAC/APL/APLCommon/test/Makefile.am +++ b/MAC/APL/APLCommon/test/Makefile.am @@ -1,4 +1,4 @@ -check_PROGRAMS = tControllerDefines tAPLUtilities tbitsetUtil tOutOfBand tAntennaMapper +check_PROGRAMS = tControllerDefines tAPLUtilities tbitsetUtil tOutOfBand tAntennaMapper tAntennaSet tAntennaPos AM_CPPFLAGS = -I../src/ tControllerDefines_SOURCES = tControllerDefines.cc @@ -21,6 +21,14 @@ tAntennaMapper_SOURCES = tAntennaMapper.cc tAntennaMapper_LDADD = ../src/libaplcommon.la tAntennaMapper_DEPENDENCIES = ../src/libaplcommon.la $(LOFAR_DEPEND) +tAntennaSet_SOURCES = tAntennaSet.cc +tAntennaSet_LDADD = ../src/libaplcommon.la +tAntennaSet_DEPENDENCIES = ../src/libaplcommon.la $(LOFAR_DEPEND) + +tAntennaPos_SOURCES = tAntennaPos.cc +tAntennaPos_LDADD = ../src/libaplcommon.la +tAntennaPos_DEPENDENCIES = ../src/libaplcommon.la $(LOFAR_DEPEND) + TESTSCRIPTS = tControllerDefines_test.sh diff --git a/MAC/APL/APLCommon/test/tAntennaPos.cc b/MAC/APL/APLCommon/test/tAntennaPos.cc new file mode 100644 index 0000000000000000000000000000000000000000..469355af5d07a3a2913214541c7d6249f13974b2 --- /dev/null +++ b/MAC/APL/APLCommon/test/tAntennaPos.cc @@ -0,0 +1,56 @@ +//# tAntennaSet.cc +//# +//# Copyright (C) 2008 +//# 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/StreamUtil.h> +#include <APL/APLCommon/AntennaPos.h> + +using namespace LOFAR; +using namespace LOFAR::APLCommon; + +int main (int argc, char* argv[]) +{ + INIT_VAR_LOGGER(argv[0], argv[0]); + + AntennaPos theAP("AntennaPos1.conf"); // read the AntennaPos.conf file into memory + + // Show the names of the sets. + LOG_DEBUG_STR("The AntennaPos1.conf file containes the following definitions:"); + LOG_DEBUG_STR("LBA count : " << theAP.nrLBAs()); + LOG_DEBUG_STR("LBA centre : " << theAP.LBACentre()); + LOG_DEBUG_STR("LBA Ant positions: " << theAP.LBAAntPos()); + LOG_DEBUG_STR("LBA RCU positions: " << theAP.LBARCUPos()); + LOG_DEBUG_STR("LBA RCU lengths : " << theAP.LBARCULengths()); + + LOG_DEBUG_STR("HBA count : " << theAP.nrHBAs()); + LOG_DEBUG_STR("HBA centre : " << theAP.HBACentre()); + LOG_DEBUG_STR("HBA Ant positions: " << theAP.HBAAntPos()); + LOG_DEBUG_STR("HBA RCU positions: " << theAP.HBARCUPos()); + LOG_DEBUG_STR("HBA RCU lengths : " << theAP.HBARCULengths()); + + return (0); +} + diff --git a/MAC/APL/APLCommon/test/tAntennaSet.cc b/MAC/APL/APLCommon/test/tAntennaSet.cc new file mode 100644 index 0000000000000000000000000000000000000000..89936b43acef100e09a02f66edbbd1501a398440 --- /dev/null +++ b/MAC/APL/APLCommon/test/tAntennaSet.cc @@ -0,0 +1,111 @@ +//# tAntennaSet.cc +//# +//# Copyright (C) 2008 +//# 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/StreamUtil.h> +#include <APL/APLCommon/AntennaSets.h> + +using namespace LOFAR; +using namespace LOFAR::APLCommon; + +int main (int argc, char* argv[]) +{ + INIT_VAR_LOGGER(argv[0], argv[0]); + + AntennaSets theAS("AntennaSets1.conf"); // read the AntennaSets.conf file into memory + + // Show the names of the sets. + LOG_DEBUG_STR("The AntennaSets.conf file containes the following sets:"); + vector<string> theNames = theAS.antennaSetList(); + for (uint idx = 0; idx < theNames.size(); idx++) { + LOG_DEBUG_STR(idx << " : " << theNames[idx]); + } + + // test namelookup + LOG_DEBUG_STR("HBA_UNKNOWN is " << (theAS.isAntennaSet("HBA_UNKNOWN") ? "" : "NOT ") << "a set"); + LOG_DEBUG_STR("LBA_SPARSE is " << (theAS.isAntennaSet("LBA_SPARSE") ? "" : "NOT ") << "a set"); + + // show all configurations + for (uint idx = 0; idx < theNames.size(); idx++) { + LOG_DEBUG_STR("********** " << theNames[idx] << "**********"); + LOG_DEBUG_STR("RCUs EUROPE:" << theAS.RCUinputs(theNames[idx], 2)); + LOG_DEBUG_STR("RCUs REMOTE:" << theAS.RCUinputs(theNames[idx], 1)); + LOG_DEBUG_STR("RCUs CORE :" << theAS.RCUinputs(theNames[idx], 0)); + // unfortunately strings are printed starting at element 0 and bitsets viceversa + // to be able to show it logical to the user we must reverse the bitset + bitset<MAX_RCUS> theRealBS = theAS.LBAallocation(theNames[idx], 2); + bitset<MAX_RCUS> thePrintableBS; + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("LBAs EUROPE:" << thePrintableBS); + theRealBS = theAS.LBAallocation(theNames[idx], 1); + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("LBAs REMOTE:" << thePrintableBS); + theRealBS = theAS.LBAallocation(theNames[idx], 0); + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("LBAs CORE :" << thePrintableBS); + + theRealBS = theAS.HBAallocation(theNames[idx], 2); + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("HBAs EUROPE:" << thePrintableBS); + theRealBS = theAS.HBAallocation(theNames[idx], 1); + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("HBAs REMOTE:" << thePrintableBS); + theRealBS = theAS.HBAallocation(theNames[idx], 0); + for (int i = 0; i < MAX_RCUS; i++) { thePrintableBS[MAX_RCUS-1-i] = theRealBS[i]; } + LOG_DEBUG_STR("HBAs CORE :" << thePrintableBS); + } + + LOG_DEBUG(" "); + LOG_DEBUG("----- Finally testing some corrupt AntennaSet files, expecting 5 exceptions... -----"); + try { + AntennaSets theWrongAS("AntennaSets2.conf"); // wrong line format + } + catch (Exception& e) {} + + try { + AntennaSets theWrongAS("AntennaSets3.conf"); // 1 station type forgotten + } + catch (Exception& e) {} + + try { + AntennaSets theWrongAS("AntennaSets4.conf"); // double definition of stationType + } + catch (Exception& e) {} + + try { + AntennaSets theWrongAS("AntennaSets5.conf"); // double definition of AntennaSet + } + catch (Exception& e) {} + + try { + AntennaSets theWrongAS("AntennaSets6.conf"); // incomplete definition at end of file. + } + catch (Exception& e) {} + + + return (0); +} +