diff --git a/LCS/AMC/AMCBase/configure.in b/LCS/AMC/AMCBase/configure.in index a221ea290544245a7438708b16cc8ee3e091aa76..8bd95b97dd37e6aa9b12653bbf6b1a5200133abe 100644 --- a/LCS/AMC/AMCBase/configure.in +++ b/LCS/AMC/AMCBase/configure.in @@ -2,7 +2,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AM_INIT_AUTOMAKE(AMCBase, 1.1, no-define) +AM_INIT_AUTOMAKE(AMCBase, 2.0, no-define) AM_CONFIG_HEADER(config.h) dnl AX_PREFIX_CONFIG_H([lofar-config.h], []) @@ -52,9 +52,9 @@ dnl dnl Check for LOFAR specific things dnl lofar_GENERAL -lofar_INTERNAL(LCS/Common,Common,,1,Common/LofarTypedefs.h,,) -lofar_INTERNAL(LCS/Blob,Blob,,1,Blob/BlobHeader.h,,) -lofar_INTERNAL(LCS/Transport,Transport,,1,Transport/TransportHolder.h,,) +lofar_INTERNAL(LCS/Common,Common,LCS-Common-3_1,1,Common/LofarTypedefs.h,,) +lofar_INTERNAL(LCS/Blob,Blob,LCS-Blob-1_0,1,Blob/BlobHeader.h,,) +lofar_INTERNAL(LCS/Transport,Transport,LCS-Transport-2_3,1,Transport/TransportHolder.h,,) dnl dnl Output Makefiles @@ -65,6 +65,5 @@ include/Makefile include/AMCBase/Makefile src/Makefile test/Makefile -test/AMCClient/Makefile AMCBase.spec ) diff --git a/LCS/AMC/AMCBase/include/AMCBase/BlobIO.h b/LCS/AMC/AMCBase/include/AMCBase/BlobIO.h new file mode 100644 index 0000000000000000000000000000000000000000..ee2ce3fc074bb97b8c666dfacffaba7ecab911ec --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/BlobIO.h @@ -0,0 +1,111 @@ +//# BlobIO.h: Blob (de)serialization methods for AMCBase classes. +//# +//# 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_AMCBASE_BLOBIO_H +#define LOFAR_AMCBASE_BLOBIO_H + +// \file +// Blob (de)serialization methods for AMCBase classes. + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes + +namespace LOFAR +{ + //# Forward declarations + class BlobOStream; + class BlobIStream; + + namespace AMC + { + //# Forward declarations + class SkyCoord; + class EarthCoord; + class TimeCoord; + class ConverterCommand; + class ConverterStatus; + struct RequestData; + struct ResultData; + + // \addtogroup AMCBase + // @{ + + //# ------- BlobOStream operators ------- #// + + // Serialize the sky coordinates \a sc to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const SkyCoord& sc); + + // Serialize the earth coordinates \a ec to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const EarthCoord& ec); + + // Serialize the time coordinates \a tc to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const TimeCoord& tc); + + // Serialize the converter command \a cc to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const ConverterCommand& cc); + + // Serialize the return value \a cs to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const ConverterStatus& cs); + + // Serialize the converter request \a req to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const RequestData& req); + + // Serialize the converter result \a res to the output blob stream \a bos. + BlobOStream& operator<<(BlobOStream& bos, const ResultData& res); + + + //# ------- BlobIStream operators ------- #// + + // De-serialize the input blob stream \a bis to the sky coordinates \a sc. + BlobIStream& operator>>(BlobIStream& bis, SkyCoord& sc); + + // De-serialize the input blob stream \a bis to the earth coordinates \a + // ec. + BlobIStream& operator>>(BlobIStream& bis, EarthCoord& ec); + + // De-serialize the input blob stream \a bis to the time coordinates \a + // tc. + BlobIStream& operator>>(BlobIStream& bis, TimeCoord& tc); + + // De-serialize the input blob stream \a bis to the converter command \a + // cc. + BlobIStream& operator>>(BlobIStream& bis, ConverterCommand& cc); + + // De-serialize the input blob stream \a bis to the return value \a cs. + BlobIStream& operator>>(BlobIStream& bis, ConverterStatus& cs); + + // De-serialize the input blob stream \a bis to the converter request \a + // req. + BlobIStream& operator>>(BlobIStream& bis, RequestData& req); + + // De-serialize the input blob stream \a bis to the converter result \a + // res. + BlobIStream& operator>>(BlobIStream& bis, ResultData& res); + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/Converter.h b/LCS/AMC/AMCBase/include/AMCBase/Converter.h index c6ff7522714340d722562229e5c3380e4ae3eb5b..87c5bd978626ffb372109c714925d69de30eabaf 100644 --- a/LCS/AMC/AMCBase/include/AMCBase/Converter.h +++ b/LCS/AMC/AMCBase/include/AMCBase/Converter.h @@ -39,142 +39,79 @@ namespace LOFAR // @{ //# Forward Declarations - class SkyCoord; - class EarthCoord; - class TimeCoord; + struct RequestData; + struct ResultData; // This class defines the interface of the diverse AMC Converter classes. + // All conversion routines operate on a struct RequestData, returning a + // struct ResultData. RequestData contains three vectors: \a skyCoord, a + // series of sky coordinates; \a earthCoord, a series of earth positions; + // and \a timeCoord, a series of points in time. ResultData contains one + // vector: \a skyCoord, a series of sky coordinates. + // + // Conversion from J2000 to another coordinate system always produces a + // vector of sky coordinates that contains all possible combinations of + // the elements in the input vectors \a skyCoord, \a earthCoord, and \a + // timeCoord. Hence, the output vector contains <tt>skyCoord.size() * + // earthCoord.size() * timeCoord.size()</tt> elements, which can be seen + // as a cube with shape <tt>[nsky,npos,ntime]</tt> in Fortran order (i.e. + // with sky as the most rapidly varying axis). + // + // Conversion from another coordinate system to J2000 always produces a + // vector of sky coordinates that is equal in size to the input vector \a + // skyCoord. The input vectors \a earthCoord and \a timeCoord should + // either both be equal in size to the input vector \a skyCoord, or both + // contain exactly one element. In the former case, the conversion routine + // will calculate one output skyCoord for each triplet of input sky + // coordinates, earth positions, and points in time. In the latter case, + // the conversion routine will convert the input sky coordinates for the + // given earth position and point in time. class Converter { public: // Destructor virtual ~Converter() {} - // Convert the given equatorial J2000 sky coordinate to azimuth/elevation - // (in radians) for the given earth position and time. - virtual SkyCoord j2000ToAzel(const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a series of sky coordinates. - virtual vector<SkyCoord> j2000ToAzel (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a sky coordinate for a series of earth positions. - virtual vector<SkyCoord> j2000ToAzel (const SkyCoord& dir, - const vector<EarthCoord>& pos, - const TimeCoord& time) = 0; - - // Convert a sky coordinate for a series of times. - virtual vector<SkyCoord> j2000ToAzel (const SkyCoord& dir, - const EarthCoord& pos, - const vector<TimeCoord>& time) = 0; - - // Convert a series of sky coordinates for a series of earth positions - // and times. - // The output vector contains <tt>dir.size() * pos.size() * - // time.size()</tt> elements which can be seen as a cube with shape - // <tt>[nsky,npos,ntime]</tt> in Fortran order (thus with sky as the - // most rapidly varying axis). - // \pre \a dir must be given in \c J2000. - // \return vector of SkyCoord in \c AZEL. - virtual vector<SkyCoord> j2000ToAzel (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time) = 0; - - // Convert an azimuth/elevation for the given earth position and time - // to ra/dec. - virtual SkyCoord azelToJ2000 (const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a series of azimuth/elevations for the given earth position - // and time to ra/dec. The output vector has the same length as the - // input \a azel vector. - // \pre \a azel must be given in \c AZEL. - // \post size of return vector is equal to size of vector \a azel. - // \return vector of SkyCoord in \c J2000. - virtual vector<SkyCoord> azelToJ2000 (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a series of azimuth/elevations for the given earth positions - // and times to ra/dec. The output vector has the same length as the - // input \a azel vector. - // \pre All input vectors must have the same length. - // \a azel must be given in \c AZEL. - // \post size of return vector is equal to size of vector \a azel. - // \return vector of SkyCoord in \c J2000. - // \note The difference with the function above is that here each \a - // azel has its own earth position and time. - virtual vector<SkyCoord> azelToJ2000 (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time) = 0; - - - // Convert the given equatorial J2000 sky coordinate to ITRF - // (in radians) for the given earth position and time. - virtual SkyCoord j2000ToItrf(const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a series of sky coordinates. - virtual vector<SkyCoord> j2000ToItrf (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a sky coordinate for a series of earth positions. - virtual vector<SkyCoord> j2000ToItrf (const SkyCoord& dir, - const vector<EarthCoord>& pos, - const TimeCoord& time) = 0; - - // Convert a sky coordinate for a series of times. - virtual vector<SkyCoord> j2000ToItrf (const SkyCoord& dir, - const EarthCoord& pos, - const vector<TimeCoord>& time) = 0; - - // Convert a series of sky coordinates for a series of earth positions - // and times. - // The output vector contains <tt>dir.size() * pos.size() * - // time.size()</tt> elements which can be seen as a cube with shape - // <tt>[nsky,npos,ntime]</tt> in Fortran order (thus with sky as the - // most rapidly varying axis). - // \pre \a dir must be given in \c J2000. - // \return vector of SkyCoord given in \c ITRF. - virtual vector<SkyCoord> j2000ToItrf (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time) = 0; - - // Convert the given ITRF sky coordinate for the given earth position - // and time to an equatorial J2000 sky coordinate - virtual SkyCoord itrfToJ2000 (const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; - - // Convert a series of ITRF sky coordinates for the given earth position - // and time to J2000 ra/dec. The output vector has the same length as - // the input \a dir vector. - // \pre \a dir must be given in \c ITRF. - // \post size of return vector is equal to size of vector \a dir. - // \return vector of SkyCoord in \c J2000. - virtual vector<SkyCoord> itrfToJ2000 (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time) = 0; + // Convert the given equatorial J2000 sky coordinates to + // azimuth/elevation (in radians) for the given earth positions and + // points in time. + // \pre \a request.skyCoord.type() == SkyCoord::J2000 + // \post \a result.skyCoord.type() == SkyCoord::AZEL + // \post \a result.skyCoord.size() == request.skyCoord.size() * + // request.earthCoord.size() * request.timeCoord.size(). + virtual void j2000ToAzel(ResultData& result, + const RequestData& request) = 0; + + // Convert a series of azimuth/elevations for the given earth + // position(s) and point(s) in time to J2000 ra/dec. + // \pre \a request.skyCoord.type() == SkyCoord::AZEL + // \pre \a request.earthCoord.size() == 1 || + // request.earthCoord.size() == request.skyCoord.size() + // \pre \a request.earthCoord.size() == request.timeCoord.size() + // \post \a result.skyCoord.type() == SkyCoord::J2000 + // \post \a result.skyCoord.size() == request.skyCoord.size() + virtual void azelToJ2000(ResultData& result, + const RequestData& request) = 0; + + // Convert the given equatorial J2000 sky coordinate to ITRF (in + // radians) for the given earth positions and points in time. + // \pre \a request.skyCoord.type() == SkyCoord::J2000 + // \post \a result.skyCoord.type() == SkyCoord::ITRF + // \post \a result.skyCoord.size() == request.skyCoord.size() * + // request.earthCoord.size() * request.timeCoord.size(). + virtual void j2000ToItrf(ResultData& result, + const RequestData& request) = 0; // Convert a series of ITRF sky coordinates for the given earth - // positions and times to J2000 ra/dec. The output vector has the same - // length as the input \a dir vector. - // \pre All input vectors must have the same length. - // \a dir must be given in \c ITRF. - // \post size of return vector is equal to size of vector \a dir. - // \return vector of SkyCoord in \c J2000. - // \note The difference with the function above is that here each \a - // dir has its own earth position and time. - virtual vector<SkyCoord> itrfToJ2000 (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time) = 0; - + // position(s) and point(s) in time to J2000 ra/dec. + // \pre \a request.skyCoord.type() == SkyCoord::ITRF + // \pre \a request.earthCoord.size() == 1 || + // request.earthCoord.size() == request.skyCoord.size() + // \pre \a request.earthCoord.size() == request.timeCoord.size() + // \post \a result.skyCoord.type() == SkyCoord::J2000 + // \post \a result.skyCoord.size() == request.skyCoord.size() + virtual void itrfToJ2000(ResultData& result, + const RequestData& request) = 0; }; // @} diff --git a/LCS/AMC/AMCBase/include/AMCBase/ConverterClient.h b/LCS/AMC/AMCBase/include/AMCBase/ConverterClient.h new file mode 100644 index 0000000000000000000000000000000000000000..c098979bc74deda2a98603944cd116ce3f2f5107 --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/ConverterClient.h @@ -0,0 +1,128 @@ +//# ConverterClient.h: Client side of the AMC client/server implementation. +//# +//# 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_AMCBASE_CONVERTERCLIENT_H +#define LOFAR_AMCBASE_CONVERTERCLIENT_H + +// \file +// Client side of the AMC client/server implementation + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <AMCBase/Converter.h> +#include <AMCBase/DH_Request.h> +#include <AMCBase/DH_Result.h> +#include <Transport/TH_Socket.h> +#include <Transport/Connection.h> + +// #include <AMCBase/SkyCoord.h> +// #include <Common/lofar_vector.h> + +namespace LOFAR +{ + //# Forward declarations + class TH_Socket; + class Connection; + + namespace AMC + { + //# Forward declarations + class ConverterCommand; + class DH_Request; + class DH_Result; + class RequestData; + class ResultData; + + // \addtogroup AMCBase + // @{ + + // This class represents the client side of the client/server + // implementation of the AMC. It implements the Converter interface. + // + // The client acts as a proxy. It sends a conversion request to the + // server; the server performs the actual conversion and returns the + // result to the client. + class ConverterClient : public Converter + { + public: + ConverterClient(const string& server = "localhost", + uint16 port = 31337); + + virtual ~ConverterClient(); + + virtual void j2000ToAzel(ResultData&, const RequestData&); + + virtual void azelToJ2000(ResultData&, const RequestData&); + + virtual void j2000ToItrf(ResultData&, const RequestData&); + + virtual void itrfToJ2000(ResultData&, const RequestData&); + + private: + //@{ + // Make this class non-copyable. + ConverterClient(const ConverterClient&); + ConverterClient& operator=(const ConverterClient&); + //@} + + // Perform actual conversion by first sending a conversion request to + // the server and then receiving the conversion result. + void doConvert(ResultData&, + const RequestData&, + const ConverterCommand&); + + // Send a conversion command to the server. The input data are stored in + // three vectors. + // \return \c true if send was successful; otherwise \c false. + bool sendRequest(const ConverterCommand&, + const RequestData&); + + // Receive the converted data from the server. + // \return \c true if receive was successful; otherwise \c false. + // \note This method is blocking. + bool recvResult(ConverterStatus&, ResultData&); + + // Data holder holding the request data to be sent to the server. + DH_Request itsRequest; + + // Data holder holding the result data to be received from the server. + DH_Result itsResult; + + // The transport holder (which is, of course, a TH_Socket) + TH_Socket itsTH; + + // Connection for sending data to the server. + Connection itsSendConn; + + // Connection for receiving data from the server. + Connection itsRecvConn; + + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/ConverterCommand.h b/LCS/AMC/AMCBase/include/AMCBase/ConverterCommand.h new file mode 100644 index 0000000000000000000000000000000000000000..73110b16e854c5a8880d87e7f77f53063c2ce01d --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/ConverterCommand.h @@ -0,0 +1,102 @@ +//# ConverterCommand.h: Commands to be sent to the AMC Converter server. +//# +//# 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_AMCBASE_CONVERTERCOMMAND_H +#define LOFAR_AMCBASE_CONVERTERCOMMAND_H + +// \file +// Commands to be sent to the AMC Converter server + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <Common/LofarTypes.h> +#include <Common/lofar_set.h> +#include <Common/lofar_iosfwd.h> +#include <Common/lofar_string.h> + +namespace LOFAR +{ + namespace AMC + { + + // \addtogroup AMCBase + // @{ + + // Class representing the commands that can be sent to the converter. The + // actual commands are defined in the enumerate type Command. This \c enum + // was defined within a class for a number of reasons: + // - to be able to define an operator<<(BlobOStream&) and + // operator>>(BlobIStream&); this is especially important when we need + // to ensure that the \c enum is streamed with a fixed size; + // - to be able to check whether the \c enum being read using + // operator>>(BlobIStream&) represents a valid enumeration value; + // - to avoid namespace pollution. + class ConverterCommand + { + public: + // All commands that can be sent to the converter. + enum Commands { + INVALID = -1, ///< Used when specified value is out of range. + J2000toAZEL, ///< From J2000 to AZEL + J2000toITRF, ///< From J2000 to ITRF + AZELtoJ2000, ///< From AZEL to J2000 + ITRFtoJ2000, ///< From ITRF to J2000 + //# Insert new types HERE !! + N_Commands ///< Number of converter commands. + }; + + // If \a cmd matches with one of the enumeration values in \c Commands, + // then itsCommand is set to \a cmd, else itsCommand is set to \c + // INVALID. + ConverterCommand(Commands cmd = INVALID); + + // Get the current converter command. + Commands get() const + { return itsCommand; } + + // Return the current converter command as a string. + const string& showCommand() const; + + // Check if the current converter command is valid. + bool isValid() const + { return itsCommand != INVALID; } + + private: + // The current convertor command. + Commands itsCommand; + + }; + + // Comparison operator + bool operator==(const ConverterCommand& lhs, const ConverterCommand& rhs); + + // Output in ASCII format. + ostream& operator<<(ostream& os, const ConverterCommand& cc); + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/ConverterStatus.h b/LCS/AMC/AMCBase/include/AMCBase/ConverterStatus.h new file mode 100644 index 0000000000000000000000000000000000000000..553ef562580827915ee0739671981a4c63b12fcf --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/ConverterStatus.h @@ -0,0 +1,102 @@ +//# ConverterStatus.h: Status that will be returned by the Converter server +//# +//# 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_AMCBASE_CONVERTERSTATUS_H +#define LOFAR_AMCBASE_CONVERTERSTATUS_H + +// \file +// Status that will be returned by the Converter server + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <Common/lofar_string.h> +#include <Common/lofar_iosfwd.h> + +namespace LOFAR +{ + namespace AMC + { + + // \addtogroup AMCBase + // @{ + + // Class representing the status that will be returned by the + // converter. This class is most useful in a client/server configuration, + // because then, the only way to communicate failure from server to client + // is through a return value. It encapsulates the return value (an + // enumerated value), with its associated return value as a string, and an + // optional additional error message. A ConverterStatus instance can be + // transported using the BlobIStream and BlobOStream classes. + class ConverterStatus + { + public: + // Status values that can be set by the Converter server. + enum Status { + UNKNOWN = -1, ///< An unknown error occurred. + OK, ///< No errors. + ERROR, ///< Something definitely went wrong. + //# Insert new return values HERE !! + N_Status ///< Number of status values. + }; + + // If \a sts matches with one of the enumeration values in Status, then + // itsStatus is set to \a sts, else itsStatus is set to \c UNKNOWN. The + // user can optionally supply extra text, providing a more detailed + // description of the actual error. + ConverterStatus(Status sts = OK, + const string& txt = string()); + + // Get the return value. + Status get() const + { return itsStatus; } + + // Return the user-supplied text. + const string& text() const + { return itsText; } + + // Return the status as a string. + const string& asString() const; + + // Return \c true if status is OK, else return \c false. + operator bool() const + { return itsStatus == OK; } + + private: + // The return status + Status itsStatus; + + // User-supplied optional text. + string itsText; + + }; + + // Output in ASCII format. + ostream& operator<<(ostream& os, const ConverterStatus& cs); + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/DH_Request.h b/LCS/AMC/AMCBase/include/AMCBase/DH_Request.h new file mode 100644 index 0000000000000000000000000000000000000000..9ca68edd5bd1b12d2018cf3e58fbc7f5a515efe8 --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/DH_Request.h @@ -0,0 +1,87 @@ +//# DH_Request.h: DataHolder for a conversion request. +//# +//# 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_AMCBASE_DH_REQUEST_H +#define LOFAR_AMCBASE_DH_REQUEST_H + +// \file +// DataHolder for a conversion request + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <Transport/DataHolder.h> +#include <Common/lofar_vector.h> + +namespace LOFAR +{ + namespace AMC + { + //# Forward declarations + class ConverterCommand; + struct RequestData; + + // \addtogroup AMCBase + // @{ + + // This class contains the conversion request that will be sent from the + // client to the server. + class DH_Request : public DataHolder + { + public: + + // Constructor. We will use extra blobs to store our variable length + // conversion requests, so we must initialize the blob machinery. + DH_Request(); + + // Destructor. + virtual ~DH_Request(); + + // Write the conversion request to be sent to the server into the I/O + // buffers of the DataHolder. + void writeBuf(const ConverterCommand&, + const RequestData&); + + // Read the conversion request that was received from the client from + // the I/O buffers of the DataHolder. + void readBuf(ConverterCommand&, + RequestData&); + + private: + + // Make a deep copy. + // \note Must be redefined, because it's defined pure virtual in the + // base class. Made it private, because we won't use it. + virtual DH_Request* clone() const; + + // Version number for this class + static const int theirVersionNr; + + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/DH_Result.h b/LCS/AMC/AMCBase/include/AMCBase/DH_Result.h new file mode 100644 index 0000000000000000000000000000000000000000..9bbd287971c577413515dd38a9aca6a1c2c90d36 --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/DH_Result.h @@ -0,0 +1,83 @@ +//# DH_Result.h: DataHolder for a conversion result. +//# +//# 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_AMCBASE_DH_RESULT_H +#define LOFAR_AMCBASE_DH_RESULT_H + +// \file +// DataHolder for a conversion result + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <Transport/DataHolder.h> +#include <Common/lofar_vector.h> + +namespace LOFAR +{ + namespace AMC + { + //# Forward declarations + class ConverterStatus; + struct ResultData; + + // \addtogroup AMCBase + // @{ + + // This class contains the conversion result that will be transferred from + // the server to the client. + class DH_Result : public DataHolder + { + public: + // Constructor. We will use extra blobs to store our variable length + // conversion results, so we must initialize the blob machinery. + DH_Result(); + + // Destructor. + virtual ~DH_Result(); + + // Write the conversion result to be sent to the client into the I/O + // buffers of the DataHolder. + void writeBuf(const ConverterStatus&, const ResultData&); + + // Read the conversion result that was received from the server from the + // I/O buffers of the DataHolder. + void readBuf(ConverterStatus&, ResultData&); + + private: + // Make a deep copy. + // \note Must be redefined, because it's defined pure virtual in the + // base class. However, we won't implement it, because we won't use it. + virtual DH_Result* clone() const; + + // Version number for this class + static const int theirVersionNr; + + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/Exceptions.h b/LCS/AMC/AMCBase/include/AMCBase/Exceptions.h index c7d92b28afe25707d3ebb54a4e4f24e30017cb5e..7b25368f070a9c203a1b48588445f0bfbe96ed18 100644 --- a/LCS/AMC/AMCBase/include/AMCBase/Exceptions.h +++ b/LCS/AMC/AMCBase/include/AMCBase/Exceptions.h @@ -36,17 +36,19 @@ namespace LOFAR namespace AMC { - // \addtogroup AMCBase + // \addtogroup AMC // @{ + // This is the base exception class for the AMC package EXCEPTION_CLASS(Exception, LOFAR::Exception); - // @} - // \addtogroup AMCClient - // @{ - // This exception is thrown when an error occurs within the AMCClient - // sub-package. - EXCEPTION_CLASS(ClientError, Exception); + // This exception is thrown when an error occurs within the conversion + // methods. + EXCEPTION_CLASS(ConverterException, Exception); + + // This exception is thrown when a network I/O error occurs + EXCEPTION_CLASS(IOException, Exception); + // @} } // namespace AMC diff --git a/LCS/AMC/AMCBase/include/AMCBase/Makefile.am b/LCS/AMC/AMCBase/include/AMCBase/Makefile.am index d586a8d8d4f6f155943daa3372c484c0c9fb7269..dd2d0a981f9e3691dd84b5bdf90aca652b3c538f 100644 --- a/LCS/AMC/AMCBase/include/AMCBase/Makefile.am +++ b/LCS/AMC/AMCBase/include/AMCBase/Makefile.am @@ -1,18 +1,17 @@ -pkginclude_AMCClientdir = $(pkgincludedir)/AMCClient - pkginclude_HEADERS = \ + BlobIO.h \ Converter.h \ + ConverterClient.h \ + ConverterCommand.h \ + ConverterStatus.h \ + DH_Request.h \ + DH_Result.h \ EarthCoord.h \ Exceptions.h \ + RequestData.h \ + ResultData.h \ SkyCoord.h \ TimeCoord.h -pkginclude_AMCClient_HEADERS = \ - AMCClient/BlobIO.h \ - AMCClient/ConverterClient.h \ - AMCClient/ConverterCommand.h \ - AMCClient/DH_Request.h \ - AMCClient/DH_Result.h - include $(top_srcdir)/Makefile.common diff --git a/LCS/AMC/AMCBase/include/AMCBase/RequestData.h b/LCS/AMC/AMCBase/include/AMCBase/RequestData.h new file mode 100644 index 0000000000000000000000000000000000000000..c7983d501c6005e3895542802d3d1f93fab0ee68 --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/RequestData.h @@ -0,0 +1,98 @@ +//# RequestData.h: Request data that will be sent to the converter +//# +//# 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_AMCBASE_REQUESTDATA_H +#define LOFAR_AMCBASE_REQUESTDATA_H + +// \file +// Request data that will be sent to the converter + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <AMCBase/SkyCoord.h> +#include <AMCBase/EarthCoord.h> +#include <AMCBase/TimeCoord.h> +#include <Common/lofar_vector.h> + +namespace LOFAR +{ + namespace AMC + { + // \addtogroup AMCBase + // @{ + + // Struct wrapping the request data that will be sent to the converter. + // The purpose of this struct is to hide the exact structure of the data + // to be sent to the converter. It is not really necessary to make the + // data members private, since we need to have easy access to the data + // members. However, note that, because the data members are public, they + // become part of the interface! So, be careful in renaming them. A number + // of constructors have been defined in order to ease the creation of a + // %RequestData instance. + struct RequestData + { + RequestData() + {} + + RequestData(const SkyCoord& sc, + const EarthCoord& ec, + const TimeCoord& tc) : + skyCoord(1, sc), earthCoord(1, ec), timeCoord(1, tc) + {} + + RequestData(const vector<SkyCoord>& sc, + const EarthCoord& ec, + const TimeCoord& tc) : + skyCoord(sc), earthCoord(1, ec), timeCoord(1, tc) + {} + + RequestData(const SkyCoord& sc, + const vector<EarthCoord>& ec, + const TimeCoord& tc) : + skyCoord(1, sc), earthCoord(ec), timeCoord(1, tc) + {} + + RequestData(const SkyCoord& sc, + const EarthCoord& ec, + const vector<TimeCoord>& tc) : + skyCoord(1, sc), earthCoord(1, ec), timeCoord(tc) + {} + + RequestData(const vector<SkyCoord>& sc, + const vector<EarthCoord>& ec, + const vector<TimeCoord>& tc) : + skyCoord(sc), earthCoord(ec), timeCoord(tc) + {} + + vector<SkyCoord> skyCoord; + vector<EarthCoord> earthCoord; + vector<TimeCoord> timeCoord; + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/include/AMCBase/ResultData.h b/LCS/AMC/AMCBase/include/AMCBase/ResultData.h new file mode 100644 index 0000000000000000000000000000000000000000..c8b28d7efb9d0c98d48179391927591951944149 --- /dev/null +++ b/LCS/AMC/AMCBase/include/AMCBase/ResultData.h @@ -0,0 +1,73 @@ +//# ResultData.h: Result data that will be received from the converter +//# +//# 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_AMCBASE_RESULTDATA_H +#define LOFAR_AMCBASE_RESULTDATA_H + +// \file +// Result data that will be received from the converter + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <AMCBase/SkyCoord.h> +#include <Common/lofar_vector.h> + +namespace LOFAR +{ + namespace AMC + { + // \addtogroup AMCBase + // @{ + + // Struct wrapping the result data that will be received from the + // converter. The purpose of this struct is to hide the exact structure of + // the data to be received from the converter. It is not really necessary + // to make the data members private, since we need to have easy access to + // the data members. However, note that, because the data members are + // public, they become part of the interface! So, be careful in renaming + // them. A number of constructors have been defined in order to ease the + // creation of a %ResultData instance. + struct ResultData + { + public: + ResultData() + {} + + ResultData(const vector<SkyCoord>& sc) : + skyCoord(sc) + {} + + ResultData(const SkyCoord& sc) : + skyCoord(1, sc) + {} + + vector<SkyCoord> skyCoord; + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCBase/src/AMCClient/ConverterClient.cc b/LCS/AMC/AMCBase/src/AMCClient/ConverterClient.cc deleted file mode 100644 index 70a595ad11ed5cd44444ae1c4c6af0966d5264f4..0000000000000000000000000000000000000000 --- a/LCS/AMC/AMCBase/src/AMCClient/ConverterClient.cc +++ /dev/null @@ -1,333 +0,0 @@ -//# ConverterClient.cc: one line description -//# -//# 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 <AMCBase/AMCClient/ConverterClient.h> -#include <AMCBase/AMCClient/ConverterCommand.h> -#include <AMCBase/Exceptions.h> -#include <AMCBase/SkyCoord.h> -#include <AMCBase/EarthCoord.h> -#include <AMCBase/TimeCoord.h> -#include <Common/StringUtil.h> - -namespace LOFAR -{ - namespace AMC - { - - ConverterClient::ConverterClient(const string& server, uint16 port) : - itsTH(server, toString(port)), - itsSendConn("send", &itsRequest, 0, &itsTH), - itsRecvConn("recv", 0, &itsResult, &itsTH) - { - if (!itsTH.init()) { - THROW (ClientError, - "Failed to connect to " << server << " at port " << port); - } - } - - - ConverterClient::~ConverterClient() - { - } - - - SkyCoord - ConverterClient::j2000ToAzel (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toAZEL, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterClient::j2000ToAzel (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toAZEL, - skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::j2000ToAzel (const SkyCoord& skyCoord, - const vector<EarthCoord>& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toAZEL, - vector<SkyCoord> (1, skyCoord), - earthCoord, - vector<TimeCoord>(1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::j2000ToAzel (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::J2000toAZEL, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - timeCoord); - } - - - vector<SkyCoord> - ConverterClient::j2000ToAzel (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::J2000toAZEL, - skyCoord, - earthCoord, - timeCoord); - } - - - SkyCoord - ConverterClient::azelToJ2000 (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::AZELtoJ2000, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterClient::azelToJ2000 (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::AZELtoJ2000, - skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::azelToJ2000 (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::AZELtoJ2000, - skyCoord, - earthCoord, - timeCoord); - } - - - SkyCoord - ConverterClient::j2000ToItrf (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toITRF, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterClient::j2000ToItrf (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toITRF, - skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::j2000ToItrf (const SkyCoord& skyCoord, - const vector<EarthCoord>& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::J2000toITRF, - vector<SkyCoord> (1, skyCoord), - earthCoord, - vector<TimeCoord>(1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::j2000ToItrf (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::J2000toITRF, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - timeCoord); - } - - - vector<SkyCoord> - ConverterClient::j2000ToItrf (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::J2000toITRF, - skyCoord, - earthCoord, - timeCoord); - } - - - SkyCoord - ConverterClient::itrfToJ2000 (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::ITRFtoJ2000, - vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterClient::itrfToJ2000 (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return doConvert(ConverterCommand::ITRFtoJ2000, - skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterClient::itrfToJ2000 (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return doConvert(ConverterCommand::ITRFtoJ2000, - skyCoord, - earthCoord, - timeCoord); - } - - - //#################### Private methods ####################// - - vector<SkyCoord> - ConverterClient::doConvert(const ConverterCommand& cmd, - const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - // Vector to hold the conversion result. - vector<SkyCoord> sc; - - // Send the request to the server, receive the result from the server, - // and return the result. - if (sendRequest(cmd, skyCoord, earthCoord, timeCoord) && recvResult(sc)) - return sc; - - // If the server has died, we will usually notice this only after the - // receive fails. So, we will give it another try. - LOG_DEBUG("ConverterClient::doConvert() - retrying ..."); - if (sendRequest(cmd, skyCoord, earthCoord, timeCoord) && recvResult(sc)) - return sc; - - // When we get here, both tries failed. Trouble! - THROW (ClientError, "Server communication failure. Bailing out!"); - } - - - bool ConverterClient::sendRequest(const ConverterCommand& cmd, - const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { - // Write the conversion request into the data holder's I/O buffer. - itsRequest.writeBuf(cmd, skyCoord, earthCoord, timeCoord); - - // Write the request from the data holder's I/O buffer to the server. - // If the write fails, we may have lost the connection to the server. - if (itsSendConn.write() == Connection::Error) { - LOG_INFO("ConverterClient::sendRequest() - " - "Connection error. Trying to reconnect ..."); - // Try to reconnect. - if (!itsTH.init()) { - THROW (ClientError, "Failed to reconnect to server"); - } - return false; - } - - // Always make this call, even though it only has effect when doing - // asynchronous communication. - itsSendConn.waitForWrite(); - - // When we get here, everything went well. - return true; - } - - - bool ConverterClient::recvResult(vector<SkyCoord>& skyCoord) - { - // Read the result from the server into the data holder's I/O buffer. - // If the read fails, we may have lost the connection to the server. - if (itsRecvConn.read() == Connection::Error) { - LOG_INFO("ConverterClient::recvResult() - " - "Connection error. Trying to reconnect ..."); - // Try to reconnect. - if (!itsTH.init()) { - THROW (ClientError, "Failed to reconnect to server"); - } - return false; - } - - // Always make this call, even though it only has effect when doing - // asynchronous communication. - itsRecvConn.waitForRead(); - - // Read the conversion result from the I/O buffer into skyCoord - itsResult.readBuf(skyCoord); - - // When we get here, everything went well. - return true; - } - - - } // namespace AMC - -} // namespace LOFAR diff --git a/LCS/AMC/AMCBase/src/AMCClient/BlobIO.cc b/LCS/AMC/AMCBase/src/BlobIO.cc similarity index 70% rename from LCS/AMC/AMCBase/src/AMCClient/BlobIO.cc rename to LCS/AMC/AMCBase/src/BlobIO.cc index 59dd58708eae2dfeaa33649a8596c7a83c24d928..db8fcb92352472496d8d0ba8bdf3b35d294e5426 100644 --- a/LCS/AMC/AMCBase/src/AMCClient/BlobIO.cc +++ b/LCS/AMC/AMCBase/src/BlobIO.cc @@ -24,12 +24,17 @@ #include <lofar_config.h> //# Includes +#include <AMCBase/BlobIO.h> #include <AMCBase/SkyCoord.h> #include <AMCBase/EarthCoord.h> #include <AMCBase/TimeCoord.h> -#include <AMCBase/AMCClient/ConverterCommand.h> +#include <AMCBase/ConverterCommand.h> +#include <AMCBase/ConverterStatus.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> #include <Blob/BlobOStream.h> #include <Blob/BlobIStream.h> +#include <Blob/BlobArray.h> #include <Common/LofarLogger.h> namespace LOFAR @@ -37,6 +42,8 @@ namespace LOFAR namespace AMC { + //# ------- BlobOStream operators ------- #// + BlobOStream& operator<<(BlobOStream& bos, const SkyCoord& sc) { bos << sc.angle0() @@ -67,6 +74,29 @@ namespace LOFAR return bos; } + BlobOStream& operator<<(BlobOStream& bos, const ConverterStatus& cs) + { + bos << static_cast<int32>(cs.get()) + << cs.text(); + return bos; + } + + BlobOStream& operator<<(BlobOStream& bos, const RequestData& req) + { + bos << req.skyCoord + << req.earthCoord + << req.timeCoord; + return bos; + } + + BlobOStream& operator<<(BlobOStream& bos, const ResultData& res) + { + bos << res.skyCoord; + return bos; + } + + + //# ------- BlobIStream operators ------- #// BlobIStream& operator>>(BlobIStream& bis, SkyCoord& sc) { @@ -106,6 +136,28 @@ namespace LOFAR return bis; } + BlobIStream& operator>>(BlobIStream& bis, ConverterStatus& cs) + { + int32 sts; + string txt; + bis >> sts >> txt; + cs = ConverterStatus(static_cast<ConverterStatus::Status>(sts), txt); + return bis; + } + + BlobIStream& operator>>(BlobIStream& bis, RequestData& req) + { + bis >> req.skyCoord >> req.earthCoord >> req.timeCoord; + return bis; + } + + BlobIStream& operator>>(BlobIStream& bis, ResultData& res) + { + bis >> res.skyCoord; + return bis; + } + + } // namespace AMC } // namespace LOFAR diff --git a/LCS/AMC/AMCBase/src/ConverterClient.cc b/LCS/AMC/AMCBase/src/ConverterClient.cc new file mode 100644 index 0000000000000000000000000000000000000000..e959f28fc3ed5294b508e879994de81fefccda57 --- /dev/null +++ b/LCS/AMC/AMCBase/src/ConverterClient.cc @@ -0,0 +1,172 @@ +//# ConverterClient.cc: one line description +//# +//# 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 <AMCBase/ConverterClient.h> +#include <AMCBase/ConverterCommand.h> +#include <AMCBase/ConverterStatus.h> +#include <AMCBase/Exceptions.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> + + +namespace LOFAR +{ + namespace AMC + { + + ConverterClient::ConverterClient(const string& server, uint16 port) : + itsTH(server, toString(port)), + itsSendConn("send", &itsRequest, 0, &itsTH), + itsRecvConn("recv", 0, &itsResult, &itsTH) + { + if (!itsTH.init()) { + THROW (IOException, + "Failed to connect to " << server << " at port " << port); + } + } + + + ConverterClient::~ConverterClient() + { + } + + + void + ConverterClient::j2000ToAzel(ResultData& result, + const RequestData& request) + { + doConvert(result, request, ConverterCommand::J2000toAZEL); + } + + + void + ConverterClient::azelToJ2000(ResultData& result, + const RequestData& request) + { + doConvert(result, request, ConverterCommand::AZELtoJ2000); + } + + + void + ConverterClient::j2000ToItrf(ResultData& result, + const RequestData& request) + { + doConvert(result, request, ConverterCommand::J2000toITRF); + } + + + void + ConverterClient::itrfToJ2000(ResultData& result, + const RequestData& request) + { + doConvert(result, request, ConverterCommand::ITRFtoJ2000); + } + + + + //#################### Private methods ####################// + + void + ConverterClient::doConvert(ResultData& result, + const RequestData& request, + const ConverterCommand& command) + { + ConverterStatus status; + + // Send the request to the server, receive the result from the server. + // If successful, check the return status: throw on error. + if (sendRequest(command, request) && recvResult(status, result)) { + if (!status) THROW (ConverterException, status.text()); + else return; + } + + // If the server has died, we will usually notice this only after the + // receive fails. So, we will give it another try. + if (sendRequest(command, request) && recvResult(status, result)) { + if (!status) THROW (ConverterException, status.text()); + else return; + } + + // When we get here, both tries failed. Trouble! + THROW (IOException, "Server communication failure. Bailing out!"); + } + + + bool ConverterClient::sendRequest(const ConverterCommand& cmd, + const RequestData& req) + { + // Write the conversion request into the data holder's I/O buffer. + itsRequest.writeBuf(cmd, req); + + // Write the request from the data holder's I/O buffer to the server. + // If the write fails, we may have lost the connection to the server. + if (itsSendConn.write() == Connection::Error) { + LOG_DEBUG("ConverterClient::sendRequest() - " + "Connection error. Trying to reconnect ..."); + // Try to reconnect. + if (!itsTH.init()) { + THROW (IOException, "Failed to reconnect to server"); + } + return false; + } + + // Always make this call, even though it only has effect when doing + // asynchronous communication. + itsSendConn.waitForWrite(); + + // When we get here, everything went well. + return true; + } + + + bool ConverterClient::recvResult(ConverterStatus& sts, ResultData& res) + { + // Read the result from the server into the data holder's I/O buffer. + // If the read fails, we may have lost the connection to the server. + if (itsRecvConn.read() == Connection::Error) { + LOG_DEBUG("ConverterClient::recvResult() - " + "Connection error. Trying to reconnect ..."); + // Try to reconnect. + if (!itsTH.init()) { + THROW (IOException, "Failed to reconnect to server"); + } + return false; + } + + // Always make this call, even though it only has effect when doing + // asynchronous communication. + itsRecvConn.waitForRead(); + + // Read the conversion result from the I/O buffer into skyCoord + itsResult.readBuf(sts, res); + + // When we get here, everything went well. + return true; + } + + } // namespace AMC + +} // namespace LOFAR diff --git a/LCS/AMC/AMCBase/src/AMCClient/ConverterCommand.cc b/LCS/AMC/AMCBase/src/ConverterCommand.cc similarity index 87% rename from LCS/AMC/AMCBase/src/AMCClient/ConverterCommand.cc rename to LCS/AMC/AMCBase/src/ConverterCommand.cc index d3e6fabf6e86609f9915d234d8d7a25cd176a853..49cce1652e3f2871ee3f3caa3471443d6cd0ead4 100644 --- a/LCS/AMC/AMCBase/src/AMCClient/ConverterCommand.cc +++ b/LCS/AMC/AMCBase/src/ConverterCommand.cc @@ -1,4 +1,4 @@ -//# ConverterCommand.cc: one line description +//# ConverterCommand.cc: Commands to be sent to the AMC Converter server. //# //# Copyright (C) 2002-2004 //# ASTRON (Netherlands Foundation for Research in Astronomy) @@ -24,8 +24,7 @@ #include <lofar_config.h> //# Includes -#include <AMCBase/AMCClient/ConverterCommand.h> -#include <Common/LofarLogger.h> +#include <AMCBase/ConverterCommand.h> namespace LOFAR { @@ -55,11 +54,17 @@ namespace LOFAR } + bool operator==(const ConverterCommand& lhs, const ConverterCommand& rhs) + { + return lhs.get() == rhs.get(); + } + + ostream& operator<<(ostream& os, const ConverterCommand& cc) { return os << cc.showCommand(); } - } // namespace AMC + } // namespace AMC } // namespace LOFAR diff --git a/LCS/AMC/AMCBase/src/ConverterStatus.cc b/LCS/AMC/AMCBase/src/ConverterStatus.cc new file mode 100644 index 0000000000000000000000000000000000000000..1818b9f203e984e70a5e09f8303555501bd7a916 --- /dev/null +++ b/LCS/AMC/AMCBase/src/ConverterStatus.cc @@ -0,0 +1,65 @@ +//# ConverterStatus.cc: Status that will be returned by the Converter server +//# +//# 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 <AMCBase/ConverterStatus.h> +#include <Common/lofar_iostream.h> + +namespace LOFAR +{ + namespace AMC + { + + ConverterStatus::ConverterStatus(Status sts, const string& txt) : + itsText(txt) + { + if (UNKNOWN < sts && sts < N_Status) itsStatus = sts; + else itsStatus = UNKNOWN; + } + + const string& ConverterStatus::asString() const + { + //# Caution: Always keep this array of strings in sync with the enum + //# Status that is defined in the header file! + static const string stsString[N_Status+1] = { + "Success", + "Converter error", + "Unknown error" //# This line should ALWAYS be last! + }; + if (itsStatus < 0) return stsString[N_Status]; + else return stsString[itsStatus]; + } + + + ostream& operator<<(ostream& os, const ConverterStatus& cs) + { + os << cs.asString(); + if (!cs.text().empty()) os << ": " << cs.text(); + return os; + } + + } // namespace AMC + +} // namespace LOFAR diff --git a/LCS/AMC/AMCBase/src/AMCClient/DH_Request.cc b/LCS/AMC/AMCBase/src/DH_Request.cc similarity index 75% rename from LCS/AMC/AMCBase/src/AMCClient/DH_Request.cc rename to LCS/AMC/AMCBase/src/DH_Request.cc index 76665541cd4e7342c0daf1b2b40570592b70c6ad..459dc006c5904ba14a1d876131c78ae245773b78 100644 --- a/LCS/AMC/AMCBase/src/AMCClient/DH_Request.cc +++ b/LCS/AMC/AMCBase/src/DH_Request.cc @@ -24,24 +24,23 @@ #include <lofar_config.h> //# Includes -#include <AMCBase/AMCClient/DH_Request.h> -#include <AMCBase/AMCClient/BlobIO.h> -#include <AMCBase/AMCClient/ConverterCommand.h> -#include <AMCBase/SkyCoord.h> -#include <AMCBase/EarthCoord.h> -#include <AMCBase/TimeCoord.h> +#include <AMCBase/DH_Request.h> +#include <AMCBase/BlobIO.h> +#include <AMCBase/ConverterCommand.h> +#include <AMCBase/RequestData.h> #include <Blob/BlobOStream.h> #include <Blob/BlobIStream.h> #include <Blob/BlobArray.h> #include <Common/LofarLogger.h> + namespace LOFAR { namespace AMC { // Initialize the verion number of this class. - const int DH_Request::theirVersionNr = 2; + const int DH_Request::theirVersionNr = 3; DH_Request::DH_Request() : DataHolder("aDH_Request", "DH_Request", theirVersionNr) @@ -62,9 +61,7 @@ namespace LOFAR void DH_Request::writeBuf(const ConverterCommand& cmd, - const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) + const RequestData& req) { // Create the output blob that will hold the request data to be sent to // the converter server. @@ -74,17 +71,13 @@ namespace LOFAR // \note We don't need to call putStart() and putEnd() on the blob // stream; this is done by the DataBlobExtra class in the Transport // library. - bos << cmd - << skyCoord - << earthCoord - << timeCoord; + bos << cmd + << req; } void DH_Request::readBuf(ConverterCommand& cmd, - vector<SkyCoord>& skyCoord, - vector<EarthCoord>& earthCoord, - vector<TimeCoord>& timeCoord) + RequestData& req) { // Open the input blob to read the data that were just received from the // converter client. @@ -95,12 +88,9 @@ namespace LOFAR // Make sure we've received the correct version of this class. ASSERT(found && version == theirVersionNr); - // Retrieve the converter command and the vectors of sky, earth, and - // time coordinates. + // Retrieve the converter request. bis >> cmd - >> skyCoord - >> earthCoord - >> timeCoord; + >> req; // Assert that we're really at the end of the blob. bis.getEnd(); @@ -110,7 +100,6 @@ namespace LOFAR DH_Request* DH_Request::clone() const { THROW(Exception, "We should NEVER call this method!"); -// return new DH_Request(*this); } } // namespace AMC diff --git a/LCS/AMC/AMCBase/src/AMCClient/DH_Result.cc b/LCS/AMC/AMCBase/src/DH_Result.cc similarity index 83% rename from LCS/AMC/AMCBase/src/AMCClient/DH_Result.cc rename to LCS/AMC/AMCBase/src/DH_Result.cc index a00f440c77ff1edcde91b61bb195e7644104e59e..abf4fafc93c16b1c4b34883bed861e3651fa08aa 100644 --- a/LCS/AMC/AMCBase/src/AMCClient/DH_Result.cc +++ b/LCS/AMC/AMCBase/src/DH_Result.cc @@ -24,15 +24,14 @@ #include <lofar_config.h> //# Includes -#include <AMCBase/AMCClient/DH_Result.h> -#include <AMCBase/AMCClient/BlobIO.h> -#include <AMCBase/AMCClient/ConverterCommand.h> -#include <AMCBase/SkyCoord.h> -#include <AMCBase/EarthCoord.h> -#include <AMCBase/TimeCoord.h> +#include <AMCBase/DH_Result.h> +#include <AMCBase/BlobIO.h> +#include <AMCBase/ResultData.h> #include <Blob/BlobOStream.h> #include <Blob/BlobIStream.h> #include <Blob/BlobArray.h> +#include <Common/LofarLogger.h> + namespace LOFAR { @@ -40,7 +39,7 @@ namespace LOFAR { // Initialize the verion number of this class. - const int DH_Result::theirVersionNr = 2; + const int DH_Result::theirVersionNr = 3; DH_Result::DH_Result() : DataHolder("aDH_Result", "DH_Result", theirVersionNr) @@ -60,7 +59,8 @@ namespace LOFAR } - void DH_Result::writeBuf(const vector<SkyCoord>& skyCoord) + void DH_Result::writeBuf(const ConverterStatus& sts, + const ResultData& res) { // Create the output blob that will hold the result data to be sent to // the converter client. @@ -70,11 +70,12 @@ namespace LOFAR // \note We don't need to call putStart() and putEnd() on the blob // stream; this is done by the DataBlobExtra class in the Transport // library. - bos << skyCoord; + bos << sts + << res; } - void DH_Result::readBuf(vector<SkyCoord>& skyCoord) + void DH_Result::readBuf(ConverterStatus& sts, ResultData& res) { // Open the input blob to read the data that were just received from the // converter server. @@ -85,8 +86,8 @@ namespace LOFAR // Make sure we've received the correct version of this class. ASSERT(found && version == theirVersionNr); - // Retrieve the vector of sky coordinates - bis >> skyCoord; + // Retrieve the converter result. + bis >> sts >> res; // Assert that we're really at the end of the blob. bis.getEnd(); @@ -96,7 +97,6 @@ namespace LOFAR DH_Result* DH_Result::clone() const { THROW(Exception, "We should NEVER call this method!"); -// return new DH_Result(*this); } } // namespace AMC diff --git a/LCS/AMC/AMCBase/src/Makefile.am b/LCS/AMC/AMCBase/src/Makefile.am index 83a75ce480e639f21e71e580143dcda07cd7b0d0..39d94d4c1af9ad2296fa5a875ceb6acb1ef26094 100644 --- a/LCS/AMC/AMCBase/src/Makefile.am +++ b/LCS/AMC/AMCBase/src/Makefile.am @@ -1,13 +1,14 @@ lib_LTLIBRARIES = libamcbase.la -libamcbase_la_SOURCES = \ +libamcbase_la_SOURCES = \ + BlobIO.cc \ + ConverterClient.cc \ + ConverterCommand.cc \ + ConverterStatus.cc \ + DH_Request.cc \ + DH_Result.cc \ EarthCoord.cc \ SkyCoord.cc \ - TimeCoord.cc \ - AMCClient/BlobIO.cc \ - AMCClient/ConverterClient.cc \ - AMCClient/ConverterCommand.cc \ - AMCClient/DH_Request.cc \ - AMCClient/DH_Result.cc + TimeCoord.cc include $(top_srcdir)/Makefile.common diff --git a/LCS/AMC/AMCBase/test/AMCClient/Makefile.am b/LCS/AMC/AMCBase/test/AMCClient/Makefile.am deleted file mode 100644 index 12b76f27c361ee5ddb4c8d031f49414b286eae25..0000000000000000000000000000000000000000 --- a/LCS/AMC/AMCBase/test/AMCClient/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -check_PROGRAMS = tConverterCommand \ - tBlobIO \ - tDH_Request \ - tDH_Result - -TESTS = tConverterCommand.sh \ - tBlobIO.sh \ - tDH_Request.sh \ - tDH_Result.sh - -tConverterCommand_SOURCES = tConverterCommand.cc -tConverterCommand_LDADD = ../../src/libamcbase.la -tConverterCommand_DEPENDENCIES = ../../src/libamcbase.la $(LOFAR_DEPEND) - -tBlobIO_SOURCES = tBlobIO.cc -tBlobIO_LDADD = ../../src/libamcbase.la -tBlobIO_DEPENDENCIES = ../../src/libamcbase.la $(LOFAR_DEPEND) - -tDH_Request_SOURCES = tDH_Request.cc -tDH_Request_LDADD = ../../src/libamcbase.la -tDH_Request_DEPENDENCIES = ../../src/libamcbase.la $(LOFAR_DEPEND) - -tDH_Result_SOURCES = tDH_Result.cc -tDH_Result_LDADD = ../../src/libamcbase.la -tDH_Result_DEPENDENCIES = ../../src/libamcbase.la $(LOFAR_DEPEND) - -TESTS_ENVIRONMENT = lofar_sharedir=$(lofar_sharedir) \ - LOFARROOT=$(LOFARROOT) - -EXTRA_DIST = $(TESTS) \ - tConverterCommand.stdout - -include $(top_srcdir)/Makefile.common diff --git a/LCS/AMC/AMCBase/test/Makefile.am b/LCS/AMC/AMCBase/test/Makefile.am index c75391296c7229a5e303fd01d9cbabafe4a373e5..f06bc58201e046108372407466e4fdfd745f4874 100644 --- a/LCS/AMC/AMCBase/test/Makefile.am +++ b/LCS/AMC/AMCBase/test/Makefile.am @@ -1,8 +1,11 @@ -SUBDIRS = . AMCClient - check_PROGRAMS = tSkyCoord \ tEarthCoord \ - tTimeCoord + tTimeCoord \ + tConverterCommand \ + tConverterStatus \ + tBlobIO \ + tDH_Request \ + tDH_Result tSkyCoord_SOURCES = tSkyCoord.cc tSkyCoord_LDADD = ../src/libamcbase.la @@ -16,15 +19,42 @@ tTimeCoord_SOURCES = tTimeCoord.cc tTimeCoord_LDADD = ../src/libamcbase.la tTimeCoord_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) +tConverterCommand_SOURCES = tConverterCommand.cc +tConverterCommand_LDADD = ../src/libamcbase.la +tConverterCommand_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) + +tConverterStatus_SOURCES = tConverterStatus.cc +tConverterStatus_LDADD = ../src/libamcbase.la +tConverterStatus_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) + +tBlobIO_SOURCES = tBlobIO.cc +tBlobIO_LDADD = ../src/libamcbase.la +tBlobIO_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) + +tDH_Request_SOURCES = tDH_Request.cc +tDH_Request_LDADD = ../src/libamcbase.la +tDH_Request_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) + +tDH_Result_SOURCES = tDH_Result.cc +tDH_Result_LDADD = ../src/libamcbase.la +tDH_Result_DEPENDENCIES = ../src/libamcbase.la $(LOFAR_DEPEND) + TESTS = tSkyCoord.sh \ tEarthCoord.sh \ - tTimeCoord.sh + tTimeCoord.sh \ + tConverterCommand.sh \ + tConverterStatus.sh \ + tBlobIO.sh \ + tDH_Request.sh \ + tDH_Result.sh TESTS_ENVIRONMENT = lofar_sharedir=$(lofar_sharedir) \ LOFARROOT=$(LOFARROOT) EXTRA_DIST = $(TESTS) \ tSkyCoord.stdout \ - tEarthCoord.stdout + tEarthCoord.stdout \ + tConverterCommand.stdout \ + tConverterStatus.stdout include $(top_srcdir)/Makefile.common diff --git a/LCS/AMC/AMCBase/test/AMCClient/tBlobIO.cc b/LCS/AMC/AMCBase/test/tBlobIO.cc similarity index 77% rename from LCS/AMC/AMCBase/test/AMCClient/tBlobIO.cc rename to LCS/AMC/AMCBase/test/tBlobIO.cc index eaa04d9f77ad28ae7c9c7d1461a938d2c2cb5973..9226003a22d758dc42eeff6400278ba30a6de1f4 100644 --- a/LCS/AMC/AMCBase/test/AMCClient/tBlobIO.cc +++ b/LCS/AMC/AMCBase/test/tBlobIO.cc @@ -24,8 +24,9 @@ #include <lofar_config.h> //# Includes -#include <AMCBase/AMCClient/BlobIO.h> -#include <AMCBase/AMCClient/ConverterCommand.h> +#include <AMCBase/BlobIO.h> +#include <AMCBase/ConverterCommand.h> +#include <AMCBase/ConverterStatus.h> #include <AMCBase/SkyCoord.h> #include <AMCBase/EarthCoord.h> #include <AMCBase/TimeCoord.h> @@ -34,7 +35,6 @@ #include <Blob/BlobOBufChar.h> #include <Blob/BlobOStream.h> #include <Common/LofarLogger.h> - #include <Common/lofar_iomanip.h> using namespace LOFAR; @@ -58,8 +58,30 @@ void test(const ConverterCommand& cco) bis >> cci; bis.getEnd(); - ASSERTSTR(cci.get() == cco.get(), - "cci = " << cci.get() << "; cco = " << cco.get()); + ASSERTSTR(cci == cco, "cci = " << cci << "; cco = " << cco); +} + + +void test(const ConverterStatus& cso) +{ + BlobOBufChar bob; + BlobOStream bos(bob); + + bos.putStart(typeid(ConverterStatus).name(), 1); + bos << cso; + bos.putEnd(); + + BlobIBufChar bib(bob.getBuffer(), bob.size()); + BlobIStream bis(bib); + + ConverterStatus csi; + bis.getStart(typeid(ConverterStatus).name()); + bis >> csi; + bis.getEnd(); + + ASSERTSTR(csi.get() == cso.get() && + csi.text() == cso.text(), + "csi = " << csi << "; cso = " << cso); } @@ -80,10 +102,7 @@ void test(const SkyCoord& sco) bis >> sci; bis.getEnd(); - ASSERTSTR(sci.angle0() == sco.angle0() && - sci.angle1() == sco.angle1() && - sci.type() == sco.type(), - "sci = " << sci << "; sco = " << sco); + ASSERTSTR(sci == sco, "sci = " << sci << "; sco = " << sco); } @@ -104,11 +123,7 @@ void test(const EarthCoord& eco) bis >> eci; bis.getEnd(); - ASSERTSTR(eci.longitude() == eco.longitude() && - eci.latitude() == eco.latitude() && - eci.height() == eco.height() && - eci.type() == eco.type(), - "eci = " << eci << "; eco = " << eco); + ASSERTSTR(eci == eco, "eci = " << eci << "; eco = " << eco); } @@ -156,6 +171,14 @@ int main(int /*argc*/, const char* const argv[]) test(ConverterCommand(static_cast<ConverterCommand::Commands>(1000))); } catch (AssertError& e) {} + test(ConverterStatus()); + test(ConverterStatus(ConverterStatus::UNKNOWN, "Unknown error")); + test(ConverterStatus(ConverterStatus::OK, "Success")); + test(ConverterStatus(ConverterStatus::ERROR, "Converter error")); + // Use of an undefined enumerated value result in UNKNOWN. + test(ConverterStatus(static_cast<ConverterStatus::Status>(1000), + "Undefined error")); + test(SkyCoord()); test(SkyCoord(0.4, -0.19, SkyCoord::ITRF)); test(SkyCoord(-1.2, 2.38, SkyCoord::AZEL)); diff --git a/LCS/AMC/AMCBase/test/AMCClient/tBlobIO.sh b/LCS/AMC/AMCBase/test/tBlobIO.sh similarity index 100% rename from LCS/AMC/AMCBase/test/AMCClient/tBlobIO.sh rename to LCS/AMC/AMCBase/test/tBlobIO.sh diff --git a/LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.cc b/LCS/AMC/AMCBase/test/tConverterCommand.cc similarity index 98% rename from LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.cc rename to LCS/AMC/AMCBase/test/tConverterCommand.cc index 747fde78b91742080fabebda9c70a42cccca0895..59e5023dd3b96efbc36f4df99296d244c284f839 100644 --- a/LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.cc +++ b/LCS/AMC/AMCBase/test/tConverterCommand.cc @@ -24,7 +24,7 @@ #include <lofar_config.h> //# Includes -#include <AMCBase/AMCClient/ConverterCommand.h> +#include <AMCBase/ConverterCommand.h> #include <Common/LofarLogger.h> using namespace LOFAR; diff --git a/LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.sh b/LCS/AMC/AMCBase/test/tConverterCommand.sh similarity index 100% rename from LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.sh rename to LCS/AMC/AMCBase/test/tConverterCommand.sh diff --git a/LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.stdout b/LCS/AMC/AMCBase/test/tConverterCommand.stdout similarity index 100% rename from LCS/AMC/AMCBase/test/AMCClient/tConverterCommand.stdout rename to LCS/AMC/AMCBase/test/tConverterCommand.stdout diff --git a/LCS/AMC/AMCBase/test/tConverterStatus.cc b/LCS/AMC/AMCBase/test/tConverterStatus.cc new file mode 100644 index 0000000000000000000000000000000000000000..7e4acc8be8a078429755f24b08f7f88be9a5a22a --- /dev/null +++ b/LCS/AMC/AMCBase/test/tConverterStatus.cc @@ -0,0 +1,70 @@ +//# tConverterStatus.cc: test program for the ConverterStatus class. +//# +//# 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 <AMCBase/ConverterStatus.h> +#include <Common/LofarLogger.h> + +using namespace LOFAR; +using namespace LOFAR::AMC; + +int main(int /*argc*/, const char* const argv[]) +{ + INIT_LOGGER(argv[0]); + + // These tests should all succeed. + try { + { + ConverterStatus cs; + ASSERT(cs.get() == ConverterStatus::OK); + ASSERT(cs); + cout << cs << endl; + } + { + ConverterStatus cs(ConverterStatus::OK, "OK, keep up the good work"); + ASSERT(cs.get() == ConverterStatus::OK); + ASSERT(cs); + cout << cs << endl; + } + { + ConverterStatus cs(ConverterStatus::ERROR, "This is NOT good!"); + ASSERT(cs.get() == ConverterStatus::ERROR); + ASSERT(!cs); + cout << cs << endl; + } + { + // Force the use of an undefined enumerated value. + ConverterStatus cs(static_cast<ConverterStatus::Status>(18649), + "This should never happen!"); + ASSERT(cs.get() == ConverterStatus::UNKNOWN); + ASSERT(!cs); + cout << cs << endl; + } + } catch (Exception& e) { + cerr << e << endl; + return 1; + } + return 2; // forces assay to flag missing .stdout file as an error +} diff --git a/LCS/AMC/AMCBase/test/tConverterStatus.sh b/LCS/AMC/AMCBase/test/tConverterStatus.sh new file mode 100755 index 0000000000000000000000000000000000000000..9dc1e69f2928eda22e7bc4c98488a8e3c1dcbb7d --- /dev/null +++ b/LCS/AMC/AMCBase/test/tConverterStatus.sh @@ -0,0 +1,2 @@ +#!/bin/sh +$lofar_sharedir/runtest.sh tConverterStatus 2>&1 > tConverterStatus.log diff --git a/LCS/AMC/AMCBase/test/tConverterStatus.stdout b/LCS/AMC/AMCBase/test/tConverterStatus.stdout new file mode 100644 index 0000000000000000000000000000000000000000..d54a35452d2df57156fb008f28edeebc76a737b1 --- /dev/null +++ b/LCS/AMC/AMCBase/test/tConverterStatus.stdout @@ -0,0 +1,4 @@ +Success +Success: OK, keep up the good work +Converter error: This is NOT good! +Unknown error: This should never happen! diff --git a/LCS/AMC/AMCBase/test/AMCClient/tDH_Request.cc b/LCS/AMC/AMCBase/test/tDH_Request.cc similarity index 66% rename from LCS/AMC/AMCBase/test/AMCClient/tDH_Request.cc rename to LCS/AMC/AMCBase/test/tDH_Request.cc index 1cd989f2be55cc5eeb68b4a39eb5055c2f7c06a9..1239b298893ab2072e25326faaf970619e8c3942 100644 --- a/LCS/AMC/AMCBase/test/AMCClient/tDH_Request.cc +++ b/LCS/AMC/AMCBase/test/tDH_Request.cc @@ -24,14 +24,16 @@ #include <lofar_config.h> //# Includes -#include <Common/LofarLogger.h> -#include <AMCBase/AMCClient/DH_Request.h> -#include <AMCBase/AMCClient/ConverterCommand.h> +#include <AMCBase/DH_Request.h> +#include <AMCBase/ConverterCommand.h> #include <AMCBase/SkyCoord.h> #include <AMCBase/EarthCoord.h> #include <AMCBase/TimeCoord.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> #include <Transport/TH_Mem.h> #include <Transport/Connection.h> +#include <Common/LofarLogger.h> using namespace LOFAR; using namespace LOFAR::AMC; @@ -42,9 +44,8 @@ int main(int /*argc*/, const char* const argv[]) try { - double usec = 1e-6; - ConverterCommand sendCmd(ConverterCommand::J2000toAZEL); + vector<SkyCoord> sendSky; sendSky.push_back(SkyCoord()); sendSky.push_back(SkyCoord(0.4, -0.19)); @@ -58,39 +59,37 @@ int main(int /*argc*/, const char* const argv[]) sendTime.push_back(TimeCoord()); sendTime.push_back(TimeCoord(0)); - TH_Mem aTH; - DH_Request sendReq; - DH_Request recvReq; - Connection conn("conn", &sendReq, &recvReq, &aTH, false); - - sendReq.writeBuf(sendCmd, sendSky, sendEarth, sendTime); - conn.write(); - ConverterCommand recvCmd; vector<SkyCoord> recvSky; vector<EarthCoord> recvEarth; vector<TimeCoord> recvTime; + TH_Mem aTH; + DH_Request sendDhReq; + DH_Request recvDhReq; + Connection conn("conn", &sendDhReq, &recvDhReq, &aTH, false); + + RequestData sendReqData(sendSky, sendEarth, sendTime); + RequestData recvReqData(recvSky, recvEarth, recvTime); + + sendDhReq.writeBuf(sendCmd, sendReqData); + conn.write(); conn.read(); - recvReq.readBuf(recvCmd, recvSky, recvEarth, recvTime); + recvDhReq.readBuf(recvCmd, recvReqData); - ASSERT(sendCmd.get() == recvCmd.get()); - ASSERT(sendSky.size() == recvSky.size()); - for (uint i=0; i < sendSky.size(); ++i) { - ASSERT(sendSky[i].angle0() == recvSky[i].angle0()); - ASSERT(sendSky[i].angle1() == recvSky[i].angle1()); + ASSERT(sendCmd == recvCmd); + ASSERT(sendReqData.skyCoord.size() == recvReqData.skyCoord.size()); + for (uint i=0; i < sendReqData.skyCoord.size(); ++i) { + ASSERT(sendReqData.skyCoord[i] == recvReqData.skyCoord[i]); } - ASSERT(sendEarth.size() == recvEarth.size()); - for (uint i=0; i < sendEarth.size(); ++i) { - ASSERT(sendEarth[i].longitude() == recvEarth[i].longitude()); - ASSERT(sendEarth[i].latitude() == recvEarth[i].latitude()); - ASSERT(sendEarth[i].height() == recvEarth[i].height()); + ASSERT(sendReqData.earthCoord.size() == recvReqData.earthCoord.size()); + for (uint i=0; i < sendReqData.earthCoord.size(); ++i) { + ASSERT(sendReqData.earthCoord[i] == recvReqData.earthCoord[i]); } - ASSERT(sendTime.size() == recvTime.size()); - for (uint i=0; i < sendTime.size(); ++i) { - ASSERT(sendTime[i].mjd() - recvTime[i].mjd() < usec); + ASSERT(sendReqData.timeCoord.size() == recvReqData.timeCoord.size()); + for (uint i=0; i < sendReqData.timeCoord.size(); ++i) { + ASSERT(sendReqData.timeCoord[i] == recvReqData.timeCoord[i]); } - } catch (Exception& e) { cerr << e << endl; diff --git a/LCS/AMC/AMCBase/test/AMCClient/tDH_Request.sh b/LCS/AMC/AMCBase/test/tDH_Request.sh similarity index 100% rename from LCS/AMC/AMCBase/test/AMCClient/tDH_Request.sh rename to LCS/AMC/AMCBase/test/tDH_Request.sh diff --git a/LCS/AMC/AMCBase/test/AMCClient/tDH_Result.cc b/LCS/AMC/AMCBase/test/tDH_Result.cc similarity index 66% rename from LCS/AMC/AMCBase/test/AMCClient/tDH_Result.cc rename to LCS/AMC/AMCBase/test/tDH_Result.cc index 3797c8f4a995b68b0160ba7fb9e6c4808faa3e29..182a04b1b01a3c555cd9163345c6e2f6e40cb433 100644 --- a/LCS/AMC/AMCBase/test/AMCClient/tDH_Result.cc +++ b/LCS/AMC/AMCBase/test/tDH_Result.cc @@ -25,8 +25,11 @@ //# Includes #include <Common/LofarLogger.h> -#include <AMCBase/AMCClient/DH_Result.h> +#include <AMCBase/ConverterStatus.h> +#include <AMCBase/DH_Result.h> #include <AMCBase/SkyCoord.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> #include <Transport/TH_Mem.h> #include <Transport/Connection.h> @@ -39,31 +42,34 @@ int main(int /*argc*/, const char* const argv[]) try { + ConverterStatus sendStat(ConverterStatus::ERROR, "Uh-oh, oops!"); + vector<SkyCoord> sendSky; sendSky.push_back(SkyCoord()); sendSky.push_back(SkyCoord(0.4, -0.19)); - - TH_Mem aTH; - DH_Result sendReq; - DH_Result recvReq; - Connection conn("conn", &sendReq, &recvReq, &aTH, false); - - sendReq.writeBuf(sendSky); - conn.write(); -// sendConn.waitForWrite(); // !!?? no TH_Mem::waitForSent() ??!! + ConverterStatus recvStat; vector<SkyCoord> recvSky; + TH_Mem aTH; + DH_Result sendDhRes; + DH_Result recvDhRes; + Connection conn("conn", &sendDhRes, &recvDhRes, &aTH, false); + + ResultData sendResData(sendSky); + ResultData recvResData(recvSky); + + sendDhRes.writeBuf(sendStat, sendResData); + conn.write(); conn.read(); -// recvConn.waitForRead(); - recvReq.readBuf(recvSky); + recvDhRes.readBuf(recvStat, recvResData); - ASSERT(sendSky.size() == recvSky.size()); - for (uint i=0; i < sendSky.size(); ++i) { - ASSERT(sendSky[i].angle0() == recvSky[i].angle0()); - ASSERT(sendSky[i].angle1() == recvSky[i].angle1()); + ASSERT(sendStat.get() == recvStat.get() && + sendStat.text() == recvStat.text()); + ASSERT(sendResData.skyCoord.size() == recvResData.skyCoord.size()); + for (uint i=0; i < sendResData.skyCoord.size(); ++i) { + ASSERT(sendResData.skyCoord[i] == recvResData.skyCoord[i]); } - } catch (Exception& e) { cerr << e << endl; diff --git a/LCS/AMC/AMCBase/test/AMCClient/tDH_Result.sh b/LCS/AMC/AMCBase/test/tDH_Result.sh similarity index 100% rename from LCS/AMC/AMCBase/test/AMCClient/tDH_Result.sh rename to LCS/AMC/AMCBase/test/tDH_Result.sh diff --git a/LCS/AMC/AMCImpl/configure.in b/LCS/AMC/AMCImpl/configure.in index 120db6658ddf748d2d07e69273be419102df998b..b741ba6378fe9387dd99e9c885a195632cb40204 100644 --- a/LCS/AMC/AMCImpl/configure.in +++ b/LCS/AMC/AMCImpl/configure.in @@ -2,7 +2,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AM_INIT_AUTOMAKE(AMCImpl, 1.1, no-define) +AM_INIT_AUTOMAKE(AMCImpl, 2.0, no-define) AM_CONFIG_HEADER(config.h) dnl AX_PREFIX_CONFIG_H([lofar-config.h], []) @@ -53,9 +53,9 @@ dnl Check for LOFAR specific things dnl lofar_GENERAL lofar_AIPSPP(1) -lofar_INTERNAL(LCS/Common,Common,,1,Common/LofarTypedefs.h,,) -lofar_INTERNAL(LCS/Transport,Transport,,1,Transport/TransportHolder.h,,) -lofar_INTERNAL(LCS/AMC/AMCBase,AMCBase,,1,AMCBase/Converter.h,,) +lofar_INTERNAL(LCS/Common,Common,LCS-Common-3_1,1,Common/LofarTypedefs.h,,) +lofar_INTERNAL(LCS/Transport,Transport,LCS-Transport-2_3,1,Transport/TransportHolder.h,,) +lofar_INTERNAL(LCS/AMC/AMCBase,AMCBase,LCS-AMC-2_0,1,AMCBase/Converter.h,,) dnl dnl Output Makefiles diff --git a/LCS/AMC/AMCImpl/include/AMCImpl/ConverterImpl.h b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterImpl.h index ecbfc17f51f8b7698159132cc726426f3229ee5c..e4e29b8c3a7c177a8b33a53418e59b017e1faa03 100644 --- a/LCS/AMC/AMCImpl/include/AMCImpl/ConverterImpl.h +++ b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterImpl.h @@ -35,6 +35,10 @@ namespace LOFAR { namespace AMC { + //# Forward declarations + struct RequestData; + struct ResultData; + // \addtogroup AMCImpl // @{ @@ -47,72 +51,13 @@ namespace LOFAR virtual ~ConverterImpl() {} - virtual SkyCoord j2000ToAzel(const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToAzel (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToAzel (const SkyCoord& dir, - const vector<EarthCoord>& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToAzel (const SkyCoord& dir, - const EarthCoord& pos, - const vector<TimeCoord>& time); - - virtual vector<SkyCoord> j2000ToAzel (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time); - - virtual SkyCoord azelToJ2000 (const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> azelToJ2000 (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> azelToJ2000 (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time); - - virtual SkyCoord j2000ToItrf(const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToItrf (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToItrf (const SkyCoord& dir, - const vector<EarthCoord>& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> j2000ToItrf (const SkyCoord& dir, - const EarthCoord& pos, - const vector<TimeCoord>& time); - - virtual vector<SkyCoord> j2000ToItrf (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time); - - virtual SkyCoord itrfToJ2000 (const SkyCoord& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> itrfToJ2000 (const vector<SkyCoord>& dir, - const EarthCoord& pos, - const TimeCoord& time); - - virtual vector<SkyCoord> itrfToJ2000 (const vector<SkyCoord>& dir, - const vector<EarthCoord>& pos, - const vector<TimeCoord>& time); - - private: - + virtual void j2000ToAzel(ResultData&, const RequestData&); + + virtual void azelToJ2000(ResultData&, const RequestData&); + + virtual void j2000ToItrf(ResultData&, const RequestData&); + + virtual void itrfToJ2000(ResultData&, const RequestData&); }; // @} diff --git a/LCS/AMC/AMCImpl/include/AMCImpl/ConverterProcess.h b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterProcess.h new file mode 100644 index 0000000000000000000000000000000000000000..3687eeb0984bb6994541a14dc6d95fc1cef62cc1 --- /dev/null +++ b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterProcess.h @@ -0,0 +1,104 @@ +//# ConverterProcess.h: process client conversion requests. +//# +//# 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_AMCIMPL_CONVERTERPROCESS_H +#define LOFAR_AMCIMPL_CONVERTERPROCESS_H + +// \file +// Process client conversion requests + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <AMCImpl/ConverterImpl.h> +#include <AMCBase/DH_Request.h> +#include <AMCBase/DH_Result.h> +#include <Transport/Connection.h> +#include <Transport/TH_Socket.h> +#include <Common/Process.h> + +namespace LOFAR +{ + //# Forward declarations. + class ConverterCommand; + class SkyCoord; + class EarthCoord; + class TimeCoord; + + namespace AMC + { + + // \addtogroup AMCImpl + // @{ + + // This class processes the conversion requests it receives from a + // ConverterClient. Whenever the ConverterServer accepts an incoming + // client connection, it creates a new ConverterProcess object and spawns + // a new process. In the new process the handleRequests() method of the + // newly create ConverterProcess object is called; this method will handle + // all client requests until the client disconnects. + class ConverterProcess : public Process + { + public: + // Constructor. \a aSocket must be a data socket + explicit ConverterProcess(Socket* aSocket); + + // Destructor. + virtual ~ConverterProcess(); + + // Handle all incoming conversion requests until the clients disconnects. + void handleRequests(); + + private: + // Receive the conversion request from the client. + bool recvRequest(ConverterCommand&, RequestData&); + + // Send the conversion result to the client. + bool sendResult(const ConverterStatus&, const ResultData&); + + // Data holder holding the request data to be sent to the server. + DH_Request itsRequest; + + // Data holder holding the result data to be received from the server. + DH_Result itsResult; + + // The transport holder (which is, of course, a TH_Socket) + TH_Socket itsTH; + + // Connection for sending data to the server. + Connection itsSendConn; + + // Connection for receiving data from the server. + Connection itsRecvConn; + + // Implementation of the Converter interface. + ConverterImpl itsConverter; + + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCImpl/include/AMCImpl/ConverterServer.h b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterServer.h new file mode 100644 index 0000000000000000000000000000000000000000..113d8297b9eb9622d81569d2a1f9e61e48e84fbc --- /dev/null +++ b/LCS/AMC/AMCImpl/include/AMCImpl/ConverterServer.h @@ -0,0 +1,92 @@ +//# ConverterServer.h: server side of the AMC client/server implementation. +//# +//# 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_AMCIMPL_CONVERTERSERVER_H +#define LOFAR_AMCIMPL_CONVERTERSERVER_H + +// \file +// Server side of the AMC client/server implementation + +//# Never #include <config.h> or #include <lofar_config.h> in a header file! + +//# Includes +#include <Common/LofarTypes.h> +#include <Common/Net/Socket.h> + +namespace LOFAR +{ + namespace AMC + { + + // \addtogroup AMCImpl + // @{ + + // This class represents the server side of the client/server + // implementation of the AMC. Its main purpose is to handle incoming + // connection requests from ConverterClient objects. It does \e not + // implement the Converter interface. + // + // Whenever the server accepts a connection, it immediately creates a new + // ConverterProcess object and spawns the current process. The newly + // created process will then handle all client requests until the client + // disconnects. The server will continue listening for incoming + // connections requests. + class ConverterServer + { + public: + // Constructor. The server will by default use port 31337 to listen for + // client connection requests. + explicit ConverterServer(uint16 port = 31337); + + // Destructor. + ~ConverterServer(); + + // Start running the event-loop. The event loop will continuously call + // the handleConnections() method, which blocks until it receives a + // connection request. + void run(); + + private: + //@{ + // Make this class non-copyable. + ConverterServer(const ConverterServer&); + ConverterServer& operator=(const ConverterServer&); + //@} + + // This method handles incoming connection requests. It blocks until it + // receives a connection request. For each connection a new process is + // spawned that will further handle any coordinate conversion requests, + // until the client side closes the connection. + void handleConnections(); + + // On this socket we will be listening for incoming connection requests. + Socket itsListenSocket; + + }; + + // @} + + } // namespace AMC + +} // namespace LOFAR + +#endif diff --git a/LCS/AMC/AMCImpl/include/AMCImpl/Makefile.am b/LCS/AMC/AMCImpl/include/AMCImpl/Makefile.am index 710b366029d642168f6b1a96b82b54663579272c..3f2371118fc1db89359cbe63681ef7eaf349a848 100644 --- a/LCS/AMC/AMCImpl/include/AMCImpl/Makefile.am +++ b/LCS/AMC/AMCImpl/include/AMCImpl/Makefile.am @@ -1,11 +1,6 @@ -pkginclude_AMCServerdir = $(pkgincludedir)/AMCServer - pkginclude_HEADERS = \ ConverterImpl.h \ - Exceptions.h - -pkginclude_AMCServer_HEADERS = \ - AMCServer/ConverterProcess.h \ - AMCServer/ConverterServer.h + ConverterProcess.h \ + ConverterServer.h include $(top_srcdir)/Makefile.common diff --git a/LCS/AMC/AMCImpl/src/ConverterImpl.cc b/LCS/AMC/AMCImpl/src/ConverterImpl.cc index a08cb87783d58a7e740786293098494cbf663937..6e81fb79f72f1353c5fb5ef3af395c4b87292633 100644 --- a/LCS/AMC/AMCImpl/src/ConverterImpl.cc +++ b/LCS/AMC/AMCImpl/src/ConverterImpl.cc @@ -25,10 +25,9 @@ //# Includes #include <AMCImpl/ConverterImpl.h> -#include <AMCImpl/Exceptions.h> -#include <AMCBase/SkyCoord.h> -#include <AMCBase/EarthCoord.h> -#include <AMCBase/TimeCoord.h> +#include <AMCBase/Exceptions.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> #include <Common/LofarLogger.h> #include <measures/Measures/MDirection.h> #include <measures/Measures/MEpoch.h> @@ -48,89 +47,46 @@ namespace LOFAR } - SkyCoord - ConverterImpl::j2000ToAzel (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) + void + ConverterImpl::j2000ToAzel (ResultData& out, + const RequestData& in) { - return j2000ToAzel (vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterImpl::j2000ToAzel (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return j2000ToAzel(skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterImpl::j2000ToAzel (const SkyCoord& skyCoord, - const vector<EarthCoord>& earthCoord, - const TimeCoord& timeCoord) - { - return j2000ToAzel(vector<SkyCoord> (1, skyCoord), - earthCoord, - vector<TimeCoord>(1, timeCoord)); - } - - - vector<SkyCoord> - ConverterImpl::j2000ToAzel (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return j2000ToAzel(vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - timeCoord); - } - + // Initialize the result data + out = ResultData(); - vector<SkyCoord> - ConverterImpl::j2000ToAzel (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { // Check pre-conditions. // -# skyCoord type must be J2000 // -# earthCoord types must be equal - for (uint i = 0; i < skyCoord.size(); ++i) { - ASSERT(skyCoord[i].type() == SkyCoord::J2000); + for (uint i = 0; i < in.skyCoord.size(); ++i) { + ASSERT(in.skyCoord[i].type() == SkyCoord::J2000); } - for (uint i = 1; i < earthCoord.size(); ++i) { - ASSERT(earthCoord[i].type() == earthCoord[0].type()); + for (uint i = 1; i < in.earthCoord.size(); ++i) { + ASSERT(in.earthCoord[i].type() == in.earthCoord[0].type()); } - // This vector will hold the result of the conversion operation. - vector<SkyCoord> result; - // If any of the input vectors has zero length, we can return // immediately. - if (skyCoord.size() == 0 || - earthCoord.size() == 0 || - timeCoord.size() == 0) - return result; + if (in.skyCoord.size() == 0 || + in.earthCoord.size() == 0 || + in.timeCoord.size() == 0) + return; // Reserve space for the result to avoid resizing of the vector. - result.reserve(skyCoord.size() * earthCoord.size() * timeCoord.size()); + out.skyCoord.reserve(in.skyCoord.size() * + in.earthCoord.size() * + in.timeCoord.size()); // Precalculate the positions on earth; they do not change with time. - vector<MVPosition> pos(earthCoord.size()); + vector<MVPosition> pos(in.earthCoord.size()); for (uint i = 0; i < pos.size(); i++) { - pos[i] = MVPosition((Quantity(earthCoord[i].height(), "m")), - (Quantity(earthCoord[i].longitude(), "rad")), - (Quantity(earthCoord[i].latitude(), "rad"))); + pos[i] = MVPosition((Quantity(in.earthCoord[i].height(), "m")), + (Quantity(in.earthCoord[i].longitude(), "rad")), + (Quantity(in.earthCoord[i].latitude(), "rad"))); } // Determine the position reference. MPosition::Types posref; - switch(earthCoord[0].type()) { + switch(in.earthCoord[0].type()) { case EarthCoord::ITRF: posref = MPosition::ITRF; break; @@ -138,8 +94,8 @@ namespace LOFAR posref = MPosition::WGS84; break; default: - THROW(ConverterError, "Invalid EarthCoord type: " - << earthCoord[0].type()); + THROW(ConverterException, "Invalid EarthCoord type: " + << in.earthCoord[0].type()); } try { @@ -148,8 +104,8 @@ namespace LOFAR MeasFrame frame; // Set initial epoch for the frame, using UTC (default) as reference. - frame.set(MEpoch(MVEpoch(timeCoord[0].getDay(), - timeCoord[0].getFraction()))); + frame.set(MEpoch(MVEpoch(in.timeCoord[0].getDay(), + in.timeCoord[0].getFraction()))); // Set initial position for the frame, using the appropriate reference. frame.set(MPosition(pos[0], posref)); @@ -159,23 +115,24 @@ namespace LOFAR MDirection::Ref (MDirection::AZEL, frame)); // For each given moment in time ... - for (uint i = 0; i < timeCoord.size(); i++) { + for (uint i = 0; i < in.timeCoord.size(); i++) { // Set the instant in time in the frame. - frame.resetEpoch(MVEpoch(timeCoord[i].getDay(), - timeCoord[i].getFraction())); + frame.resetEpoch(MVEpoch(in.timeCoord[i].getDay(), + in.timeCoord[i].getFraction())); // For each given position on earth ... - for (uint j = 0; j < earthCoord.size(); j++) { + for (uint j = 0; j < in.earthCoord.size(); j++) { // Set the position on earth in the frame. frame.resetPosition(pos[j]); // For each given direction in the sky ... - for (uint k = 0; k < skyCoord.size(); k++) { + for (uint k = 0; k < in.skyCoord.size(); k++) { // Define the astronomical direction as a J2000 direction. - MVDirection sky(skyCoord[k].angle0(), skyCoord[k].angle1()); + MVDirection sky(in.skyCoord[k].angle0(), + in.skyCoord[k].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -184,7 +141,8 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::AZEL)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::AZEL)); } } @@ -192,46 +150,26 @@ namespace LOFAR } catch (AipsError& e) { - THROW (ConverterError, "AipsError: " << e.what()); + THROW (ConverterException, "AipsError: " << e.what()); } // Check on post-condition that the return vector contains // <tt>skyCoord.size() * earthCoord.size() * timeCoord.size()</tt> // elements. - ASSERT (result.size() == - skyCoord.size() * earthCoord.size() * timeCoord.size()); - - return result; - } + ASSERT (out.skyCoord.size() == + in.skyCoord.size() * in.earthCoord.size() * in.timeCoord.size()); - - SkyCoord - ConverterImpl::azelToJ2000 (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return azelToJ2000(vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; + return; } - vector<SkyCoord> - ConverterImpl::azelToJ2000 (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) + void + ConverterImpl::azelToJ2000 (ResultData& out, + const RequestData& in) { - return azelToJ2000(skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } + // Initialize the result data + out = ResultData(); - - vector<SkyCoord> - ConverterImpl::azelToJ2000 (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { // Check pre-conditions. // -# \a earthCoord and \a timeCoord must have equal sizes; // -# if \a earthCoord and \a timeCoord have sizes unequal to one, then @@ -240,34 +178,31 @@ namespace LOFAR // pre-condition. // -# skyCoord type must be AZEL // -# earthCoord types must be the equal - ASSERT (earthCoord.size() == timeCoord.size()); - if (earthCoord.size() != 1) { - ASSERT (earthCoord.size() == skyCoord.size()); + ASSERT (in.earthCoord.size() == in.timeCoord.size()); + if (in.earthCoord.size() != 1) { + ASSERT (in.earthCoord.size() == in.skyCoord.size()); } - for (uint i = 0; i < skyCoord.size(); ++i) { - ASSERT (skyCoord[i].type() == SkyCoord::AZEL); + for (uint i = 0; i < in.skyCoord.size(); ++i) { + ASSERT (in.skyCoord[i].type() == SkyCoord::AZEL); } - for (uint i = 1; i < earthCoord.size(); ++i) { - ASSERT (earthCoord[i].type() == earthCoord[0].type()); + for (uint i = 1; i < in.earthCoord.size(); ++i) { + ASSERT (in.earthCoord[i].type() == in.earthCoord[0].type()); } - // This vector will hold the result of the conversion operation. - vector<SkyCoord> result; - // Reserve space for the result to avoid resizing of the vector. - result.reserve(skyCoord.size()); + out.skyCoord.reserve(in.skyCoord.size()); // Precalculate the positions on earth; they do not change with time. - vector<MVPosition> pos(earthCoord.size()); + vector<MVPosition> pos(in.earthCoord.size()); for (uint i = 0; i < pos.size(); i++) { - pos[i] = MVPosition((Quantity(earthCoord[i].height(), "m")), - (Quantity(earthCoord[i].longitude(), "rad")), - (Quantity(earthCoord[i].latitude(), "rad"))); + pos[i] = MVPosition((Quantity(in.earthCoord[i].height(), "m")), + (Quantity(in.earthCoord[i].longitude(), "rad")), + (Quantity(in.earthCoord[i].latitude(), "rad"))); } // Determine the position reference. MPosition::Types posref; - switch(earthCoord[0].type()) { + switch(in.earthCoord[0].type()) { case EarthCoord::ITRF: posref = MPosition::ITRF; break; @@ -275,8 +210,8 @@ namespace LOFAR posref = MPosition::WGS84; break; default: - THROW(ConverterError, "Invalid EarthCoord type: " - << earthCoord[0].type()); + THROW(ConverterException, "Invalid EarthCoord type: " + << in.earthCoord[0].type()); } try { @@ -285,8 +220,8 @@ namespace LOFAR MeasFrame frame; // Set initial epoch for the frame, using UTC (default) as reference. - frame.set(MEpoch(MVEpoch(timeCoord[0].getDay(), - timeCoord[0].getFraction()))); + frame.set(MEpoch(MVEpoch(in.timeCoord[0].getDay(), + in.timeCoord[0].getFraction()))); // Set initial position for the frame, using the appropriate reference. frame.set(MPosition(pos[0], posref)); @@ -297,13 +232,13 @@ namespace LOFAR // If there's only one earthCoord and one timeCoord, we only need to // loop over all \a skyCoord values. - if (timeCoord.size() == 1) { + if (in.timeCoord.size() == 1) { // For each given direction in the sky ... - for (uint i = 0; i < skyCoord.size(); i++) { + for (uint i = 0; i < in.skyCoord.size(); i++) { // Define the astronomical direction w.r.t. the reference frame. - MVDirection sky(skyCoord[i].angle0(), skyCoord[i].angle1()); + MVDirection sky(in.skyCoord[i].angle0(), in.skyCoord[i].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -312,7 +247,8 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::J2000)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::J2000)); } } @@ -321,17 +257,17 @@ namespace LOFAR else { // For each triplet ... - for (uint i = 0; i < skyCoord.size(); i++) { + for (uint i = 0; i < in.skyCoord.size(); i++) { // Set the instant in time in the frame. - frame.resetEpoch(MVEpoch(timeCoord[i].getDay(), - timeCoord[i].getFraction())); + frame.resetEpoch(MVEpoch(in.timeCoord[i].getDay(), + in.timeCoord[i].getFraction())); // Set the position on earth in the frame. frame.resetPosition(pos[i]); // Define the astronomical direction w.r.t. the reference frame. - MVDirection sky(skyCoord[i].angle0(), skyCoord[i].angle1()); + MVDirection sky(in.skyCoord[i].angle0(), in.skyCoord[i].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -340,107 +276,64 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::J2000)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::J2000)); } } } catch (AipsError& e) { - THROW (ConverterError, "AipsError: " << e.what()); + THROW (ConverterException, "AipsError: " << e.what()); } // Check post-condition. - ASSERT(result.size() == skyCoord.size()); + ASSERT(out.skyCoord.size() == in.skyCoord.size()); - // Return the result vector. - return result; + return; } - SkyCoord - ConverterImpl::j2000ToItrf(const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) + void + ConverterImpl::j2000ToItrf (ResultData& out, + const RequestData& in) { - return j2000ToItrf(vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; - } - - - vector<SkyCoord> - ConverterImpl::j2000ToItrf (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return j2000ToItrf(skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterImpl::j2000ToItrf (const SkyCoord& skyCoord, - const vector<EarthCoord>& earthCoord, - const TimeCoord& timeCoord) - { - return j2000ToItrf(vector<SkyCoord> (1, skyCoord), - earthCoord, - vector<TimeCoord> (1, timeCoord)); - } - - - vector<SkyCoord> - ConverterImpl::j2000ToItrf (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const vector<TimeCoord>& timeCoord) - { - return j2000ToItrf(vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - timeCoord); - } - + // Initialize the result data + out = ResultData(); - vector<SkyCoord> - ConverterImpl::j2000ToItrf (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { // Check pre-conditions. // -# skyCoord type must be J2000 // -# earthCoord types must be equal - for (uint i=0; i<skyCoord.size(); ++i) { - ASSERT(skyCoord[i].type() == SkyCoord::J2000); + for (uint i = 0; i < in.skyCoord.size(); ++i) { + ASSERT(in.skyCoord[i].type() == SkyCoord::J2000); } - for (uint i = 1; i < earthCoord.size(); ++i) { - ASSERT(earthCoord[i].type() == earthCoord[0].type()); + for (uint i = 1; i < in.earthCoord.size(); ++i) { + ASSERT(in.earthCoord[i].type() == in.earthCoord[0].type()); } - // This vector will hold the result of the conversion operation. - vector<SkyCoord> result; - // If any of the input vectors has zero length, we can return // immediately. - if (skyCoord.size() == 0 || - earthCoord.size() == 0 || - timeCoord.size() == 0) - return result; + if (in.skyCoord.size() == 0 || + in.earthCoord.size() == 0 || + in.timeCoord.size() == 0) + return; // Reserve space for the result to avoid resizing of the vector. - result.reserve(skyCoord.size() * earthCoord.size() * timeCoord.size()); + out.skyCoord.reserve(in.skyCoord.size() * + in.earthCoord.size() * + in.timeCoord.size()); // Precalculate the positions on earth; they do not change with time. - vector<MVPosition> pos(earthCoord.size()); + vector<MVPosition> pos(in.earthCoord.size()); for (uint i = 0; i < pos.size(); i++) { - pos[i] = MVPosition((Quantity(earthCoord[i].height(), "m")), - (Quantity(earthCoord[i].longitude(), "rad")), - (Quantity(earthCoord[i].latitude(), "rad"))); + pos[i] = MVPosition((Quantity(in.earthCoord[i].height(), "m")), + (Quantity(in.earthCoord[i].longitude(), "rad")), + (Quantity(in.earthCoord[i].latitude(), "rad"))); } // Determine the position reference. MPosition::Types posref; - switch(earthCoord[0].type()) { + switch(in.earthCoord[0].type()) { case EarthCoord::ITRF: posref = MPosition::ITRF; break; @@ -448,8 +341,8 @@ namespace LOFAR posref = MPosition::WGS84; break; default: - THROW(ConverterError, "Invalid EarthCoord type: " - << earthCoord[0].type()); + THROW(ConverterException, "Invalid EarthCoord type: " + << in.earthCoord[0].type()); } try { @@ -458,8 +351,8 @@ namespace LOFAR MeasFrame frame; // Set initial epoch for the frame, using UTC (default) as reference. - frame.set(MEpoch(MVEpoch(timeCoord[0].getDay(), - timeCoord[0].getFraction()))); + frame.set(MEpoch(MVEpoch(in.timeCoord[0].getDay(), + in.timeCoord[0].getFraction()))); // Set initial position for the frame, using the appropriate reference. frame.set(MPosition(pos[0], posref)); @@ -469,23 +362,24 @@ namespace LOFAR MDirection::Ref (MDirection::ITRF, frame)); // For each given moment in time ... - for (uint i = 0; i < timeCoord.size(); i++) { + for (uint i = 0; i < in.timeCoord.size(); i++) { // Set the instant in time in the frame. - frame.resetEpoch(MVEpoch(timeCoord[i].getDay(), - timeCoord[i].getFraction())); + frame.resetEpoch(MVEpoch(in.timeCoord[i].getDay(), + in.timeCoord[i].getFraction())); // For each given position on earth ... - for (uint j = 0; j < earthCoord.size(); j++) { + for (uint j = 0; j < in.earthCoord.size(); j++) { // Set the position on earth in the frame. frame.resetPosition(pos[j]); // For each given direction in the sky ... - for (uint k = 0; k < skyCoord.size(); k++) { + for (uint k = 0; k < in.skyCoord.size(); k++) { // Define the astronomical direction as a J2000 direction. - MVDirection sky(skyCoord[k].angle0(), skyCoord[k].angle1()); + MVDirection sky(in.skyCoord[k].angle0(), + in.skyCoord[k].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -494,7 +388,8 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::ITRF)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::ITRF)); } } @@ -502,46 +397,26 @@ namespace LOFAR } catch (AipsError& e) { - THROW (ConverterError, "AipsError: " << e.what()); + THROW (ConverterException, "AipsError: " << e.what()); } // Check on post-condition that the return vector contains // <tt>skyCoord.size() * earthCoord.size() * timeCoord.size()</tt> // elements. - ASSERT (result.size() == - skyCoord.size() * earthCoord.size() * timeCoord.size()); - - return result; - } + ASSERT (out.skyCoord.size() == + in.skyCoord.size() * in.earthCoord.size() * in.timeCoord.size()); - - SkyCoord - ConverterImpl::itrfToJ2000 (const SkyCoord& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) - { - return itrfToJ2000(vector<SkyCoord> (1, skyCoord), - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)) [0]; + return; } - vector<SkyCoord> - ConverterImpl::itrfToJ2000 (const vector<SkyCoord>& skyCoord, - const EarthCoord& earthCoord, - const TimeCoord& timeCoord) + void + ConverterImpl::itrfToJ2000 (ResultData& out, + const RequestData& in) { - return itrfToJ2000(skyCoord, - vector<EarthCoord>(1, earthCoord), - vector<TimeCoord> (1, timeCoord)); - } + // Initialize the result data + out = ResultData(); - - vector<SkyCoord> - ConverterImpl::itrfToJ2000 (const vector<SkyCoord>& skyCoord, - const vector<EarthCoord>& earthCoord, - const vector<TimeCoord>& timeCoord) - { // Check pre-conditions. // -# \a earthCoord and \a timeCoord must have equal sizes; // -# if \a earthCoord and \a timeCoord have sizes unequal to one, then @@ -550,34 +425,31 @@ namespace LOFAR // pre-condition. // -# skyCoord type must be ITRF // -# earthCoord types must be the equal - ASSERT (earthCoord.size() == timeCoord.size()); - if (earthCoord.size() != 1) { - ASSERT (earthCoord.size() == skyCoord.size()); + ASSERT (in.earthCoord.size() == in.timeCoord.size()); + if (in.earthCoord.size() != 1) { + ASSERT (in.earthCoord.size() == in.skyCoord.size()); } - for (uint i = 0; i < skyCoord.size(); ++i) { - ASSERT (skyCoord[i].type() == SkyCoord::ITRF); + for (uint i = 0; i < in.skyCoord.size(); ++i) { + ASSERT (in.skyCoord[i].type() == SkyCoord::ITRF); } - for (uint i = 1; i < earthCoord.size(); ++i) { - ASSERT (earthCoord[i].type() == earthCoord[0].type()); + for (uint i = 1; i < in.earthCoord.size(); ++i) { + ASSERT (in.earthCoord[i].type() == in.earthCoord[0].type()); } - // This vector will hold the result of the conversion operation. - vector<SkyCoord> result; - // Reserve space for the result to avoid resizing of the vector. - result.reserve(skyCoord.size()); + out.skyCoord.reserve(in.skyCoord.size()); // Precalculate the positions on earth; they do not change with time. - vector<MVPosition> pos(earthCoord.size()); + vector<MVPosition> pos(in.earthCoord.size()); for (uint i = 0; i < pos.size(); i++) { - pos[i] = MVPosition((Quantity(earthCoord[i].height(), "m")), - (Quantity(earthCoord[i].longitude(), "rad")), - (Quantity(earthCoord[i].latitude(), "rad"))); + pos[i] = MVPosition((Quantity(in.earthCoord[i].height(), "m")), + (Quantity(in.earthCoord[i].longitude(), "rad")), + (Quantity(in.earthCoord[i].latitude(), "rad"))); } // Determine the position reference. MPosition::Types posref; - switch(earthCoord[0].type()) { + switch(in.earthCoord[0].type()) { case EarthCoord::ITRF: posref = MPosition::ITRF; break; @@ -585,8 +457,8 @@ namespace LOFAR posref = MPosition::WGS84; break; default: - THROW(ConverterError, "Invalid EarthCoord type: " - << earthCoord[0].type()); + THROW(ConverterException, "Invalid EarthCoord type: " + << in.earthCoord[0].type()); } try { @@ -595,8 +467,8 @@ namespace LOFAR MeasFrame frame; // Set initial epoch for the frame, using UTC (default) as reference. - frame.set(MEpoch(MVEpoch(timeCoord[0].getDay(), - timeCoord[0].getFraction()))); + frame.set(MEpoch(MVEpoch(in.timeCoord[0].getDay(), + in.timeCoord[0].getFraction()))); // Set initial position for the frame, using the appropriate reference. frame.set(MPosition(pos[0], posref)); @@ -607,13 +479,13 @@ namespace LOFAR // If there's only one earthCoord and one timeCoord, we only need to // loop over all \a skyCoord values. - if (timeCoord.size() == 1) { + if (in.timeCoord.size() == 1) { // For each given direction in the sky ... - for (uint i = 0; i < skyCoord.size(); i++) { + for (uint i = 0; i < in.skyCoord.size(); i++) { // Define the astronomical direction w.r.t. the reference frame. - MVDirection sky(skyCoord[i].angle0(), skyCoord[i].angle1()); + MVDirection sky(in.skyCoord[i].angle0(), in.skyCoord[i].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -622,7 +494,8 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::J2000)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::J2000)); } } @@ -631,17 +504,17 @@ namespace LOFAR else { // For each triplet ... - for (uint i = 0; i < skyCoord.size(); i++) { + for (uint i = 0; i < in.skyCoord.size(); i++) { // Set the instant in time in the frame. - frame.resetEpoch(MVEpoch(timeCoord[i].getDay(), - timeCoord[i].getFraction())); + frame.resetEpoch(MVEpoch(in.timeCoord[i].getDay(), + in.timeCoord[i].getFraction())); // Set the position on earth in the frame. frame.resetPosition(pos[i]); // Define the astronomical direction w.r.t. the reference frame. - MVDirection sky(skyCoord[i].angle0(), skyCoord[i].angle1()); + MVDirection sky(in.skyCoord[i].angle0(), in.skyCoord[i].angle1()); // Convert this direction, using the conversion engine. MDirection dir = conv(sky); @@ -650,21 +523,21 @@ namespace LOFAR Vector<Double> angles = dir.getValue().get(); // Convert to local sky coordinates and add to the return vector. - result.push_back(SkyCoord(angles(0), angles(1), SkyCoord::J2000)); + out.skyCoord.push_back(SkyCoord(angles(0), angles(1), + SkyCoord::J2000)); } } } catch (AipsError& e) { - THROW (ConverterError, "AipsError: " << e.what()); + THROW (ConverterException, "AipsError: " << e.what()); } // Check post-condition. - ASSERT(result.size() == skyCoord.size()); + ASSERT(out.skyCoord.size() == in.skyCoord.size()); - // Return the result vector. - return result; + return; } diff --git a/LCS/AMC/AMCImpl/src/AMCServer/ConverterProcess.cc b/LCS/AMC/AMCImpl/src/ConverterProcess.cc similarity index 70% rename from LCS/AMC/AMCImpl/src/AMCServer/ConverterProcess.cc rename to LCS/AMC/AMCImpl/src/ConverterProcess.cc index bcffa775240d08893d96b69b25f6f21825bd0d6f..e867ab72453136fb56dc7db34e64bd670120fba8 100644 --- a/LCS/AMC/AMCImpl/src/AMCServer/ConverterProcess.cc +++ b/LCS/AMC/AMCImpl/src/ConverterProcess.cc @@ -24,12 +24,12 @@ #include <lofar_config.h> //# Includes -#include <AMCImpl/AMCServer/ConverterProcess.h> -#include <AMCImpl/Exceptions.h> -#include <AMCBase/AMCClient/ConverterCommand.h> -#include <AMCBase/SkyCoord.h> -#include <AMCBase/EarthCoord.h> -#include <AMCBase/TimeCoord.h> +#include <AMCImpl/ConverterProcess.h> +#include <AMCBase/Exceptions.h> +#include <AMCBase/ConverterCommand.h> +#include <AMCBase/ConverterStatus.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> namespace LOFAR { @@ -57,60 +57,58 @@ namespace LOFAR // While the client is connected, handle incoming requests. while(itsRecvConn.isConnected()) { - - ConverterCommand cmd; - vector<SkyCoord> skyCoord; - vector<EarthCoord> earthCoord; - vector<TimeCoord> timeCoord; - + + ConverterCommand command; + ConverterStatus status; + RequestData request; + ResultData result; + // Receive conversion request. If the receive fails, the client // probably hung up. - if (!recvRequest(cmd, skyCoord, earthCoord, timeCoord)) break; - - // ConverterImpl may throw a ConverterError; we don't want to let this - // exception escape. + if (!recvRequest(command, request)) break; + + // ConverterImpl may throw a ConverterException; we don't want to let + // this exception escape. try { - + // Process the conversion request, invoking the right conversion // method. - switch(cmd.get()) { + switch(command.get()) { case ConverterCommand::J2000toAZEL: - skyCoord = - itsConverter.j2000ToAzel(skyCoord, earthCoord, timeCoord); + itsConverter.j2000ToAzel(result, request); break; case ConverterCommand::J2000toITRF: - skyCoord = - itsConverter.j2000ToItrf(skyCoord, earthCoord, timeCoord); + itsConverter.j2000ToItrf(result, request); break; case ConverterCommand::AZELtoJ2000: - skyCoord = - itsConverter.azelToJ2000(skyCoord, earthCoord, timeCoord); + itsConverter.azelToJ2000(result, request); break; case ConverterCommand::ITRFtoJ2000: - skyCoord = - itsConverter.itrfToJ2000(skyCoord, earthCoord, timeCoord); + itsConverter.itrfToJ2000(result, request); break; default: LOG_DEBUG_STR("ConverterProcess::handleRequests() - " << "Received invalid converter command (" - << cmd << ")"); - } + << command << ")"); + } // switch + } - catch (ConverterError& e) { + catch (ConverterException& e) { LOG_DEBUG_STR(e); + status = ConverterStatus(ConverterStatus::ERROR, e.what()); } - + // Send the conversion result to the client. If the send fails, the // client probably hung up. - if (!sendResult(skyCoord)) break; - } + if (!sendResult(status, result)) break; + + } // while + } - - bool ConverterProcess::recvRequest(ConverterCommand& cmd, - vector<SkyCoord>& skyCoord, - vector<EarthCoord>& earthCoord, - vector<TimeCoord>& timeCoord) + + bool ConverterProcess::recvRequest(ConverterCommand& command, + RequestData& request) { // Read the result from the client into the data holder's I/O buffer. // If the read fails, the client probably hung up. @@ -126,17 +124,18 @@ namespace LOFAR // Read the conversion request from the I/O buffer into \a cmd, \a // skyCoord, \a earthCoord, and \a timeCoord. - itsRequest.readBuf(cmd, skyCoord, earthCoord, timeCoord); + itsRequest.readBuf(command, request); // Everything went well. return true; } - bool ConverterProcess::sendResult(const vector<SkyCoord>& skyCoord) + bool ConverterProcess::sendResult(const ConverterStatus& status, + const ResultData& result) { // Write the conversion result into the data holder's I/O buffer. - itsResult.writeBuf(skyCoord); + itsResult.writeBuf(status, result); // Write the result from the data holder's I/O buffer to the client. if (itsSendConn.write() == Connection::Error) { diff --git a/LCS/AMC/AMCImpl/src/AMCServer/ConverterServer.cc b/LCS/AMC/AMCImpl/src/ConverterServer.cc similarity index 95% rename from LCS/AMC/AMCImpl/src/AMCServer/ConverterServer.cc rename to LCS/AMC/AMCImpl/src/ConverterServer.cc index dac2f7d592eebe67ab6fe1db760ceec4873590d7..43b79cdc48145add0247c41c8427bddcc67726d7 100644 --- a/LCS/AMC/AMCImpl/src/AMCServer/ConverterServer.cc +++ b/LCS/AMC/AMCImpl/src/ConverterServer.cc @@ -24,9 +24,9 @@ #include <lofar_config.h> //# Includes -#include <AMCImpl/AMCServer/ConverterServer.h> -#include <AMCImpl/AMCServer/ConverterProcess.h> -#include <AMCImpl/Exceptions.h> +#include <AMCImpl/ConverterServer.h> +#include <AMCImpl/ConverterProcess.h> +#include <AMCBase/Exceptions.h> #include <Common/StringUtil.h> namespace LOFAR @@ -38,7 +38,7 @@ namespace LOFAR itsListenSocket("server", toString(port), Socket::TCP) { if (!itsListenSocket.ok()) { - THROW (ServerError, + THROW (IOException, formatString("Failed to create listen socket on port %d - %s", port, itsListenSocket.errstr().c_str())); } diff --git a/LCS/AMC/AMCImpl/src/Makefile.am b/LCS/AMC/AMCImpl/src/Makefile.am index 05eeb2180d3ca9411f188eaacee3f461d148ad6c..74448dc8bf1e6721187c58d18b57447e9584582f 100644 --- a/LCS/AMC/AMCImpl/src/Makefile.am +++ b/LCS/AMC/AMCImpl/src/Makefile.am @@ -1,12 +1,12 @@ lib_LTLIBRARIES = libamcimpl.la libamcimpl_la_SOURCES = ConverterImpl.cc \ - AMCServer/ConverterProcess.cc \ - AMCServer/ConverterServer.cc + ConverterProcess.cc \ + ConverterServer.cc bin_PROGRAMS = amcserver -amcserver_SOURCES = AMCServer/amcserver.cc +amcserver_SOURCES = amcserver.cc amcserver_LDADD = libamcimpl.la amcserver_DEPENDENCIES = libamcimpl.la $(LOFAR_DEPEND) diff --git a/LCS/AMC/AMCImpl/src/AMCServer/amcserver.cc b/LCS/AMC/AMCImpl/src/amcserver.cc similarity index 97% rename from LCS/AMC/AMCImpl/src/AMCServer/amcserver.cc rename to LCS/AMC/AMCImpl/src/amcserver.cc index fd095fdbabe6ba43de7d208170d617facfab3be9..907708a7f5a82c9aabacbfaa23d71c1a9cec1565 100644 --- a/LCS/AMC/AMCImpl/src/AMCServer/amcserver.cc +++ b/LCS/AMC/AMCImpl/src/amcserver.cc @@ -25,7 +25,7 @@ //# Includes #include <Common/LofarLogger.h> -#include <AMCImpl/AMCServer/ConverterServer.h> +#include <AMCImpl/ConverterServer.h> using namespace LOFAR; using namespace LOFAR::AMC; diff --git a/LCS/AMC/AMCImpl/test/Makefile.am b/LCS/AMC/AMCImpl/test/Makefile.am index 222cd0b7372eb96bf5d6b6eb85e0827b7478506b..a54207e2bdfe2c31063ad993ba57e4330146e92a 100644 --- a/LCS/AMC/AMCImpl/test/Makefile.am +++ b/LCS/AMC/AMCImpl/test/Makefile.am @@ -2,7 +2,7 @@ check_PROGRAMS = tConverter tConverterStress tConverter_SOURCES = tConverter.cc tConverter_LDADD = ../src/libamcimpl.la -tConverter_DEPENDENCIES = ../src/libamcimpl.la $(LOFAR_DEPEND) +#tConverter_DEPENDENCIES = ../src/libamcimpl.la $(LOFAR_DEPEND) tConverterStress_SOURCES = tConverterStress.cc tConverterStress_LDADD = ../src/libamcimpl.la diff --git a/LCS/AMC/AMCImpl/test/tConverter.cc b/LCS/AMC/AMCImpl/test/tConverter.cc index 074fde81e2ade2557725a0b21d4815ff65d431c8..bed4f607b3faa471717052bd8a388b55a13ef9f7 100644 --- a/LCS/AMC/AMCImpl/test/tConverter.cc +++ b/LCS/AMC/AMCImpl/test/tConverter.cc @@ -24,11 +24,13 @@ #include <lofar_config.h> //# Includes +#include <AMCImpl/ConverterImpl.h> #include <AMCBase/SkyCoord.h> #include <AMCBase/EarthCoord.h> #include <AMCBase/TimeCoord.h> -#include <AMCBase/AMCClient/ConverterClient.h> -#include <AMCImpl/ConverterImpl.h> +#include <AMCBase/ConverterClient.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> #include <Common/LofarLogger.h> #include <Common/Exception.h> #include <Common/LofarTypes.h> @@ -116,8 +118,9 @@ int main(int /*argc*/, const char* const argv[]) times[2] = // same arbitrary time + 1 day TimeCoord (times[0].mjd(), 1.); - cout.precision(9); + RequestData request(skies, poss, times); + cout.precision(9); cout << "**** Original data ****" << endl; cout << "skies = " << skies << endl; cout << "poss = " << poss << endl; @@ -126,53 +129,64 @@ int main(int /*argc*/, const char* const argv[]) // Check conversion J2000 --> AZEL and vice versa { - vector<SkyCoord> result = conv->j2000ToAzel (skies, poss, times); - ASSERT (result.size() == skies.size() * poss.size() * times.size()); + ResultData result; + conv->j2000ToAzel(result, request); + ASSERT (result.skyCoord.size() == + skies.size() * poss.size() * times.size()); cout << "\n**** Convert from J2000 to AZEL and vice versa ****\n"; - cout << "result = " << result << endl; + cout << "result = " << result.skyCoord << endl; for (uint i = 0; i < skies.size() * poss.size() * times.size(); i++) { - ASSERT (result[i].type() == SkyCoord::AZEL); + ASSERT (result.skyCoord[i].type() == SkyCoord::AZEL); } int inx=0; for (uint i = 0; i < times.size(); i++) { for (uint j = 0; j < poss.size(); j++) { vector<SkyCoord> sk(skies.size()); for (uint k = 0; k < skies.size(); k++) { - sk[k] = result[inx++]; + sk[k] = result.skyCoord[inx++]; } // Convert back from AZEL to J2000; should yield original data - vector<SkyCoord> res2 = conv->azelToJ2000 (sk, poss[j], times[i]); + ResultData res2; + conv->azelToJ2000 (res2, RequestData(sk, poss[j], times[i])); for (uint k = 0; k < skies.size(); k++) { - ASSERT (res2[k].type() == SkyCoord::J2000); - ASSERT (compare(res2[k].angle0(), skies[k].angle0(), epsilon)); - ASSERT (compare(res2[k].angle1(), skies[k].angle1(), epsilon)); + ASSERT (res2.skyCoord[k].type() == SkyCoord::J2000); + ASSERT (compare(res2.skyCoord[k].angle0(), + skies[k].angle0(), epsilon)); + ASSERT (compare(res2.skyCoord[k].angle1(), + skies[k].angle1(), epsilon)); } } } - } + } + // Check conversion J2000 --> ITRF { - vector<SkyCoord> result = conv->j2000ToItrf (skies, poss, times); - ASSERT (result.size() == skies.size() * poss.size() * times.size()); + ResultData result; + conv->j2000ToItrf (result, request); + ASSERT (result.skyCoord.size() == + skies.size() * poss.size() * times.size()); cout << "\n**** Convert from J2000 to ITRF and vice versa ****\n"; - cout << "result = " << result << endl; + cout << "result = " << result.skyCoord << endl; for (uint i = 0; i < skies.size() * poss.size() * times.size(); i++) { - ASSERT (result[i].type() == SkyCoord::ITRF); + ASSERT (result.skyCoord[i].type() == SkyCoord::ITRF); } int inx=0; for (uint i = 0; i < times.size(); i++) { for (uint j = 0; j < poss.size(); j++) { vector<SkyCoord> sk(skies.size()); for (uint k = 0; k < skies.size(); k++) { - sk[k] = result[inx++]; + sk[k] = result.skyCoord[inx++]; } // Convert back from ITRF to J2000; should yield original data - vector<SkyCoord> res2 = conv->itrfToJ2000 (sk, poss[j], times[i]); + ResultData res2; + conv->itrfToJ2000 (res2, RequestData(sk, poss[j], times[i])); for (uint k = 0; k < skies.size(); k++) { - ASSERT (res2[k].type() == SkyCoord::J2000); - ASSERT (compare(res2[k].angle0(), skies[k].angle0(), epsilon)); - ASSERT (compare(res2[k].angle1(), skies[k].angle1(), epsilon)); + ASSERT (res2.skyCoord[k].type() == SkyCoord::J2000); + ASSERT (compare(res2.skyCoord[k].angle0(), + skies[k].angle0(), epsilon)); + ASSERT (compare(res2.skyCoord[k].angle1(), + skies[k].angle1(), epsilon)); } } } diff --git a/LCS/AMC/AMCImpl/test/tConverter.run b/LCS/AMC/AMCImpl/test/tConverter.run index f87ba819f54b9a42859f0a51491d04d92240876d..245a337930cfcae745a9e83e58d68343d32669c0 100755 --- a/LCS/AMC/AMCImpl/test/tConverter.run +++ b/LCS/AMC/AMCImpl/test/tConverter.run @@ -39,9 +39,9 @@ then # Exit and interrupt handler. $! is the process id of the last background # process started, i.e. the converter server. trap 'if [ $STATUS != 0 ] && [ $STATUS != 2 ]; then \ - mv amcserver_tmp.log amcserver.err 2>/dev/null; \ + mv -f amcserver_tmp.log amcserver.err 2>/dev/null; \ else \ - rm -f amcserver_tmp.log; \ + rm -f amcserver_tmp.log amcserver.err; \ fi; \ if kill -0 $! 2>/dev/null; then kill -9 $! 2>/dev/null; fi; \ rm -f $SERVER.log_prop; \ @@ -62,7 +62,7 @@ STATUS=$? # If something went wrong, secure the log file(s) if [ $STATUS != 0 ] && [ $STATUS != 2 ] then - mv tConverter_tmp.log tConverter_$TYPE.err 2>/dev/null + mv -f tConverter_tmp.log tConverter_$TYPE.err 2>/dev/null fi exit $STATUS diff --git a/LCS/AMC/AMCImpl/test/tConverterStress.cc b/LCS/AMC/AMCImpl/test/tConverterStress.cc index 8584b2d12b6205fb3d7d34ace15639046d6d8242..c6049ea3958896837e9e767c45f02dc3e0f80b68 100644 --- a/LCS/AMC/AMCImpl/test/tConverterStress.cc +++ b/LCS/AMC/AMCImpl/test/tConverterStress.cc @@ -27,7 +27,9 @@ #include <AMCBase/SkyCoord.h> #include <AMCBase/EarthCoord.h> #include <AMCBase/TimeCoord.h> -#include <AMCBase/AMCClient/ConverterClient.h> +#include <AMCBase/RequestData.h> +#include <AMCBase/ResultData.h> +#include <AMCBase/ConverterClient.h> #include <AMCImpl/ConverterImpl.h> #include <Common/LofarLogger.h> #include <Common/Exception.h> @@ -72,12 +74,15 @@ int main(int /*argc*/, const char* const argv[]) SkyCoord sky(1, 0.3); // arbitrary source direction EarthCoord earth(0.111646531, 0.921760253, 25, EarthCoord::WGS84); // DWL TimeCoord time(2004, 11, 19, 15, 22, 39); // arbitrary time + RequestData request(sky, earth, time); + ResultData result; for (uint i = 0; i < runs; i++) { try { LOG_INFO_STR("Client #" << i); auto_ptr<Converter> conv(createConverter()); - conv->j2000ToAzel (sky, earth, time); + ASSERT(conv.get()); + conv->j2000ToAzel (result, request); } catch (Exception& e) { LOG_WARN_STR(e); diff --git a/LCS/AMC/AMCImpl/test/tConverterStress.run b/LCS/AMC/AMCImpl/test/tConverterStress.run index 0fbfda97fadc98615cf0d5b792c5846fa5662862..22a76650c7fb688dd9306dd4c3539e7703049e6c 100755 --- a/LCS/AMC/AMCImpl/test/tConverterStress.run +++ b/LCS/AMC/AMCImpl/test/tConverterStress.run @@ -47,6 +47,7 @@ then rm -f amcserver_tmp.log; \ fi; \ if kill -0 $! 2>/dev/null; then kill -9 $! 2>/dev/null; fi; \ + rm -f $SERVER.log_prop \ exit $STATUS' 0 1 2 3 15 # Start the server in the background. diff --git a/LCS/AMC/lofarconf.in b/LCS/AMC/lofarconf.in index 8dd87590a37b6b3a54e570ed117ec09e86157858..7c64077d3156ce96ae3b18c9435599da8ebd0084 100644 --- a/LCS/AMC/lofarconf.in +++ b/LCS/AMC/lofarconf.in @@ -1,2 +1,2 @@ -AMCBase #-vLCS-AMC-1_1 -AMCImpl #-vLCS-AMC-1_1 +AMCBase #-vLCS-AMC-2_0 +AMCImpl #-vLCS-AMC-2_0 diff --git a/LCS/AMC/package.dox b/LCS/AMC/package.dox index fbc4a3a8cde835a0592f8b71ce9ac961fc92cb62..e6bc5310073f579647c81e50420156c6d10a927e 100644 --- a/LCS/AMC/package.dox +++ b/LCS/AMC/package.dox @@ -20,30 +20,15 @@ // // AMCBase contains the interface definition of the conversion methods and // some basic classes that define sky coordinates, earth coordinates -// (position on earth) and time. - -// @{ - -// \defgroup AMCClient AMCClient -// -// AMCClient contains the implementation of the client side of the AMC -// client/server. - -// @} +// (position on earth) and time. Furthermore, it contains the implementation +// of the client side of the AMC client/server, plus a number of classes +// needed for data transfer between client and server. // \defgroup AMCImpl AMCImpl // // AMCImpl contains the implementation of the conversion methods. -//# Furthermore ... - -// @{ - -// \defgroup AMCServer AMCServer -// -// AMCServer contains the implementation of the server side of the AMC -// client/server. - -// @} +// Furthermore it contains the implementation of the server side of the AMC +// client/server. // @}