diff --git a/MAC/APL/PAC/CAL_Protocol/include/APL/CAL_Protocol/AntennaArray.h b/MAC/APL/PAC/CAL_Protocol/include/APL/CAL_Protocol/AntennaArray.h index 4d76a4e539cbdcebdc68619020bd57eb4c60cfef..e259e1bb860c44428513f5432ec65e646cb8ad05 100644 --- a/MAC/APL/PAC/CAL_Protocol/include/APL/CAL_Protocol/AntennaArray.h +++ b/MAC/APL/PAC/CAL_Protocol/include/APL/CAL_Protocol/AntennaArray.h @@ -24,110 +24,93 @@ #ifndef ANTENNAARRAY_H_ #define ANTENNAARRAY_H_ -#include <string> #include <blitz/array.h> -#include <map> +#include <Common/lofar_map.h> +#include <Common/lofar_vector.h> +#include <Common/lofar_string.h> #include <Common/LofarTypes.h> namespace LOFAR { namespace CAL { - /** - * 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 would also be described by - * separate AntennaArray instance. - * The AntennaArray instantes are created using information from a configuration file. - */ - class AntennaArray - { - public: - - /** - * Create a new antenna array. - * @param name The name of this antenna array. - * @param pos The x,y,z positions of the antennas (dimensions: nantennas x npol (2) x 3 (x,y,z) - * @param rcuindex The mapping from antenna to input RCU. If the mapping is one-on-one then this - * parameter can be omitted. This is used for creating subarrays of an AntennaArray. - */ - AntennaArray(); // only used by CAL_Protocol.prot, should not be used directly - AntennaArray(std::string name, - const blitz::Array<double, 1>& geoloc, - const blitz::Array<double, 3>& pos, - const blitz::Array<int16, 2>* rcuindex = 0); - virtual ~AntennaArray(); - - /** - * Get the name of the array. - * @return The name of the array or subarray (e.g. LBA_ARRAY, HBA_ARRAY, SINGLEPOL_LBA_ARRAY, etc). - */ - std::string getName() const { return m_name; } - - /** - * Get geographical location. - * @return geographical location as 1-dimensional blitz array with three elements. - */ - const blitz::Array<double, 1>& getGeoLoc() const { return m_geoloc; } - - /** - * Get the positions of the antennas. - * @return The array with positions of the antennas. - */ - const blitz::Array<double, 3>& getAntennaPos() const { return m_pos; } - - /** - * @return The number of dual polarized antennas (one antenna = two dipoles) - */ - int getNumAntennas() const { return m_pos.extent(blitz::firstDim); } - - /** - * Get the RCU index of a particular antenna. - */ - inline int16 getRCUIndex(int nantenna, int npol) const { return m_rcuindex(nantenna, npol); } - - /** - * Assignment operator - */ - AntennaArray& operator=(const AntennaArray& other); - - protected: - - /* prevent copy */ - AntennaArray(const AntennaArray& other); // no implementation - - std::string m_name; // name of this antenna array - blitz::Array<double, 1> m_geoloc; // geographical location - blitz::Array<double, 3> m_pos; // three dimensions, Nantennas x Npol x 3 (x,y,z) - blitz::Array<int16, 2> m_rcuindex; // the index of the rcu to which a dipole is connected, dimensions Nantennas x Npol - }; - - /** - * Factory class for the Antenna class. Manages one or more AntennaArrays which are loaded from file. - */ - class AntennaArrays - { - public: - AntennaArrays(); - virtual ~AntennaArrays(); - - /** - * Get an antenna array by name. - * @return a pointer to the AntennaArray or 0 if the array was not found. - */ - const AntennaArray* getByName(std::string name); - - /** - * Get all antenna arrays. A second call to this method replaces the antenna arrays - * loaded by the first call. - * @param url Load antenna arrays from this resource location (e.g. filename or database table). - * @param numantennas The array loaded must have exactly this number of antennas. - */ - void getAll(std::string url); - - private: - std::map<std::string, const AntennaArray*> m_arrays; - }; +/** +* 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 would also be described by +* separate AntennaArray instance. +* The AntennaArray instantes are created using information from a configuration file. +*/ +class AntennaArray +{ +public: + // Create a new antenna array. + // @param name The name of this antenna array. + // @param pos The x,y,z positions of the antennas (dimensions: nantennas x npol (2) x 3 (x,y,z) + // @param rcuindex The mapping from antenna to input RCU. If the mapping is one-on-one then this + // parameter can be omitted. This is used for creating subarrays of an AntennaArray. + AntennaArray(); // only used by CAL_Protocol.prot, should not be used directly + AntennaArray(string name, + const blitz::Array<double, 1>& geoloc, + const blitz::Array<double, 3>& pos, + const blitz::Array<int16, 2>* rcuindex = 0); + virtual ~AntennaArray(); + + // Get the name of the array. + // @return The name of the array or subarray (e.g. LBA_ARRAY, HBA_ARRAY, SINGLEPOL_LBA_ARRAY, etc). + string getName() const { return m_name; } + + // Get geographical location. + // @return geographical location as 1-dimensional blitz array with three elements. + const blitz::Array<double, 1>& getGeoLoc() const { return m_geoloc; } + + // Get the positions of the antennas. + // @return The array with positions of the antennas. + const blitz::Array<double, 3>& getAntennaPos() const { return m_pos; } + + // @return The number of dual polarized antennas (one antenna = two dipoles) + int getNumAntennas() const { return m_pos.extent(blitz::firstDim); } + + // Get the RCU index of a particular antenna. + inline int16 getRCUIndex(int nantenna, int npol) const { return m_rcuindex(nantenna, npol); } + + // Assignment operator + AntennaArray& operator=(const AntennaArray& other); + +protected: + /* prevent copy */ + AntennaArray(const AntennaArray& other); // no implementation + + string m_name; // name of this antenna array + blitz::Array<double, 1> m_geoloc; // geographical location + blitz::Array<double, 3> m_pos; // three dimensions, Nantennas x Npol x 3 (x,y,z) + blitz::Array<int16, 2> m_rcuindex; // the index of the rcu to which a dipole is connected, dimensions Nantennas x Npol + }; + +// +// Factory class for the Antenna class. Manages one or more AntennaArrays which are loaded from file. +// +class AntennaArrays +{ +public: + AntennaArrays(); + virtual ~AntennaArrays(); + + // Get all antenna arrays from the given filename + // @param url Load antenna arrays from this resource location (e.g. filename or database table). + void getAll(string url); + + // Get an antenna array by name. + // @return a pointer to the AntennaArray or 0 if the array was not found. + const AntennaArray* getByName(string name); + + // Get a list of ames of all loaded antennaarrays + // @return a pointer to the AntennaArray or 0 if the array was not found. + vector<string> getNameList(); + +private: + map<string, const AntennaArray*> m_arrays; +}; }; // namespace CAL }; // namespace LOFAR diff --git a/MAC/APL/PAC/CAL_Protocol/src/AntennaArray.cc b/MAC/APL/PAC/CAL_Protocol/src/AntennaArray.cc index 5ffc5736db97ef0f95d13e07b113c003ee541eaf..1b532f40519667507c0eeb2b5e63844547c962cf 100644 --- a/MAC/APL/PAC/CAL_Protocol/src/AntennaArray.cc +++ b/MAC/APL/PAC/CAL_Protocol/src/AntennaArray.cc @@ -47,23 +47,23 @@ AntennaArray::AntennaArray() m_rcuindex = 0; } -AntennaArray::AntennaArray(string name, - const Array<double, 1>& geoloc, - const Array<double, 3>& pos, - const Array<int16, 2>* rcuindex) - : m_name(name), m_geoloc(geoloc), m_pos(pos) +AntennaArray::AntennaArray( string name, + const Array<double, 1>& geoloc, + const Array<double, 3>& pos, + const Array<int16, 2>* rcuindex) : + m_name(name), + m_geoloc(geoloc), + m_pos(pos) { - m_rcuindex.resize(m_pos.extent(firstDim), m_pos.extent(secondDim)); - - if (rcuindex) - { - m_rcuindex = *rcuindex; - } - else - { - firstIndex i; - m_rcuindex = i; - } + m_rcuindex.resize(m_pos.extent(firstDim), m_pos.extent(secondDim)); + + if (rcuindex) { + m_rcuindex = *rcuindex; + } + else { + firstIndex i; + m_rcuindex = i; + } } AntennaArray::~AntennaArray() @@ -90,6 +90,8 @@ AntennaArray& AntennaArray::operator=(const AntennaArray& rhs) return *this; } +// +// ---------------- Class ANTENNAARRAYS --------------- AntennaArrays::AntennaArrays() { } @@ -97,8 +99,7 @@ AntennaArrays::AntennaArrays() AntennaArrays::~AntennaArrays() { for (map<string, const AntennaArray*>::const_iterator it = m_arrays.begin(); - it != m_arrays.end(); ++it) - { + it != m_arrays.end(); ++it) { if ((*it).second) delete (*it).second; } } @@ -128,3 +129,21 @@ void AntennaArrays::getAll(std::string url) LOG_INFO_STR("Read array definition '" << arraydata.getName() << "' from file '" << url << "'"); } } + +// +// getNameList() : vector<string> +// +vector<string> AntennaArrays::getNameList() +{ + vector<string> names; + map<string,const AntennaArray*>::iterator iter = m_arrays.begin(); + map<string,const AntennaArray*>::iterator end = m_arrays.end(); + + while (iter != end) { + names.push_back(iter->first); + iter++; + } + + return (names); +} +