diff --git a/.gitattributes b/.gitattributes index 334555df18a1d968a1e3b3360fe8774a0f12cf99..dc2d7efccc2491d39614593126a35d3814fab97b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4049,6 +4049,12 @@ RTCP/Interface/src/FinalMetaData.cc -text RTCP/Interface/src/Stream.cc -text RTCP/Interface/test/tCorrelatedData.cc -text RTCP/Interface/test/tMultiDimArray.cc -text +RTCP/LofarStMan/CMakeLists.txt -text +RTCP/LofarStMan/include/LofarStMan/CMakeLists.txt -text +RTCP/LofarStMan/src/CMakeLists.txt -text +RTCP/LofarStMan/src/makeFLAGwritable -text +RTCP/LofarStMan/test/CMakeLists.txt -text +RTCP/LofarStMan/test/tIOPerf.sh eol=lf RTCP/MetaDataGatherer/CMakeLists.txt -text RTCP/MetaDataGatherer/src/CMakeLists.txt -text RTCP/MetaDataGatherer/src/FinalMetaDataGatherer.cc -text @@ -4393,6 +4399,7 @@ SDP/SPP/VHDL/FFT/aukfft_selone.tdf -text svneol=unset#unset SDP/SPP/VHDL/FFT/aukfft_twaa.tdf -text svneol=unset#unset SDP/SPP/VHDL/FFT/aukfft_twidrom.tdf -text SDP/SPP/VHDL/FFT/aukfft_twidrom_4k.tdf -text +SubSystems/Online_OutputProc/CMakeLists.txt -text SubSystems/Online_Storage/CMakeLists.txt -text /jenkins_make -text /lofar_config.h.cmake -text diff --git a/CEP/Calibration/BBSControl/include/BBSControl/CalSession.h b/CEP/Calibration/BBSControl/include/BBSControl/CalSession.h index 391b92ae1e6ba1fbda6fafedbb92c397952cf961..9b7d168b4f61f99e1014a7a5ce006e92e8f51fbd 100644 --- a/CEP/Calibration/BBSControl/include/BBSControl/CalSession.h +++ b/CEP/Calibration/BBSControl/include/BBSControl/CalSession.h @@ -89,7 +89,6 @@ public: CalSession(const string &key, const string &db, const string &user, const string &password = "", const string &host = "localhost", const string &port = ""); - ~CalSession(); ProcessId getProcessId() const; @@ -294,6 +293,7 @@ private: mutable vector<size_t> itsSlotCount; mutable map<ProcessId, size_t> itsRegisterMap; mutable vector<Worker> itsRegister; + mutable bool itsRegisterDirty; // Triggers that have been registered with the database. // \note Triggers cannot be copied, so we must use a shared pointer. diff --git a/CEP/Calibration/BBSControl/src/CalSession.cc b/CEP/Calibration/BBSControl/src/CalSession.cc index 33782f2f26df57476f66ce7c53638f5b0758cca0..04f36fd231dbd629f0a55dff847ea79afad3f4e1 100644 --- a/CEP/Calibration/BBSControl/src/CalSession.cc +++ b/CEP/Calibration/BBSControl/src/CalSession.cc @@ -42,22 +42,22 @@ #if defined(CATCH_PQXX_AND_RETHROW) # error CATCH_PQXX_AND_RETHROW is already defined and should not be redefined #else -# define CATCH_PQXX_AND_RETHROW \ - catch (pqxx::broken_connection& e) { \ - THROW (DatabaseException, "pqxx::broken_connection:\n" \ - << e.what()); \ - } \ - catch (pqxx::sql_error& e) { \ - THROW (DatabaseException, "pqxx::sql_error:\n" \ - << "Query: " << e.query() << endl << e.what()); \ - } \ - catch (pqxx::in_doubt_error& e) { \ - THROW (DatabaseException, "pqxx::in_doubt_error:\n" \ - << e.what()); \ - } \ - catch (pqxx::internal_error& e) { \ - THROW (DatabaseException, "pqxx::internal_error:\n" \ - << e.what()); \ +# define CATCH_PQXX_AND_RETHROW \ + catch (pqxx::broken_connection& e) { \ + THROW (DatabaseException, "pqxx::broken_connection:\n" \ + << e.what()); \ + } \ + catch (pqxx::sql_error& e) { \ + THROW (DatabaseException, "pqxx::sql_error:\n" \ + << "Query: " << e.query() << endl << e.what()); \ + } \ + catch (pqxx::in_doubt_error& e) { \ + THROW (DatabaseException, "pqxx::in_doubt_error:\n" \ + << e.what()); \ + } \ + catch (pqxx::internal_error& e) { \ + THROW (DatabaseException, "pqxx::internal_error:\n" \ + << e.what()); \ } #endif @@ -90,7 +90,8 @@ namespace CalSession::CalSession(const string &key, const string &db, const string &user, const string &password, const string &host, const string &port) : itsSessionId(-1), - itsProcessId(ProcessId::id()) + itsProcessId(ProcessId::id()), + itsRegisterDirty(true) { // Build connection string. string opts("dbname='" + db + "' user='" + user + "' host='" + host + "'"); @@ -116,10 +117,6 @@ CalSession::CalSession(const string &key, const string &db, const string &user, syncWorkerRegister(true); } -CalSession::~CalSession() -{ -} - ProcessId CalSession::getProcessId() const { return itsProcessId; @@ -127,8 +124,9 @@ ProcessId CalSession::getProcessId() const bool CalSession::registerAsControl() { - int32 status = -1; + itsRegisterDirty = true; + int32 status = -1; try { itsConnection->perform(PQRegisterAsControl(itsSessionId, itsProcessId, @@ -142,8 +140,9 @@ bool CalSession::registerAsControl() bool CalSession::registerAsKernel(const string &filesys, const string &path, const Axis::ShPtr &freqAxis, const Axis::ShPtr &timeAxis) { - int32 status = -1; + itsRegisterDirty = true; + int32 status = -1; try { itsConnection->perform(PQRegisterAsKernel(itsSessionId, itsProcessId, @@ -156,8 +155,9 @@ bool CalSession::registerAsKernel(const string &filesys, const string &path, bool CalSession::registerAsSolver(size_t port) { - int32 status = -1; + itsRegisterDirty = true; + int32 status = -1; try { itsConnection->perform(PQRegisterAsSolver(itsSessionId, itsProcessId, @@ -171,7 +171,6 @@ bool CalSession::registerAsSolver(size_t port) void CalSession::setState(State state) { int32 status = -1; - try { itsConnection->perform(PQSetState(itsSessionId, itsProcessId, state, @@ -189,7 +188,6 @@ CalSession::State CalSession::getState() const { int32 status = -1; State result; - try { itsConnection->perform(PQGetState(itsSessionId, status, result)); @@ -207,7 +205,6 @@ CalSession::State CalSession::getState() const void CalSession::setTimeAxis(const Axis::ShPtr &axis) { int32 status = -1; - try { itsConnection->perform(PQSetAxisTime(itsSessionId, itsProcessId, axis, @@ -225,7 +222,6 @@ Axis::ShPtr CalSession::getTimeAxis() { int32 status = -1; Axis::ShPtr axis; - try { itsConnection->perform(PQGetAxisTime(itsSessionId, status, axis)); @@ -243,7 +239,6 @@ Axis::ShPtr CalSession::getTimeAxis() void CalSession::setParset(const ParameterSet &parset) const { int32 status = -1; - try { itsConnection->perform(PQSetParset(itsSessionId, itsProcessId, parset, @@ -261,7 +256,6 @@ ParameterSet CalSession::getParset() const { int32 status = -1; ParameterSet parset; - try { itsConnection->perform(PQGetParset(itsSessionId, status, parset)); @@ -278,6 +272,8 @@ ParameterSet CalSession::getParset() const void CalSession::initWorkerRegister(const CEP::VdsDesc &vds, bool useSolver) { + itsRegisterDirty = true; + try { itsConnection->perform(PQInitWorkerRegister(itsSessionId, itsProcessId, @@ -288,8 +284,9 @@ void CalSession::initWorkerRegister(const CEP::VdsDesc &vds, bool useSolver) void CalSession::setWorkerIndex(const ProcessId &worker, size_t index) { - int32 status = -1; + itsRegisterDirty = true; + int32 status = -1; try { itsConnection->perform(PQSetWorkerIndex(itsSessionId, itsProcessId, @@ -309,7 +306,6 @@ CommandId CalSession::postCommand(const Command& cmd, WorkerType addressee) { int32 status = -1; CommandId id(-1); - try { itsConnection->perform(PQPostCommand(itsSessionId, itsProcessId, @@ -330,7 +326,6 @@ pair<CommandId, shared_ptr<Command> > CalSession::getCommand() const int32 status = -1; pair<CommandId, shared_ptr<Command> > cmd(CommandId(-1), shared_ptr<Command>()); - try { itsConnection->perform(PQGetCommand(itsSessionId, itsProcessId, status, @@ -352,7 +347,6 @@ void CalSession::postResult(const CommandId &id, const CommandResult &result) const { int32 status = -1; - try { itsConnection->perform(PQPostResult(itsSessionId, itsProcessId, id, @@ -372,7 +366,6 @@ CalSession::CommandStatus CalSession::getCommandStatus(const CommandId &id) int32 status = -1; WorkerType addressee; CommandStatus cmdStatus; - try { itsConnection->perform(PQGetCommandStatus(id, status, addressee, @@ -393,7 +386,6 @@ vector<pair<ProcessId, CommandResult> > CalSession::getResults(const CommandId &id) const { vector<pair<ProcessId, CommandResult> > results; - try { itsConnection->perform(PQGetResults(id, results)); @@ -465,7 +457,7 @@ bool CalSession::isSolver(const ProcessId &id) const size_t CalSession::getIndex() const { - // Note: syncWorkerRegister() already called via getWorkerIndex(ProcessId). + // Note: syncWorkerRegister() already called via getIndex(ProcessId). return getIndex(getProcessId()); } @@ -548,7 +540,6 @@ Axis::ShPtr CalSession::getFreqAxis(const ProcessId &id) const int32 status = -1; Axis::ShPtr axis; - try { itsConnection->perform(PQGetWorkerAxisFreq(itsSessionId, id, status, @@ -576,7 +567,6 @@ Axis::ShPtr CalSession::getTimeAxis(const ProcessId &id) const int32 status = -1; Axis::ShPtr axis; - try { itsConnection->perform(PQGetWorkerAxisTime(itsSessionId, id, status, @@ -634,29 +624,31 @@ ProcessId CalSession::getWorkerByIndex(WorkerType type, size_t index) const void CalSession::syncWorkerRegister(bool force) const { - if(!force && !waitForTrigger(Trigger::WorkerRegisterModified, 0)) + if(force + || itsRegisterDirty + || waitForTrigger(Trigger::WorkerRegisterModified, 0)) { - return; - } + vector<size_t> tmpSlotCount; + vector<Worker> tmpRegister; - vector<size_t> tmpSlotCount; - vector<Worker> tmpRegister; + try + { + itsConnection->perform(PQGetWorkerRegister(itsSessionId, + tmpSlotCount, tmpRegister)); + } + CATCH_PQXX_AND_RETHROW; - try - { - itsConnection->perform(PQGetWorkerRegister(itsSessionId, tmpSlotCount, - tmpRegister)); - } - CATCH_PQXX_AND_RETHROW; + itsSlotCount = tmpSlotCount; + itsRegister = tmpRegister; - itsSlotCount = tmpSlotCount; - itsRegister = tmpRegister; + // Recreate the mapping from ProcessId to index in the register. + itsRegisterMap.clear(); + for(size_t i = 0; i < itsRegister.size(); ++i) + { + itsRegisterMap[itsRegister[i].id] = i; + } - // Recreate the mapping from ProcessId to index in the register. - itsRegisterMap.clear(); - for(size_t i = 0; i < itsRegister.size(); ++i) - { - itsRegisterMap[itsRegister[i].id] = i; + itsRegisterDirty = false; } } diff --git a/CEP/Calibration/BBSControl/src/bbs-controller.cc b/CEP/Calibration/BBSControl/src/bbs-controller.cc index 06e5aa86cab979832dae637ddfdb3c62a2b2a3aa..ee11d46875973589f53ac0d4c8e7896b5751213e 100644 --- a/CEP/Calibration/BBSControl/src/bbs-controller.cc +++ b/CEP/Calibration/BBSControl/src/bbs-controller.cc @@ -97,11 +97,11 @@ int main(int argc, char *argv[]) if(options.getBool("Help", false)) { - cout << "Usage: " << progName << " [OPTION]... VDS PARSET" << endl + cout << "Usage: " << progName << " [OPTION]... GDS PARSET" << endl << endl << "Control the distributed execution of the reduction of the observation" " described" << endl - << "by the specified VDS file. (The VDS file is mainly just a list of" + << "by the specified GDS file. (The GDS file is mainly just a list of" " paths to" << endl << "measurement sets (MS) that together constitute the observation.) The" " reduction" << endl diff --git a/CEP/Calibration/BBSControl/src/bbs-reducer.cc b/CEP/Calibration/BBSControl/src/bbs-reducer.cc index 0468fd7eac75165c85c4bcf37d92abd6c54cab20..75dba011c2c78accd5a8efec1fcdda9ef70d7108 100644 --- a/CEP/Calibration/BBSControl/src/bbs-reducer.cc +++ b/CEP/Calibration/BBSControl/src/bbs-reducer.cc @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) { cout << "Usage: " << progName << " [OPTION]... MS PARSET" << endl #ifdef HAVE_PQXX - << " Or: " << progName << " [OPTION]... -D FILESYSTEM MS PARSET" << endl + << " Or: " << progName << " [OPTION]... -D FILESYSTEM MS" << endl #endif << endl << "Calibrate a single MS using the reduction strategy described by" diff --git a/CEP/Calibration/StationResponse/include/StationResponse/Station.h b/CEP/Calibration/StationResponse/include/StationResponse/Station.h index d65817326845e4a4c9b03161d391ad6330a66337..90a5cb9578c9ea98f6bc62285fdd2e5e68ec65a4 100644 --- a/CEP/Calibration/StationResponse/include/StationResponse/Station.h +++ b/CEP/Calibration/StationResponse/include/StationResponse/Station.h @@ -44,9 +44,9 @@ namespace StationResponse class Station { public: - typedef shared_ptr<Station> Ptr; - typedef shared_ptr<const Station> ConstPtr; - typedef vector<AntennaField::Ptr> FieldList; + typedef shared_ptr<Station> Ptr; + typedef shared_ptr<const Station> ConstPtr; + typedef vector<AntennaField::ConstPtr> FieldList; /*! * \brief Construct a new Station instance. @@ -95,7 +95,7 @@ public: * * Use this method to add the appropriate antenna fields to the station. */ - void addAntennaField(const AntennaField::Ptr &field); + void addAntennaField(const AntennaField::ConstPtr &field); /*! * \brief Return an iterator that points to the beginning of the list of diff --git a/CEP/Calibration/StationResponse/src/Station.cc b/CEP/Calibration/StationResponse/src/Station.cc index 4fd119a41a19778252283215b38b456091ce26e3..4e9e9b905a1da600ffd25647b7fad16efd84dc3a 100644 --- a/CEP/Calibration/StationResponse/src/Station.cc +++ b/CEP/Calibration/StationResponse/src/Station.cc @@ -31,7 +31,8 @@ namespace StationResponse Station::Station(const string &name, const vector3r_t &position) : itsName(name), - itsPosition(position) + itsPosition(position), + itsPhaseReference(position) { } @@ -55,7 +56,7 @@ const vector3r_t &Station::phaseReference() const return itsPhaseReference; } -void Station::addAntennaField(const AntennaField::Ptr &field) +void Station::addAntennaField(const AntennaField::ConstPtr &field) { itsFields.push_back(field); } diff --git a/CEP/Imager/LofarFT/src/awimager.cc b/CEP/Imager/LofarFT/src/awimager.cc index f01dd60e9742234b22f508ad604a694df75166f9..9eafdd8bce7cd3af5753514cf277de453f458c5a 100644 --- a/CEP/Imager/LofarFT/src/awimager.cc +++ b/CEP/Imager/LofarFT/src/awimager.cc @@ -519,8 +519,11 @@ int main (Int argc, char** argv) "If set to true, then find the optimal number of W-planes, given spheroid support, wmax and field of view.", "bool"); inputs.create ("ChanBlockSize", "0", - "Channel block size. Use if you want to use a different CF per block of channels.", - "int"); + "Channel block size. Use if you want to use a different CF per block of channels.", + "int"); + inputs.create ("antenna", "", + "Baseline selection string.", + "string"); // inputs.create ("FillFactor", "1", // "Fraction of the data that will be selected from the selected MS. (don't use it yet)", @@ -618,6 +621,7 @@ int main (Int argc, char** argv) Bool SingleGridMode = inputs.getBool("SingleGridMode"); Bool FindNWplanes = inputs.getBool("FindNWplanes"); Int ChanBlockSize = inputs.getInt("ChanBlockSize"); + String antenna = inputs.getString("antenna"); //Double FillFactor= 1.;//inputs.getDouble("FillFactor"); @@ -786,7 +790,7 @@ int main (Int argc, char** argv) String(), // timerng String(), // fieldnames Vector<Int>(), // antIndex - String(), // antnames + antenna, // antnames String(), // spwstring uvdist, // uvdist String(), // scan diff --git a/CEP/PyBDSM/src/python/opts.py b/CEP/PyBDSM/src/python/opts.py index a85c5c2ffef11ccaac017eb6da9b367d747ebd5c..c2873e6d7f3357cf634bba96aec4364eba1f5fb7 100644 --- a/CEP/PyBDSM/src/python/opts.py +++ b/CEP/PyBDSM/src/python/opts.py @@ -1092,7 +1092,7 @@ class Opts(object): #-------------------------SPECTRAL INDEX OPTIONS-------------------------------- flagchan_rms = Bool(True, doc = "Flag channels before (averaging and) "\ - "extracting spectral index, if their rms if "\ + "extracting spectral index, if their rms is "\ "more than 5 (clipped) sigma outside the median "\ "rms over all channels, but only if <= 10% of "\ "channels\n"\ @@ -1125,7 +1125,7 @@ class Opts(object): "there is insufficient SNR, neighboring channels "\ "are averaged to attempt to obtain the target SNR. "\ "Channels with SNRs below this will be flagged if "\ - "flagchan_snr=True.\n"\ + "flagchan_snr = True\n"\ "The maximum allowable number of channels to average "\ "is determined by the specind_maxchan parameter.", group = "spectralindex_do") diff --git a/CEP/PyBDSM/src/python/spectralindex.py b/CEP/PyBDSM/src/python/spectralindex.py index 3225ccb0714eee98c18eec4da2845bbe7a58b606..355e076c4894e2b092c32a7cf766756f1a86ec95 100644 --- a/CEP/PyBDSM/src/python/spectralindex.py +++ b/CEP/PyBDSM/src/python/spectralindex.py @@ -406,8 +406,8 @@ class Op_spectralindex(Op): clipped rms is too high, the channel is averaged with as many neighboring channels as necessary to obtain at least the desired rms. This is done until the number of OK channels is 2. The averaging is done first at - the frequency extremes, as frequency range the resulting averaged flux array - will be maximized. + the frequency extremes, as the frequency range of the resulting averaged + flux array will be maximized. For example, if the desired rms is 0.1 and the list of rms's is: diff --git a/CEP/PyBDSM/src/python/threshold.py b/CEP/PyBDSM/src/python/threshold.py index b6c6f393a24bbb43d27dc78b59d9213f48150276..aec020dde432306f6f048bf96cef955702a4c947 100644 --- a/CEP/PyBDSM/src/python/threshold.py +++ b/CEP/PyBDSM/src/python/threshold.py @@ -61,11 +61,14 @@ class Op_threshold(Op): slope = opts.fdr_alpha/s0 # sort erf of normalised image as vector v = N.sort(0.5*erfc(N.ravel((data-img.mean_arr)/img.rms_arr)/sq2))[::-1] + pcrit = None for i,x in enumerate(v): if x < slope*i/size: pcrit = x break - dumr1 = 1.0-2.0*pcrit; + if pcrit is None: + raise RuntimeError("FDR thresholding failed. Please check the input image for problems.") + dumr1 = 1.0-2.0*pcrit dumr = 8.0/3.0/pi*(pi-3.0)/(4.0-pi) # approx for inv(erfc) sigcrit = sqrt(-2.0/pi/dumr-log(1.0-dumr1*dumr1)/2.0+ \ diff --git a/CMake/LofarPackageList.cmake b/CMake/LofarPackageList.cmake index 1b5fa3d8bf03049ab009b6c0df8c017b1ac3ed19..2114ef854205fc2e52c8f5fbce5f3b8cca524301 100644 --- a/CMake/LofarPackageList.cmake +++ b/CMake/LofarPackageList.cmake @@ -1,7 +1,7 @@ # - Create for each LOFAR package a variable containing the absolute path to # its source directory. # -# Generated by gen_LofarPackageList_cmake.sh at Tue May 7 14:25:22 CEST 2013 +# Generated by gen_LofarPackageList_cmake.sh at Mon Nov 11 18:40:47 CET 2013 # # ---- DO NOT EDIT ---- # @@ -59,10 +59,13 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED) set(Stream_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/Stream) set(Tools_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/Tools) set(Transport_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/Transport) + set(MSLofar_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/MSLofar) + set(LofarStMan_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/LofarStMan) set(Firmware_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCU/Firmware) set(StationTest_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCU/StationTest) set(checkhardware_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCU/checkhardware) set(Firmware-Tools_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCU/Firmware/tools) + set(MACTools_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCU/StationTest/MACTools) set(APLCommon_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/APLCommon) set(RTCCommon_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/RTCCommon) set(RTDBCommon_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/RTDBCommon) @@ -79,6 +82,8 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED) set(StationCU_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/StationCU) set(TestCtlr_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/TestCtlr) set(CR_Protocol_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/CR_Protocol) + set(Service_Broker_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/CUDaemons/Service_Broker) + set(CT_StartDaemon_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/CUDaemons/CT_StartDaemon) set(CAL_Protocol_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/PAC/CAL_Protocol) set(IBS_Protocol_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/PAC/IBS_Protocol) set(Cal_Server_SOURCE_DIR ${CMAKE_SOURCE_DIR}/MAC/APL/PAC/Cal_Server) @@ -107,7 +112,6 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED) set(IONProc_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/IONProc) set(Storage_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/Storage) set(Run_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/Run) - set(LofarStMan_SOURCE_DIR ${CMAKE_SOURCE_DIR}/LCS/LofarStMan) set(MetaDataGatherer_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/MetaDataGatherer) set(Cobalt_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/Cobalt) set(InputProc_SOURCE_DIR ${CMAKE_SOURCE_DIR}/RTCP/Cobalt/InputProc) @@ -125,6 +129,7 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED) set(MCU_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/MCU_MAC) set(CN_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/CN_MAC) set(Online_Storage_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/Online_Storage) + set(Online_OutputProc_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/Online_OutputProc) set(ST_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/ST_MAC) set(Offline_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/Offline) set(SAS_OTDB_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/SAS_OTDB) diff --git a/LCS/ApplCommon/include/ApplCommon/CMakeLists.txt b/LCS/ApplCommon/include/ApplCommon/CMakeLists.txt index 573101c6971d27095cc8ea6d642d014aa4b0a7ea..58ce3fd81ec94dd7b04d2ba49a13c25db39be5bc 100644 --- a/LCS/ApplCommon/include/ApplCommon/CMakeLists.txt +++ b/LCS/ApplCommon/include/ApplCommon/CMakeLists.txt @@ -7,6 +7,7 @@ set(inst_HEADERS LofarDirs.h Observation.h PosixTime.h + PVSSDatapointDefs.h StationConfig.h StationDatatypes.h StationInfo.h) diff --git a/LCS/ApplCommon/include/ApplCommon/PVSSDatapointDefs.h b/LCS/ApplCommon/include/ApplCommon/PVSSDatapointDefs.h new file mode 100644 index 0000000000000000000000000000000000000000..de52032ae11224981dc35aa965b937ee8599c34d --- /dev/null +++ b/LCS/ApplCommon/include/ApplCommon/PVSSDatapointDefs.h @@ -0,0 +1,515 @@ +// This file was generated by create_db_files v2.0 on Mon Sep 16 12:18:59 UTC 2013 + +#ifndef LOFAR_DEPLOYMENT_PVSSDATAPOINTS_H +#define LOFAR_DEPLOYMENT_PVSSDATAPOINTS_H +// process +#define PN_FSM_PROCESSID "process.processID" +#define PN_FSM_START_TIME "process.startTime" +#define PN_FSM_STOP_TIME "process.stopTime" +#define PN_FSM_LOG_MSG "process.logMsg" +#define PN_FSM_ERROR "process.error" +#define PN_FSM_CURRENT_ACTION "process.currentAction" +// object +#define PN_OBJ_STATE "object.state" +#define PN_OBJ_CHILD_STATE "object.childState" +#define PN_OBJ_MESSAGE "object.message" +#define PN_OBJ_LEAF "object.leaf" + +// MACScheduler +#define PSN_MAC_SCHEDULER "LOFAR_PermSW_MACScheduler" +#define PST_MAC_SCHEDULER "MACScheduler" +#define PN_MS_PLANNED_OBSERVATIONS "plannedObservations" +#define PN_MS_ACTIVE_OBSERVATIONS "activeObservations" +#define PN_MS_FINISHED_OBSERVATIONS "finishedObservations" +#define PN_MS_OTDB_CONNECTED "OTDB.connected" +#define PN_MS_OTDB_LAST_POLL "OTDB.lastPoll" +#define PN_MS_OTDB_POLLINTERVAL "OTDB.pollinterval" + +// CRTriggerControl +#define PSN_CR_TRIGGER_CONTROL "LOFAR_PermSW_CRTriggerControl" +#define PST_CR_TRIGGER_CONTROL "CRTriggerControl" + +// Observation +#define PSN_OBSERVATION "LOFAR_ObsSW_@observation@" +#define PST_OBSERVATION "Observation" +#define PN_OBS_CLAIM_CLAIM_DATE "claim.claimDate" +#define PN_OBS_CLAIM_NAME "claim.name" +#define PN_OBS_CLAIM_PERIOD "claimPeriod" +#define PN_OBS_PREPARE_PERIOD "preparePeriod" +#define PN_OBS_START_TIME "startTime" +#define PN_OBS_STOP_TIME "stopTime" +#define PN_OBS_BAND_FILTER "bandFilter" +#define PN_OBS_NYQUISTZONE "nyquistzone" +#define PN_OBS_ANTENNA_ARRAY "antennaArray" +#define PN_OBS_RECEIVER_LIST "receiverList" +#define PN_OBS_SAMPLE_CLOCK "sampleClock" +#define PN_OBS_RUN_STATE "runState" +#define PN_OBS_MEASUREMENT_SET "measurementSet" +#define PN_OBS_PROCESS_TYPE "processType" +#define PN_OBS_PROCESS_SUBTYPE "processSubtype" +#define PN_OBS_STRATEGY "strategy" +#define PN_OBS_STATION_LIST "stationList" +#define PN_OBS_INPUT_NODE_LIST "inputNodeList" +#define PN_OBS_BGL_NODE_LIST "BGLNodeList" +#define PN_OBS_STORAGE_NODE_LIST "storageNodeList" +#define PN_OBS_BEAMS_ANGLE1 "Beams.angle1" +#define PN_OBS_BEAMS_ANGLE2 "Beams.angle2" +#define PN_OBS_BEAMS_DIRECTION_TYPE "Beams.directionType" +#define PN_OBS_BEAMS_SUBBAND_LIST "Beams.subbandList" +#define PN_OBS_TIED_ARRAY_BEAMS_BEAM_INDEX "TiedArrayBeams.beamIndex" +#define PN_OBS_TIED_ARRAY_BEAMS_ANGLE1 "TiedArrayBeams.angle1" +#define PN_OBS_TIED_ARRAY_BEAMS_ANGLE2 "TiedArrayBeams.angle2" +#define PN_OBS_TIED_ARRAY_BEAMS_DIRECTION_TYPE "TiedArrayBeams.directionType" +#define PN_OBS_TIED_ARRAY_BEAMS_DISPERSION "TiedArrayBeams.dispersion" +#define PN_OBS_TIED_ARRAY_BEAMS_COHERENT "TiedArrayBeams.coherent" + +// ObservationControl +#define PSN_OBSERVATION_CONTROL "LOFAR_ObsSW_@observation@_ObservationControl" +#define PST_OBSERVATION_CONTROL "ObservationControl" +#define PN_OBSCTRL_COMMAND "command" + +// InputBuffer +#define PSN_INPUT_BUFFER "LOFAR_PermSW_@psionode@_InputBuffer" +#define PST_INPUT_BUFFER "InputBuffer" +#define PN_IPB_STATION_NAME "stationName" +#define PN_IPB_OBSERVATION_NAME "observationName" +#define PN_IPB_STREAM0_BLOCKS_IN "stream0.blocksIn" +#define PN_IPB_STREAM0_PERC_BAD "stream0.percBad" +#define PN_IPB_STREAM0_REJECTED "stream0.rejected" +#define PN_IPB_STREAM1_BLOCKS_IN "stream1.blocksIn" +#define PN_IPB_STREAM1_PERC_BAD "stream1.percBad" +#define PN_IPB_STREAM1_REJECTED "stream1.rejected" +#define PN_IPB_STREAM2_BLOCKS_IN "stream2.blocksIn" +#define PN_IPB_STREAM2_PERC_BAD "stream2.percBad" +#define PN_IPB_STREAM2_REJECTED "stream2.rejected" +#define PN_IPB_STREAM3_BLOCKS_IN "stream3.blocksIn" +#define PN_IPB_STREAM3_PERC_BAD "stream3.percBad" +#define PN_IPB_STREAM3_REJECTED "stream3.rejected" +#define PN_IPB_LATE "late" +#define PN_IPB_IO_TIME "IOTime" + +// Adder +#define PSN_ADDER "LOFAR_ObsSW_@osionode@_@adder@" +#define PST_ADDER "Adder" +#define PN_ADD_DROPPING "dropping" +#define PN_ADD_DROPPED "dropped" +#define PN_ADD_DATA_PRODUCT_TYPE "dataProductType" +#define PN_ADD_DATA_PRODUCT "dataProduct" +#define PN_ADD_FILE_NAME "fileName" +#define PN_ADD_LOCUS_NODE "locusNode" +#define PN_ADD_WRITER "writer" +#define PN_ADD_DIRECTORY "directory" +#define PN_ADD_OBSERVATION_NAME "observationName" + +// Writer +#define PSN_WRITER "LOFAR_ObsSW_@oslocusnode@_@writer@" +#define PST_WRITER "Writer" +#define PN_WTR_WRITTEN "written" +#define PN_WTR_DROPPED "dropped" +#define PN_WTR_FILE_NAME "fileName" +#define PN_WTR_DATA_RATE "dataRate" +#define PN_WTR_DATA_PRODUCT_TYPE "dataProductType" +#define PN_WTR_OBSERVATION_NAME "observationName" + +// IONode +#define PSN_IO_NODE "LOFAR_PIC_BGP_@midplane@_@ionode@" +#define PST_IO_NODE "IONode" +#define PN_ION_STATION0 "station0" +#define PN_ION_IP0 "IP0" +#define PN_ION_MAC0 "MAC0" +#define PN_ION_STATION1 "station1" +#define PN_ION_IP1 "IP1" +#define PN_ION_MAC1 "MAC1" +#define PN_ION_MAC_FOREIGN "MACForeign" +#define PN_ION_USE2ND_STATION "use2ndStation" +#define PN_ION_USED_STATION "usedStation" +#define PN_ION_USEDIP "usedIP" +#define PN_ION_USEDMAC "usedMAC" + +// LocusNode +#define PSN_LOCUS_NODE "LOFAR_PIC_@osrack@_@locusnode@" +#define PST_LOCUS_NODE "LocusNode" +#define PN_LCN_FREE "free" +#define PN_LCN_TOTAL "total" +#define PN_LCN_CLAIMED "claimed" + +// CEPHardwareMonitor +#define PSN_CEP_HARDWARE_MONITOR "LOFAR_PermSW_CEPHardwareMonitor" +#define PST_CEP_HARDWARE_MONITOR "CEPHardwareMonitor" +#define PN_CHM_BGP_CONNECTED "BGP.connected" +#define PN_CHM_CLUSTER_CONNECTED "Cluster.connected" + +// OnlineControl +#define PSN_ONLINE_CONTROL "LOFAR_ObsSW_@observation@_OnlineControl" +#define PST_ONLINE_CONTROL "OnlineControl" + +// BGPAppl +#define PSN_BGP_APPL "LOFAR_ObsSW_@observation@_OnlineControl_BGPAppl" +#define PST_BGP_APPL "BGPAppl" +#define PN_BGPA_IO_NODE_LIST "ioNodeList" +#define PN_BGPA_ADDER_LIST "adderList" +#define PN_BGPA_LOCUS_NODE_LIST "locusNodeList" +#define PN_BGPA_WRITER_LIST "writerList" +#define PN_BGPA_DATA_PRODUCT_LIST "dataProductList" +#define PN_BGPA_DATA_PRODUCT_TYPE_LIST "dataProductTypeList" + +// CobaltStationInput +#define PSN_COBALT_STATION_INPUT "LOFAR_PermSW_@pscobaltnode@_CobaltStationInput" +#define PST_COBALT_STATION_INPUT "CobaltStationInput" +#define PN_CSI_STATION_NAME "stationName" +#define PN_CSI_OBSERVATION_NAME "observationName" +#define PN_CSI_STREAM0_BLOCKS_IN "stream0.blocksIn" +#define PN_CSI_STREAM0_REJECTED "stream0.rejected" +#define PN_CSI_STREAM1_BLOCKS_IN "stream1.blocksIn" +#define PN_CSI_STREAM1_REJECTED "stream1.rejected" +#define PN_CSI_STREAM2_BLOCKS_IN "stream2.blocksIn" +#define PN_CSI_STREAM2_REJECTED "stream2.rejected" +#define PN_CSI_STREAM3_BLOCKS_IN "stream3.blocksIn" +#define PN_CSI_STREAM3_REJECTED "stream3.rejected" + +// CobaltGPUProc +#define PSN_COBALTGPU_PROC "LOFAR_ObsSW_@observation@_@oscobaltnode@_@cobaltgpuproc@" +#define PST_COBALTGPU_PROC "CobaltGPUProc" +#define PN_CGP_OBSERVATION_NAME "observationName" +#define PN_CGP_DATA_PRODUCT_TYPE "dataProductType" +#define PN_CGP_SUBBAND "subband" +#define PN_CGP_DROPPING "dropping" +#define PN_CGP_WRITTEN "written" +#define PN_CGP_DROPPED "dropped" + +// CobaltOutputProc +#define PSN_COBALT_OUTPUT_PROC "LOFAR_ObsSW_@observation@_@cobaltoutputproc@" +#define PST_COBALT_OUTPUT_PROC "CobaltOutputProc" +#define PN_COP_LOCUS_NODE "locusNode" +#define PN_COP_DATA_PRODUCT_TYPE "dataProductType" +#define PN_COP_FILE_NAME "fileName" +#define PN_COP_DIRECTORY "directory" +#define PN_COP_DROPPING "dropping" +#define PN_COP_WRITTEN "written" +#define PN_COP_DROPPED "dropped" + +// Cabinet +#define PSN_CABINET "LOFAR_PIC_@cabinet@" +#define PST_CABINET "Cabinet" +#define PN_CAB_FRONT_DOOR_OPEN "frontDoorOpen" +#define PN_CAB_FRONT_FAN_INNER "frontFanInner" +#define PN_CAB_FRONT_FAN_OUTER "frontFanOuter" +#define PN_CAB_FRONT_AIRFLOW "frontAirflow" +#define PN_CAB_BACK_DOOR_OPEN "backDoorOpen" +#define PN_CAB_BACK_FAN_INNER "backFanInner" +#define PN_CAB_BACK_FAN_OUTER "backFanOuter" +#define PN_CAB_BACK_AIRFLOW "backAirflow" +#define PN_CAB_TEMP_ALARM "tempAlarm" +#define PN_CAB_HUMIDITY_ALARM "humidityAlarm" +#define PN_CAB_TEMPERATURE "temperature" +#define PN_CAB_TEMP_MIN "tempMin" +#define PN_CAB_TEMP_MAX "tempMax" +#define PN_CAB_TEMP_MAX_MAX "tempMaxMax" +#define PN_CAB_HUMIDITY "humidity" +#define PN_CAB_HUMIDITY_MAX "humidityMax" +#define PN_CAB_HUMIDITY_MAX_MAX "humidityMaxMax" +#define PN_CAB_CONTROL_MODE "controlMode" +#define PN_CAB_TEMPERATURE_SENSOR "temperatureSensor" +#define PN_CAB_HUMIDITY_CONTROL "humidityControl" +#define PN_CAB_DOOR_CONTROL "doorControl" + +// SubRack +#define PSN_SUB_RACK "LOFAR_PIC_@cabinet@_@subrack@" +#define PST_SUB_RACK "SubRack" +#define PN_SRCK_SPU_STATUS_STATE "SPU.status.state" +#define PN_SRCK_SPU_STATUS_CHILD_STATE "SPU.status.childState" +#define PN_SRCK_SPU_STATUS_MESSAGE "SPU.status.message" +#define PN_SRCK_SPU_STATUS_LEAF "SPU.status.leaf" +#define PN_SRCK_SPU__VHBA "SPU.Vhba" +#define PN_SRCK_SPU__VLBA "SPU.Vlba" +#define PN_SRCK_SPU__VDIG "SPU.Vdig" +#define PN_SRCK_SPU_TEMPERATURE "SPU.temperature" +#define PN_SRCK_CLOCK_BOARD_STATUS_STATE "clockBoard.status.state" +#define PN_SRCK_CLOCK_BOARD_STATUS_CHILD_STATE "clockBoard.status.childState" +#define PN_SRCK_CLOCK_BOARD_STATUS_MESSAGE "clockBoard.status.message" +#define PN_SRCK_CLOCK_BOARD_STATUS_LEAF "clockBoard.status.leaf" +#define PN_SRCK_CLOCK_BOARD__VFSP "clockBoard.Vfsp" +#define PN_SRCK_CLOCK_BOARD__VCLOCK "clockBoard.Vclock" +#define PN_SRCK_CLOCK_BOARD_VERSION "clockBoard.version" +#define PN_SRCK_CLOCK_BOARD_FREQ "clockBoard.freq" +#define PN_SRCK_CLOCK_BOARD_LOCK160 "clockBoard.lock160" +#define PN_SRCK_CLOCK_BOARD_LOCK200 "clockBoard.lock200" +#define PN_SRCK_CLOCK_BOARD_TEMPERATURE "clockBoard.temperature" + +// RSPBoard +#define PSN_RSP_BOARD "LOFAR_PIC_@cabinet@_@subrack@_@RSPBoard@" +#define PST_RSP_BOARD "RSPBoard" +#define PN_RSP_VOLTAGE12 "voltage12" +#define PN_RSP_VOLTAGE25 "voltage25" +#define PN_RSP_VOLTAGE33 "voltage33" +#define PN_RSP_VERSION "version" +#define PN_RSP_BITMODE "bitmode" +#define PN_RSP_BITMODE_CAPABILITY "bitmodeCapability" +#define PN_RSP_ALERT "alert" +#define PN_RSP_SPLITTER_ON "splitterOn" +#define PN_RSP__ETHERNET_STATUS_STATE "Ethernet.status.state" +#define PN_RSP__ETHERNET_STATUS_CHILD_STATE "Ethernet.status.childState" +#define PN_RSP__ETHERNET_STATUS_MESSAGE "Ethernet.status.message" +#define PN_RSP__ETHERNET_STATUS_LEAF "Ethernet.status.leaf" +#define PN_RSP_ETHERNET_PACKETS_RECEIVED "Ethernet.packetsReceived" +#define PN_RSP_ETHERNET_PACKETS_ERROR "Ethernet.packetsError" +#define PN_RSP_ETHERNET_LAST_ERROR "Ethernet.lastError" +#define PN_RSP_MEP_SEQNR "MEP.seqnr" +#define PN_RSP_MEP_ERROR "MEP.error" +#define PN_RSP_BP_STATUS_STATE "BP.status.state" +#define PN_RSP_BP_STATUS_CHILD_STATE "BP.status.childState" +#define PN_RSP_BP_STATUS_MESSAGE "BP.status.message" +#define PN_RSP_BP_STATUS_LEAF "BP.status.leaf" +#define PN_RSP_BP_TEMPERATURE "BP.temperature" +#define PN_RSP_BP_VERSION "BP.version" +#define PN_RSP_AP0_STATUS_STATE "AP0.status.state" +#define PN_RSP_AP0_STATUS_CHILD_STATE "AP0.status.childState" +#define PN_RSP_AP0_STATUS_MESSAGE "AP0.status.message" +#define PN_RSP_AP0_STATUS_LEAF "AP0.status.leaf" +#define PN_RSP_AP0_TEMPERATURE "AP0.temperature" +#define PN_RSP_AP0_VERSION "AP0.version" +#define PN_RSP_AP0_SYNC_SAMPLE_COUNT "AP0.SYNC.sampleCount" +#define PN_RSP_AP0_SYNC_SYNC_COUNT "AP0.SYNC.syncCount" +#define PN_RSP_AP0_SYNC_ERROR_COUNT "AP0.SYNC.errorCount" +#define PN_RSP_AP1_STATUS_STATE "AP1.status.state" +#define PN_RSP_AP1_STATUS_CHILD_STATE "AP1.status.childState" +#define PN_RSP_AP1_STATUS_MESSAGE "AP1.status.message" +#define PN_RSP_AP1_STATUS_LEAF "AP1.status.leaf" +#define PN_RSP_AP1_TEMPERATURE "AP1.temperature" +#define PN_RSP_AP1_VERSION "AP1.version" +#define PN_RSP_AP1_SYNC_SAMPLE_COUNT "AP1.SYNC.sampleCount" +#define PN_RSP_AP1_SYNC_SYNC_COUNT "AP1.SYNC.syncCount" +#define PN_RSP_AP1_SYNC_ERROR_COUNT "AP1.SYNC.errorCount" +#define PN_RSP_AP2_STATUS_STATE "AP2.status.state" +#define PN_RSP_AP2_STATUS_CHILD_STATE "AP2.status.childState" +#define PN_RSP_AP2_STATUS_MESSAGE "AP2.status.message" +#define PN_RSP_AP2_STATUS_LEAF "AP2.status.leaf" +#define PN_RSP_AP2_TEMPERATURE "AP2.temperature" +#define PN_RSP_AP2_VERSION "AP2.version" +#define PN_RSP_AP2_SYNC_SAMPLE_COUNT "AP2.SYNC.sampleCount" +#define PN_RSP_AP2_SYNC_SYNC_COUNT "AP2.SYNC.syncCount" +#define PN_RSP_AP2_SYNC_ERROR_COUNT "AP2.SYNC.errorCount" +#define PN_RSP_AP3_STATUS_STATE "AP3.status.state" +#define PN_RSP_AP3_STATUS_CHILD_STATE "AP3.status.childState" +#define PN_RSP_AP3_STATUS_MESSAGE "AP3.status.message" +#define PN_RSP_AP3_STATUS_LEAF "AP3.status.leaf" +#define PN_RSP_AP3_TEMPERATURE "AP3.temperature" +#define PN_RSP_AP3_VERSION "AP3.version" +#define PN_RSP_AP3_SYNC_SAMPLE_COUNT "AP3.SYNC.sampleCount" +#define PN_RSP_AP3_SYNC_SYNC_COUNT "AP3.SYNC.syncCount" +#define PN_RSP_AP3_SYNC_ERROR_COUNT "AP3.SYNC.errorCount" + +// RCU +#define PSN_RCU "LOFAR_PIC_@cabinet@_@subrack@_@RSPBoard@_@rcu@" +#define PST_RCU "RCU" +#define PN_RCU_DELAY "Delay" +#define PN_RCU_INPUT_ENABLE "InputEnable" +#define PN_RCU_LBL_ENABLE "LBLEnable" +#define PN_RCU_LBH_ENABLE "LBHEnable" +#define PN_RCU_HBA_ENABLE "HBAEnable" +#define PN_RCU_BAND_SEL_LBA_HBA "bandSelLbaHba" +#define PN_RCU_HBA_FILTER_SEL "HBAFilterSel" +#define PN_RCU_VL_ENABLE "VlEnable" +#define PN_RCU_VH_ENABLE "VhEnable" +#define PN_RCU_VDD_VCC_ENABLE "VddVccEnable" +#define PN_RCU_BAND_SEL_LBL_LBH "bandSelLblLbh" +#define PN_RCU_LBA_FILTER_SEL "LBAFilterSel" +#define PN_RCU_ATTENUATION "Attenuation" +#define PN_RCU_NOF_OVERFLOW "nofOverflow" +#define PN_RCU_ADC_STATISTICS_OVERFLOW "ADCStatistics.overflow" +#define PN_RCU_ANTENNAS "antennas" +#define PN_RCU_TBB_ERROR "TBB.error" +#define PN_RCU_TBB_MODE "TBB.mode" +#define PN_RCU_TBB_START_ADDR "TBB.startAddr" +#define PN_RCU_TBB_BUF_SIZE "TBB.bufSize" +#define PN_RCU_TRIGGER_STARTLEVEL "Trigger.startlevel" +#define PN_RCU_TRIGGER_BASELEVEL "Trigger.baselevel" +#define PN_RCU_TRIGGER_STOPLEVEL "Trigger.stoplevel" +#define PN_RCU_TRIGGER_FILTER "Trigger.filter" +#define PN_RCU_TRIGGER_WINDOW "Trigger.window" +#define PN_RCU_TRIGGER_OPERATING_MODE "Trigger.operatingMode" +#define PN_RCU_TRIGGER_TRIGGER_MODE "Trigger.triggerMode" +#define PN_RCU_TRIGGER_FILTER0_COEFF0 "Trigger.filter0.coeff0" +#define PN_RCU_TRIGGER_FILTER0_COEFF1 "Trigger.filter0.coeff1" +#define PN_RCU_TRIGGER_FILTER0_COEFF2 "Trigger.filter0.coeff2" +#define PN_RCU_TRIGGER_FILTER0_COEFF3 "Trigger.filter0.coeff3" +#define PN_RCU_TRIGGER_FILTER1_COEFF0 "Trigger.filter1.coeff0" +#define PN_RCU_TRIGGER_FILTER1_COEFF1 "Trigger.filter1.coeff1" +#define PN_RCU_TRIGGER_FILTER1_COEFF2 "Trigger.filter1.coeff2" +#define PN_RCU_TRIGGER_FILTER1_COEFF3 "Trigger.filter1.coeff3" + +// TBBoard +#define PSN_TB_BOARD "LOFAR_PIC_@cabinet@_@subrack@_@TBBoard@" +#define PST_TB_BOARD "TBBoard" +#define PN_TBB_BOARDID "boardID" +#define PN_TBB_RAM_SIZE "RAMSize" +#define PN_TBB_SW_VERSION "SWVersion" +#define PN_TBB_BOARD_VERSION "boardVersion" +#define PN_TBB_TP_VERSION "TPVersion" +#define PN_TBB_MP0_VERSION "MP0Version" +#define PN_TBB_MP1_VERSION "MP1Version" +#define PN_TBB_MP2_VERSION "MP2Version" +#define PN_TBB_MP3_VERSION "MP3Version" +#define PN_TBB_VOLTAGE12 "voltage12" +#define PN_TBB_VOLTAGE25 "voltage25" +#define PN_TBB_VOLTAGE33 "voltage33" +#define PN_TBB_TEMPPCB "tempPCB" +#define PN_TBB_TEMPTP "tempTP" +#define PN_TBB_TEMPMP0 "tempMP0" +#define PN_TBB_TEMPMP1 "tempMP1" +#define PN_TBB_TEMPMP2 "tempMP2" +#define PN_TBB_TEMPMP3 "tempMP3" +#define PN_TBB_RECORDING "recording" +#define PN_TBB_IMAGE_INFO_VERSION "imageInfo.version" +#define PN_TBB_IMAGE_INFO_WRITE_DATE "imageInfo.writeDate" +#define PN_TBB_IMAGE_INFO_TP_FILE "imageInfo.TPFile" +#define PN_TBB_IMAGE_INFO_MP_FILE "imageInfo.MPFile" + +// LBAAntenna +#define PSN_LBA_ANTENNA "LOFAR_PIC_@lbaantenna@" +#define PST_LBA_ANTENNA "LBAAntenna" + +// HBAAntenna +#define PSN_HBA_ANTENNA "LOFAR_PIC_@hbaantenna@" +#define PST_HBA_ANTENNA "HBAAntenna" + +// StationInfo +#define PSN_STATION_INFO "LOFAR_PIC_StationInfo" +#define PST_STATION_INFO "StationInfo" +#define PN_STI_STATIONID "stationID" +#define PN_STI_N_RSP_BOARDS "N_RSPBoards" +#define PN_STI_N_TB_BOARDS "N_TBBoards" +#define PN_STI_N_LBAS "N_LBAS" +#define PN_STI_N_HBAS "N_HBAS" +#define PN_STI_HBA__SPLIT "HBA_Split" +#define PN_STI_WIDE_LBAS "wide_LBAS" +#define PN_STI_POWER48_ON "power48On" +#define PN_STI_POWER220_ON "power220On" +#define PN_STI_DATASTREAM0 "datastream0" +#define PN_STI_DATASTREAM1 "datastream1" +#define PN_STI_CABINET_X "Cabinet.X" +#define PN_STI_CABINET_Y "Cabinet.Y" +#define PN_STI_CABINET_Z "Cabinet.Z" +#define PN_STI_HBA_NR_BROKEN "HBA.nrBroken" +#define PN_STI_HBA_NR_BROKEN_ARCHIVE "HBA.nrBrokenArchive" +#define PN_STI_HBA_CENTERX "HBA.centerX" +#define PN_STI_HBA_CENTERY "HBA.centerY" +#define PN_STI_HBA_CENTERZ "HBA.centerZ" +#define PN_STI_HBA_HBA0_CENTERX "HBA.HBA0.centerX" +#define PN_STI_HBA_HBA0_CENTERY "HBA.HBA0.centerY" +#define PN_STI_HBA_HBA0_CENTERZ "HBA.HBA0.centerZ" +#define PN_STI_HBA_HBA0__NORMAL_VECTOR_X "HBA.HBA0.NormalVector.X" +#define PN_STI_HBA_HBA0__NORMAL_VECTOR_Y "HBA.HBA0.NormalVector.Y" +#define PN_STI_HBA_HBA0__NORMAL_VECTOR_Z "HBA.HBA0.NormalVector.Z" +#define PN_STI_HBA_HBA0__ROTATION_MATRIX_X "HBA.HBA0.RotationMatrix.X" +#define PN_STI_HBA_HBA0__ROTATION_MATRIX_Y "HBA.HBA0.RotationMatrix.Y" +#define PN_STI_HBA_HBA0__ROTATION_MATRIX_Z "HBA.HBA0.RotationMatrix.Z" +#define PN_STI_HBA_HBA0_ROTATION "HBA.HBA0.rotation" +#define PN_STI_HBA_HBA1_CENTERX "HBA.HBA1.centerX" +#define PN_STI_HBA_HBA1_CENTERY "HBA.HBA1.centerY" +#define PN_STI_HBA_HBA1_CENTERZ "HBA.HBA1.centerZ" +#define PN_STI_HBA_HBA1__NORMAL_VECTOR_X "HBA.HBA1.NormalVector.X" +#define PN_STI_HBA_HBA1__NORMAL_VECTOR_Y "HBA.HBA1.NormalVector.Y" +#define PN_STI_HBA_HBA1__NORMAL_VECTOR_Z "HBA.HBA1.NormalVector.Z" +#define PN_STI_HBA_HBA1__ROTATION_MATRIX_X "HBA.HBA1.RotationMatrix.X" +#define PN_STI_HBA_HBA1__ROTATION_MATRIX_Y "HBA.HBA1.RotationMatrix.Y" +#define PN_STI_HBA_HBA1__ROTATION_MATRIX_Z "HBA.HBA1.RotationMatrix.Z" +#define PN_STI_HBA_HBA1_ROTATION "HBA.HBA1.rotation" +#define PN_STI_LBA_NR_BROKEN "LBA.nrBroken" +#define PN_STI_LBA_NR_BROKEN_ARCHIVE "LBA.nrBrokenArchive" +#define PN_STI_LBA_CENTERX "LBA.centerX" +#define PN_STI_LBA_CENTERY "LBA.centerY" +#define PN_STI_LBA_CENTERZ "LBA.centerZ" +#define PN_STI_LBA__NORMAL_VECTOR_X "LBA.NormalVector.X" +#define PN_STI_LBA__NORMAL_VECTOR_Y "LBA.NormalVector.Y" +#define PN_STI_LBA__NORMAL_VECTOR_Z "LBA.NormalVector.Z" +#define PN_STI_LBA__ROTATION_MATRIX_X "LBA.RotationMatrix.X" +#define PN_STI_LBA__ROTATION_MATRIX_Y "LBA.RotationMatrix.Y" +#define PN_STI_LBA__ROTATION_MATRIX_Z "LBA.RotationMatrix.Z" + +// LogProcessor +#define PSN_LOG_PROCESSOR "LOFAR_PermSW_Daemons_LogProcessor" +#define PST_LOG_PROCESSOR "LogProcessor" + +// SASGateway +#define PSN_SAS_GATEWAY "LOFAR_PermSW_Daemons_SASGateway" +#define PST_SAS_GATEWAY "SASGateway" + +// SoftwareMonitor +#define PSN_SOFTWARE_MONITOR "LOFAR_PermSW_Daemons_SoftwareMonitor" +#define PST_SOFTWARE_MONITOR "SoftwareMonitor" +#define PN_SWM_SW_LEVEL "SWLevel" + +// HardwareMonitor +#define PSN_HARDWARE_MONITOR "LOFAR_PermSW_HardwareMonitor" +#define PST_HARDWARE_MONITOR "HardwareMonitor" +#define PN_HWM_RSP_CONNECTED "RSP.connected" +#define PN_HWM_TBB_CONNECTED "TBB.connected" +#define PN_HWM_EC_CONNECTED "EC.connected" + +// SHMInfoServer +#define PSN_SHM_INFO_SERVER "LOFAR_PermSW_SHMInfoServer" +#define PST_SHM_INFO_SERVER "SHMInfoServer" + +// StationControl +#define PSN_STATION_CONTROL "LOFAR_PermSW_StationControl" +#define PST_STATION_CONTROL "StationControl" +#define PN_SC_ACTIVE_OBSERVATIONS "activeObservations" + +// ClockControl +#define PSN_CLOCK_CONTROL "LOFAR_PermSW_ClockControl" +#define PST_CLOCK_CONTROL "ClockControl" +#define PN_CLC_CONNECTED "connected" +#define PN_CLC_REQUESTED_CLOCK "requestedClock" +#define PN_CLC_ACTUAL_CLOCK "actualClock" +#define PN_CLC_REQUESTED_BITMODE "requestedBitmode" +#define PN_CLC_ACTUAL_BITMODE "actualBitmode" + +// StnObservation +#define PSN_STN_OBSERVATION "LOFAR_ObsSW_@observation@" +#define PST_STN_OBSERVATION "StnObservation" +#define PN_OBS_NAME "name" +#define PN_OBS_CLAIM_CLAIM_DATE "claim.claimDate" +#define PN_OBS_CLAIM_NAME "claim.name" +#define PN_OBS_RECEIVER_BITMAP "receiverBitmap" +#define PN_OBS_HBA_BITMAP "HBABitmap" +#define PN_OBS_LBA_BITMAP "LBABitmap" + +// BeamControl +#define PSN_BEAM_CONTROL "LOFAR_ObsSW_@observation@_BeamControl" +#define PST_BEAM_CONTROL "BeamControl" +#define PN_BC_CONNECTED "connected" +#define PN_BC_SUB_ARRAY "subArray" +#define PN_BC_SUBBAND_LIST "subbandList" +#define PN_BC_BEAMLET_LIST "beamletList" +#define PN_BC_ANGLE1 "angle1" +#define PN_BC_ANGLE2 "angle2" +#define PN_BC_DIRECTION_TYPE "directionType" +#define PN_BC_BEAM_NAME "beamName" + +// CalibrationControl +#define PSN_CALIBRATION_CONTROL "LOFAR_ObsSW_@observation@_CalibrationControl" +#define PST_CALIBRATION_CONTROL "CalibrationControl" +#define PN_CC_CONNECTED "connected" +#define PN_CC_BEAM_NAMES "beamNames" +#define PN_CC_ANTENNA_ARRAY "antennaArray" +#define PN_CC_FILTER "filter" +#define PN_CC_NYQUISTZONE "nyquistzone" +#define PN_CC_RCUS "rcus" + +// TBBControl +#define PSN_TBB_CONTROL "LOFAR_ObsSW_@observation@_TBBControl" +#define PST_TBB_CONTROL "TBBControl" +#define PN_TBC_CONNECTED "connected" +#define PN_TBC_TRIGGER_RCU_NR "trigger.rcuNr" +#define PN_TBC_TRIGGER_SEQUENCE_NR "trigger.sequenceNr" +#define PN_TBC_TRIGGER_TIME "trigger.time" +#define PN_TBC_TRIGGER_SAMPLE_NR "trigger.sampleNr" +#define PN_TBC_TRIGGER_SUM "trigger.sum" +#define PN_TBC_TRIGGER_NR_SAMPLES "trigger.nrSamples" +#define PN_TBC_TRIGGER_PEAK_VALUE "trigger.peakValue" +#define PN_TBC_TRIGGER_FLAGS "trigger.flags" +#define PN_TBC_TRIGGER_TABLE "trigger.table" +#define PN_TBC_TRIGGER_MISSED "trigger.missed" + +#endif diff --git a/LCS/ApplCommon/include/ApplCommon/StationInfo.h b/LCS/ApplCommon/include/ApplCommon/StationInfo.h index fba98ff296f7cc55ffbef1323270b715f4b8bf74..2569e63e86585fa8c6bf981837c4a011085cb8af 100644 --- a/LCS/ApplCommon/include/ApplCommon/StationInfo.h +++ b/LCS/ApplCommon/include/ApplCommon/StationInfo.h @@ -53,6 +53,17 @@ string stationRingName(); // Core, Remote, Europe string PVSSDatabaseName(const string& someName = ""); // hostname w/o CUtype string realHostname(const string& someName); // adds 'C' when it is missing. +// Get the ObservationNr from the controllername. +uint32 getObservationNr (const string& ObservationName); + +// Get the instanceNr from the controllername. +uint16 getInstanceNr (const string& ObservationName); + +// Construct PS name solving markers line @observation@, @ring@, etc. +string createPropertySetName(const string& propSetMask, + const string& controllerName, + const string& realDPname = "REALDPNAME"); + string PVSS2SASname(const string& PVSSname); // convert PVSS DPname to SAS DPname string SAS2PVSSname(const string& SASname); // convert SAS DPname to PVSS DPname diff --git a/LCS/ApplCommon/src/StationInfo.cc b/LCS/ApplCommon/src/StationInfo.cc index f6cbc084553db80ca2528ea2ffef8883bb669e5d..f77212a37763a0a4e900324c695ba5ae53b7e0e5 100644 --- a/LCS/ApplCommon/src/StationInfo.cc +++ b/LCS/ApplCommon/src/StationInfo.cc @@ -25,6 +25,7 @@ #include <Common/lofar_string.h> #include <Common/LofarTypes.h> +#include <Common/ParameterSet.h> // indexValue #include <Common/StringUtil.h> #include <Common/SystemUtil.h> #include <ApplCommon/StationInfo.h> @@ -138,6 +139,160 @@ string realHostname(const string& someName) return (someName+'C'); } +// +// getObservationNr(controllerName) +// +// Get the ObservationNr from the controllername. +uint32 getObservationNr (const string& controllerName) +{ + return (indexValue(controllerName, "{}")); +} + +// +// getInstanceNr(controllername) +// +// Get the instanceNr from the controllername. +uint16 getInstanceNr (const string& controllerName) +{ + string cntlrName (controllerName); // destroyable copy + rtrim(cntlrName, "{}0123456789"); + return (indexValue(cntlrName, "[]")); +} + +// +// createPropertySetName(propSetMask) +// +// A PropSetMask may contain the markers: +// @ring@ +// @station@ +// @instance@ +// @observation@ +// @cabinet@ +// @subrack@ +// @RSPboard@ +// @TBboard@ +// @rcu@ +// @bgp@ +// @midplane@ +// @ionode@ +// @osrack@ +// @ossubcluster@ +// @storagenode@ +// @offlinenode@ +// @inputbuffer@ +// @adder@ +// @storage@ +// @cobaltnode@ +// @cobaltnic@ +// @oscobaltnode@ +// @pscobaltnode@ +// @cobaltgpuproc@ +// +string createPropertySetName(const string& propSetMask, + const string& controllerName, + const string& realDPname) +{ + string psName(propSetMask); // editable copy + string::size_type pos; + // when name contains @ring@_@station@ cut out this marker and prepend hostname + // stationname+: -> LOFAR_ObsSW_@ring@_@station@_CalCtrl_xxx --> CS010:LOFAR_ObsSW_CalCtrl_xxx + if ((pos = psName.find("@ring@_@station@_")) != string::npos) { + psName.erase(pos, 17); + psName = PVSSDatabaseName(myHostname(false)) + ":" + psName; + } + + if ((pos = psName.find("@ring@")) != string::npos) { + psName.replace(pos, 6, stationRingName()); + } + + if ((pos = psName.find("@station@")) != string::npos) { + psName.replace(pos, 9, PVSSDatabaseName(myHostname(false))); + } + + if ((pos = psName.find("@instance@")) != string::npos) { + uint16 instanceNr = getInstanceNr(controllerName); + if (instanceNr) { + psName.replace(pos, 10, lexical_cast<string>(instanceNr)); + } + else { + psName.replace(pos, 10, ""); + } + } + + if ((pos = psName.find("LOFAR_ObsSW_@observation@")) != string::npos) { + psName.replace(pos, 25, realDPname); + } + + if ((pos = psName.find("@cabinet@")) != string::npos) { + psName.replace(pos, 9, string("Cabinet%d")); + } + if ((pos = psName.find("@subrack@")) != string::npos) { + psName.replace(pos, 9, string("Subrack%d")); + } + if ((pos = psName.find("@RSPBoard@")) != string::npos) { + psName.replace(pos, 10, string("RSPBoard%d")); + } + if ((pos = psName.find("@TBBoard@")) != string::npos) { + psName.replace(pos, 9, string("TBBoard%d")); + } + if ((pos = psName.find("@rcu@")) != string::npos) { + psName.replace(pos, 5, string("RCU%d")); + } + if ((pos = psName.find("@bgp@")) != string::npos) { + psName.replace(pos, 5, string("BGP%d")); + } + if ((pos = psName.find("@midplane@")) != string::npos) { + psName.replace(pos, 10, string("Midplane%d")); + } + if ((pos = psName.find("@ionode@")) != string::npos) { + psName.replace(pos, 8, string("IONode%02d")); + } + if ((pos = psName.find("@osionode@")) != string::npos) { + psName.replace(pos, 10, string("OSIONode%02d")); + } + if ((pos = psName.find("@locusnode@")) != string::npos) { + psName.replace(pos, 11, string("LocusNode%03d")); + } + if ((pos = psName.find("@osrack@")) != string::npos) { + psName.replace(pos, 8, string("OSRack%d")); + } + if ((pos = psName.find("@ossubcluster@")) != string::npos) { + psName.replace(pos, 14, string("OSSubcluster%d")); + } + if ((pos = psName.find("@storagenode@")) != string::npos) { + psName.replace(pos, 13, string("StorageNode%d")); + } + if ((pos = psName.find("@offlinenode@")) != string::npos) { + psName.replace(pos, 13, string("OfflineNode%d")); + } + if ((pos = psName.find("@inputbuffer@")) != string::npos) { + psName.replace(pos, 13, string("InputBuffer%d")); + } + if ((pos = psName.find("@adder@")) != string::npos) { + psName.replace(pos, 7, string("Adder%d")); + } + if ((pos = psName.find("@storage@")) != string::npos) { + psName.replace(pos, 9, string("Storage%d")); + } + if ((pos = psName.find("@cobaltnode@")) != string::npos) { + psName.replace(pos, 12, string("CBT%03d")); + } + if ((pos = psName.find("@cobaltnic@")) != string::npos) { + psName.replace(pos, 11, string("CobaltNIC%02d")); + } + if ((pos = psName.find("@oscobaltnode@")) != string::npos) { + psName.replace(pos, 14, string("OSCBT%03d")); + } + if ((pos = psName.find("@pscobaltnode@")) != string::npos) { + psName.replace(pos, 14, string("PSCBT%03d")); + } + if ((pos = psName.find("@cobaltgpuproc@")) != string::npos) { + psName.replace(pos, 15, string("CobaltGPUProc%02d")); + } + + return (psName); +} + #if defined HAVE_BOOST_REGEX // diff --git a/LCS/Common/include/Common/StringUtil.h b/LCS/Common/include/Common/StringUtil.h index f8105ea4ab4d87d98e67a3424ab80db7a803de4c..d97c4edf1a30904c01d4e43c4272723aaae835c3 100644 --- a/LCS/Common/include/Common/StringUtil.h +++ b/LCS/Common/include/Common/StringUtil.h @@ -143,6 +143,9 @@ uint lskipws (const string& value, uint st, uint end); // It returns st if all whitespace. uint rskipws (const string& value, uint st, uint end); +// Skip the leading and trailing whitespace and square brackets. +string stripBrackets(const string& orgStr); + // Skip past a quoted string. // The quote character is the first character (at position st). // Usually the quote character is ' or ", but it could be any other character. diff --git a/LCS/Common/src/StringUtil.cc b/LCS/Common/src/StringUtil.cc index 3a0f794b1804f8a61f5f0b906e01c2093d5f9590..4a06213b4bbca1d4b2e4696cfa6b52f7590b93fb 100644 --- a/LCS/Common/src/StringUtil.cc +++ b/LCS/Common/src/StringUtil.cc @@ -508,7 +508,7 @@ uint64 strToUint64 (const string& aString) throw(Exception) string compactedArrayString(const string& orgStr) { string baseString(orgStr); // destroyable copy - ltrim(baseString, " ["); // strip of brackets + ltrim(baseString, " ["); // strip off brackets rtrim(baseString, " ]"); // and split into a vector @@ -597,11 +597,11 @@ string compactedArrayString(const string& orgStr) return (result+"]"); } -string stripBraces(const string& orgStr) +string stripBrackets(const string& orgStr) { string baseString(orgStr); // destroyable copy - ltrim(baseString, " ["); // strip of brackets - rtrim(baseString, " ]"); + ltrim(baseString, " \t["); // strip off brackets + rtrim(baseString, " \t]"); return baseString; } diff --git a/LCS/Common/test/tStringUtil.cc b/LCS/Common/test/tStringUtil.cc index 2c78c5a6cead9576201513a5f9d34057375925ba..490f92458d4aaad889e88c6302de39826cb30cdf 100644 --- a/LCS/Common/test/tStringUtil.cc +++ b/LCS/Common/test/tStringUtil.cc @@ -157,6 +157,22 @@ bool testSkipws() return true; } +bool testStripBrackets() +{ + string r1(" a String with leading and trailing whitespace "); + string r2("a String without leading and trailing whitespace"); + string r3(" [a string with [ and ] inside and surrounding the text. ] "); + string r4("[ [ a string with multiple [ and ] inside and surrounding the text. ] ] "); + + cout << "Bracket-stripped C++ strings:" << endl; + cout << ">" << stripBrackets(r1) << "<" << endl; + cout << ">" << stripBrackets(r2) << "<" << endl; + cout << ">" << stripBrackets(r3) << "<" << endl; + cout << ">" << stripBrackets(r4) << "<" << endl; + + return true; +} + bool testCase() { @@ -376,6 +392,7 @@ int main() testCompare(false) && testCompare(true) && testTrim() && + testStripBrackets()&& testSkipws() && testCase() && testToString() && diff --git a/LCS/Common/test/tStringUtil.stdout b/LCS/Common/test/tStringUtil.stdout index ca5aec84203e3b2b7b869989068d11dcaf9d388f..34b1d39f063886623013a6fb680155ea98e17e22 100644 --- a/LCS/Common/test/tStringUtil.stdout +++ b/LCS/Common/test/tStringUtil.stdout @@ -30,6 +30,11 @@ Trimmed C strings: >a String with leading and trailing whitespace< , len=45 >a String without leading and trailing whitespace< , len=48 >String with(out) itemnr and arrayindex< , len=38 +Bracket-stripped C++ strings: +>a String with leading and trailing whitespace< +>a String without leading and trailing whitespace< +>a string with [ and ] inside and surrounding the text.< +>a string with multiple [ and ] inside and surrounding the text.< Lowercase and uppercase a string: orginal: The zip code of Hondelage in Germany is 38108 lowered: the zip code of hondelage in germany is 38108 @@ -132,6 +137,6 @@ toString(double(M_PI*1e12),"%+08.12g") = +3.14159265359e+12 [(1,2,3)] ==> [(1,2,3)] Performance test of expandArrayString >>> -timer: avg = 46163, total = 46163 cycles, count = 1 +timer: avg = 28.6 us, total = 28.6 us, count = 1 <<< [abc001,abc002,abc003,abc004,abc005,abc006,abc007,abc008,abc009,abc010,abc45,abc46,abc47,abc48,abc49,abc50] diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h index f15072bfd5278f786c4196bc6d116ce673e0fcff..04352c5fed3179687619be457f8865442c11eaa7 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h @@ -106,12 +106,6 @@ string getExecutable (uint16 cntlrType); // return 'shared' bit of controllertype bool isSharedController(uint16 cntrlType) ; -// Get the ObservationNr from the controllername. -uint32 getObservationNr (const string& ObservationName); - -// Get the instanceNr from the controllername. -uint16 getInstanceNr (const string& ObservationName); - // Get the controllerType from the controllername. int32 getControllerType (const string& ObservationName); @@ -121,11 +115,6 @@ string observationName(int obsID); // Get the name of the parset of the observation. string observationParset(int obsID); -// Construct PS name solving markers line @observation@, @ring@, etc. -string createPropertySetName(const string& propSetMask, - const string& controllerName, - const string& realDPname = "REALDPNAME"); - // Construct a message the matches the given CTState and send it on the port. bool sendControlResult(GCF::TM::GCFPortInterface& port, uint16 signal, diff --git a/MAC/APL/APLCommon/src/ControllerDefines.cc b/MAC/APL/APLCommon/src/ControllerDefines.cc index bc70abd9ca487c8b365e72570ff683fae30ab074..ba80f725ad8bca02ca1a6459749469d1800a5c50 100644 --- a/MAC/APL/APLCommon/src/ControllerDefines.cc +++ b/MAC/APL/APLCommon/src/ControllerDefines.cc @@ -27,9 +27,8 @@ #include <Common/LofarLogger.h> #include <Common/StringUtil.h> // rtrim #include <Common/SystemUtil.h> -#include <Common/ParameterSet.h> // indexValue +#include <ApplCommon/LofarDirs.h> #include <APL/APLCommon/ControllerDefines.h> -#include <ApplCommon/StationInfo.h> #include "Controller_Protocol.ph" #include <boost/config.hpp> @@ -160,26 +159,6 @@ bool isSharedController(uint16 cntlrType) return (controllerTable[cntlrType].shared); } -// -// getObservationNr(controllerName) -// -// Get the ObservationNr from the controllername. -uint32 getObservationNr (const string& controllerName) -{ - return (indexValue(controllerName, "{}")); -} - -// -// getInstanceNr(controllername) -// -// Get the instanceNr from the controllername. -uint16 getInstanceNr (const string& controllerName) -{ - string cntlrName (controllerName); // destroyable copy - rtrim(cntlrName, "{}0123456789"); - return (indexValue(cntlrName, "[]")); -} - // // getControllerType(controllerName) // @@ -230,140 +209,6 @@ string observationParset(int obsID) return (formatString("%s/%s", LOFAR_SHARE_LOCATION, observationName(obsID).c_str())); } -// -// createPropertySetName(propSetMask) -// -// A PropSetMask may contain the markers: -// @ring@ -// @station@ -// @instance@ -// @observation@ -// @cabinet@ -// @subrack@ -// @RSPboard@ -// @TBboard@ -// @rcu@ -// @bgp@ -// @midplane@ -// @ionode@ -// @osrack@ -// @ossubcluster@ -// @storagenode@ -// @offlinenode@ -// @inputbuffer@ -// @adder@ -// @storage@ -// @cobaltnode@ -// @cobaltnic@ -// @oscobaltnode@ -// @pscobaltnode@ -// @cobaltgpuproc@ -// -string createPropertySetName(const string& propSetMask, - const string& controllerName, - const string& realDPname) -{ - string psName(propSetMask); // editable copy - string::size_type pos; - // when name contains @ring@_@station@ cut out this marker and prepend hostname - // stationname+: -> LOFAR_ObsSW_@ring@_@station@_CalCtrl_xxx --> CS010:LOFAR_ObsSW_CalCtrl_xxx - if ((pos = psName.find("@ring@_@station@_")) != string::npos) { - psName.erase(pos, 17); - psName = PVSSDatabaseName(myHostname(false)) + ":" + psName; - } - - if ((pos = psName.find("@ring@")) != string::npos) { - psName.replace(pos, 6, stationRingName()); - } - - if ((pos = psName.find("@station@")) != string::npos) { - psName.replace(pos, 9, PVSSDatabaseName(myHostname(false))); - } - - if ((pos = psName.find("@instance@")) != string::npos) { - uint16 instanceNr = getInstanceNr(controllerName); - if (instanceNr) { - psName.replace(pos, 10, lexical_cast<string>(instanceNr)); - } - else { - psName.replace(pos, 10, ""); - } - } - - if ((pos = psName.find("LOFAR_ObsSW_@observation@")) != string::npos) { - psName.replace(pos, 25, realDPname); - } - - if ((pos = psName.find("@cabinet@")) != string::npos) { - psName.replace(pos, 9, string("Cabinet%d")); - } - if ((pos = psName.find("@subrack@")) != string::npos) { - psName.replace(pos, 9, string("Subrack%d")); - } - if ((pos = psName.find("@RSPBoard@")) != string::npos) { - psName.replace(pos, 10, string("RSPBoard%d")); - } - if ((pos = psName.find("@TBBoard@")) != string::npos) { - psName.replace(pos, 9, string("TBBoard%d")); - } - if ((pos = psName.find("@rcu@")) != string::npos) { - psName.replace(pos, 5, string("RCU%d")); - } - if ((pos = psName.find("@bgp@")) != string::npos) { - psName.replace(pos, 5, string("BGP%d")); - } - if ((pos = psName.find("@midplane@")) != string::npos) { - psName.replace(pos, 10, string("Midplane%d")); - } - if ((pos = psName.find("@ionode@")) != string::npos) { - psName.replace(pos, 8, string("IONode%02d")); - } - if ((pos = psName.find("@osionode@")) != string::npos) { - psName.replace(pos, 10, string("OSIONode%02d")); - } - if ((pos = psName.find("@locusnode@")) != string::npos) { - psName.replace(pos, 11, string("LocusNode%03d")); - } - if ((pos = psName.find("@osrack@")) != string::npos) { - psName.replace(pos, 8, string("OSRack%d")); - } - if ((pos = psName.find("@ossubcluster@")) != string::npos) { - psName.replace(pos, 14, string("OSSubcluster%d")); - } - if ((pos = psName.find("@storagenode@")) != string::npos) { - psName.replace(pos, 13, string("StorageNode%d")); - } - if ((pos = psName.find("@offlinenode@")) != string::npos) { - psName.replace(pos, 13, string("OfflineNode%d")); - } - if ((pos = psName.find("@inputbuffer@")) != string::npos) { - psName.replace(pos, 13, string("InputBuffer%d")); - } - if ((pos = psName.find("@adder@")) != string::npos) { - psName.replace(pos, 7, string("Adder%d")); - } - if ((pos = psName.find("@storage@")) != string::npos) { - psName.replace(pos, 9, string("Storage%d")); - } - if ((pos = psName.find("@cobaltnode@")) != string::npos) { - psName.replace(pos, 12, string("CBT%03d")); - } - if ((pos = psName.find("@cobaltnic@")) != string::npos) { - psName.replace(pos, 11, string("CobaltNIC%02d")); - } - if ((pos = psName.find("@oscobaltnode@")) != string::npos) { - psName.replace(pos, 14, string("OSCBT%03d")); - } - if ((pos = psName.find("@pscobaltnode@")) != string::npos) { - psName.replace(pos, 14, string("PSCBT%03d")); - } - if ((pos = psName.find("@cobaltgpuproc@")) != string::npos) { - psName.replace(pos, 15, string("CobaltGPUProc%02d")); - } - - return (psName); -} - // // sendControlResult(port, CONTROLsignal, cntlrName, result) // diff --git a/MAC/APL/APLCommon/src/swlevel b/MAC/APL/APLCommon/src/swlevel index de4035faa5762dc54878a7731c91b993e20173ec..230dc8391daccd04780508811c4dc2f744a21ac7 100644 --- a/MAC/APL/APLCommon/src/swlevel +++ b/MAC/APL/APLCommon/src/swlevel @@ -53,7 +53,7 @@ SyntaxError() echo "-s: Show current level, exit (-S: only print number)" echo "-p: Print last set level from logfile (-P: only print number)" echo "-v: Show running LOFAR version, exit (-V: only print version)" - echo "-u: Show users owning running processes (-U: same)" + echo "-u: Show users owning running processes (-U: same)" echo "-i: Load RSP firmware from image [x] (default image is 1)" echo "-l: Set to level as provided (optional)" echo "-q: Quit process with name processname" @@ -184,10 +184,8 @@ start_prog() sudo rm -f $LOGDIR/$prog.log.? 1>/dev/null 2>&1 if [ "$prog" = "RSPDriver" ]; then selectImage - sudo -b $BINDIR/$prog 1>>$LOGDIR/$prog.stdout.${curdate} 2>&1 - else - sudo -b $BINDIR/$prog 1>>$LOGDIR/$prog.stdout.${curdate} 2>&1 - fi + fi + sudo -b $BINDIR/$prog 1>>$LOGDIR/$prog.stdout.${curdate} 2>&1 else echo Starting $prog rm -f $LOGDIR/$prog.log*.? 1>/dev/null 2>&1 @@ -249,42 +247,43 @@ stop_prog() usleep 500000 done - # when normal kill did not work, kill it with -9 + # when normal kill did not work, kill is with -9 for pid in `/sbin/pidof ${prog}` do echo "Hard killing ${prog}(${pid})" $asroot kill -9 $pid 1>/dev/null 2>&1 usleep 500000 done - - # if user0 or lofarsys, try normal kill as root - for pid in `/sbin/pidof ${prog}` - do - if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then - sudo kill $pid 1>/dev/null 2>&1 - usleep 50000 - fi - done - - # if user0 or lofarsys, try hard kill as root - for pid in `/sbin/pidof ${prog}` - do - if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then - sudo kill -9 $pid 1>/dev/null 2>&1 - usleep 50000 - fi - done - - # if still alive, write a message - for pid in `/sbin/pidof ${prog}` - do - echo -n "Could not kill ${prog}(${pid}); " - if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then - echo "tried it as root as well, giving up..." - else - echo "probably run by another user, contact your system administrator" - fi + # if user0 or lofarsys, try normal kill as root + + for pid in `/sbin/pidof ${prog}` + do + if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then + sudo kill $pid 1>/dev/null 2>&1 + usleep 50000 + fi + done + + # if user0 or lofarsys, try hard kill as root + for pid in `/sbin/pidof ${prog}` + do + if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then + sudo kill -9 $pid 1>/dev/null 2>&1 + usleep 50000 + fi + done + + # if still alive, write a message + for pid in `/sbin/pidof ${prog}` + do + echo -n "Could not kill ${prog}(${pid}); " + if [ "$user" == "user0" -o "$user" == "lofarsys" ]; then + echo "tried it as root as well, giving up..." + else + echo "probably run by another user, contact your system administrator" + fi done + } # @@ -323,7 +322,7 @@ status_prog() # find out the processID of the possibly (running) process obsid=() - pid_user=() + pid_user=() /sbin/pidof ${prog} 1>/dev/null 2>&1 if [ $? -eq 0 ]; then pid=( `/sbin/pidof ${prog}` ) @@ -331,8 +330,8 @@ status_prog() for apid in ${pid[@]} do obsid[i]=`ps -p $apid --no-heading -o command | awk -F{ '{print $2}' | awk -F} '{print $1}'` - if [ $show_users -eq 1 ]; then - pid_user[i]=`ps -p $apid -o user=` + if [ $show_users -eq 1 ]; then + pid_user[i]=`ps -p $apid -o user=` fi i=$i+1 done @@ -345,9 +344,9 @@ status_prog() fi if [ "$pid" != "DOWN" ] && [ ${#obsid[0]} != 0 ]; then - echo ${levelnr}:${prog}:${pid[*]}:${obsid[*]} | awk -F: '{ printf "%s : %-25s %s [ObsID: %s]\n", $1, $2, $3, $4 }' - elif [ "$pid" != "DOWN" ] && [ ${show_users} -eq 1 ]; then - echo ${levelnr}:${prog}:${pid[*]}:${pid_user[*]} | awk -F: '{ printf "%s : %-25s %s [%s]\n", $1, $2, $3, $4 }' + echo ${levelnr}:${prog}:${pid[*]}:${obsid[*]} | awk -F: '{ printf "%s : %-25s %s [ObsID: %s]\n", $1, $2, $3, $4 }' + elif [ "$pid" != "DOWN" ] && [ ${show_users} -eq 1 ]; then + echo ${levelnr}:${prog}:${pid[*]}:${pid_user[*]} | awk -F: '{ printf "%s : %-25s %s [%s]\n", $1, $2, $3, $4 }' else echo ${levelnr}:${prog}:${pid[*]} | awk -F: '{ printf "%s : %-25s %s\n", $1, $2, $3}' fi @@ -436,26 +435,56 @@ goto_level() # then power up to new level for (( l=1 ; l<=newlevel ; l++ )) do - if [ $l == 3 -a -e $BINDIR/rspctl ]; then - # First make sure RSP images are properly loaded - # Introduce a timeout of 60 sec for images to initialize - echo "Waiting for images to be initialized" - timeout=59 - sleep 1 - for (( s=0 ; s<timeout; s++ )) - do - rsu_ready=`( rspctl --version | grep "0.0" ) >& /dev/null; echo $?` - if [ $rsu_ready == 1 ]; then - echo "Images are loaded" - break - fi - sleep 1 - done - if [ $s == $timeout ]; then - echo "Could not load RSP images in time; Reset RSP boards" - exit 1 - fi - fi + if [ $l == 3 ]; then + if [ -e $BINDIR/rspctl ]; then + # First make sure RSP images are properly loaded + # Introduce a timeout of 60 sec for images to initialize + echo "Waiting for RSP images to be initialized" + timeout=59 + sleep 1 + for (( s=0 ; s<timeout; s++ )) + do + rsu_ready=`( rspctl --version | grep "0.0" ) >& /dev/null; echo $?` + if [ $rsu_ready == 1 ]; then + echo "RSP Images are loaded" + break + fi + sleep 1 + done + if [ $s == $timeout ]; then + echo "Could not load RSP images in time; Reset RSP boards" + exit 1 + fi + fi + if [ -e $BINDIR/tbbctl ]; then + # Now make sure TBB images are properly loaded + # Introduce a timeout of 60 sec for images to initialize + echo "Waiting for TBB images to be initialized" + timeout=59 + sleep 1 + for (( s=0 ; s<timeout; s++ )) + do + tbb_respons=`tbbctl --version` + tbb_ready=`( echo $tbb_respons | grep "\ V\ " ) >& /dev/null; echo $?` + if [ $tbb_ready -eq 0 ]; then + sleep 10 + echo "TBB Images are loaded" + break + fi + tbb_down=`( echo $tbb_respons | grep "TBBDriver is NOT responding" )>& /dev/null; echo $?` + if [ $tbb_down -eq 0 ]; then + echo "TBBDriver is not responding; cannot continue start of TBBs" + # Trigger message furtheron in the code + s=$timeout + break + fi + sleep 1 + done + if [ $s == $timeout ]; then + echo "Could not load TBB images; Reset TBB boards" + fi + fi + fi cat $LEVELTABLE | cut -d"#" -f1 | awk '{ if (NF>0) print $0 }' | grep "^${l}:" | grep ":u:" | while read line do ( @@ -549,52 +578,52 @@ handle_args() # Handle arguments if [ ${#} -gt 1 ]; then - if [[ $1 != \-* ]]; then - echo "Warning: all arguments except level $1 will be ignored" - fi + if [[ $1 != \-* ]]; then + echo "Warning: all arguments except level $1 will be ignored" + fi fi - while getopts "hSsPpVvi:l:q:r:uU" flag + while getopts "hUuSsPpVvi:l:q:r:" flag do case "$flag" in - [uU]) - show_users=1 - show_level - ;; + [uU]) + show_users=1 + show_level + ;; [sS]) - show_level $flag - ;; + show_level $flag + ;; [pP]) - print_level $flag - ;; + print_level $flag + ;; [vV]) - show_lofar_version $flag - ;; + show_lofar_version $flag + ;; i) - imageForced=1 - image=$OPTARG - # This is needed to be able to retrieve the requested swlevel - # when it is not provided with option -l - shift $((OPTIND-1)); OPTIND=1 - ;; + imageForced=1 + image=$OPTARG + # This is needed to be able to retrieve the requested swlevel + # when it is not provided with option -l + shift $((OPTIND-1)); OPTIND=1 + ;; q) - procesname=$OPTARG - stop_prog $procesname - exit - ;; + procesname=$OPTARG + stop_prog $procesname + exit + ;; r) - procesname=$OPTARG - start_prog $procesname - exit - ;; + procesname=$OPTARG + start_prog $procesname + exit + ;; l) - level=$OPTARG - ;; + level=$OPTARG + ;; h) - SyntaxError - ;; + SyntaxError + ;; *) - exit - ;; + exit + ;; esac done if [ -z $level ]; then diff --git a/MAC/APL/CEPCU/src/CEPHardwareMonitor/BlueGeneMonitor.cc b/MAC/APL/CEPCU/src/CEPHardwareMonitor/BlueGeneMonitor.cc index 350d5f831a19f8beededb99096d1d427095e02b1..c37e41339065fd4b93ccf74a5657c0562d72e163 100644 --- a/MAC/APL/CEPCU/src/CEPHardwareMonitor/BlueGeneMonitor.cc +++ b/MAC/APL/CEPCU/src/CEPHardwareMonitor/BlueGeneMonitor.cc @@ -25,14 +25,13 @@ #include <Common/LofarLocators.h> #include <Common/StringUtil.h> #include <Common/ParameterSet.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <GCF/PVSS/PVSSinfo.h> #include <MACIO/MACServiceInfo.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/RTDBCommon/RTDButilities.h> #include <GCF/RTDB/DP_Protocol.ph> -//#include <APL/APLCommon/StationInfo.h> #include <errno.h> #include <signal.h> #include <unistd.h> // usleep @@ -45,7 +44,6 @@ #define MAX2(a,b) ((a) > (b)) ? (a) : (b) namespace LOFAR { - using namespace APLCommon; using namespace APL::RTDBCommon; using namespace GCF::TM; using namespace GCF::PVSS; diff --git a/MAC/APL/CEPCU/src/CEPHardwareMonitor/ClusterMonitor.cc b/MAC/APL/CEPCU/src/CEPHardwareMonitor/ClusterMonitor.cc index 20fffaa8bea52424587d96af6f05f636fb337737..3df9e8519bb8f9de5959713b367e5b276178133d 100644 --- a/MAC/APL/CEPCU/src/CEPHardwareMonitor/ClusterMonitor.cc +++ b/MAC/APL/CEPCU/src/CEPHardwareMonitor/ClusterMonitor.cc @@ -26,14 +26,13 @@ #include <Common/lofar_vector.h> #include <Common/StringUtil.h> #include <Common/ParameterSet.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <GCF/PVSS/PVSSinfo.h> #include <MACIO/MACServiceInfo.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/RTDBCommon/RTDButilities.h> #include <GCF/RTDB/DP_Protocol.ph> -//#include <APL/APLCommon/StationInfo.h> #include <errno.h> #include <signal.h> #include <unistd.h> // usleep @@ -46,7 +45,6 @@ #define MAX2(a,b) ((a) > (b)) ? (a) : (b) namespace LOFAR { - using namespace APLCommon; using namespace APL::RTDBCommon; using namespace GCF::TM; using namespace GCF::PVSS; diff --git a/MAC/APL/CUDaemons/CMakeLists.txt b/MAC/APL/CUDaemons/CMakeLists.txt index 94240e20992eb001f750e2f05a81422e71134eed..796bac5402943646ac20d6825d068c2a1feeca86 100644 --- a/MAC/APL/CUDaemons/CMakeLists.txt +++ b/MAC/APL/CUDaemons/CMakeLists.txt @@ -1,9 +1,18 @@ # $Id$ # Do not split the following line, otherwise makeversion will fail! -lofar_package(CUDaemons 1.0 DEPENDS Common ApplCommon APLCommon GCFTM MACIO) +#lofar_package(CUDaemons 1.0 DEPENDS Common ApplCommon GCFTM MACIO) -add_definitions(-DBOOST_DISABLE_THREADS) +#add_definitions(-DBOOST_DISABLE_THREADS) -add_subdirectory(src) -#add_subdirectory(test) # Tests currently do not compile! +#add_subdirectory(src) +##add_subdirectory(test) # Tests currently do not compile! + + + +#include(LofarPackageVersion) + +#lofar_add_library(cudaemons Package__Version.cc) + +lofar_add_package(Service_Broker) +lofar_add_package(CT_StartDaemon) diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CMakeLists.txt b/MAC/APL/CUDaemons/CT_StartDaemon/CMakeLists.txt similarity index 52% rename from MAC/APL/CUDaemons/src/CTStartDaemon/CMakeLists.txt rename to MAC/APL/CUDaemons/CT_StartDaemon/CMakeLists.txt index 5e5e9ca7526c4fd33631f415e72be95cd4e36d96..1f13ae77dff07ec04105c75a42bbfac4a06e3abb 100644 --- a/MAC/APL/CUDaemons/src/CTStartDaemon/CMakeLists.txt +++ b/MAC/APL/CUDaemons/CT_StartDaemon/CMakeLists.txt @@ -1,5 +1,13 @@ # $Id$ +lofar_package(CT_StartDaemon 1.0 DEPENDS Common ApplCommon GCFTM MACIO APLCommon) + +include(LofarPackageVersion) + +lofar_add_library(ctstartdaemon + Package__Version.cc) + lofar_add_bin_program(CTStartDaemon CTStartDaemonMain.cc CTStartDaemon.cc) + install(PROGRAMS startController.sh DESTINATION bin) install(FILES CTStartDaemon.conf DESTINATION etc) diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc b/MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.cc similarity index 99% rename from MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc rename to MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.cc index 4ed741946521270728fd1d74b3b0bb756fb79121..da1c15c822fff82280933259da8eaa66044414eb 100644 --- a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc +++ b/MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.cc @@ -36,7 +36,7 @@ #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StartDaemon_Protocol.ph> #include "CTStartDaemon.h" -#include <CUDaemons/Package__Version.h> +#include <CT_StartDaemon/Package__Version.h> using namespace LOFAR::GCF::TM; @@ -56,7 +56,7 @@ CTStartDaemon::CTStartDaemon(const string& name) : itsTimerPort (0) { LOG_TRACE_FLOW(formatString("CTStartDaemon(%s)", getName().c_str())); - LOG_INFO(Version::getInfo<CUDaemonsVersion>("CTStartDaemon")); + LOG_INFO(Version::getInfo<CT_StartDaemonVersion>("CTStartDaemon")); itsListener = new GCFTCPPort(*this, MAC_SVCMASK_STARTDAEMON, GCFPortInterface::MSPP, STARTDAEMON_PROTOCOL); diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.conf b/MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.conf similarity index 100% rename from MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.conf rename to MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.conf diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.h b/MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.h similarity index 100% rename from MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.h rename to MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemon.h diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemonMain.cc b/MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemonMain.cc similarity index 100% rename from MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemonMain.cc rename to MAC/APL/CUDaemons/CT_StartDaemon/CTStartDaemonMain.cc diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/startController.sh b/MAC/APL/CUDaemons/CT_StartDaemon/startController.sh similarity index 100% rename from MAC/APL/CUDaemons/src/CTStartDaemon/startController.sh rename to MAC/APL/CUDaemons/CT_StartDaemon/startController.sh diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/CMakeLists.txt b/MAC/APL/CUDaemons/Service_Broker/CMakeLists.txt similarity index 60% rename from MAC/APL/CUDaemons/src/ServiceBroker/CMakeLists.txt rename to MAC/APL/CUDaemons/Service_Broker/CMakeLists.txt index 447161c480aa880f04347cd2ac953c2f2aa06ba6..4a8f64a31a8ed183f213e76763f21ca4d3a42f4c 100644 --- a/MAC/APL/CUDaemons/src/ServiceBroker/CMakeLists.txt +++ b/MAC/APL/CUDaemons/Service_Broker/CMakeLists.txt @@ -1,8 +1,14 @@ # $Id$ +lofar_package(Service_Broker 1.0 DEPENDS Common GCFTM MACIO) # Add current directory to the -I path. include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include(LofarPackageVersion) + +lofar_add_library(servicebroker + Package__Version.cc) + lofar_add_bin_program(ServiceBroker ServiceBrokerMain.cc ServiceBroker.cc) install(FILES ServiceBroker.conf DESTINATION etc) diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc b/MAC/APL/CUDaemons/Service_Broker/ServiceBroker.cc similarity index 99% rename from MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc rename to MAC/APL/CUDaemons/Service_Broker/ServiceBroker.cc index 068dcd45f8ca31de41b5cbdf3afc960b5d925561..44732d926469aeba30b8930a05f58aca553a1f02 100644 --- a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc +++ b/MAC/APL/CUDaemons/Service_Broker/ServiceBroker.cc @@ -32,7 +32,7 @@ #include <MACIO/GCF_Event.h> //#include <GCF/TM/GCF_Protocols.h> #include "ServiceBroker.h" -#include <CUDaemons/Package__Version.h> +#include <Service_Broker/Package__Version.h> namespace LOFAR { using namespace MACIO; @@ -54,7 +54,7 @@ ServiceBroker::ServiceBroker() : itsNrPorts(0), itsNrFreePorts(0) { - LOG_INFO(Version::getInfo<CUDaemonsVersion>("ServiceBroker")); + LOG_INFO(Version::getInfo<Service_BrokerVersion>("ServiceBroker")); // register the protocol for debugging purposes registerProtocol(SB_PROTOCOL, SB_PROTOCOL_STRINGS); diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.conf b/MAC/APL/CUDaemons/Service_Broker/ServiceBroker.conf similarity index 100% rename from MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.conf rename to MAC/APL/CUDaemons/Service_Broker/ServiceBroker.conf diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.h b/MAC/APL/CUDaemons/Service_Broker/ServiceBroker.h similarity index 100% rename from MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.h rename to MAC/APL/CUDaemons/Service_Broker/ServiceBroker.h diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBrokerMain.cc b/MAC/APL/CUDaemons/Service_Broker/ServiceBrokerMain.cc similarity index 100% rename from MAC/APL/CUDaemons/src/ServiceBroker/ServiceBrokerMain.cc rename to MAC/APL/CUDaemons/Service_Broker/ServiceBrokerMain.cc diff --git a/MAC/APL/CURTDBDaemons/src/PVSSGateway/PVSSGateway.cc b/MAC/APL/CURTDBDaemons/src/PVSSGateway/PVSSGateway.cc index 62a4e0adf208aa382cf222ba2b02b4d783d28a4c..073a02770b22766827d116eba05b274b353031d9 100644 --- a/MAC/APL/CURTDBDaemons/src/PVSSGateway/PVSSGateway.cc +++ b/MAC/APL/CURTDBDaemons/src/PVSSGateway/PVSSGateway.cc @@ -21,11 +21,11 @@ //# $Id: PVSSGateway.cc 23417 2012-12-20 14:06:29Z loose $ #include <lofar_config.h> -#include <ApplCommon/PosixTime.h> #include <Common/LofarLogger.h> #include <Common/Version.h> #include <Common/ParameterSet.h> -#include <APL/APLCommon/ControllerDefines.h> +#include <ApplCommon/PosixTime.h> +#include <ApplCommon/StationInfo.h> #include <MACIO/GCF_Event.h> #include <MACIO/MACServiceInfo.h> #include <MACIO/KVT_Protocol.ph> @@ -40,7 +40,6 @@ namespace LOFAR { using namespace MACIO; - using namespace APLCommon; namespace GCF { using namespace TM; using namespace PVSS; diff --git a/MAC/APL/Log_Client/src/CMakeLists.txt b/MAC/APL/Log_Client/src/CMakeLists.txt index 50ee837da9c7a88c2ceeaa0a7311d03f646e0fa7..2912465deb7a1c7aa8f33b12ec002b4ac7fb3ef2 100644 --- a/MAC/APL/Log_Client/src/CMakeLists.txt +++ b/MAC/APL/Log_Client/src/CMakeLists.txt @@ -11,4 +11,8 @@ lofar_add_library(log_client Package__Version.cc) lofar_add_bin_program(versionlog_client versionlog_client.cc) lofar_add_bin_program(LogClient LogClientMain.cc LogClient.cc) -install(FILES LogClient.conf DESTINATION etc) +install(FILES + LogClient.conf + LogClient.log_prop + DESTINATION etc) + diff --git a/MAC/APL/Log_Client/src/LogClient.cc b/MAC/APL/Log_Client/src/LogClient.cc index 190ac8cd28cbf9014fb4d01e745bb6a53e01e054..c7af00711ac042e5151613b1011637b54b0fa969 100644 --- a/MAC/APL/Log_Client/src/LogClient.cc +++ b/MAC/APL/Log_Client/src/LogClient.cc @@ -422,13 +422,15 @@ string LogClient::_searchClientDP(spi::InternalLoggingEvent& logEvent, return (""); // [2][4] } - // DPname is not filled in yet, tried to find it if we are still - // within the first 10 messages. Note: msgCnt is initialized with -10. + // DPname is not filled in yet, tried to find it if we are still within the + // first maxInitMsgCount messages. + // Note: msgCnt is initialized with -maxInitMsgCount. if (++(iter->second.msgCnt) > 0) { - // when msgCnt reached 0 we could report that we tried it 10 times - // but we don't know the name of the log-stream, so just return + // when msgCnt reached 0 we will report that we tried it maxInitMsgCount + // times but we don't know the name of the log-stream, so just return if (itsInTestMode && iter->second.msgCnt == 1) { - LOG_ERROR("*** *** No 'MACProcessScope:' found in the first 10 message! *** ***"); + LOG_ERROR_STR("*** *** No 'MACProcessScope:' found in the first " + << LogProc::maxInitMsgCount << " messages! *** ***"); } return (""); } diff --git a/MAC/APL/Log_Client/src/LogClient.h b/MAC/APL/Log_Client/src/LogClient.h index 3c580e19873a91738eed2c75d77bc60d172cb6d5..c444314ad2e2322ed3dffc724ddd4c4e24311b6b 100644 --- a/MAC/APL/Log_Client/src/LogClient.h +++ b/MAC/APL/Log_Client/src/LogClient.h @@ -73,12 +73,14 @@ private: // client adminsitration struct LogProc { + // Max. number of message that will be searched for identification string + static const int32 maxInitMsgCount = 20; string DPname; int32 msgCnt; int32 errCnt; bool valid; - LogProc() : msgCnt(-10),errCnt(0),valid(false) {}; - explicit LogProc(const string& name) : DPname(name),msgCnt(-10),errCnt(0),valid(false) {}; + LogProc() : msgCnt(-maxInitMsgCount),errCnt(0),valid(false) {}; + explicit LogProc(const string& name) : DPname(name),msgCnt(-maxInitMsgCount),errCnt(0),valid(false) {}; }; typedef map<GCFPortInterface*, LogProc> LogProcMap; LogProcMap itsClients; diff --git a/MAC/APL/Log_Client/src/LogClient.log_prop b/MAC/APL/Log_Client/src/LogClient.log_prop new file mode 100644 index 0000000000000000000000000000000000000000..215fd0cea80d2bc04b00b287674fd28b1d2c66fe --- /dev/null +++ b/MAC/APL/Log_Client/src/LogClient.log_prop @@ -0,0 +1,50 @@ +# +# setup the right levels for logging and tracing +# +# Note: In production you don't want to loose any information so a daily rolling-file +# is used and tracing is switched off. +# For debugging purposes the daily rolling-file becomes too large so a size-based +# rolling file is used and tracing is switched on. +# +# Please do not change the logger lines below, only comment them in or out. + +# For PRODUCTION: +# - Select the appropriate log-level for the rootLogger (DEBUG or INFO) +# - Leave the TRC logger on DEBUG,DUMP +# - Comment out the rootLogger and the TRC logger in the TEST section of this file +#log4cplus.rootLogger=DEBUG, DAILYFILE +log4cplus.rootLogger=INFO, STDOUT +log4cplus.logger.TRC=DEBUG, STDOUT + +# For TESTING: +# - Select the appropriate trace level for the TRC logger +# - Leave the rootLogger on DEBUG, ROLFILE +# - Comment out the rootLogger and the TRC logger in the PRODUCTION section of this file +#log4cplus.rootLogger=DEBUG, ROLFILE +#log4cplus.logger.TRC=TRACE5, ROLFILE + + +# The next line should always be active. +log4cplus.additivity.TRC=FALSE + +# Definitions of the output channels +log4cplus.appender.STDOUT=log4cplus::ConsoleAppender +log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout +log4cplus.appender.STDOUT.layout.ConversionPattern=%D{%d-%m-%y %H:%M:%S} %-5p %c{3} - %m [%.25l]%n + +log4cplus.appender.DAILYFILE=log4cplus::DailyRollingFileAppender +log4cplus.appender.DAILYFILE.File=/opt/lofar/var/log/${LOG4CPLUS_LOGFILENAME}.log +log4cplus.appender.DAILYFILE.Schedule=DAILY +log4cplus.appender.DAILYFILE.MaxBackupIndex=14 +log4cplus.appender.DAILYFILE.layout=log4cplus::PatternLayout +log4cplus.appender.DAILYFILE.layout.ConversionPattern=%x %D{%d-%m-%y %H:%M:%S} %-5p %c{3} - %m [%.25l]%n + +log4cplus.appender.ROLFILE=log4cplus::RollingFileAppender +log4cplus.appender.ROLFILE.File=/opt/lofar/var/log/${LOG4CPLUS_LOGFILENAME}.log +log4cplus.appender.ROLFILE.MaxFileSize=10MB +log4cplus.appender.ROLFILE.MaxBackupIndex=9 +log4cplus.appender.ROLFILE.layout=log4cplus::PatternLayout +log4cplus.appender.ROLFILE.layout.ConversionPattern=%x %D{%d-%m-%y %H:%M:%S} %-5p %c{3} - %m [%.25l]%n + +log4cplus.appender.DUMP=log4cplus::NullAppender + diff --git a/MAC/APL/StationCU/src/ClockControl/ClockControl.cc b/MAC/APL/StationCU/src/ClockControl/ClockControl.cc index 65423c1a9819c24a473a806d47a3c1f706de91ae..c551aec30441add6688fcf238605677d824ae914 100644 --- a/MAC/APL/StationCU/src/ClockControl/ClockControl.cc +++ b/MAC/APL/StationCU/src/ClockControl/ClockControl.cc @@ -26,6 +26,7 @@ #include <Common/ParameterSet.h> #include <ApplCommon/StationConfig.h> +#include <ApplCommon/StationInfo.h> #include <MACIO/MACServiceInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <APL/APLCommon/APL_Defines.h> diff --git a/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc index adcc499e5fb0028dd3ebc7f697753ac5fc2ffe09..74ccce3700a704504cbf34aa114726b5e753236d 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc @@ -26,18 +26,17 @@ #include <Common/LofarConstants.h> #include <Common/StringUtil.h> #include <Common/hexdump.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <GCF/PVSS/PVSSinfo.h> #include <MACIO/MACServiceInfo.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/APLUtilities.h> #include <ApplCommon/StationConfig.h> #include <APL/RTDBCommon/RTDButilities.h> #include <EC_Protocol.ph> #include <GCF/RTDB/DP_Protocol.ph> #include <GCF/TM/GCF_RawPort.h> -//#include <APL/APLCommon/StationInfo.h> #include <signal.h> #include "ECMonitor.h" diff --git a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc index 91b483e3cc1bc8af53f888a72c67d9b7be864939..921c4039edb79b9741f31c74f3b0432bef0749fe 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc @@ -25,16 +25,15 @@ #include <Common/LofarLocators.h> #include <Common/StringUtil.h> #include <Common/ParameterSet.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <GCF/PVSS/PVSSinfo.h> #include <MACIO/MACServiceInfo.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/AntennaMapper.h> #include <APL/RTDBCommon/RTDButilities.h> #include <APL/RSP_Protocol/RSP_Protocol.ph> #include <GCF/RTDB/DP_Protocol.ph> -//#include <APL/APLCommon/StationInfo.h> #include <signal.h> #include <unistd.h> // usleep diff --git a/MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.cc index e6ecabf756501d1d96282a0b857cf9f2756ddd5f..c7d1c9d0f6292c137ce1639ac93a2c711c9bc87d 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.cc @@ -23,15 +23,14 @@ #include <Common/LofarLogger.h> #include <Common/LofarConstants.h> #include <Common/StringUtil.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <MACIO/MACServiceInfo.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/APLUtilities.h> #include <APL/RTDBCommon/RTDButilities.h> #include <APL/TBB_Protocol/TBB_Protocol.ph> #include <GCF/RTDB/DP_Protocol.ph> -//#include <APL/APLCommon/StationInfo.h> #include <signal.h> #include "TBBMonitor.h" diff --git a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc index 524673d378e04ad939d05e874b3863e973fcf496..8323c99fbcc9b179a4ab551cb52624ad1c09c5ff 100644 --- a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc +++ b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc @@ -32,10 +32,10 @@ #include <Common/LofarLogger.h> #include <Common/SystemUtil.h> #include <ApplCommon/StationConfig.h> +#include <ApplCommon/StationInfo.h> #include <GCF/PVSS/GCF_PVTypes.h> #include <GCF/TM/GCF_Protocols.h> #include <APL/APLCommon/ChildControl.h> -#include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <GCF/RTDB/DP_Protocol.ph> #include "PVSSDatapointDefs.h" diff --git a/MAC/Deployment/data/PVSS/data/IONode.dpdef b/MAC/Deployment/data/PVSS/data/IONode.dpdef index bda5d896571557e5223d7730053e27f80837bc52..b5830ff097955582043a2bafb3aad9e1310d4aca 100644 --- a/MAC/Deployment/data/PVSS/data/IONode.dpdef +++ b/MAC/Deployment/data/PVSS/data/IONode.dpdef @@ -1,10 +1,13 @@ station0 string IP0 string MAC0 string +RSP0 string station1 string IP1 string MAC1 string +RSP1 string MACForeign string +RSPForeign string use2ndStation bool usedStation string usedIP string @@ -19,6 +22,7 @@ usedRSP string !_mp_IONode.usedStation IONode 60 _mp_IONode.station0:_original.._value, _mp_IONode.station1:_original.._value, _mp_IONode.use2ndStation:_original.._value "p3?p2:p1" !_mp_IONode.usedIP IONode 60 _mp_IONode.IP0:_original.._value, _mp_IONode.IP1:_original.._value, LOFAR_PIC_BGP.BGPSwitch:_original.._value "p3?p2:p1" !_mp_IONode.usedMAC IONode 60 _mp_IONode.MAC0:_original.._value, _mp_IONode.MAC1:_original.._value, _mp_IONode.MACForeign:_original.._value, LOFAR_PIC_BGP.BGPSwitch:_original.._value, _mp_IONode.use2ndStation:_original.._value "p5?p3:(p4?p2:p1)" +!_mp_IONode.usedRSP IONode 60 _mp_IONode.RSP0:_original.._value, _mp_IONode.RSP1:_original.._value, _mp_IONode.RSPForeign:_original.._value, LOFAR_PIC_BGP.BGPSwitch:_original.._value, _mp_IONode.use2ndStation:_original.._value "p5?p3:(p4?p2:p1)" ! !# DpValue !ElementName TypeName _original.._value diff --git a/MAC/MACIO/CMakeLists.txt b/MAC/MACIO/CMakeLists.txt index f30d81ebc7d89ef4cca014dfbaacd933d3e6160a..9c6b261c8aa9e6a5db307575c9070b545e67b46e 100644 --- a/MAC/MACIO/CMakeLists.txt +++ b/MAC/MACIO/CMakeLists.txt @@ -1,6 +1,6 @@ # $Id$ -lofar_package(MACIO 1.0 DEPENDS ApplCommon Common) +lofar_package(MACIO 1.0 DEPENDS Common) include(LofarFindPackage) lofar_find_package(Boost COMPONENTS date_time) diff --git a/MAC/Navigator2/panels/Observations/Observations.pnl b/MAC/Navigator2/panels/Observations/Observations.pnl index e6395443c53f17365836aa67ff08d6e94a5a7a3c..95dffa8a00aa4bdd8dae0f3fc6fb7e3b6baa3bc0 100644 --- a/MAC/Navigator2/panels/Observations/Observations.pnl +++ b/MAC/Navigator2/panels/Observations/Observations.pnl @@ -154,7 +154,7 @@ LANG:1 12 Observations 2 212 "PRIMITIVE_TEXT14" "" -1 5 3 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E +1 0 0 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E E E 42 0 0 0 0 0 E E E @@ -164,8 +164,8 @@ LANG:1 0 1 "dashclr"N "_Transparent" -E E 0 1 1 2 1 E U 1 E 7 29 135 42 -0 2 2 "0s" 0 0 0 194 0 0 135 29 1 +E E 0 1 1 2 1 E U 1 E 12 30 140 43 +0 2 2 "0s" 0 0 0 194 0 0 140 30 1 1 LANG:1 33 MS Shell Dlg,-1,11,5,75,0,0,0,0,0 0 1 @@ -173,7 +173,7 @@ LANG:1 21 Planned Observations: 2 213 "PRIMITIVE_TEXT15" "" -1 -10 26 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E +1 0 0 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E E E 44 0 0 0 0 0 E E E @@ -183,8 +183,8 @@ LANG:1 0 1 "dashclr"N "_Transparent" -E E 0 1 1 2 1 E U 1 E 2 290 120 303 -0 2 2 "0s" 0 0 0 194 0 0 120 290 1 +E E 0 1 1 2 1 E U 1 E 12 290 130 303 +0 2 2 "0s" 0 0 0 194 0 0 130 290 1 1 LANG:1 33 MS Shell Dlg,-1,11,5,75,0,0,0,0,0 0 1 @@ -192,7 +192,7 @@ LANG:1 20 Active Observations: 2 214 "PRIMITIVE_TEXT16" "" -1 0 534 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E +1 5 534 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E E E 46 0 0 0 0 0 E E E @@ -202,8 +202,8 @@ LANG:1 0 1 "dashclr"N "_Transparent" -E E 0 1 1 2 1 E U 1 E 1 560 130 573 -0 2 2 "0s" 0 0 0 194 0 0 130 560 1 +E E 0 1 1 2 1 E U 1 E 6 560 135 573 +0 2 2 "0s" 0 0 0 194 0 0 135 560 1 1 LANG:1 33 MS Shell Dlg,-1,11,5,75,0,0,0,0,0 0 1 diff --git a/MAC/Navigator2/panels/objects/Observations/Observation_small.pnl b/MAC/Navigator2/panels/objects/Observations/Observation_small.pnl index 09df658d27c3bb941b01bc80bc97d1d035364de8..5349667c1bbb521e8d1b5f88e3ce8d11e91c12b5 100644 --- a/MAC/Navigator2/panels/objects/Observations/Observation_small.pnl +++ b/MAC/Navigator2/panels/objects/Observations/Observation_small.pnl @@ -217,7 +217,7 @@ E 1 LANG:1 0 -125 "State" 1 1 0 "s" 1 +150 "State" 1 1 0 "s" 1 LANG:1 1 S E 1 diff --git a/MAC/Navigator2/panels/objects/Processes/SWControler_small.pnl b/MAC/Navigator2/panels/objects/Processes/SWControler_small.pnl index c889f1fe1863bccac7417f846a24f6789ea8ff12..d15c23336240d9268f29d6e8ae3f8b23098e6ac4 100644 --- a/MAC/Navigator2/panels/objects/Processes/SWControler_small.pnl +++ b/MAC/Navigator2/panels/objects/Processes/SWControler_small.pnl @@ -7,6 +7,8 @@ PANEL,-1 -1 399 95 N "_3DFace" 2 "main() { station = $station+\":\"; + + updateConnected = false; baseDP = station+\"LOFAR_\"+$name; @@ -67,11 +69,11 @@ void levelChanged(string dp1, int swlvl, private void observationChanged(string dp1, dyn_string observations, string dp2, bool invalid) { - if (updateConnected) { - if (dpDisconnect(\"updateSWController\", baseDP +\".status.state:_online.._value\", - baseDP +\".status.state:_online.._invalid\") == -1) { + if (updateConnected) { +// if (dpDisconnect(\"updateSWController\", baseDP +\".status.state:_online.._value\", +// baseDP +\".status.state:_online.._invalid\") == -1) { updateConnected = false; - } +// } } firstObservation = \"\"; diff --git a/MAC/Navigator2/panels/objects/Processes/adderView_small.pnl b/MAC/Navigator2/panels/objects/Processes/adderView_small.pnl index 8c9f021bcf77ede04d66a6227c1b30a75cf67b74..753ea8e0c1ea9b549386f0d7836a406506f9afb3 100644 --- a/MAC/Navigator2/panels/objects/Processes/adderView_small.pnl +++ b/MAC/Navigator2/panels/objects/Processes/adderView_small.pnl @@ -1,7 +1,7 @@ V 11 1 LANG:1 0 -PANEL,-1 -1 156 103 N "_3DFace" 1 +PANEL,-1 -1 382 103 N "_3DFace" 1 "$observation" "main() { @@ -9,8 +9,30 @@ PANEL,-1 -1 156 103 N "_3DFace" 1 // we just need to make clear the type of this baseDP to get the right panel. // The panel itself will sort out the list of adders belonging to it baseDP =CEPDBName+\"LOFAR_ObsSW_OSIONode00_Adder0\"; - delay(5); - reload(); + obsDP=MainDBName+claimManager_nameToRealName(\"LOFAR_ObsSW_\"+observation); + + if (navFunct_dpReachable(obsDP)){ + if (dpConnect(\"obsRunning\", obsDP+\".runState:_online.._value\", + obsDP+\".runState:_online.._invalid\")) { + setValue(\"adderObject\", \"backCol\", \"Lofar_dpdoesnotexist\"); + } + } else { + setValue(\"adderObject\", \"backCol\", \"Lofar_dpOffline\"); + } +} + +private void obsRunning(string dp1,string running, + string dp2,bool invalid) { + + if (!invalid) { + if (strpos(running,\"Running\")>=0) { + reload(); + } else { + setValue(\"adderObject\", \"backCol\", \"Lofar_off\"); + } + } else { + setValue(\"adderObject\", \"backCol\", \"Lofar_dpOffline\"); + } } private void reload() { @@ -86,6 +108,7 @@ void adderCB(dyn_string dps, dyn_bool values) ""0 1 E "#uses \"navPanel.ctl\" string baseDP= \"\"; +string obsDP; string observation; dyn_string connectTo; dyn_string adders; diff --git a/MAC/Navigator2/panels/objects/Processes/stationStreamView_small.pnl b/MAC/Navigator2/panels/objects/Processes/stationStreamView_small.pnl index 4d0ed82a8474f548ad5ab1127c9df09620b1464f..193c1e5e037bc7f4b9944fb853cacf4703ef0245 100644 --- a/MAC/Navigator2/panels/objects/Processes/stationStreamView_small.pnl +++ b/MAC/Navigator2/panels/objects/Processes/stationStreamView_small.pnl @@ -9,7 +9,48 @@ PANEL,-1 -1 450 72 N "_3DFace" 2 stream = \"stream\"+$streamNr; station=$station; - reload(); + string streamDP = station+\":LOFAR_PIC_StationInfo\"; // check if the stream datapoint for this view are enabled and accessible + // the streams determine if a certain part of this object is actually involved in a measurement + if (dpExists(streamDP)) { + if (dpConnect(\"updateStreamCB\", streamDP +\".datastream0:_online.._value\", + streamDP +\".datastream1:_online.._value\", + streamDP +\".datastream0:_online.._invalid\") == -1) { + LOG_ERROR(\"stationStreamView_small.pnl:main|Couldn't connect to: \"+streamDP+\" \"+getLastError()); + setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_off\"); + + } + } else { + setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_dpdoesnotexist\"); + setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_dpdoesnotexist\"); + setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_dpdoesnotexist\"); + setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_dpdoesnotexist\"); + } +} + +void updateStreamCB(string dp1, bool s0, + string dp2, bool s1, + string dp3, bool invalid) { + + // change all found DP's to contain all the elements that contain the stream.percBad + if (connected && dynlen(connectTo) > 0 ) { + dpDisconnect(\"monitorStreamsCB\",connectToSave); + dynClear(connectToSave); + connected = false; + } + + if (!invalid) { + stream0=s0; + stream1=s1; + reload(); + } else { + setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_invalid\"); + setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_invalid\"); + setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_invalid\"); + setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_invalid\"); + } } private void reload() { @@ -17,26 +58,34 @@ private void reload() { // get all the InputBuffers used by this station inputBuffers = navFunct_getInputBuffersForStation(station); - - // change all found DP's to contain all the elements that contain the stream.percBad - if (connected) { - dpDisconnect(\"stationStreamCB\",connectTo); - dynClear(connectTo); + if (dynlen(connectToSave) > 0) { + dpDisconnect(\"monitorStreamsCB\", connectToSave); + dynClear(connectToSave); } for (int i=1; i<= dynlen(inputBuffers); i++) { - dynAppend(connectTo,inputBuffers[i]+\".\"+stream+\".percBad:_online.._value\"); + // We need to know if this station is involved in an active observation to see if the inputbuffers are showing real values. + // if not connected then we grey out the symbol + if (navFunct_stationInObservation(station,\"active\")) { + dynAppend(connectTo,inputBuffers[i]+\".\"+stream+\".percBad:_online.._value\"); + } else { + setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_off\"); + } } - // check if the required datapoint for this view are enabled and accessible if (navFunct_dpReachable(CEPDBName) && dynlen(connectTo)>0 ){ - if (dpConnect(\"stationStreamCB\", connectTo) == -1) { - setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_dpdoesnotexist\"); - setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_dpdoesnotexist\"); - setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_dpdoesnotexist\"); - setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_dpdoesnotexist\"); + // if connect fails we turn the object off + if (dpConnect(\"monitorStreamsCB\", connectTo) == -1) { + setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject0\", \"foreCol\", \"Lofar_off\"); + setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_off\"); } } else { + // make a difference between an unreachable database or an empty connect list if (dynlen(connectTo) <= 0) { setValue(\"stationStreamObject0\", \"backCol\", \"Lofar_off\"); setValue(\"stationStreamObject1\", \"backCol\", \"Lofar_off\"); @@ -49,70 +98,110 @@ private void reload() { setValue(\"stationStreamObject1\", \"foreCol\", \"Lofar_dpOffline\"); } } + connectToSave=connectTo; + dynClear(connectTo); } -void stationStreamCB(dyn_string dps, dyn_float values) + +// this function is called when one of the inputbuffer stream values changes +// only stations involved in an actively running observation are included in this call +void monitorStreamsCB(dyn_string dps, dyn_float values) { - string toolTipText = station+\" \"+stream+\"<br>--------------<br>\"; + string toolTipText = station+\" \"+stream; int count=0; - string color = \"Lofar_off\"; + string color = \"Lofar_operational\"; dyn_string toollist; - // We need to know if this station is involved in an active observation to see if the inputbuffers are showing real values. - // if not connected then we grey out the symbol - - if (navFunct_stationInObservation(station,\"active\")) { - color = \"Lofar_operational\"; - // Here we get all bad values and we have to determine how many are wrong. if a station has more then 10% bad data (i.e. a single value in the values list - // exceeds 10%, or more then 10% of the stations have bad data we need to set the color to red, if bad data occurs but its lower then the above mentioned - // values we set the color to orange, and if no bad percentages occur the color is green. - + // Here we get all bad values and we have to determine how many are wrong. if a station has more then 10% bad data (i.e. a single value in the values list + // exceeds 10%, or more then 10% of the stations have bad data we need to set the color to red, if bad data occurs but its lower then the above mentioned + // values we set the color to orange, and if no bad percentages occur the color is green. - for (int i = 1; i<= dynlen(values); i++) { - int rsppos = 0; - float val = values[i]; - string dp = dps[i]; - string ionode = substr(dp,strpos(dp,\"PSIONode\"),10); - if (val > 0.0 && val < 33.0) { - color = \"Lofar_test\"; - } else if (val >= 33.0 && val < 66.0) { - color = \"Lofar_maintenance\"; - } else if (val >= 66.0 && val < 100.0) { - color = \"Lofar_suspicious\"; - } else if (val >= 100.0) { - color = \"Lofar_broken\"; - } - - if (val > 0.0) { - string station; - string usedRSP=\"\"; - int nr = substr(dp,strpos(dp,\"PSIONode\")+8,2); - string IONodeDP = navFunct_IONode2DPName(nr); - dpGet(IONodeDP+\".usedStation\",station); - dpGet(IONodeDP+\".usedRSP\",usedRSP); - if (usedRSP == \"RSP1\") rsppos = 1; - - string aS=station+\" HBA\"+rsppos+\"</t> :\"+val+\"<br>\"; - dynAppend(toollist,aS); - count++; - } - setValue(\"stationStreamObject\"+rsppos, \"backCol\", color); - setValue(\"stationStreamObject\"+rsppos, \"foreCol\", color); - if (strpos(station,\"CS\") < 0) { - rsppos=1; + + bool rsp0found = false; + bool rsp1found = false; + for (int i = 1; i<= dynlen(values); i++) { + + string usedStation; + string usedRSP=\"\"; + int rsppos = 0; + + float val = values[i]; + string dp = dps[i]; + string ionode = substr(dp,strpos(dp,\"PSIONode\"),10); + + //in case of the corestations we will have two HBA outputs, determined by the RSP we are connected to so find out what RSPBoard we are connected to + int nr = substr(dp,strpos(dp,\"PSIONode\")+8,2); + string IONodeDP = navFunct_IONode2DPName(nr); + dpGet(IONodeDP+\".usedStation\",usedStation); + dpGet(IONodeDP+\".usedRSP\",usedRSP); + if (usedRSP == \"RSP1\") { + rsp1found = true; + rsppos = 1; + } else { + rsp0found = true; + rsppos = 0; + } + + if (val == 0.0) { + color = \"Lofar_operational\"; + } else if (val > 0.0 && val < 33.0) { + color = \"Lofar_test\"; + } else if (val >= 33.0 && val < 66.0) { + color = \"Lofar_maintenance\"; + } else if (val >= 66.0 && val < 100.0) { + color = \"Lofar_suspicious\"; + } else if (val >= 100.0) { + color = \"Lofar_broken\"; + } + toolTipText+=\" HBA\"+rsppos+\"<br>--------------<br>\"; + if (val > 0.0) { + string aS=station+\"</t> :\"+val+\"<br>\"; + dynAppend(toollist,aS); + count++; + } + + + if (strpos(station,\"CS\") < 0) { + rsp0found=true; + rsp1found=true; + setValue(\"stationStreamObject0\", \"backCol\", color); + setValue(\"stationStreamObject0\", \"foreCol\", color); + setValue(\"stationStreamObject1\", \"backCol\", color); + setValue(\"stationStreamObject1\", \"foreCol\", color); + } else { + rsp0found=true; + rsp1found=false; + if ((rsppos == 0 && stream0) || (rsppos ==1 && stream1)) { setValue(\"stationStreamObject\"+rsppos, \"backCol\", color); setValue(\"stationStreamObject\"+rsppos, \"foreCol\", color); + } else { + setValue(\"stationStreamObject\"+rsppos, \"backCol\", \"Lofar_off\"); + setValue(\"stationStreamObject\"+rsppos, \"foreCol\", \"Lofar_off\"); } - } - if (!count) { - toolTipText += \"All ok\"; + } + + // check what HBA part was available + if (dynlen(values) <= 1) { + if (!rsp0found) { + setValue(\"stationStreamObject0\",\"backCol\",\"Lofar_off\"); + setValue(\"stationStreamObject0\",\"foreCol\",\"Lofar_off\"); + } + if (!rsp1found) { + setValue(\"stationStreamObject1\",\"backCol\",\"Lofar_off\"); + setValue(\"stationStreamObject1\",\"foreCol\",\"Lofar_off\"); } } + + if (!count) { + toolTipText += \"All ok\"; + } else { + toolTipText += toollist; + } + setValue(\"stationStreamObject0\",\"toolTipText\",toolTipText); setValue(\"stationStreamObject1\",\"toolTipText\",toolTipText); - }" 0 E "main(int x, int y) { @@ -132,8 +221,11 @@ E "#uses \"navPanel.ctl\" string baseDP=\"\"; string stream = \"\"; +bool stream0 = false; +bool stream1 = false; string station = \"\"; dyn_string connectTo; +dyn_string connectToSave; dyn_string inputBuffers; bool connected = false; bool bDoubleClicked = false; diff --git a/MAC/Navigator2/panels/objects/Processes/streamView_small.pnl b/MAC/Navigator2/panels/objects/Processes/streamView_small.pnl index c83bf9969506069e16c0409ab74ae950bd4b89f7..1927c5e0a9590ae559376c6d599280105d7703f5 100644 --- a/MAC/Navigator2/panels/objects/Processes/streamView_small.pnl +++ b/MAC/Navigator2/panels/objects/Processes/streamView_small.pnl @@ -15,27 +15,31 @@ PANEL,-1 -1 414 134 N "_3DFace" 2 obsDP=MainDBName+claimManager_nameToRealName(\"LOFAR_ObsSW_\"+observation); - // find starttime and endtime and current time and calculate %done - - string sStart; - time start; - dpGet(obsDP+\".startTime\",sStart); - if (!navFunct_lofarDate2PVSSDate(sStart,start)) { - LOG_ERROR(\"streamView_small.pnl:reload|illegal startTime: \"+sStart); - return; + if (navFunct_dpReachable(obsDP)){ + if (dpConnect(\"obsRunning\", obsDP+\".runState:_online.._value\", + obsDP+\".runState:_online.._invalid\")== -1) { + setValue(\"streamObject\", \"backCol\", \"Lofar_dpdoesnotexist\"); + LOG_DEBUG(\"streamView_small.pnl:main|Couldnt connect to \"+obsDP+\".runState:_online.._value\"); + } + } else { + setValue(\"streamObject\", \"backCol\", \"Lofar_dpOffline\"); } +} - int retry=0; - while ( getCurrentTime() < start) { - delay(2); - retry++; - if (retry >= 90) { - break; +private void obsRunning(string dp1,string running, + string dp2,bool invalid) { + + if (!invalid) { + if (strpos(running,\"Running\")>=0) { + reload(); + } else { + setValue(\"streamObject\", \"backCol\", \"Lofar_off\"); } - } - reload(); + } else { + setValue(\"streamObject\", \"backCol\", \"Lofar_dpOffline\"); + } } - + private void reload() { // get all the InputBuffers used by this observation diff --git a/MAC/Navigator2/panels/objects/Processes/writerDroppedl.pnl b/MAC/Navigator2/panels/objects/Processes/writerDroppedl.pnl index e6062512063447903a083f001587ca8da90d0aa4..09b393439a67cd21a4ae3abb4bf1c1e20cd92353 100644 --- a/MAC/Navigator2/panels/objects/Processes/writerDroppedl.pnl +++ b/MAC/Navigator2/panels/objects/Processes/writerDroppedl.pnl @@ -1,13 +1,36 @@ V 11 1 LANG:1 0 -PANEL,-1 -1 128 81 N "_3DFace" 1 +PANEL,-1 -1 430 81 N "_3DFace" 1 "$observation" "main() { observation = $observation; - delay(5); - reload(); + + obsDP=MainDBName+claimManager_nameToRealName(\"LOFAR_ObsSW_\"+observation); + + if (navFunct_dpReachable(obsDP)){ + if (dpConnect(\"obsRunning\", obsDP+\".runState:_online.._value\", + obsDP+\".runState:_online.._invalid\")){ + setValue(\"writerObject\", \"backCol\", \"Lofar_dpdoesnotexist\"); + } + } else { + setValue(\"writerObject\", \"backCol\", \"Lofar_dpOffline\"); + } +} + +private void obsRunning(string dp1,string running, + string dp2,bool invalid) { + + if (!invalid) { + if (strpos(running,\"Running\")>=0) { + reload(); + } else { + setValue(\"writerObject\", \"backCol\", \"Lofar_off\"); + } + } else { + setValue(\"writerObject\", \"backCol\", \"Lofar_dpOffline\"); + } } private void reload() { @@ -82,6 +105,7 @@ void writerCB(dyn_string dps, dyn_int values) E "#uses \"navPanel.ctl\" string baseDP; +string obsDP; string observation; dyn_string connectTo; dyn_string writers; diff --git a/MAC/Navigator2/scripts/libs/navProgressCtrl.ctl b/MAC/Navigator2/scripts/libs/navProgressCtrl.ctl index c88ba7ad321d4774bb5ecf2fb4a8bc42dc43ccb7..addd76e08dbaed71e8eb1233c2b36b9825563a5a 100644 --- a/MAC/Navigator2/scripts/libs/navProgressCtrl.ctl +++ b/MAC/Navigator2/scripts/libs/navProgressCtrl.ctl @@ -91,7 +91,7 @@ void navProgressCtrl_handleObservation(string selection){ LOG_DEBUG("navProgressCtrl.ctl:navProgressCtrl_handleObservation| finished: "+finished); - if (percent >= 0 && percent <= 100) { + if (percent >0 && percent <= 100) { percentDone = finished/percent; } if (percentDone > 100) { diff --git a/MAC/Navigator2/scripts/readStationBGPconnections.ctl b/MAC/Navigator2/scripts/readStationBGPconnections.ctl index 2befaea4927ed21d7ad270145e11dbffbeafef96..e726d7989089e25fa167f42d5012f5443971a12d 100644 --- a/MAC/Navigator2/scripts/readStationBGPconnections.ctl +++ b/MAC/Navigator2/scripts/readStationBGPconnections.ctl @@ -69,6 +69,7 @@ main() string ip = linesplitted[4]; string mac = linesplitted[5]; string macForeign = ""; + string rspForeign = ""; // the station/mac/ip places are for the cases were rsp1 can be the 2nd ear or a foreign station // if a foreign station is used they will be in the list as R(00-01)_BG(1-3)_(DE,FR,SE,UK)(601-608) // and the real ionode can be found based on the shared ipnr @@ -87,7 +88,9 @@ main() if (showDebug) DebugN(" found match for ip in: " + dynStr_RSPfile[idx]); dyn_string sp = strsplit(dynStr_RSPfile[idx]," \t"); ionode= sp[3]; - macForeign= mac; + macForeign = mac; + //foreign stations always connected to HBA1 (= RSP1) allthough the foreign station will say RSP0 + rspForeign = "RSP"+1; break; } } @@ -105,19 +108,23 @@ main() dyn_string rsp = strsplit(rspstr,"_"); - int nr = rsp[2]; - if (showDebug) DebugN( "node: "+ionode+ " rspfull: " + rspstr+ " rsp[2]" + rsp[2]+ " nr: "+nr + if (showDebug) DebugN( "node: "+ionode+ " ioname: "+ioname+" rspfull: " + rspstr+ " rsp[2]" + rsp[2] + " ip: "+ip+ " mac: "+mac); if (dpExists(ioname)) { dpSet(ioname+".IP"+stationPlace,ip); - dpSet(ioname+".usedRSP","RSP"+rsp[2]); if (macForeign != "") { dpSet(ioname+".MACForeign",macForeign); - dpSet(ioname+".station1",station); + dpSet(ioname+".station1",station); } else { dpSet(ioname+".MAC"+stationPlace,mac); dpSet(ioname+".station0",station); } + if (rspForeign != "") { + dpSet(ioname+".RSPForeign",rspForeign); + dpSet(ioname+".RSP1","RSP"+rsp[2]); + } else { + dpSet(ioname+".RSP"+stationPlace,"RSP"+rsp[2]); + } } else { DebugN(ionode+" gives wrong dp: " , ioname); } diff --git a/RTCP/Cobalt/GPUProc/etc/default.parset b/RTCP/Cobalt/GPUProc/etc/default.parset index 0c6d319fde5e75791c918729b0030ded2943cda4..84fa5794b44561793fd77d3e8e95cae31e6dcacb 100644 --- a/RTCP/Cobalt/GPUProc/etc/default.parset +++ b/RTCP/Cobalt/GPUProc/etc/default.parset @@ -187,3 +187,6 @@ Observation.DataProducts.Output_Beamformed.locations=[localhost:.] # host:direct # Number of channels used for the coherent dedispersion kernel Cobalt.Beamformer.dedispersionFFTsize=2048 + +# Dummy identification name for MAC Log Processor +_DPname=LOFAR_ObsSW_TempObs0000 diff --git a/RTCP/Cobalt/GPUProc/src/rtcp.cc b/RTCP/Cobalt/GPUProc/src/rtcp.cc index 7165111bde7e699d585fd5af22d3095270cc38f6..e58bfe5d1d84b4f57ad36c27e8130c267546c74b 100644 --- a/RTCP/Cobalt/GPUProc/src/rtcp.cc +++ b/RTCP/Cobalt/GPUProc/src/rtcp.cc @@ -47,6 +47,8 @@ #include <boost/lexical_cast.hpp> #include <Common/LofarLogger.h> +#include <Common/SystemUtil.h> +#include <Common/StringUtil.h> #include <CoInterface/Parset.h> #include <CoInterface/OutputTypes.h> @@ -54,6 +56,9 @@ #include <InputProc/SampleType.h> #include <InputProc/Buffer/StationID.h> +#include <ApplCommon/PVSSDatapointDefs.h> +#include <ApplCommon/StationInfo.h> + #include "global_defines.h" #include "OpenMP_Lock.h" #include <GPUProc/Station/StationInput.h> @@ -208,6 +213,14 @@ int main(int argc, char **argv) * INIT stage */ + // Send identification string to the MAC Log Processor + LOG_INFO_STR("MACProcessScope: " << + str(format(createPropertySetName( + PSN_COBALTGPU_PROC, "", ps.getString("_DPname"))) + % toUpper(myHostname(false)) + % (ps.settings.nodes.size() > size_t(rank) ? + ps.settings.nodes[rank].cpu : 0))); + if (rank == 0) { LOG_INFO_STR("nr stations = " << ps.nrStations()); LOG_INFO_STR("nr subbands = " << ps.nrSubbands()); diff --git a/RTCP/Cobalt/GPUProc/src/rtcp.log_prop b/RTCP/Cobalt/GPUProc/src/rtcp.log_prop index d4cfc5761f7248b6c918ebf2e4479a3d83238a32..e990ec6123dbbf0833da193e082e2ee3df89084b 100644 --- a/RTCP/Cobalt/GPUProc/src/rtcp.log_prop +++ b/RTCP/Cobalt/GPUProc/src/rtcp.log_prop @@ -1,5 +1,8 @@ # Configure the loggers +# TODO: rtcp currently crashes randomly with a segmentation fault when +# logging to the MACCLP socket appender. +#log4cplus.rootLogger=INFO, STDOUT, MACCLP log4cplus.rootLogger=INFO, STDOUT log4cplus.logger.TRC=INFO @@ -9,11 +12,20 @@ log4cplus.additivity.LCS.ApplCommon=false log4cplus.logger.LCS.MSLofar=WARN, STDOUT log4cplus.additivity.LCS.MSLofar=false -# Define the appenders +# Logging to console log4cplus.appender.STDOUT=log4cplus::ConsoleAppender log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout log4cplus.appender.STDOUT.layout.ConversionPattern=rtcp:${MPIRANK}@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n +# Logging to logging server on CCU001 +# HERE BE DRAGONS: Do NOT set the logging threshold for the MACCLP appender +# above INFO in the log_prop file, or identification with the MAC Log Processor +# will fail! +log4cplus.appender.MACCLP=log4cplus::SocketAppender +log4cplus.appender.MACCLP.port=23999 +log4cplus.appender.MACCLP.host=ccu001 +log4cplus.appender.MACCLP.Threshold=INFO + #log4cplus.appender.STDERR=log4cplus::ConsoleAppender #log4cplus.appender.STDERR.layout=log4cplus::PatternLayout #log4cplus.appender.STDERR.layout.ConversionPattern=rtcp:${MPIRANK}@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n diff --git a/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokes.sh b/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokes.sh new file mode 100755 index 0000000000000000000000000000000000000000..6fd52ed6b9b93634cff8e94f593d77ae2277e390 --- /dev/null +++ b/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokes.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./runctest.sh tIncoherentStokes diff --git a/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokesTranspose.sh b/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokesTranspose.sh new file mode 100755 index 0000000000000000000000000000000000000000..2c65f30a1c9f510efcf082de9b9d166f57b1935d --- /dev/null +++ b/RTCP/Cobalt/GPUProc/test/cuda/tIncoherentStokesTranspose.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./runctest.sh tIncoherentStokesTranspose diff --git a/RTCP/Cobalt/OutputProc/src/outputProc.cc b/RTCP/Cobalt/OutputProc/src/outputProc.cc index 2bb96dc3a5c2a99b2ec5ce6c98ce11da378cbecf..7a06712943ef3294af4a4b94b12aa89950a03754 100644 --- a/RTCP/Cobalt/OutputProc/src/outputProc.cc +++ b/RTCP/Cobalt/OutputProc/src/outputProc.cc @@ -34,10 +34,6 @@ #include <boost/format.hpp> #include <boost/lexical_cast.hpp> -#if defined HAVE_MPI -#include <mpi.h> -#endif - #include <Common/LofarLogger.h> #include <Common/CasaLogSink.h> #include <Common/StringUtil.h> @@ -45,6 +41,8 @@ #include <Common/NewHandler.h> #include <Common/Thread/Thread.h> #include <ApplCommon/Observation.h> +#include <ApplCommon/PVSSDatapointDefs.h> +#include <ApplCommon/StationInfo.h> #include <Stream/PortBroker.h> #include <CoInterface/Exceptions.h> #include <CoInterface/Parset.h> @@ -60,6 +58,7 @@ LOFAR::NewHandler h(LOFAR::BadAllocException::newHandler); using namespace LOFAR; using namespace LOFAR::Cobalt; using namespace std; +using boost::format; // Use a terminate handler that can produce a backtrace. Exception::TerminateHandler t(Exception::terminate); @@ -103,6 +102,15 @@ int main(int argc, char *argv[]) Parset parset(&controlStream); + // Send identification string to the MAC Log Processor + LOG_INFO_STR("MACProcessScope: " << + str(format(createPropertySetName( + PSN_COBALT_OUTPUT_PROC, "", + parset.getString("_DPname"))) + % myRank)); + + Observation obs(&parset, false, 64); // FIXME: assume 64 psets, because Observation still deals with BG/P + const vector<string> &hostnames = parset.settings.outputProcHosts; ASSERT(myRank < hostnames.size()); string myHostName = hostnames[myRank]; diff --git a/RTCP/Cobalt/OutputProc/src/outputProc.log_prop b/RTCP/Cobalt/OutputProc/src/outputProc.log_prop index 225a78b51bef774f574de4b23aaa6cd5b585fc60..9baf34c42a46bcb242e75443bbe0ef27dec1e32c 100644 --- a/RTCP/Cobalt/OutputProc/src/outputProc.log_prop +++ b/RTCP/Cobalt/OutputProc/src/outputProc.log_prop @@ -1,6 +1,9 @@ # Configure the loggers -log4cplus.rootLogger=DEBUG, STDOUT +# TODO: outputProc currently crashes randomly with a segmentation fault when +# logging to the MACCLP socket appender. +#log4cplus.rootLogger=INFO, STDOUT, MACCLP +log4cplus.rootLogger=INFO, STDOUT log4cplus.logger.TRC=INFO # prevent debug messages: accept >=WARN only, and don't forward messages to the rootLogger @@ -9,11 +12,17 @@ log4cplus.additivity.LCS.ApplCommon=false log4cplus.logger.LCS.MSLofar=WARN, STDOUT log4cplus.additivity.LCS.MSLofar=false -# Define the appenders +# Logging to console log4cplus.appender.STDOUT=log4cplus::ConsoleAppender log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout log4cplus.appender.STDOUT.layout.ConversionPattern=outputProc@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n +# Logging to logging server on CCU001 +log4cplus.appender.MACCLP=log4cplus::SocketAppender +log4cplus.appender.MACCLP.port=23999 +log4cplus.appender.MACCLP.host=ccu001 +log4cplus.appender.MACCLP.Threshold=WARN + #log4cplus.appender.STDERR=log4cplus::ConsoleAppender #log4cplus.appender.STDERR.layout=log4cplus::PatternLayout #log4cplus.appender.STDERR.layout.ConversionPattern=outputProc@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n diff --git a/RTCP/Cobalt/OutputProc/test/CMakeLists.txt b/RTCP/Cobalt/OutputProc/test/CMakeLists.txt index f5564b9c88dcfc97ba4ffe4af8b0f578ac0a5d84..2f8924293d5a1c34c00f34d5f76896265ed73d26 100644 --- a/RTCP/Cobalt/OutputProc/test/CMakeLists.txt +++ b/RTCP/Cobalt/OutputProc/test/CMakeLists.txt @@ -13,7 +13,7 @@ configure_file( configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/tMSWriterCorrelated.parset.in ${CMAKE_CURRENT_BINARY_DIR}/tMSWriterCorrelated.parset @ONLY) -lofar_add_test(tMSWriterCorrelated tMSWriterCorrelated.cc) +#lofar_add_test(tMSWriterCorrelated tMSWriterCorrelated.cc) disabled until fixed in #5075 lofar_add_test(tDAL tDAL.cc) lofar_add_test(tFastFileStream tFastFileStream.cc) #lofar_add_test(tAH_TestStorage tAH_TestStorage.cc) diff --git a/RTCP/LofarStMan/CMakeLists.txt b/RTCP/LofarStMan/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe1055ff57c1789c63e9805ea21d8e826767e1be --- /dev/null +++ b/RTCP/LofarStMan/CMakeLists.txt @@ -0,0 +1,10 @@ +# $Id: CMakeLists.txt 14280 2009-10-16 13:48:46Z loose $ + +lofar_package(LofarStMan 1.0 DEPENDS Common) + +include(LofarFindPackage) +lofar_find_package(Casacore COMPONENTS casa measures tables REQUIRED) + +add_subdirectory(include/LofarStMan) +add_subdirectory(src) +add_subdirectory(test) diff --git a/RTCP/LofarStMan/include/LofarStMan/CMakeLists.txt b/RTCP/LofarStMan/include/LofarStMan/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..bb24ef7a85aee0d9d9cdae80e1df4232d440bc92 --- /dev/null +++ b/RTCP/LofarStMan/include/LofarStMan/CMakeLists.txt @@ -0,0 +1,10 @@ +# List of header files that will be installed. +set(inst_HEADERS) + +# Create symbolic link to include directory. +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME}) + +# Install header files. +install(FILES ${inst_HEADERS} DESTINATION include/${PACKAGE_NAME}) diff --git a/RTCP/LofarStMan/include/LofarStMan/LofarColumn.h b/RTCP/LofarStMan/include/LofarStMan/LofarColumn.h new file mode 100644 index 0000000000000000000000000000000000000000..933b213c434d0d88f74ea59122dca696f64dba8c --- /dev/null +++ b/RTCP/LofarStMan/include/LofarStMan/LofarColumn.h @@ -0,0 +1,256 @@ +//# LofarColumn.h: A Column in the LOFAR Storage Manager +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#ifndef LOFAR_LOFARSTMAN_LOFARCOLUMN_H +#define LOFAR_LOFARSTMAN_LOFARCOLUMN_H + + +//# Includes +#include <LofarStMan/LofarStMan.h> +#include <Common/lofar_vector.h> +#include <tables/Tables/StManColumn.h> +#include <measures/Measures/MeasFrame.h> +#include <measures/Measures/MDirection.h> +#include <measures/Measures/MBaseline.h> +#include <casa/Arrays/Vector.h> +#include <casa/Arrays/IPosition.h> +#include <casa/Containers/Block.h> +#include <casa/OS/Conversion.h> + +namespace LOFAR { + +// <summary> +// A column in the LOFAR Storage Manager. +// </summary> + +// <use visibility=local> + +// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLofarStMan.cc"> +// </reviewed> + +// <prerequisite> +//# Classes you should understand before using this one. +// <li> <linkto class=LofarStMan>LofarStMan</linkto> +// </prerequisite> + +// <synopsis> +// For each column a specific Column class exists. +// </synopsis> + +class LofarColumn : public casa::StManColumn +{ +public: + explicit LofarColumn (LofarStMan* parent, int dtype) + : StManColumn (dtype), + itsParent (parent) + {} + virtual ~LofarColumn(); + // Most columns are not writable (only DATA is writable). + virtual casa::Bool isWritable() const; + // Set column shape of fixed shape columns; it does nothing. + virtual void setShapeColumn (const casa::IPosition& shape); + // Prepare the column. By default it does nothing. + virtual void prepareCol(); +protected: + LofarStMan* itsParent; +}; + +// <summary>ANTENNA1 column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class Ant1Column : public LofarColumn +{ +public: + explicit Ant1Column (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~Ant1Column(); + virtual void getIntV (casa::uInt rowNr, casa::Int* dataPtr); +}; + +// <summary>ANTENNA2 column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class Ant2Column : public LofarColumn +{ +public: + explicit Ant2Column (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~Ant2Column(); + virtual void getIntV (casa::uInt rowNr, casa::Int* dataPtr); +}; + +// <summary>TIME and TIME_CENTROID column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class TimeColumn : public LofarColumn +{ +public: + explicit TimeColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~TimeColumn(); + virtual void getdoubleV (casa::uInt rowNr, casa::Double* dataPtr); +private: + casa::Double itsValue; +}; + +// <summary>INTERVAL and EXPOSURE column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class IntervalColumn : public LofarColumn +{ +public: + explicit IntervalColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~IntervalColumn(); + virtual void getdoubleV (casa::uInt rowNr, casa::Double* dataPtr); +private: + casa::Double itsValue; +}; + +// <summary>All columns in the LOFAR Storage Manager with value 0.</summary> +// <use visibility=local> +class ZeroColumn : public LofarColumn +{ +public: + explicit ZeroColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~ZeroColumn(); + virtual void getIntV (casa::uInt rowNr, casa::Int* dataPtr); +private: + casa::Int itsValue; +}; + +// <summary>All columns in the LOFAR Storage Manager with value False.</summary> +// <use visibility=local> +class FalseColumn : public LofarColumn +{ +public: + explicit FalseColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~FalseColumn(); + virtual void getBoolV (casa::uInt rowNr, casa::Bool* dataPtr); +private: + casa::Bool itsValue; +}; + +// <summary>UVW column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class UvwColumn : public LofarColumn +{ +public: + explicit UvwColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~UvwColumn(); + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArraydoubleV (casa::uInt rowNr, + casa::Array<casa::Double>* dataPtr); + virtual void prepareCol(); +private: + casa::MDirection itsPhaseDir; //# could be SUN, etc. + casa::MDirection itsJ2000Dir; //# Phase dir in J2000 + casa::MeasFrame itsFrame; + vector<casa::MBaseline> itsAntMB; + vector<casa::Vector<double> > itsAntUvw; + casa::Block<bool> itsUvwFilled; + int itsLastBlNr; + bool itsCanCalc; //# false = UVW cannot be calc. +}; + +// <summary>DATA column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class DataColumn : public LofarColumn +{ +public: + explicit DataColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~DataColumn(); + virtual casa::Bool isWritable() const; + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArrayComplexV (casa::uInt rowNr, + casa::Array<casa::Complex>* dataPtr); + virtual void putArrayComplexV (casa::uInt rowNr, + const casa::Array<casa::Complex>* dataPtr); +}; + +// <summary>FLAG column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class FlagColumn : public LofarColumn +{ +public: + explicit FlagColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~FlagColumn(); + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArrayBoolV (casa::uInt rowNr, + casa::Array<casa::Bool>* dataPtr); +}; + +// <summary>WEIGHT column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class WeightColumn : public LofarColumn +{ +public: + explicit WeightColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~WeightColumn(); + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArrayfloatV (casa::uInt rowNr, + casa::Array<casa::Float>* dataPtr); +}; + +// <summary>SIGMA column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class SigmaColumn : public LofarColumn +{ +public: + explicit SigmaColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~SigmaColumn(); + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArrayfloatV (casa::uInt rowNr, + casa::Array<casa::Float>* dataPtr); +}; + +// <summary>WEIGHT_SPECTRUM column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class WSpectrumColumn : public LofarColumn +{ +public: + explicit WSpectrumColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~WSpectrumColumn(); + virtual casa::IPosition shape (casa::uInt rownr); + virtual void getArrayfloatV (casa::uInt rowNr, + casa::Array<casa::Float>* dataPtr); +}; + +// <summary>FLAG_CATEGORY column in the LOFAR Storage Manager.</summary> +// <use visibility=local> +class FlagCatColumn : public LofarColumn +{ +public: + explicit FlagCatColumn (LofarStMan* parent, int dtype) + : LofarColumn(parent, dtype) {} + virtual ~FlagCatColumn(); + virtual casa::Bool isShapeDefined (casa::uInt rownr); + virtual casa::IPosition shape (casa::uInt rownr); +}; + + +} //# end namespace + +#endif diff --git a/RTCP/LofarStMan/include/LofarStMan/LofarStMan.h b/RTCP/LofarStMan/include/LofarStMan/LofarStMan.h new file mode 100644 index 0000000000000000000000000000000000000000..0815bee1e74a4aebacd2b2443aec1d236b6e26d6 --- /dev/null +++ b/RTCP/LofarStMan/include/LofarStMan/LofarStMan.h @@ -0,0 +1,352 @@ +//# LofarStMan.h: Storage Manager for the main table of a LOFAR MS +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#ifndef LOFAR_LOFARSTMAN_LOFARSTMAN_H +#define LOFAR_LOFARSTMAN_LOFARSTMAN_H + +//# Includes +#include <tables/Tables/DataManager.h> +#include <casa/IO/MMapIO.h> +#include <casa/IO/LargeFiledesIO.h> +#include <casa/Containers/Block.h> +#include <casa/Containers/Record.h> +#include <Common/LofarTypes.h> +#include <Common/lofar_vector.h> + + +namespace LOFAR { + +//# Forward Declarations. +class LofarColumn; + +// <summary> +// The Storage Manager for the main table of a raw LOFAR MS +// </summary> + +// <use visibility=export> + +// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLofarStMan.cc"> +// </reviewed> + +// <prerequisite> +//# Classes you should understand before using this one. +// <li> The Table Data Managers concept as described in module file +// <linkto module="Tables:Data Managers">Tables.h</linkto> +// </prerequisite> + +// <etymology> +// LofarStMan is the data manager which stores the data for a LOFAR MS. +// </etymology> + +// <synopsis> +// LofarStMan is a specific storage manager for the main table of a LOFAR MS. +// For performance purposes the raw data from the correlator is directly +// written to a disk file. However, to be able to use the data directly as a +// MeasurementSet, this specific storage manager is created offering access to +// all mandatory columns in the main table of the MS. +// +// Similar to other storage managers, the LofarStMan files need to be part of +// the table directory. There are two files: +// <ul> +// <li> The meta file contains the meta data describing baselines, start time, +// integration time, etc. It needs to be written as an AipsIO file. +// The meta info should also tell the endianness of the data file. +// <li> The data file consists of NSEQ data blocks each containing: +// <ul> +// <li> 4-byte sequence number defining the time stamp. +// <li> Complex data with shape [npol,nchan,nbasel]. +// <li> Unsigned short nr of samples used in each data point. It has shape +// [nchan,nbasel]. It defines WEIGHT_SPECTRUM and FLAG. +// <li> Filler bytes to align the blocks as given in the meta info. +// </ul> +// The sequence numbers are ascending, but there can be holes due to +// missing time stamps. +// </ul> +// The first versions of the data file can only handle regularly shaped data +// with equal integration times. A future version might be able to deal with +// varying integration times (depending on baseline length). +// +// Most of the MS columns (like DATA_DESC_ID) are not stored in the data file; +// usually they map to the value 0. This is also true for the UVW column, so +// the UVW coordinates need to be added to the table in a separate step because +// the online system does not have the resources to do it. +// +// All columns are readonly with the exception of DATA. +// </synopsis> + +// <motivation> +// The common Table storage managers are too slow for the possibly high +// output rate of the LOFAR correlator. +// </motivation> + +// <example> +// The following example shows how to create a table and how to attach +// the storage manager to some columns. +// <srcblock> +// SetupNewTable newtab("name.data", tableDesc, Table::New); +// LofarStMan stman; // define storage manager +// newtab.bindColumn ("DATA", stman); // bind column to st.man. +// newtab.bindColumn ("FLAG", stman); // bind column to st.man. +// Table tab(newtab); // actually create table +// </srcblock> +// </example> + +//# <todo asof="$DATE:$"> +//# A List of bugs, limitations, extensions or planned refinements. +//# </todo> + + +class LofarStMan : public casa::DataManager +{ +public: + // Create a Lofar storage manager with the given name. + // If no name is used, it is set to "LofarStMan" + explicit LofarStMan (const casa::String& dataManagerName = "LofarStMan"); + + // Create a Lofar storage manager with the given name. + // The specifications are part of the record (as created by dataManagerSpec). + LofarStMan (const casa::String& dataManagerName, const casa::Record& spec); + + ~LofarStMan(); + + // Clone this object. + virtual casa::DataManager* clone() const; + + // Get the type name of the data manager (i.e. LofarStMan). + virtual casa::String dataManagerType() const; + + // Get the name given to the storage manager (in the constructor). + virtual casa::String dataManagerName() const; + + // Record a record containing data manager specifications. + virtual casa::Record dataManagerSpec() const; + + // Get the number of rows in this storage manager. + uint getNRow() const + { return itsNrRows; } + + // The storage manager cannot add rows. + virtual casa::Bool canAddRow() const; + + // The storage manager cannot delete rows. + virtual casa::Bool canRemoveRow() const; + + // The storage manager can add columns, which does not really do something. + virtual casa::Bool canAddColumn() const; + + // Columns can be removed, but it does not do anything at all. + virtual casa::Bool canRemoveColumn() const; + + // Make the object from the type name string. + // This function gets registered in the DataManager "constructor" map. + // The caller has to delete the object. + static casa::DataManager* makeObject (const casa::String& aDataManType, + const casa::Record& spec); + + // Register the class name and the static makeObject "constructor". + // This will make the engine known to the table system. + static void registerClass(); + + + // Get data. + // <group> + const casa::Block<int32>& ant1() const + { return itsAnt1; } + const casa::Block<int32>& ant2() const + { return itsAnt2; } + double time (uint blocknr); + double interval() const + { return itsTimeIntv; } + uint nchan() const + { return itsNChan; } + uint npol() const + { return itsNPol; } + double maxnSample() const + { return itsMaxNrSample; } + void getData (uint rownr, casa::Complex* buf); + void putData (uint rownr, const casa::Complex* buf); + + const casa::uChar* getNSample1 (uint rownr, bool swapIfNeeded); + const casa::uShort* getNSample2 (uint rownr, bool swapIfNeeded); + const casa::uInt* getNSample4 (uint rownr, bool swapIfNeeded); + // </group> + + uint getLofarStManVersion() const + { return itsVersion; } + + uint getNrBytesPerNrValidSamples() const + { return itsNrBytesPerNrValidSamples; } + +private: + // Copy constructor cannot be used. + LofarStMan (const LofarStMan& that); + + // Assignment cannot be used. + LofarStMan& operator= (const LofarStMan& that); + + // Flush and optionally fsync the data. + // It does nothing, and returns False. + virtual casa::Bool flush (casa::AipsIO&, casa::Bool doFsync); + + // Let the storage manager create files as needed for a new table. + // This allows a column with an indirect array to create its file. + virtual void create (casa::uInt nrrow); + + // Open the storage manager file for an existing table. + // Return the number of rows in the data file. + // <group> + virtual void open (casa::uInt nrrow, casa::AipsIO&); //# should never be called + virtual casa::uInt open1 (casa::uInt nrrow, casa::AipsIO&); + // </group> + + // Prepare the columns (needed for UvwColumn). + virtual void prepare(); + + // Resync the storage manager with the new file contents. + // It does nothing. + // <group> + virtual void resync (casa::uInt nrrow); //# should never be called + virtual casa::uInt resync1 (casa::uInt nrrow); + // </group> + + // Reopen the storage manager files for read/write. + // It does nothing. + virtual void reopenRW(); + + // The data manager will be deleted (because all its columns are + // requested to be deleted). + // So clean up the things needed (e.g. delete files). + virtual void deleteManager(); + + // Add rows to the storage manager. + // It cannot do it, so throws an exception. + virtual void addRow (casa::uInt nrrow); + + // Delete a row from all columns. + // It cannot do it, so throws an exception. + virtual void removeRow (casa::uInt rowNr); + + // Do the final addition of a column. + // It won't do anything. + virtual void addColumn (casa::DataManagerColumn*); + + // Remove a column from the data file. + // It won't do anything. + virtual void removeColumn (casa::DataManagerColumn*); + + // Create a column in the storage manager on behalf of a table column. + // The caller has to delete the newly created object. + // <group> + // Create a scalar column. + virtual casa::DataManagerColumn* makeScalarColumn (const casa::String& aName, + int aDataType, + const casa::String& aDataTypeID); + // Create a direct array column. + virtual casa::DataManagerColumn* makeDirArrColumn (const casa::String& aName, + int aDataType, + const casa::String& aDataTypeID); + // Create an indirect array column. + virtual casa::DataManagerColumn* makeIndArrColumn (const casa::String& aName, + int aDataType, + const casa::String& aDataTypeID); + // </group> + + // Initialize by reading the header info. + void init(); + + // Open the data file and seqnr file. + // The seqnr is always memory-mapped (it is very small). + // The data file is only memory-mapped in 64 bit systems because the + // address space of 32-bit systems is too small for it. + void openFiles (bool writable); + + // Memory map the seqnr file. + void mapSeqFile(); + + // Close all files. + void closeFiles(); + + // Get a pointer to data to be read. + const void* getReadPointer (casa::uInt blocknr, casa::uInt offset, + casa::uInt size) + { + return readFile (blocknr, offset, size); + } + + // Get a pointer where data can be written. + void* getWritePointer (casa::uInt /*blocknr*/, casa::uInt /*offset*/, + casa::uInt size) + { + return getBuffer (size); + } + + // Write the data. It is a no-op if mmap is used. + void writeData (casa::uInt blocknr, casa::uInt offset, casa::uInt size) + { + writeFile (blocknr, offset, size); + } + + // Read or write the data for regular files. + void* readFile (casa::uInt blocknr, casa::uInt offset, casa::uInt size); + void* getBuffer (casa::uInt size); + void writeFile (casa::uInt blocknr, casa::uInt offset, casa::uInt size); + + + //# Declare member variables. + // Name of data manager. + casa::String itsDataManName; + // The number of rows in the columns. + uint itsNrRows; + // The antennae forming the baselines. + casa::Block<int32> itsAnt1; + casa::Block<int32> itsAnt2; + // The start time and interval. + double itsStartTime; + double itsTimeIntv; + uint32 itsNChan; + uint32 itsNPol; + uint32 itsNrBytesPerNrValidSamples; + // The column objects. + vector<LofarColumn*> itsColumns; + // On 32-bit systems regular IO is used. + int itsFD; + casa::LargeFiledesIO* itsRegFile; + casa::Block<char> itsBuffer; //# buffer of size itsBLDataSize for regular IO + // The seqnr file (if present) is always memory-mapped because it is small. + casa::MMapIO* itsSeqFile; + bool itsDoSwap; //# True = byte-swapping is needed + int64 itsBlockSize; //# size of a block containing a seqnr + int64 itsBLDataSize; //# data size of a single baseline + int64 itsDataStart; //# start of data in a block + int64 itsSampStart; //# start of nsamples in a block + //# Buffer to hold swapped nsample values. + casa::Block<casa::uShort> itsNSampleBuf2; + casa::Block<casa::uInt> itsNSampleBuf4; + double itsMaxNrSample; //# weight = nsample / itsMaxNrSample; + casa::Record itsSpec; + + uint itsVersion; //# Version of LofarStMan MeasurementSet +}; + + +} //# end namespace + +#endif diff --git a/RTCP/LofarStMan/include/LofarStMan/Register.h b/RTCP/LofarStMan/include/LofarStMan/Register.h new file mode 100644 index 0000000000000000000000000000000000000000..01d9faf91bb4c2217e80a0d4246accf542efffc9 --- /dev/null +++ b/RTCP/LofarStMan/include/LofarStMan/Register.h @@ -0,0 +1,29 @@ +//# Register.h: Register the DataManager create functiuons. +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#ifndef LOFAR_LOFARSTMAN_REGISTER_H +#define LOFAR_LOFARSTMAN_REGISTER_H + +extern "C" { + void register_lofarstman(); +} + +#endif diff --git a/RTCP/LofarStMan/src/CMakeLists.txt b/RTCP/LofarStMan/src/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2d8209b345c578ed3765828d3dd84ffe276d6084 --- /dev/null +++ b/RTCP/LofarStMan/src/CMakeLists.txt @@ -0,0 +1,17 @@ +# $Id: CMakeLists.txt 14273 2009-10-16 10:08:29Z loose $ + +include(LofarPackageVersion) + +lofar_add_library(lofarstman + Package__Version.cc + LofarStMan.cc + LofarColumn.cc + Register.cc + ) + +lofar_add_bin_program(versionlofarstman versionlofarstman.cc) +lofar_add_bin_program(fixlsmeta fixlsmeta.cc) + +install(PROGRAMS + makeFLAGwritable + DESTINATION bin) diff --git a/RTCP/LofarStMan/src/LofarColumn.cc b/RTCP/LofarStMan/src/LofarColumn.cc new file mode 100644 index 0000000000000000000000000000000000000000..5242713dc79145e637a9bc6572a1c3cfb8caf2b3 --- /dev/null +++ b/RTCP/LofarStMan/src/LofarColumn.cc @@ -0,0 +1,515 @@ +//# LofarColumn.cc: A Column in the LOFAR Storage Manager +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <LofarStMan/LofarColumn.h> + +#include <tables/Tables/DataManError.h> +#include <tables/Tables/Table.h> +#include <tables/Tables/TableRecord.h> +#include <measures/TableMeasures/ScalarMeasColumn.h> +#include <measures/TableMeasures/ArrayMeasColumn.h> +#include <measures/Measures/MEpoch.h> +#include <measures/Measures/MDirection.h> +#include <measures/Measures/MCDirection.h> +#include <measures/Measures/MPosition.h> +#include <measures/Measures/MCPosition.h> +#include <measures/Measures/MBaseline.h> +#include <measures/Measures/MCBaseline.h> +#include <measures/Measures/MeasConvert.h> +#include <measures/Measures/MeasTable.h> +#include <measures/Measures/Muvw.h> +#include <casa/Arrays/Array.h> +#include <casa/Utilities/Assert.h> +#include <casa/Exceptions/Error.h> + +using namespace casa; + + +namespace LOFAR { + + LofarColumn::~LofarColumn() + {} + Bool LofarColumn::isWritable() const + { + return False; + } + void LofarColumn::setShapeColumn (const IPosition&) + {} + void LofarColumn::prepareCol() + {} + + Ant1Column::~Ant1Column() + {} + void Ant1Column::getIntV (uInt rownr, Int* dataPtr) + { + // Fill ColumnCache object. + const Block<Int>& ants = itsParent->ant1(); + columnCache().setIncrement (1); + uInt strow = rownr / ants.size() * ants.size(); + columnCache().setIncrement (1); + columnCache().set (strow, strow + ants.size() - 1, ants.storage()); + *dataPtr = ants[rownr-strow]; + } + + Ant2Column::~Ant2Column() + {} + void Ant2Column::getIntV (uInt rownr, Int* dataPtr) + { + // Fill ColumnCache object. + const Block<Int>& ants = itsParent->ant2(); + uInt strow = rownr / ants.size() * ants.size(); + columnCache().setIncrement (1); + columnCache().set (strow, strow + ants.size() - 1, ants.storage()); + *dataPtr = ants[rownr-strow]; + } + + TimeColumn::~TimeColumn() + {} + void TimeColumn::getdoubleV (uInt rownr, Double* dataPtr) + { + // Get time of the block containing this row. + uInt nrbasel = itsParent->ant1().size(); + uInt blnr = rownr / nrbasel; + itsValue = itsParent->time (blnr); + // Fill ColumnCache object. + uInt strow = blnr * nrbasel; + columnCache().setIncrement (0); + columnCache().set (strow, strow + nrbasel - 1, &itsValue); + *dataPtr = itsValue; + } + + IntervalColumn::~IntervalColumn() + {} + void IntervalColumn::getdoubleV (uInt, Double* dataPtr) + { + itsValue = itsParent->interval(); + columnCache().setIncrement (0); + columnCache().set (0, itsParent->getNRow()-1, &itsValue); + *dataPtr = itsValue; + } + + ZeroColumn::~ZeroColumn() + {} + void ZeroColumn::getIntV (uInt, Int* dataPtr) + { + itsValue = 0; + columnCache().setIncrement (0); + columnCache().set (0, itsParent->getNRow()-1, &itsValue); + *dataPtr = 0; + } + + FalseColumn::~FalseColumn() + {} + void FalseColumn::getBoolV (uInt, Bool* dataPtr) + { + itsValue = False; + columnCache().setIncrement (0); + columnCache().set (0, itsParent->getNRow()-1, &itsValue); + *dataPtr = 0; + } + + UvwColumn::~UvwColumn() + {} + void UvwColumn::prepareCol() + { + // Read the station positions from the ANTENNA subtable + // and convert them to a baseline in ITRF. + const TableRecord& keyset = itsParent->table().keywordSet(); + itsCanCalc = keyset.isDefined ("ANTENNA"); + if (itsCanCalc) { + Table anttab (keyset.asTable ("ANTENNA")); + AlwaysAssert (anttab.nrow() > 0, AipsError); + int nrant = anttab.nrow(); + ROScalarMeasColumn<MPosition> antcol (anttab, "POSITION"); + MPosition arrayPos; + Vector<Double> pos0; + for (int i=0; i<nrant; ++i) { + // Read antenna position and convert to ITRF. + MPosition mpos = MPosition::Convert (antcol(i), MPosition::ITRF)(); + if (i == 0) { + pos0 = mpos.getValue().getVector(); + } + // Use position of middle station as array position. + if (i == nrant/2) { + arrayPos = mpos; + } + Vector<Double> pos = mpos.getValue().getVector(); + MVPosition mvpos((pos[0] - pos0[0]), + (pos[1] - pos0[1]), + (pos[2] - pos0[2])); + itsAntMB.push_back (MBaseline (MVBaseline(mvpos), MBaseline::ITRF)); + } + // Read the phase reference position from the FIELD subtable. + // Only use the first value from the PHASE_DIR array. + Table fldtab (itsParent->table().keywordSet().asTable ("FIELD")); + AlwaysAssert (fldtab.nrow() == 1, AipsError); + ROArrayMeasColumn<MDirection> fldcol (fldtab, "PHASE_DIR"); + itsPhaseDir = fldcol(0).data()[0]; + // Create a reference frame. Use the middle antenna as array position. + itsFrame.set (arrayPos); + // Initialize the rest which is used to cache the UVW per antenna. + // The cache is only useful if the MS is accessed in time order, but that + // is normally the case. + itsLastBlNr = -1; + itsAntUvw.resize (nrant); + itsUvwFilled.resize (nrant); + itsUvwFilled = false; + } + } + IPosition UvwColumn::shape (uInt) + { + return IPosition(1,3); + } + void UvwColumn::getArraydoubleV (uInt rownr, Array<Double>* dataPtr) + { + if (!itsCanCalc) { + *dataPtr = 0.; + } else { + // Get nr of the block containing this row. + int nrbasel = itsParent->ant1().size(); + int blnr = rownr / nrbasel; + int antinx = rownr - blnr * nrbasel; + int ant1 = itsParent->ant1()[antinx]; + int ant2 = itsParent->ant2()[antinx]; + // If a different block (i.e. time), we have to calculate the UVWs. + if (blnr != itsLastBlNr) { + itsLastBlNr = blnr; + Quantum<Double> tm(itsParent->time(blnr), "s"); + itsFrame.set (MEpoch(MVEpoch(tm.get("d").getValue()), MEpoch::UTC)); + itsJ2000Dir = MDirection::Convert (itsPhaseDir, + MDirection::Ref(MDirection::J2000, + itsFrame))(); + itsFrame.set (itsJ2000Dir); + itsUvwFilled = false; + } + // Calculate the UVWs for this timestamp if not done yet. + int ant = ant1; + for (int i=0; i<2; ++i) { + if (!itsUvwFilled[ant]) { + MBaseline& mbl = itsAntMB[ant]; + mbl.getRefPtr()->set(itsFrame); // attach frame + MBaseline::Convert mcvt(mbl, MBaseline::J2000); + MVBaseline bas = mcvt().getValue(); + MVuvw jvguvw(bas, itsJ2000Dir.getValue()); + itsAntUvw[ant] = Muvw(jvguvw, Muvw::J2000).getValue().getVector(); + itsUvwFilled[ant] = true; + } + ant = ant2; + } + // The UVW of the baseline is the difference of the antennae. + *dataPtr = itsAntUvw[ant2] - itsAntUvw[ant1]; + } + } + + DataColumn::~DataColumn() + {} + Bool DataColumn::isWritable() const + { + return True; + } + IPosition DataColumn::shape (uInt) + { + return IPosition(2, itsParent->npol(), itsParent->nchan()); + } + void DataColumn::getArrayComplexV (uInt rownr, Array<Complex>* dataPtr) + { + Bool deleteIt; + Complex* data = dataPtr->getStorage(deleteIt); + itsParent->getData (rownr, data); + dataPtr->putStorage (data, deleteIt); + } + void DataColumn::putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr) + { + Bool deleteIt; + const Complex* data = dataPtr->getStorage(deleteIt); + itsParent->putData (rownr, data); + dataPtr->freeStorage (data, deleteIt); + } + + FlagColumn::~FlagColumn() + {} + IPosition FlagColumn::shape (uInt) + { + return IPosition(2, itsParent->npol(), itsParent->nchan()); + } + void FlagColumn::getArrayBoolV (uInt rownr, Array<Bool>* dataPtr) + { + uInt npol = itsParent->npol(); + + switch(itsParent->getLofarStManVersion()) { + case 1: + { + const uShort* data = itsParent->getNSample2 (rownr, False); + const uShort* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Bool>::contiter iter=dataPtr->cbegin(); data<dataEnd; ++data) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } else { + for (Array<Bool>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } + } break; + case 2: + case 3: + { + switch (itsParent->getNrBytesPerNrValidSamples()) { + + case 1: + { + const uChar* data = itsParent->getNSample1 (rownr, False); + const uChar* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Bool>::contiter iter=dataPtr->cbegin(); data<dataEnd; ++data) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } else { + for (Array<Bool>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } + } break; + + case 2: + { + const uShort* data = itsParent->getNSample2 (rownr, False); + const uShort* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Bool>::contiter iter=dataPtr->cbegin(); data<dataEnd; ++data) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } else { + for (Array<Bool>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } + } break; + + case 4: + { + const uInt* data = itsParent->getNSample4 (rownr, False); + const uInt* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Bool>::contiter iter=dataPtr->cbegin(); data<dataEnd; ++data) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } else { + for (Array<Bool>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Bool flagged = (*data == 0); + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = flagged; + } + } + } + } break; + + default: + throw; + } + } break; + default: + throw; + } + } + + + WeightColumn::~WeightColumn() + {} + IPosition WeightColumn::shape (uInt) + { + return IPosition(1, itsParent->npol()); + } + void WeightColumn::getArrayfloatV (uInt, Array<Float>* dataPtr) + { + *dataPtr = float(1); + } + + SigmaColumn::~SigmaColumn() + {} + IPosition SigmaColumn::shape (uInt) + { + return IPosition(1, itsParent->npol()); + } + void SigmaColumn::getArrayfloatV (uInt, Array<Float>* dataPtr) + { + *dataPtr = float(1); + } + + WSpectrumColumn::~WSpectrumColumn() + {} + IPosition WSpectrumColumn::shape (uInt) + { + return IPosition(2, itsParent->npol(), itsParent->nchan()); + } + void WSpectrumColumn::getArrayfloatV (uInt rownr, Array<Float>* dataPtr) + { + double maxn = itsParent->maxnSample(); + uInt npol = itsParent->npol(); + + switch (itsParent->getLofarStManVersion()) { + case 1: + { + const uShort* data = itsParent->getNSample2 (rownr, True); + const uShort* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Float>::contiter iter=dataPtr->cbegin(); + data<dataEnd; ++data) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } else { + for (Array<Float>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } + } break; + case 2: + case 3: + { + switch (itsParent->getNrBytesPerNrValidSamples()) { + case 1: + { + const uChar* data = itsParent->getNSample1(rownr, True); + const uChar* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Float>::contiter iter=dataPtr->cbegin(); + data<dataEnd; ++data) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } else { + for (Array<Float>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } + } break; + case 2: + { + const uShort* data = itsParent->getNSample2(rownr, True); + const uShort* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Float>::contiter iter=dataPtr->cbegin(); + data<dataEnd; ++data) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } else { + for (Array<Float>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } + } break; + + case 4: + { + const uInt* data = itsParent->getNSample4(rownr, True); + const uInt* dataEnd = data + itsParent->nchan(); + + if (dataPtr->contiguousStorage()) { + for (Array<Float>::contiter iter=dataPtr->cbegin(); + data<dataEnd; ++data) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } else { + for (Array<Float>::iterator iter=dataPtr->begin(); + data<dataEnd; ++data, ++iter) { + Float weight = *data / maxn; + for (uInt i=0; i<npol; ++i, ++iter) { + *iter = weight; + } + } + } + } break; + default: + throw; + } + } break; + default: + throw; + } + } + + FlagCatColumn::~FlagCatColumn() + {} + Bool FlagCatColumn::isShapeDefined (uInt) + { + return False; + } + IPosition FlagCatColumn::shape (uInt) + { + throw DataManError ("LofarStMan: no data in column FLAG_CATEGORY"); + } + +} //# end namespace diff --git a/RTCP/LofarStMan/src/LofarStMan.cc b/RTCP/LofarStMan/src/LofarStMan.cc new file mode 100644 index 0000000000000000000000000000000000000000..3a62a0a0a116820610b52e98ea56edb97d56c8b7 --- /dev/null +++ b/RTCP/LofarStMan/src/LofarStMan.cc @@ -0,0 +1,537 @@ +//# LofarStMan.cc: Storage Manager for the main table of a LOFAR MS +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <LofarStMan/LofarStMan.h> +#include <LofarStMan/LofarColumn.h> +#include <tables/Tables/Table.h> +#include <tables/Tables/DataManError.h> +#include <casa/Containers/Record.h> +#include <casa/Containers/BlockIO.h> +#include <casa/IO/AipsIO.h> +#include <casa/OS/CanonicalConversion.h> +#include <casa/OS/HostInfo.h> +#include <casa/OS/DOos.h> +#include <casa/Utilities/Assert.h> +#include <casa/iostream.h> + +using namespace casa; + + +namespace LOFAR { + +LofarStMan::LofarStMan (const String& dataManName) +: DataManager (), + itsDataManName (dataManName), + itsFD (-1), + itsRegFile (0), + itsSeqFile (0) +{} + +LofarStMan::LofarStMan (const String& dataManName, + const Record&) +: DataManager (), + itsDataManName (dataManName), + itsFD (-1), + itsRegFile (0), + itsSeqFile (0) +{} + +LofarStMan::LofarStMan (const LofarStMan& that) +: DataManager (), + itsDataManName (that.itsDataManName), + itsFD (-1), + itsRegFile (0), + itsSeqFile (0) +{} + +LofarStMan::~LofarStMan() +{ + for (uInt i=0; i<ncolumn(); i++) { + delete itsColumns[i]; + } + closeFiles(); +} + +DataManager* LofarStMan::clone() const +{ + return new LofarStMan (*this); +} + +String LofarStMan::dataManagerType() const +{ + return "LofarStMan"; +} + +String LofarStMan::dataManagerName() const +{ + return itsDataManName; +} + +Record LofarStMan::dataManagerSpec() const +{ + return itsSpec; +} + + +DataManagerColumn* LofarStMan::makeScalarColumn (const String& name, + int dtype, + const String&) +{ + LofarColumn* col; + if (name == "TIME" || name == "TIME_CENTROID") { + col = new TimeColumn(this, dtype); + } else if (name == "ANTENNA1") { + col = new Ant1Column(this, dtype); + } else if (name == "ANTENNA2") { + col = new Ant2Column(this, dtype); + } else if (name == "INTERVAL" || name == "EXPOSURE") { + col = new IntervalColumn(this, dtype); + } else if (name == "FLAG_ROW") { + col = new FalseColumn(this, dtype); + } else { + col = new ZeroColumn(this, dtype); + } + itsColumns.push_back (col); + return col; +} + +DataManagerColumn* LofarStMan::makeDirArrColumn (const String& name, + int dataType, + const String& dataTypeId) +{ + return makeIndArrColumn (name, dataType, dataTypeId); +} + +DataManagerColumn* LofarStMan::makeIndArrColumn (const String& name, + int dtype, + const String&) +{ + LofarColumn* col; + if (name == "UVW") { + col = new UvwColumn(this, dtype); + } else if (name == "DATA") { + col = new DataColumn(this, dtype); + } else if (name == "FLAG") { + col = new FlagColumn(this, dtype); + } else if (name == "FLAG_CATEGORY") { + col = new FlagCatColumn(this, dtype); + } else if (name == "WEIGHT") { + col = new WeightColumn(this, dtype); + } else if (name == "SIGMA") { + col = new SigmaColumn(this, dtype); + } else if (name == "WEIGHT_SPECTRUM") { + col = new WSpectrumColumn(this, dtype); + } else { + throw DataManError (name + " is unknown column for LofarStMan"); + } + itsColumns.push_back (col); + return col; +} + +DataManager* LofarStMan::makeObject (const String& group, const Record& spec) +{ + // This function is called when reading a table back. + return new LofarStMan (group, spec); +} + +void LofarStMan::registerClass() +{ + DataManager::registerCtor ("LofarStMan", makeObject); +} + +Bool LofarStMan::canAddRow() const +{ + return False; +} +Bool LofarStMan::canRemoveRow() const +{ + return False; +} +Bool LofarStMan::canAddColumn() const +{ + return True; +} +Bool LofarStMan::canRemoveColumn() const +{ + return True; +} + +void LofarStMan::addRow (uInt) +{ + throw DataManError ("LofarStMan cannot add rows"); +} +void LofarStMan::removeRow (uInt) +{ + throw DataManError ("LofarStMan cannot remove rows"); +} +void LofarStMan::addColumn (DataManagerColumn*) +{} +void LofarStMan::removeColumn (DataManagerColumn*) +{} + +Bool LofarStMan::flush (AipsIO&, Bool) +{ + return False; +} + +void LofarStMan::create (uInt nrows) +{ + itsNrRows = nrows; +} + +void LofarStMan::open (uInt, AipsIO&) +{ + throw DataManError ("LofarStMan::open should never be called"); +} +uInt LofarStMan::open1 (uInt, AipsIO&) +{ + // Read meta info. + init(); + openFiles (table().isWritable()); + return itsNrRows; +} + +void LofarStMan::prepare() +{ + for (uInt i=0; i<ncolumn(); i++) { + itsColumns[i]->prepareCol(); + } +} + +void LofarStMan::openFiles (bool writable) +{ + // Open the data file using unbuffered IO. + // First close if needed. + closeFiles(); + String fname (fileName() + "data"); + itsFD = LargeFiledesIO::open (fname.c_str(), writable); + itsRegFile = new LargeFiledesIO (itsFD); + // Set correct number of rows. + itsNrRows = itsRegFile->length() / itsBlockSize * itsAnt1.size(); + // Map the file with seqnrs. + mapSeqFile(); + // Size the buffer if needed. + if (int64(itsBuffer.size()) < itsBLDataSize) { + itsBuffer.resize (itsBLDataSize); + } +} + +void LofarStMan::mapSeqFile() +{ + delete itsSeqFile; + itsSeqFile = 0; + try { + itsSeqFile = new MMapIO (fileName() + "seqnr"); + } catch (...) { + delete itsSeqFile; + itsSeqFile = 0; + } + // Check the size of the sequencenumber file, close file if it doesn't match. + if (itsSeqFile && (itsSeqFile->getFileSize() / sizeof(uInt) == itsNrRows)) { + delete itsSeqFile; + itsSeqFile = 0; + } +} + +void LofarStMan::closeFiles() +{ + if (itsFD >= 0) { + LargeFiledesIO::close (itsFD); + itsFD = -1; + } + delete itsRegFile; + itsRegFile = 0; + delete itsSeqFile; + itsSeqFile = 0; +} + +void LofarStMan::resync (uInt) +{ + throw DataManError ("LofarStMan::resync should never be called"); +} +uInt LofarStMan::resync1 (uInt) +{ + uInt nrows = itsRegFile->length() / itsBlockSize * itsAnt1.size(); + // Reopen file if different nr of rows. + if (nrows != itsNrRows) { + openFiles (table().isWritable()); + } + return itsNrRows; +} + +void LofarStMan::reopenRW() +{ + openFiles (true); +} + +void LofarStMan::deleteManager() +{ + closeFiles(); + DOos::remove (fileName()+"meta", False, False); + DOos::remove (fileName()+"data", False, False); + DOos::remove (fileName()+"seqnr", False, False); +} + +void LofarStMan::init() +{ + AipsIO aio(fileName() + "meta"); + itsVersion = aio.getstart ("LofarStMan"); + if (itsVersion > 3) { + throw DataManError ("LofarStMan can only handle up to version 3"); + } + Bool asBigEndian; + uInt alignment; + if (itsVersion == 2) { + // In version 2 antenna1 and antenna2 were swapped. + aio >> itsAnt2 >> itsAnt1; + } else { + aio >> itsAnt1 >> itsAnt2; + } + aio >> itsStartTime >> itsTimeIntv >> itsNChan + >> itsNPol >> itsMaxNrSample >> alignment >> asBigEndian; + if (itsVersion > 1) { + aio >> itsNrBytesPerNrValidSamples; + } else { + itsNrBytesPerNrValidSamples = 2; + } + aio.getend(); + // Set start time to middle of first time slot. + itsStartTime += itsTimeIntv*0.5; + AlwaysAssert (itsAnt1.size() == itsAnt2.size(), AipsError); + uInt nrant = itsAnt1.size(); + itsDoSwap = (asBigEndian != HostInfo::bigEndian()); + // A block contains an Int seqnr, Complex data per baseline,chan,pol and + // uShort nsample per baseline,chan. Align it as needed. + itsBLDataSize = itsNChan * itsNPol * 8; // #bytes/baseline + if (alignment <= 1) { + itsDataStart = 4; + itsSampStart = itsDataStart + nrant*itsBLDataSize; + switch (itsVersion) { + case 1: + case 2: + case 3: + itsBlockSize = itsSampStart + nrant*itsNChan*2; + break; + default: + throw DataManError("LofarStMan can only handle up to version 3"); + } + } else { + itsDataStart = alignment; + itsSampStart = itsDataStart + (nrant*itsBLDataSize + alignment-1) + / alignment * alignment; + switch (itsVersion) { + case 1: + case 2: + case 3: + itsBlockSize = itsSampStart + (nrant*itsNChan*2 + alignment-1) + / alignment * alignment; + break; + default: + throw DataManError("LofarStMan can only handle up to version 3"); + } + } + if (itsDoSwap) { + switch (itsVersion) { + case 1: + itsNSampleBuf2.resize(itsNChan * 2); + break; + case 2: + case 3: + { + switch (itsNrBytesPerNrValidSamples) { + case 1: + break; + case 2: + itsNSampleBuf2.resize (itsNChan * 2); + break; + case 4: + itsNSampleBuf4.resize (itsNChan * 2); + break; + } + } break; + default: + throw; + } + } + // Fill the specification record (only used for reporting purposes). + itsSpec.define ("version", itsVersion); + itsSpec.define ("alignment", alignment); + itsSpec.define ("bigEndian", asBigEndian); + itsSpec.define ("maxNrSample", itsMaxNrSample); + itsSpec.define ("nrBytesPerNrValidSamples", itsNrBytesPerNrValidSamples); +} + +Double LofarStMan::time (uInt blocknr) +{ + uInt seqnr; + const void* ptr; + if (itsSeqFile) { + ptr = itsSeqFile->getReadPointer(blocknr * sizeof(uInt)); + } else { + ptr = getReadPointer (blocknr, 0, sizeof(Int)); + } + if (itsDoSwap) { + CanonicalConversion::reverse4 (&seqnr, ptr); + } else { + seqnr = *static_cast<const uInt*>(ptr); + } + return itsStartTime + seqnr*itsTimeIntv; +} + +void LofarStMan::getData (uInt rownr, Complex* buf) +{ + uInt blocknr = rownr / itsAnt1.size(); + uInt baseline = rownr - blocknr*itsAnt1.size(); + uInt offset = itsDataStart + baseline * itsBLDataSize; + const void* ptr = getReadPointer (blocknr, offset, itsBLDataSize); + if (itsDoSwap) { + const char* from = (const char*)ptr; + char* to = (char*)buf; + const char* fromend = from + itsBLDataSize; + while (from < fromend) { + CanonicalConversion::reverse4 (to, from); + to += 4; + from += 4; + } + } else { + memcpy (buf, ptr, itsBLDataSize); + } + if (itsVersion < 3) { + // The first RTCP versions generated conjugate data. + for (uint i=0; i<itsBLDataSize/sizeof(Complex); ++i) { + buf[i] = conj(buf[i]); + } + } +} + +void LofarStMan::putData (uInt rownr, const Complex* buf) +{ + uInt blocknr = rownr / itsAnt1.size(); + uInt baseline = rownr - blocknr*itsAnt1.size(); + uInt offset = itsDataStart + baseline * itsBLDataSize; + void* ptr = getWritePointer (blocknr, offset, itsBLDataSize); + // The first RTCP versions generated conjugate data. + if (itsVersion < 3) { + Complex val; + const Complex* from = buf; + char* to = (char*)ptr; + char* toend = to + itsBLDataSize; + while (to < toend) { + val = conj(*from); + if (itsDoSwap) { + CanonicalConversion::reverse4 (to, &val); + CanonicalConversion::reverse4 (to + sizeof(float), + ((char*)(&val)) + sizeof(float)); + } else { + memcpy (to, &val, sizeof(Complex)); + } + to += sizeof(Complex); + from++; + } + } else if (itsDoSwap) { + const char* from = (const char*)buf; + char* to = (char*)ptr; + const char* fromend = from + itsBLDataSize; + while (from < fromend) { + CanonicalConversion::reverse4 (to, from); + to += 4; + from += 4; + } + } else { + memcpy (ptr, buf, itsBLDataSize); + } + writeData (blocknr, offset, itsBLDataSize); +} + +const uChar* LofarStMan::getNSample1 (uInt rownr, Bool) +{ + uInt blocknr = rownr / itsAnt1.size(); + uInt baseline = rownr - blocknr*itsAnt1.size(); + uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); + + const uChar* from = (const uChar*)ptr; + return from; +} + +const uShort* LofarStMan::getNSample2 (uInt rownr, Bool swapIfNeeded) +{ + uInt blocknr = rownr / itsAnt1.size(); + uInt baseline = rownr - blocknr*itsAnt1.size(); + uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); + + const uShort* from = (const uShort*)ptr; + + if (!swapIfNeeded || !itsDoSwap) { + return from; + } + + uShort* to = itsNSampleBuf2.storage(); + for (uInt i=0; i<itsNChan; ++i) { + CanonicalConversion::reverse2 (to+i, from+i); + } + return to; +} + +const uInt* LofarStMan::getNSample4 (uInt rownr, Bool swapIfNeeded) +{ + uInt blocknr = rownr / itsAnt1.size(); + uInt baseline = rownr - blocknr*itsAnt1.size(); + uInt offset = itsSampStart + baseline * itsNChan*itsNrBytesPerNrValidSamples; + const void* ptr = getReadPointer (blocknr, offset, itsNChan*itsNrBytesPerNrValidSamples); + + const uInt* from = (const uInt*)ptr; + + if (!swapIfNeeded || !itsDoSwap) { + return from; + } + + uInt* to = itsNSampleBuf4.storage(); + for (uInt i=0; i<itsNChan; ++i) { + CanonicalConversion::reverse4 (to+i, from+i); + } + return to; +} + + +void* LofarStMan::readFile (uInt blocknr, uInt offset, uInt size) +{ + AlwaysAssert (size <= itsBuffer.size(), AipsError); + itsRegFile->seek (blocknr*itsBlockSize + offset); + itsRegFile->read (size, itsBuffer.storage()); + return itsBuffer.storage(); +} + +void* LofarStMan::getBuffer (uInt size) +{ + AlwaysAssert (size <= itsBuffer.size(), AipsError); + return itsBuffer.storage(); +} + +void LofarStMan::writeFile (uInt blocknr, uInt offset, uInt size) +{ + AlwaysAssert (size <= itsBuffer.size(), AipsError); + itsRegFile->seek (blocknr*itsBlockSize + offset); + itsRegFile->write (size, itsBuffer.storage()); +} + +} //# end namespace diff --git a/RTCP/LofarStMan/src/Register.cc b/RTCP/LofarStMan/src/Register.cc new file mode 100644 index 0000000000000000000000000000000000000000..174e61fc05c8cafdf98432caf54e9bd29d022392 --- /dev/null +++ b/RTCP/LofarStMan/src/Register.cc @@ -0,0 +1,32 @@ +//# Register.cc: Register the DataManager create functiuons. +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +//# Includes +#include <LofarStMan/Register.h> +#include <LofarStMan/LofarStMan.h> + +using namespace LOFAR; + +void register_lofarstman() +{ + LofarStMan::registerClass(); +} + diff --git a/RTCP/LofarStMan/src/fixlsmeta.cc b/RTCP/LofarStMan/src/fixlsmeta.cc new file mode 100644 index 0000000000000000000000000000000000000000..4ce99510fef4bf835b87299d50bf7f6e6b704e33 --- /dev/null +++ b/RTCP/LofarStMan/src/fixlsmeta.cc @@ -0,0 +1,129 @@ +//# fixlsmeta.cc: Program to fix the meta info of the LofarStMan +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <lofar_config.h> +#include <LofarStMan/LofarStMan.h> +#include <Common/LofarLogger.h> +#include <Common/Exception.h> +#include <casa/IO/AipsIO.h> +#include <casa/Containers/BlockIO.h> +#include <casa/Quanta/MVTime.h> +#include <casa/Quanta/Quantum.h> +#include <casa/Inputs/Input.h> +#include <casa/iostream.h> + +using namespace casa; +using namespace LOFAR; + +// Use a terminate handler that can produce a backtrace. +Exception::TerminateHandler t(Exception::terminate); + +int main (int argc, char* argv[]) +{ + try { + Input inputs(1); + // Define the input keywords + inputs.version("201020515GvD"); + inputs.create ("ms", "", + "Name of input MS", + "string"); + inputs.create ("timedivisor", "1", + "Factor to divide the time interval by", + "float"); + inputs.create ("timemultiplier", "1", + "Factor to multiply the time interval with", + "float"); + inputs.create ("starttime", "", + "New start time like 2-Mar-2012/07:34:12.52" + "string"); + // Fill the input value from the command line. + inputs.readArguments (argc, argv); + + // Get and check the input specification. + String msin (inputs.getString("ms")); + if (msin == "") { + throw AipsError(" an input MS must be given"); + } + double timeDivisor (inputs.getDouble("timedivisor")); + double timeMultiplier (inputs.getDouble("timemultiplier")); + string startStr (inputs.getString("starttime")); + + Bool asBigEndian; + uInt alignment; + Block<int32> ant1; + Block<int32> ant2; + double startTime; + double timeIntv; + uint32 nChan; + uint32 nPol; + uint32 nBytesPerNrValidSamples=2; + double maxNrSample; + int version; + { + // Open and read the meta file. + AipsIO aio(msin + "/table.f0meta"); + version = aio.getstart ("LofarStMan"); + ASSERTSTR (version <= 3, + "fixlsmeta can only handle up to version 3"); + aio >> ant1 >> ant2 >> startTime >> timeIntv >> nChan + >> nPol >> maxNrSample >> alignment >> asBigEndian; + if (version > 1) { + aio >> nBytesPerNrValidSamples; + } + aio.getend(); + } + // Fix the interval. + if (timeDivisor != 1 && timeMultiplier != 1) { + cout << "time interval changed from " << timeIntv << " to "; + timeIntv /= timeDivisor; + timeIntv *= timeMultiplier; + cout <<timeIntv << endl; + } + // Fix the start time. + if (!startStr.empty()) { + Quantity q; + ASSERTSTR (MVTime::read(q, startStr, True), + startStr << " is an invalid date/time"); + cout << "start time changed from " << startTime << " to "; + startTime = q.getValue("s"); + cout <<startTime << endl; + } + { + // Create and write the meta file. + AipsIO aio(msin + "/table.f0meta", ByteIO::New); + aio.putstart ("LofarStMan", version); + aio << ant1 << ant2 << startTime << timeIntv << nChan + << nPol << maxNrSample << alignment << asBigEndian; + if (version > 1) { + aio << nBytesPerNrValidSamples; + } + aio.putend(); + } + + } catch (Exception& ex) { + cerr << "Caught a LOFAR exception: " << ex << endl; + return 1; + } catch (AipsError& x) { + cerr << "Caught an AIPS error: " << x.getMesg() << endl; + return 1; + } + return 0; // exit with success status +} diff --git a/RTCP/LofarStMan/src/makeFLAGwritable b/RTCP/LofarStMan/src/makeFLAGwritable new file mode 100755 index 0000000000000000000000000000000000000000..d2f0eabf84b233c790381ee713993737181fa0f7 --- /dev/null +++ b/RTCP/LofarStMan/src/makeFLAGwritable @@ -0,0 +1,101 @@ +#!/usr/bin/env python + +# makeFLAGwritable: make the FLAG column in an MS writable +# +# Copyright (C) 2009 +# ASTRON (Netherlands Institute for Radio Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite 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 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +# +# @author Ger van Diepen <diepen AT astron nl> +# +# $Id$ + +import pyrap.tables as pt +import sys + +# Let the FLAG column use the SSM. +# This is done by creating a new column, copying the data, and renaming it. +# Note that first renaming FLAG to, say, FLAGOLD does not work because +# LofarStMan does not know FLAGOLD. + +def makeFlagWritable (msname, flagtablename): + ms = pt.table(msname, readonly=False) + # Only add if a cell is defined but cannot be written. + add = False + if ms.iscelldefined('FLAG', 0): + try: + ms.putcell('FLAG', 0, ms.getcell('FLAG', 0)) + except: + add = True; + if add: + shape = ms.getcell('FLAG', 0).shape + # Define the data manager to be used. + dminfo = {'*1': {'TYPE':'StandardStMan', + 'NAME':'SSMFlag', + 'SPEC':{'BUCKETSIZE':32768}}} + # Make a column description with option Direct,FixedShape. + tabdesc = pt.maketabdesc (pt.makearrcoldesc("FLAG__TMP", False, + options=5, shape=shape)) + if len(flagtablename) > 0: + # Create the table to contain the flags + flagtab = pt.table (flagtablename, tabdesc, ms.nrows(), + dminfo=dminfo) + flagtab.flush() + dminfo = {'*1': {'TYPE':'ForwardColumnEngine', + 'NAME':'ForwardFlag', + 'SPEC':{'FORWARDTABLE':flagtablename}}} + # Add the column to the MS. + ms.addcols (tabdesc, dminfo) + print 'Created new FLAG column; copying old values ...' + # Copy the flags. + t = pt.taql ('update %s set FLAG__TMP = FLAG' % msname) + t = 0 + # Remove the old column and rename the new one. + ms.removecols ('FLAG') + ms.renamecol ('FLAG__TMP', 'FLAG') + ms.flush() + if len(flagtablename) == 0: + print 'FLAG column now stored with SSM to make it writable' + else: + flagtab = pt.table (flagtablename, readonly=False) + flagtab.renamecol ('FLAG__TMP', 'FLAG') + flagtab.flush() + print 'FLAG column now forwarded to table', flagtablename + else: + print 'FLAG column is already writable' + + +def main(argv=None): + if argv is None: + argv = sys.argv + if len(argv) < 2: + print 'run as: makeFLAGwritable msname [flagtablename]' + print ' If column FLAG in the given MS is not writable, it will replace' + print ' by a writable FLAG column and copy the current values.' + print ' If a flagtable name is given, it will create that table with a' + print ' FLAG column and forward the FLAG column in the MS to it.' + print ' In this way the flags can be written on the compute node disk' + print ' instead of the storage node disk.' + print ' If no flagtable name is given, it will add a normal FLAG column.' + return 1 + flagtablename = '' + if len(argv) > 2: + flagtablename = argv[2] + makeFlagWritable (argv[1], flagtablename) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/RTCP/LofarStMan/test/CMakeLists.txt b/RTCP/LofarStMan/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fb344a7125b44cb9daa82b7d28997e799cac8a8e --- /dev/null +++ b/RTCP/LofarStMan/test/CMakeLists.txt @@ -0,0 +1,7 @@ +# $Id: CMakeLists.txt 14273 2009-10-16 10:08:29Z loose $ + +include(LofarCTest) + +lofar_add_test(tLofarStMan tLofarStMan.cc) +lofar_add_test(tfix tfix.cc) +lofar_add_test(tIOPerf tIOPerf.cc) diff --git a/RTCP/LofarStMan/test/checkuvw.py b/RTCP/LofarStMan/test/checkuvw.py new file mode 100644 index 0000000000000000000000000000000000000000..18f11b9a4824364acbec486ce28655923d0759fa --- /dev/null +++ b/RTCP/LofarStMan/test/checkuvw.py @@ -0,0 +1,93 @@ +# This script checks if LofarStMan and casacore's derivedmscal get the +# same values for UVWs of J2000 sources and of the sun. +# It uses the dataset L33277_SAP000_SB000_uv.MS/FIELD which has +# a phase center in J2000 coordinates. +# It sets the phase center to SUN to test its UVW coordinates. +# At the end it sets for each time slot the SUN's J2000 direction as +# a J2000 direction in the PHASE_DIR column to test if LofarStMan and +# DerivedMSCal give the same result as for a proper SUN direction. + +from pyrap.tables import * +import numpy as np + +# Set the phase dir in case it is incorrect. +print "Reset phase dir to J2000 ..." +t = table ('L33277_SAP000_SB000_uv.MS/FIELD', readonly=False, ack=False) +t.putcolkeyword ('PHASE_DIR', 'MEASINFO.Ref', 'J2000') +t.putcol ('PHASE_DIR', t.getcol('REFERENCE_DIR')) +t.close() + +# Calculate the J2000 direction of the SUN for each time slot. +print "Calculate J2000 direction of SUN ..." +dird = taql('calc meas.j2000("SUN", [select unique TIME from L33277_SAP000_SB000_uv.MS] s)') +dirs = dird['0']; # result is dict with one entry containing array with dirs + +# Check if J2000 UVWs are fine. +# Note that LofarStMan calculates UVW. +print "Compare J2000 UVWs from LofarStMan and DerivedMSCal ..." +t = taql('select from L33277_SAP000_SB000_uv.MS where not all(near(UVW, mscal.uvw(), 1e-5))') +if t.nrows() > 0: + print "***",t.nrows(),"rows mismatch between UVW and mscal.uvw()" +t.close() + +# Find all rows for each time slot. +print "Find rows per time slot ..." +t = table ('L33277_SAP000_SB000_uv.MS', ack=False) +rowlist = [] +for iter in t.iter('TIME'): + rowlist.append (iter.rownumbers()) + iter.close() +t.close() + +# Calculate the UVWs for the SUN using derivedmscal. +print "Compare mscal.uvw('SUN') and mscal.uvw() ..." +t = taql('select mscal.uvw("SUN") as uvw from L33277_SAP000_SB000_uv.MS') +uvwSun1 = t.getcol('uvw') +t.close() + +# Put SUN in the reference type and get those UVWs again. +t = table ('L33277_SAP000_SB000_uv.MS/FIELD', readonly=False, ack=False) +t.putcolkeyword ('PHASE_DIR', 'MEASINFO.Ref', 'SUN') +t.close() +t = taql('select mscal.uvw() as uvw from L33277_SAP000_SB000_uv.MS') +uvwSun2 = t.getcol('uvw') +t.close() + +# Check if equal. +res = np.where (abs(uvwSun1 - uvwSun2) > 0.00001) +if len(res[0]) > 0: + print "*** diff between mscal() and mscal('SUN')" + +# Check if SUN UVWs are fine. +# Note that LofarStMan calculates UVW. +print "Compare SUN UVWs from LofarStMan and DerivedMSCal ..." +t = taql('select from L33277_SAP000_SB000_uv.MS where not all(near(UVW, mscal.uvw(), 1e-5))') +if t.nrows() > 0: + print "***",t.nrows(),"rows mismatch between UVW and mscal.uvw()" +t.close() + +# Now loop through all timeslots. +print "Compare for each time slot UVW of SUN and of J2000's SUN ..." +for i in range(min(100,len(rowlist))): + # Put the SUN J2000 dir in the PHASE_DIR column. + # So for this time slot only we pretend the SUN has a J2000 direction. + t = table ('L33277_SAP000_SB000_uv.MS/FIELD', readonly=False, ack=False) + t.putcolkeyword ('PHASE_DIR', 'MEASINFO.Ref', 'J2000') + t.putcell ("PHASE_DIR", 0, dirs[i:i+1,]) + t.close() + # Get the table subset for the time slot. + t = table ('L33277_SAP000_SB000_uv.MS', ack=False) + t1 = t.selectrows(rowlist[i]) + t2 = t1.query ('not all(near(UVW, mscal.uvw(), 1e-5))') + if t2.nrows() != 0: + print "***",t2.nrows(),"rows mismatch between UVW and mscal.uvw() for time",i + t2.close() + t2 = t1.select('mscal.uvw() as uvw') # get UVW using derivedmscal + uvwMsCal = t2.getcol ('uvw') + t2.close() + t1.close() + t.close() + # The UVWs should match with the SUN ones calculated earlier. + res = np.where (abs(uvwSun1[rowlist[i][0]:rowlist[i][-1]+1,] - uvwMsCal)>0.00001) + if len(res[0]) > 0: + print "*** mscal difference for time",i diff --git a/RTCP/LofarStMan/test/tIOPerf.cc b/RTCP/LofarStMan/test/tIOPerf.cc new file mode 100644 index 0000000000000000000000000000000000000000..d6b3e54b1be63578b86af59833ed01132bb0da6f --- /dev/null +++ b/RTCP/LofarStMan/test/tIOPerf.cc @@ -0,0 +1,508 @@ +//# tIOPerf.cc: Test program for LofarStMan-like IO performance +//# Copyright (C) 2010 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <casa/Containers/Block.h> +#include <casa/OS/Timer.h> +#include <casa/BasicSL/String.h> +#include <Common/LofarLogger.h> +#include <unistd.h> +#include <fcntl.h> +#include <iostream> +#include <sstream> +#include <stdexcept> + +using namespace casa; +using namespace std; + +// This program tests the class LofarStMan and related classes. +// The results are written to stdout. The script executing this program, +// compares the results with the reference output file. +// +// It uses the given phase center, station positions, times, and baselines to +// get known UVW coordinates. In this way the UVW calculation can be checked. +// +// argv parameters: +// 1. nr of time slots +// 2. nr of antennae +// 3. nr of channels +// 4. nr of polarizations +// 5. alignment +// 6. nr of time slots per baseline (type=3) or baselines per file (type=2) +// 7. type 1=write sequentially +// 2=split baselines over multiple files +// 3=write N subsequent time slots per baseline +// 8. subtype 0=do all +// 1=write data +// 2=read in time order (all baselines together) +// 4=read in time order (per baseline, but cached) +// 8=read in baseline order (no caching) +// 16=read in baseline order (cache (nant+1)/2 baselines) +// 9. file extension; name is tIOPerf_tmp.data<ext> + +uInt nalign (uInt size, uInt alignment) +{ + return (size + alignment-1) / alignment * alignment; +} + +void writeData (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(nalign(npol*nchan*nrbl*8, alignment), 0); + Block<Char> seqnr(nalign(4, alignment), 0); + Block<Char> samples(nalign(nchan*npol*nrbl*2, alignment), 0); + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), + O_RDWR | O_CREAT | O_TRUNC, 0644); + // Write all data. + Int64 leng=0; + Timer timer; + for (uInt i=0; i<nseq; ++i) { + leng += write (fd, seqnr.storage(), seqnr.size()); + leng += write (fd, data.storage(), data.size()); + leng += write (fd, samples.storage(), samples.size()); + } + timer.show ("write before fsync"); + fsync (fd); + close (fd); + timer.show ("write after fsync "); + cout << " wrote " << leng << " bytes" << endl; +} + +void writeData2 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nblperfile, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(nalign(npol*nchan*nrbl*8, alignment), 0); + Block<Char> seqnr(nalign(4, alignment), 0); + Block<Char> samples(nalign(nchan*npol*nrbl*2, alignment), 0); + // Open the files. + uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + Block<int> fds(nfiles); + for (uInt i=0; i<nfiles; ++i) { + fds[i] = open (("tIOPerf_tmp.dat"+ext+String::toString(i)).chars(), + O_RDWR | O_CREAT | O_TRUNC, 0644); + } + // Write all data. + Int64 leng=0; + Int64 snr=0; + Timer timer; + for (uInt i=0; i<nseq; ++i) { + for (uInt j=0; j<nfiles; ++j) { + uInt nb = std::min(nblperfile, nrbl-j*nblperfile); + for (uInt k=0; k<nb; ++k) { + *(Int64*)(data.storage()+k*nchan*npol*8) = ++snr; + } + leng += write (fds[j], seqnr.storage(), seqnr.size()); + leng += write (fds[j], data.storage(), nb*nchan*npol*8); + leng += write (fds[j], samples.storage(), nb*nchan*npol*2); + } + } + timer.show ("write2 before fsync"); + for (uInt j=0; j<nfiles; ++j) { + fsync (fds[j]); + close (fds[j]); + } + timer.show ("write2 after fsync "); + cout << " wrote " << leng << " bytes into " << nfiles << " files" << endl; +} + +void writeData3 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nseqperbl, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(nalign(npol*nchan*nrbl*nseqperbl*8, alignment), 0); + Block<Char> seqnr(nalign(nseqperbl*4, alignment), 0); + Block<Char> samples(nalign(nchan*npol*nrbl*nseqperbl*2, alignment), 0); + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), + O_RDWR | O_CREAT | O_TRUNC, 0644); + // Write all data. + Int64 leng=0; + Timer timer; + for (uInt i=0; i<nseq; i+=nseqperbl) { + leng += write (fd, seqnr.storage(), seqnr.size()); + leng += write (fd, data.storage(), data.size()); + leng += write (fd, samples.storage(), samples.size()); + } + timer.show ("write3 before fsync"); + fsync (fd); + close (fd); + timer.show ("write3 after fsync "); + cout << " wrote " << leng << " bytes" << endl; +} + +void readSeq (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*nrbl*8, 0); + Block<Char> seqnr(4, 0); + Block<Char> samples(nchan*npol*nrbl*2, 0); + uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Int64 offset = seqnr.size() + nalseq; + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt i=0; i<nseq; ++i) { + lseek (fd, offset, SEEK_SET); + leng += read (fd, data.storage(), data.size()); + offset += seqnr.size() + nalseq + data.size() + naldata + samples.size() + nalsamp; + } + timer.show ("readseq "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + close (fd); +} + +void readSeq2 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nblperfile, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*nrbl*8, 0); + Block<Char> seqnr(4, 0); + Block<Char> samples(nchan*npol*nrbl*2, 0); + //uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + //uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + // Open the files. + uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + Block<int> fds(nfiles); + Block<Int64> offsets(nfiles); + for (uInt i=0; i<nfiles; ++i) { + fds[i] = open (("tIOPerf_tmp.dat"+ext+String::toString(i)).chars(), + O_RDONLY); + offsets[i] = seqnr.size() + nalseq; + } + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt i=0; i<nseq; ++i) { + for (uInt j=0; j<nfiles; ++j) { + uInt nb = std::min(nblperfile, nrbl-j*nblperfile); + lseek (fds[j], offsets[j], SEEK_SET); + leng += read (fds[j], data.storage(), nb*nchan*npol*8); + offsets[j] += seqnr.size() + nalseq + nb*nchan*npol*10; + } + } + timer.show ("readseq2 "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + for (uInt j=0; j<nfiles; ++j) { + close (fds[j]); + } +} + +void readSeq3 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nseqperbl, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*nrbl*nseqperbl*8, 0); + Block<Char> seqnr(nseqperbl*4, 0); + Block<Char> samples(nchan*npol*nrbl*nseqperbl*2, 0); + uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Int64 offset = seqnr.size() + nalseq; + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt i=0; i<nseq; i+=nseqperbl) { + lseek (fd, offset, SEEK_SET); + leng += read (fd, data.storage(), data.size()); + offset += seqnr.size() + nalseq + data.size() + naldata + samples.size() + nalsamp; + } + timer.show ("readseq3 "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + close (fd); +} + +void readSeq3a (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nseqperbl, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*nrbl*nseqperbl*8, 0); + Block<Char> seqnr(nseqperbl*4, 0); + Block<Char> samples(nchan*npol*nrbl*nseqperbl*2, 0); + uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + Int64 offset = seqnr.size() + nalseq; + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt i=0; i<nseq; i+=nseqperbl) { + // Preread the data sequentially, so it is cached by the system. + // Thereafter the next random reads do not need actual disk seeks. + lseek (fd, offset, SEEK_SET); + ASSERT (size_t(read (fd, data.storage(), data.size())) == data.size()); + for (uInt j=0; j<nseqperbl; ++j) { + Int64 offset1 = offset + j*npol*nchan*8; + for (uInt k=0; k<nrbl; ++k) { + lseek (fd, offset1, SEEK_SET); + leng += read (fd, data.storage(), npol*nchan*8); + offset1 += nseqperbl*npol*nchan*8; + } + } + offset += seqnr.size() + nalseq + data.size() + naldata + samples.size() + nalsamp; + } + timer.show ("readseq3a "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + close (fd); +} + +void readBL (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*8, 0); + Block<Char> seqnr(4, 0); + Block<Char> samples(nchan*npol*nrbl*2, 0); + uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt j=0; j<nrbl; ++j) { + Int64 offset = seqnr.size() + nalseq + j*data.size(); + for (uInt i=0; i<nseq; ++i) { + lseek (fd, offset, SEEK_SET); + leng += read (fd, data.storage(), data.size()); + offset += (seqnr.size() + nalseq + naldata + samples.size() + nalsamp + + nrbl*data.size()); + } + } + timer.show ("readbl "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + close (fd); +} + +void readBL2 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nblperfile, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*8, 0); + Block<Char> seqnr(4, 0); + Block<Char> samples(nchan*npol*nrbl*2, 0); + //uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + //uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + // Open the files. + uInt nfiles = (nrbl + nblperfile - 1)/ nblperfile; + Block<int> fds(nfiles); + for (uInt i=0; i<nfiles; ++i) { + fds[i] = open (("tIOPerf_tmp.dat"+ext+String::toString(i)).chars(), + O_RDONLY); + } + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt j=0; j<nrbl; ++j) { + uInt fdnr = j/nblperfile; + uInt nb = std::min(nblperfile, nrbl-fdnr*nblperfile); + Int64 offset = seqnr.size() + nalseq + (j-fdnr*nblperfile)*nchan*npol*8; + for (uInt i=0; i<nseq; ++i) { + lseek (fds[fdnr], offset, SEEK_SET); + leng += read (fds[fdnr], data.storage(), nchan*npol*8); + Int64 snr = *(Int64*)(data.storage()); + if (snr != 1+j+i*nrbl) { + cout << "** read snr " << snr << ", expected " << 1+j+i*nrbl << endl; + } + offset += (seqnr.size() + nalseq + nb*nchan*npol*10); + } + } + timer.show ("readbl2 "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + for (uInt j=0; j<nfiles; ++j) { + close (fds[j]); + } +} + +void readBL3 (uInt nseq, uInt nant, uInt nchan, uInt npol, + uInt alignment, uInt nseqperbl, bool useNbb, const String& ext) +{ + uInt nrbl = nant*(nant+1)/2; + uInt nbb = 1; + if (useNbb) nbb = (nant+1)/2; + // Create and initialize blocks for data, seqnr, and nsample. + Block<Char> data(npol*nchan*nrbl*nseqperbl*8, 0); + Block<Char> seqnr(nseqperbl*4, 0); + Block<Char> samples(nchan*npol*nrbl*nseqperbl*2, 0); + uInt naldata = nalign (data.size(), alignment) - data.size(); + uInt nalseq = nalign (seqnr.size(), alignment) - seqnr.size(); + uInt nalsamp = nalign (samples.size(), alignment - samples.size()); + //uInt npart = nseq/nseqperbl; + // Open the file. + int fd = open (("tIOPerf_tmp.dat"+ext).chars(), O_RDONLY); + // Read all data. + Int64 leng = 0; + Timer timer; + for (uInt j=0; j<nrbl; ++j) { + Int64 offset = seqnr.size() + nalseq + j*npol*nchan*nseqperbl*8; + for (uInt k=0; k<nseq; k+=nseqperbl) { + ///cout<<"bl="<<j<<" seq="<<k << " offset="<<offset<<' '<<npol*nchan*nbb*nseqperbl*8<<endl; + lseek (fd, offset, SEEK_SET); + if (nbb > 1 && j%nbb == 0) { + leng += read (fd, data.storage(), npol*nchan*nbb*nseqperbl*8); + } + leng += read (fd, data.storage(), npol*nchan*nseqperbl*8); + offset += (seqnr.size() + nalseq + data.size() + naldata + + samples.size() + nalsamp); + } + } + timer.show ("readbl3 "); + cout << " data read " << leng << " bytes; expected " + << Int64(nseq)*nrbl*npol*nchan*8 << endl; + close (fd); +} + + +int main (int argc, char* argv[]) +{ + try { + // Get nseq, nant, nchan, npol from argv. + uInt nseq=10; + uInt nant=16; + uInt nchan=256; + uInt npol=4; + uInt align = 512; + if (argc > 1) { + istringstream istr(argv[1]); + istr >> nseq; + } + if (argc > 2) { + istringstream istr(argv[2]); + istr >> nant; + } + if (argc > 3) { + istringstream istr(argv[3]); + istr >> nchan; + } + if (argc > 4) { + istringstream istr(argv[4]); + istr >> npol; + } + if (argc > 5) { + istringstream istr(argv[5]); + istr >> align; + } + uInt nblperfile = (nant+1)/2; + if (argc > 6) { + istringstream istr(argv[6]); + istr >> nblperfile; + } + uInt type = 0; + if (argc > 7) { + istringstream istr(argv[7]); + istr >> type; + } + uInt subtype = 1+2+4+8+16+32+64+128; + if (argc > 8) { + istringstream istr(argv[8]); + istr >> subtype; + } + String ext; + if (argc > 9) { + ext = argv[9]; + } + + if (type == 2) { + if ((subtype & 1) == 1) { + writeData2 (nseq, nant, nchan, npol, align, nblperfile, ext); + } + if ((subtype & 2) == 2) { + readSeq2 (nseq, nant, nchan, npol, align, nblperfile, ext); + } + if ((subtype & 4) == 4) { + readBL2 (nseq, nant, nchan, npol, align, nblperfile, ext); + } + } else if (type == 3) { + if ((subtype & 1) == 1) { + writeData3 (nseq, nant, nchan, npol, align, nblperfile, ext); + } + if ((subtype & 2) == 2) { + readSeq3 (nseq, nant, nchan, npol, align, nblperfile, ext); + } + if ((subtype & 4) == 4) { + readSeq3a (nseq, nant, nchan, npol, align, nblperfile, ext); + } + if ((subtype & 8) == 8) { + readBL3 (nseq, nant, nchan, npol, align, nblperfile, false, ext); + } + if ((subtype & 16) == 16) { + readBL3 (nseq, nant, nchan, npol, align, nblperfile, true, ext); + } + } else { + if ((subtype & 1) == 1) { + writeData (nseq, nant, nchan, npol, align, ext); + } + if ((subtype & 2) == 2) { + readSeq (nseq, nant, nchan, npol, align, ext); + } + if ((subtype & 4) == 4) { + readBL (nseq, nant, nchan, npol, align, ext); + } + } + } catch (std::exception& x) { + cout << "Caught an exception: " << x.what() << endl; + return 1; + } + return 0; // exit with success status +} + + +/* +Remarks: + +1. First stepping sequentially, then by baseline is not bad at all provided that the MS is not very much larger than memory. In such a case a lot of data is already mapped in and does not need to be read randomly. +Test this for a, say, 40 GByte MS by first stepping through it in time, then by baseline. +Probably reading in half the MS is good enough. + +2. Reading an entire tile and thereafter by time is much better than by time. +However, readseq3a might benefit from the data still in the file cache from readseq3. +Yet, readseq3a is much faster when first reading a tile. +Probably readbl3 benefits in the same way. + +*/ diff --git a/RTCP/LofarStMan/test/tIOPerf.sh b/RTCP/LofarStMan/test/tIOPerf.sh new file mode 100755 index 0000000000000000000000000000000000000000..d75d435bf42601afaeac63e88f5f800a506fee3e --- /dev/null +++ b/RTCP/LofarStMan/test/tIOPerf.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./runctest.sh tIOPerf diff --git a/RTCP/LofarStMan/test/tLofarStMan.cc b/RTCP/LofarStMan/test/tLofarStMan.cc new file mode 100644 index 0000000000000000000000000000000000000000..8411fdb5e1de90ee71b0c9aba46f565fec81c538 --- /dev/null +++ b/RTCP/LofarStMan/test/tLofarStMan.cc @@ -0,0 +1,599 @@ +//# tLofarStMan.cc: Test program for the LofarStMan class +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <LofarStMan/LofarStMan.h> +#include <tables/Tables/TableDesc.h> +#include <tables/Tables/SetupNewTab.h> +#include <tables/Tables/Table.h> +#include <tables/Tables/TableLock.h> +#include <tables/Tables/ScaColDesc.h> +#include <tables/Tables/ArrColDesc.h> +#include <tables/Tables/ScalarColumn.h> +#include <tables/Tables/ArrayColumn.h> +#include <measures/TableMeasures/TableMeasRefDesc.h> +#include <measures/TableMeasures/TableMeasValueDesc.h> +#include <measures/TableMeasures/TableMeasDesc.h> +#include <measures/TableMeasures/ScalarMeasColumn.h> +#include <measures/TableMeasures/ArrayMeasColumn.h> +#include <measures/Measures/MDirection.h> +#include <measures/Measures/MCDirection.h> +#include <measures/Measures/MPosition.h> +#include <measures/Measures/MCPosition.h> +#include <casa/Arrays/Array.h> +#include <casa/Arrays/ArrayMath.h> +#include <casa/Arrays/ArrayIO.h> +#include <casa/Arrays/ArrayLogical.h> +#include <casa/Containers/BlockIO.h> +#include <casa/OS/RegularFile.h> +#include <casa/Utilities/Assert.h> +#include <casa/IO/RegularFileIO.h> +#include <casa/IO/RawIO.h> +#include <casa/IO/CanonicalIO.h> +#include <casa/OS/HostInfo.h> +#include <casa/Exceptions/Error.h> +#include <casa/iostream.h> +#include <casa/sstream.h> + +using namespace LOFAR; +using namespace casa; + +// This program tests the class LofarStMan and related classes. +// The results are written to stdout. The script executing this program, +// compares the results with the reference output file. +// +// It uses the given phase center, station positions, times, and baselines to +// get known UVW coordinates. In this way the UVW calculation can be checked. + + +void createField (Table& mainTable) +{ + // Build the table description. + TableDesc td; + td.addColumn (ArrayColumnDesc<Double>("PHASE_DIR")); + TableMeasRefDesc measRef(MDirection::J2000); + TableMeasValueDesc measVal(td, "PHASE_DIR"); + TableMeasDesc<MDirection> measCol(measVal, measRef); + measCol.write (td); + // Now create a new table from the description. + SetupNewTable newtab("tLofarStMan_tmp.data/FIELD", td, Table::New); + Table tab(newtab, 1); + ArrayMeasColumn<MDirection> fldcol (tab, "PHASE_DIR"); + Vector<MDirection> phaseDir(1); + phaseDir[0] = MDirection(MVDirection(Quantity(-1.92653768, "rad"), + Quantity(1.09220917, "rad")), + MDirection::J2000); + fldcol.put (0, phaseDir); + mainTable.rwKeywordSet().defineTable ("FIELD", tab); +} + +void createAntenna (Table& mainTable, uInt nant) +{ + // Build the table description. + TableDesc td; + td.addColumn (ArrayColumnDesc<Double>("POSITION")); + TableMeasRefDesc measRef(MPosition::ITRF); + TableMeasValueDesc measVal(td, "POSITION"); + TableMeasDesc<MPosition> measCol(measVal, measRef); + measCol.write (td); + // Now create a new table from the description. + SetupNewTable newtab("tLofarStMan_tmp.data/ANTENNA", td, Table::New); + Table tab(newtab, nant); + ScalarMeasColumn<MPosition> poscol (tab, "POSITION"); + // Use the positions of WSRT RT0-3. + Vector<double> vals(3); + vals[0] = 3828763; vals[1] = 442449; vals[2] = 5064923; + poscol.put (0, MPosition(Quantum<Vector<double> >(vals,"m"), + MPosition::ITRF)); + vals[0] = 3828746; vals[1] = 442592; vals[2] = 5064924; + poscol.put (1, MPosition(Quantum<Vector<double> >(vals,"m"), + MPosition::ITRF)); + vals[0] = 3828729; vals[1] = 442735; vals[2] = 5064925; + poscol.put (2, MPosition(Quantum<Vector<double> >(vals,"m"), + MPosition::ITRF)); + vals[0] = 3828713; vals[1] = 442878; vals[2] = 5064926; + poscol.put (3, MPosition(Quantum<Vector<double> >(vals,"m"), + MPosition::ITRF)); + // Write the remaining columns with the same position. + // They are not used in the UVW check. + for (uInt i=4; i<nant; ++i) { + poscol.put (i, MPosition(Quantum<Vector<double> >(vals,"m"), + MPosition::ITRF)); + } + mainTable.rwKeywordSet().defineTable ("ANTENNA", tab); +} + +void createTable (uInt nant) +{ + // Build the table description. + // Add all mandatory columns of the MS main table. + TableDesc td("", "1", TableDesc::Scratch); + td.comment() = "A test of class Table"; + td.addColumn (ScalarColumnDesc<Double>("TIME")); + td.addColumn (ScalarColumnDesc<Int>("ANTENNA1")); + td.addColumn (ScalarColumnDesc<Int>("ANTENNA2")); + td.addColumn (ScalarColumnDesc<Int>("FEED1")); + td.addColumn (ScalarColumnDesc<Int>("FEED2")); + td.addColumn (ScalarColumnDesc<Int>("DATA_DESC_ID")); + td.addColumn (ScalarColumnDesc<Int>("PROCESSOR_ID")); + td.addColumn (ScalarColumnDesc<Int>("FIELD_ID")); + td.addColumn (ScalarColumnDesc<Int>("ARRAY_ID")); + td.addColumn (ScalarColumnDesc<Int>("OBSERVATION_ID")); + td.addColumn (ScalarColumnDesc<Int>("STATE_ID")); + td.addColumn (ScalarColumnDesc<Int>("SCAN_NUMBER")); + td.addColumn (ScalarColumnDesc<Double>("INTERVAL")); + td.addColumn (ScalarColumnDesc<Double>("EXPOSURE")); + td.addColumn (ScalarColumnDesc<Double>("TIME_CENTROID")); + td.addColumn (ScalarColumnDesc<Bool>("FLAG_ROW")); + td.addColumn (ArrayColumnDesc<Double>("UVW",IPosition(1,3), + ColumnDesc::Direct)); + td.addColumn (ArrayColumnDesc<Complex>("DATA")); + td.addColumn (ArrayColumnDesc<Float>("SIGMA")); + td.addColumn (ArrayColumnDesc<Float>("WEIGHT")); + td.addColumn (ArrayColumnDesc<Float>("WEIGHT_SPECTRUM")); + td.addColumn (ArrayColumnDesc<Bool>("FLAG")); + td.addColumn (ArrayColumnDesc<Bool>("FLAG_CATEGORY")); + // Now create a new table from the description. + SetupNewTable newtab("tLofarStMan_tmp.data", td, Table::New); + // Create the storage manager and bind all columns to it. + LofarStMan sm1; + newtab.bindAll (sm1); + // Finally create the table. The destructor writes it. + Table tab(newtab); + // Create the subtables needed to calculate UVW coordinates. + createField (tab); + createAntenna (tab, nant); +} + +uInt nalign (uInt size, uInt alignment) +{ + return (size + alignment-1) / alignment * alignment - size; +} + +void createData (uInt nseq, uInt nant, uInt nchan, uInt npol, + Double startTime, Double interval, const Complex& startValue, + uInt alignment, Bool bigEndian, uInt myStManVersion, + uInt myNrBytesPerValidSamples=2) +{ + // Create the baseline vectors (no autocorrelations). + uInt nrbl = nant*nant; + Block<Int> ant1(nrbl); + Block<Int> ant2(nrbl); + uInt inx=0; + + for (uInt i=0; i<nant; ++i) { + for (uInt j=0; j<nant; ++j) { + if (myStManVersion != 2) { + // Use baselines 0,0, 0,1, 1,1 ... n,n + ant1[inx] = j; + ant2[inx] = i; + } else { + // Use baselines 0,0, 1,0, 1,1 ... n,n (will be swapped by LofarStMan) + ant1[inx] = i; + ant2[inx] = j; + } + ++inx; + } + } + // Create the meta file. The destructor closes it. + { + // If not big-endian, use local format (which might be big-endian). + if (!bigEndian) { + bigEndian = HostInfo::bigEndian(); + } + double maxNSample = 32768; + + AlwaysAssertExit(myStManVersion <= 3); + + AipsIO aio("tLofarStMan_tmp.data/table.f0meta", ByteIO::New); + aio.putstart ("LofarStMan", myStManVersion); // version 1, 2, or 3 + aio << ant1 << ant2 << startTime << interval << nchan + << npol << maxNSample << alignment << bigEndian; + if (myStManVersion > 1) { + aio << myNrBytesPerValidSamples; + } + aio.close(); + } + // Now create the data file. + RegularFileIO file(RegularFile("tLofarStMan_tmp.data/table.f0data"), + ByteIO::New); + // Write in canonical (big endian) or local format. + TypeIO* cfile; + if (bigEndian) { + cfile = new CanonicalIO(&file); + } else { + cfile = new RawIO(&file); + } + + // Create and initialize data and nsample. + Array<Complex> data(IPosition(2,npol,nchan)); + indgen (data, startValue, Complex(0.01, 0.01)); + + Array<uChar> nsample1(IPosition(1, nchan)); + Array<uShort> nsample2(IPosition(1, nchan)); + Array<uInt> nsample4(IPosition(1, nchan)); + + indgen (nsample1); + indgen (nsample2); + indgen (nsample4); + + + // Allocate space for possible block alignment. + if (alignment < 1) { + alignment = 1; + } + Block<Char> align1(nalign(4, alignment), 0); + Block<Char> align2(nalign(nrbl*8*data.size(), alignment), 0); + + uInt nsamplesSize=0; + if (myStManVersion < 2) { + nsamplesSize = nrbl*2*nsample2.size(); + } else { + nsamplesSize = nrbl*myNrBytesPerValidSamples*nsample2.size(); + } + + Block<Char> align3(nalign(nsamplesSize, alignment), 0); + + // Write the data as nseq blocks. + for (uInt i=0; i<nseq; ++i) { + cfile->write (1, &i); + + if (align1.size() > 0) { + cfile->write (align1.size(), align1.storage()); + } + for (uInt j=0; j<nrbl; ++j) { + // The RTCP wrote the conj of the data for version 1 and 2. + if (myStManVersion < 3) { + Array<Complex> cdata = conj(data); + cfile->write (data.size(), cdata.data()); + } else { + cfile->write (data.size(), data.data()); + } + data += Complex(0.01, 0.02); + } + if (align2.size() > 0) { + cfile->write (align2.size(), align2.storage()); + } + + if (myStManVersion < 2) { + for (uInt j=0; j<nrbl; ++j) { + cfile->write (nsample2.size(), nsample2.data()); + nsample2 += uShort(1); + } + } else { + + for (uInt j=0; j<nrbl; ++j) { + switch (myNrBytesPerValidSamples) { + case 1: + { + cfile->write(nsample1.size(), nsample1.data()); + nsample1 += uChar(1); + } break; + case 2: + { + cfile->write(nsample2.size(), nsample2.data()); + nsample2 += uShort(1); + } break; + case 4: + { + cfile->write(nsample4.size(), nsample4.data()); + nsample4 += uInt(1); + } break; + } + } + } + + if (align3.size() > 0) { + cfile->write (align3.size(), align3.storage()); + } + } + delete cfile; + + if (myStManVersion > 1) { + TypeIO* sfile = 0; + // create seperate file for sequence numbers if version > 1 + RegularFileIO file(RegularFile("tLofarStMan_tmp.data/table.f0seqnr"), + ByteIO::New); + // Write in canonical (big endian) or local format. + if (bigEndian) { + sfile = new CanonicalIO(&file); + } else { + sfile = new RawIO(&file); + } + for (uInt i=0; i<nseq; ++i) { + sfile->write (1, &i); + } + delete sfile; + } +} + + +void checkUVW (uInt row, uInt nant, Vector<Double> uvw) +{ + // Expected outcome of UVW for antenna 0-3 and seqnr 0-1 + static double uvwVals[] = { + 0, 0, 0, + 0.423756, -127.372, 67.1947, + 0.847513, -254.744, 134.389, + 0.277918, -382.015, 201.531, + -0.423756, 127.372, -67.1947, + 0, 0, 0, + 0.423756, -127.372, 67.1947, + -0.145838, -254.642, 134.336, + -0.847513, 254.744, -134.389, + -0.423756, 127.372, -67.1947, + 0, 0, 0, + -0.569594, -127.27, 67.1417, + -0.277918, 382.015, -201.531, + 0.145838, 254.642, -134.336, + 0.569594, 127.27, -67.1417, + 0, 0, 0, + 0, 0, 0, + 0.738788, -127.371, 67.1942, + 1.47758, -254.742, 134.388, + 1.22276, -382.013, 201.53, + -0.738788, 127.371, -67.1942, + 0, 0, 0, + 0.738788, -127.371, 67.1942, + 0.483976, -254.642, 134.336, + -1.47758, 254.742, -134.388, + -0.738788, 127.371, -67.1942, + 0, 0, 0, + -0.254812, -127.271, 67.1421, + -1.22276, 382.013, -201.53, + -0.483976, 254.642, -134.336, + 0.254812, 127.271, -67.1421, + 0, 0, 0 + }; + uInt nrbl = nant*nant; + uInt seqnr = row / nrbl; + uInt bl = row % nrbl; + uInt ant1 = bl % nant; + uInt ant2 = bl / nant; + // Only check first two time stamps and first four antennae. + if (seqnr < 2 && ant1 < 4 && ant2 < 4) { + AlwaysAssertExit (near(uvw[0], + uvwVals[3*(seqnr*16 + 4*ant1 + ant2)], + 1e-5)) + } +} + +void readTable (uInt nseq, uInt nant, uInt nchan, uInt npol, + Double startTime, Double interval, const Complex& startValue) +{ + uInt nbasel = nant*nant; + // Open the table and check if #rows is as expected. + Table tab("tLofarStMan_tmp.data"); + uInt nrow = tab.nrow(); + AlwaysAssertExit (nrow = nseq*nbasel); + AlwaysAssertExit (!tab.canAddRow()); + AlwaysAssertExit (!tab.canRemoveRow()); + AlwaysAssertExit (tab.canRemoveColumn(Vector<String>(1, "DATA"))); + // Create objects for all mandatory MS columns. + ROArrayColumn<Complex> dataCol(tab, "DATA"); + ROArrayColumn<Float> weightCol(tab, "WEIGHT"); + ROArrayColumn<Float> wspecCol(tab, "WEIGHT_SPECTRUM"); + ROArrayColumn<Float> sigmaCol(tab, "SIGMA"); + ROArrayColumn<Double> uvwCol(tab, "UVW"); + ROArrayColumn<Bool> flagCol(tab, "FLAG"); + ROArrayColumn<Bool> flagcatCol(tab, "FLAG_CATEGORY"); + ROScalarColumn<Double> timeCol(tab, "TIME"); + ROScalarColumn<Double> centCol(tab, "TIME_CENTROID"); + ROScalarColumn<Double> intvCol(tab, "INTERVAL"); + ROScalarColumn<Double> expoCol(tab, "EXPOSURE"); + ROScalarColumn<Int> ant1Col(tab, "ANTENNA1"); + ROScalarColumn<Int> ant2Col(tab, "ANTENNA2"); + ROScalarColumn<Int> feed1Col(tab, "FEED1"); + ROScalarColumn<Int> feed2Col(tab, "FEED2"); + ROScalarColumn<Int> ddidCol(tab, "DATA_DESC_ID"); + ROScalarColumn<Int> pridCol(tab, "PROCESSOR_ID"); + ROScalarColumn<Int> fldidCol(tab, "FIELD_ID"); + ROScalarColumn<Int> arridCol(tab, "ARRAY_ID"); + ROScalarColumn<Int> obsidCol(tab, "OBSERVATION_ID"); + ROScalarColumn<Int> stidCol(tab, "STATE_ID"); + ROScalarColumn<Int> scnrCol(tab, "SCAN_NUMBER"); + ROScalarColumn<Bool> flagrowCol(tab, "FLAG_ROW"); + // Create and initialize expected data and weight. + Array<Complex> dataExp(IPosition(2,npol,nchan)); + indgen (dataExp, startValue, Complex(0.01, 0.01)); + Array<Float> weightExp(IPosition(2,1,nchan)); + + indgen (weightExp, Float(0),Float(1./32768)); + // Loop through all rows in the table and check the data. + uInt row=0; + for (uInt i=0; i<nseq; ++i) { + + for (uInt j=0; j<nant; ++j) { + for (uInt k=0; k<nant; ++k) { + + // Contents must be present except for FLAG_CATEGORY. + AlwaysAssertExit (dataCol.isDefined (row)); + AlwaysAssertExit (weightCol.isDefined (row)); + AlwaysAssertExit (wspecCol.isDefined (row)); + AlwaysAssertExit (sigmaCol.isDefined (row)); + AlwaysAssertExit (flagCol.isDefined (row)); + AlwaysAssertExit (!flagcatCol.isDefined (row)); + // Check data, weight, sigma, weight_spectrum, flag + AlwaysAssertExit (allNear (dataCol(row), dataExp, 1e-7)); + AlwaysAssertExit (weightCol.shape(row) == IPosition(1,npol)); + AlwaysAssertExit (allEQ (weightCol(row), Float(1))); + AlwaysAssertExit (sigmaCol.shape(row) == IPosition(1,npol)); + AlwaysAssertExit (allEQ (sigmaCol(row), Float(1))); + Array<Float> weights = wspecCol(row); + AlwaysAssertExit (weights.shape() == IPosition(2,npol,nchan)); + for (uInt p=0; p<npol; ++p) { + + if (!allNear(weights(IPosition(2,p,0),IPosition(2,p,nchan-1)),weightExp, 1e-7)) { + + std::cout << "weights: " << std::endl; + std::cout << weights(IPosition(2,p,0), IPosition(2,p,nchan-1)) << std::endl; + + std::cout << "weigthExp: " << std::endl; + std::cout << weightExp << std:: endl; + + } + } + Array<Bool> flagExp (weights == Float(0)); + AlwaysAssertExit (allEQ (flagCol(row), flagExp)); + // Check ANTENNA1 and ANTENNA2 + + AlwaysAssertExit (ant1Col(row) == int32(k)); + AlwaysAssertExit (ant2Col(row) == int32(j)); + + dataExp += Complex(0.01, 0.02); + weightExp += Float(1./32768); + ++row; + } + } + } + // Check values in TIME column. + Vector<Double> times = timeCol.getColumn(); + AlwaysAssertExit (times.size() == nrow); + row=0; + startTime += interval/2; + for (uInt i=0; i<nseq; ++i) { + for (uInt j=0; j<nbasel; ++j) { + AlwaysAssertExit (near(times[row], startTime)); + ++row; + } + startTime += interval; + } + // Check the other columns. + AlwaysAssertExit (allNear(centCol.getColumn(), times, 1e-13)); + AlwaysAssertExit (allNear(intvCol.getColumn(), interval, 1e-13)); + AlwaysAssertExit (allNear(expoCol.getColumn(), interval, 1e-13)); + AlwaysAssertExit (allEQ(feed1Col.getColumn(), 0)); + AlwaysAssertExit (allEQ(feed2Col.getColumn(), 0)); + AlwaysAssertExit (allEQ(ddidCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(pridCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(fldidCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(arridCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(obsidCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(stidCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(scnrCol.getColumn(), 0)); + AlwaysAssertExit (allEQ(flagrowCol.getColumn(), False)); + // Check the UVW coordinates. + for (uInt i=0; i<nrow; ++i) { + checkUVW (i, nant, uvwCol(i)); + } + RefRows rownrs(0,2,1); + Slicer slicer(IPosition(2,0,0), IPosition(2,1,1)); + cout << wspecCol(0).shape() << endl; + Array<float> wg = wspecCol.getColumnCells (rownrs); +} + +void updateTable (uInt nchan, uInt npol, const Complex& startValue) +{ + // Open the table for write. + Table tab("tLofarStMan_tmp.data", Table::Update); + uInt nrow = tab.nrow(); + // Create object for DATA column. + ArrayColumn<Complex> dataCol(tab, "DATA"); + // Check we can write the column, but not change the shape. + AlwaysAssertExit (tab.isColumnWritable ("DATA")); + AlwaysAssertExit (!dataCol.canChangeShape()); + // Create and initialize data. + Array<Complex> data(IPosition(2,npol,nchan)); + indgen (data, startValue, Complex(0.01, 0.01)); + // Loop through all rows in the table and write the data. + for (uInt row=0; row<nrow; ++row) { + dataCol.put (row, data); + data += Complex(0.01, 0.02); + } +} + +void copyTable() +{ + Table tab("tLofarStMan_tmp.data"); + // Deep copy the table. + tab.deepCopy ("tLofarStMan_tmp.datcp", Table::New, true); +} + + +int main (int argc, char* argv[]) +{ + try { + // Register LofarStMan to be able to read it back. + LofarStMan::registerClass(); + // Get nseq, nant, nchan, npol from argv. + uInt nseq=10; + uInt nant=16; + uInt nchan=256; + uInt npol=4; + if (argc > 1) { + istringstream istr(argv[1]); + istr >> nseq; + } + if (nseq == 0) { + Table tab(argv[2]); + cout << "nrow=" << tab.nrow() << endl; + ROArrayColumn<double> uvwcol(tab, "UVW"); + cout << "uvws="<< uvwcol(0) << endl; + cout << "uvws="<< uvwcol(1) << endl; + cout << "uvwe="<< uvwcol(tab.nrow()-1) << endl; + } else { + if (argc > 2) { + istringstream istr(argv[2]); + istr >> nant; + } + if (argc > 3) { + istringstream istr(argv[3]); + istr >> nchan; + } + if (argc > 4) { + istringstream istr(argv[4]); + istr >> npol; + } + // Test the various versions. + for (int v=1; v<4; ++v) { + cout << "Test version " << v << endl; + // Create the table. + createTable (nant); + // Write data in big-endian and check it. Align on 512. + // Use this start time and interval to get known UVWs. + // They are the same as used in DPPP/tUVWFlagger. + double interval= 30.; + double startTime = 4472025740.0 - interval*0.5; + createData (nseq, nant, nchan, npol, startTime, interval, + Complex(0.1, 0.1), 512, True, v); + readTable (nseq, nant, nchan, npol, startTime, interval, + Complex(0.1, 0.1)); + // Update the table and check again. + updateTable (nchan, npol, Complex(-3.52, -20.3)); + readTable (nseq, nant, nchan, npol, startTime, interval, + Complex(-3.52, -20.3)); + // Write data in local format and check it. No alignment. + createData (nseq, nant, nchan, npol, startTime, interval, + Complex(3.1, -5.2), 0, False, v); + readTable (nseq, nant, nchan, npol, startTime, interval, + Complex(3.1, -5.2)); + // Update the table and check again. + updateTable (nchan, npol, Complex(3.52, 20.3)); + readTable (nseq, nant, nchan, npol, startTime, interval, + Complex(3.52, 20.3)); + copyTable(); + } + } + } catch (AipsError& x) { + cout << "Caught an exception: " << x.getMesg() << endl; + return 1; + } + return 0; // exit with success status +} diff --git a/RTCP/LofarStMan/test/tLofarStMan.sh b/RTCP/LofarStMan/test/tLofarStMan.sh new file mode 100755 index 0000000000000000000000000000000000000000..0a655e5f5118add34da77e014e6d200ce7ed00c5 --- /dev/null +++ b/RTCP/LofarStMan/test/tLofarStMan.sh @@ -0,0 +1,2 @@ +#!/bin/sh +./runctest.sh tLofarStMan diff --git a/RTCP/LofarStMan/test/tfix.cc b/RTCP/LofarStMan/test/tfix.cc new file mode 100644 index 0000000000000000000000000000000000000000..451a7107701a155bb1eac448d638c48da0be8fab --- /dev/null +++ b/RTCP/LofarStMan/test/tfix.cc @@ -0,0 +1,66 @@ +//# tfix.cc: Fix oldMSs by adding WEIGHT_SPECTRUM column +//# Copyright (C) 2009 +//# ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite 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 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite 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 the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <LofarStMan/LofarStMan.h> +#include <tables/Tables/TableDesc.h> +#include <tables/Tables/Table.h> +#include <tables/Tables/ArrColDesc.h> +#include <casa/Exceptions/Error.h> +#include <casa/iostream.h> + +using namespace LOFAR; +using namespace casa; + +// This program adds column WEIGHT_SPECTRUM using LofarStMan. +// It adds it to the existing LofarStMan data manager in an MS, otherwise +// another data manager is created whih will not be able to find the data files. + + +void fixTable (const String& name) +{ + Table t(name, Table::Update); + if (t.tableDesc().isColumn("WEIGHT_SPECTRUM")) { + cout << "MS already contains column WEIGHT_SPECTRUM" << endl; + } else { + TableDesc td; + ArrayColumnDesc<Float> cd("WEIGHT_SPECTRUM"); + //# Note: True means add to existing LofarStMan. + t.addColumn (cd, "LofarStMan", True); + cout << "Added column WEIGHT_SPECTRUM to the MS" << endl; + } +} + +int main (int argc, char* argv[]) +{ + try { + // Register LofarStMan to be able to read it back. + LofarStMan::registerClass(); + if (argc <= 1) { + cout << "Run as: tfix msname" << endl; + return 0; + } + fixTable (argv[1]); + } catch (AipsError x) { + cout << "Caught an exception: " << x.getMesg() << endl; + return 1; + } + return 0; // exit with success status +} diff --git a/RTCP/Run/src/BlueGeneControl.conf b/RTCP/Run/src/BlueGeneControl.conf index daa66548b3f124f066ec9235b3f711b2d8dc9c44..c63cdaed86fa1b1cd1e8102fe053a104f531307d 100644 --- a/RTCP/Run/src/BlueGeneControl.conf +++ b/RTCP/Run/src/BlueGeneControl.conf @@ -8,7 +8,7 @@ if [ "$USER" == "lofarsys" ] then if [ "`basename $HOME`" == "lofartest" ] then - PARTITION=R01-M0-N04-64 # test partition + PARTITION=LOFARTEST # test partition else PARTITION=R00 # production partition fi diff --git a/RTCP/Run/src/LOFAR/Parset.py b/RTCP/Run/src/LOFAR/Parset.py index de3445852ba486a9ccbd94b957b2c15a79ceaa42..326be0bdd4dd482f822f5fce8c6de3154734b70c 100644 --- a/RTCP/Run/src/LOFAR/Parset.py +++ b/RTCP/Run/src/LOFAR/Parset.py @@ -116,7 +116,7 @@ class Parset(util.Parset.Parset): if partition: self.setPartition( partition ) - if self.partition and self.partition != "R00R01": + if self.partition and self.partition != "R00R01" and self.partition != "LOFARTEST": overrideRack( Stations, int(self.partition[2]) ) # storage nodes diff --git a/RTCP/Run/src/LOFAR/Partitions.py b/RTCP/Run/src/LOFAR/Partitions.py index d19ecd8a61ac6f2ff96e1e39a3dd1e6fa8fa39ab..d23f1e183949750711e6b925de0ae19609e96878 100755 --- a/RTCP/Run/src/LOFAR/Partitions.py +++ b/RTCP/Run/src/LOFAR/Partitions.py @@ -18,6 +18,8 @@ sys.path += [os.path.abspath(os.path.dirname(__file__)+"/..")] # R00-M0 = R00-M0-N00-256 + R00-M0-N08-256 # R00 = R00-M0 + R00-M1 +# LOFARTEST = R01-M0-N00-J00 + R01-M0-N08-J00 + PartitionPsets = {} for R in xrange(3): rack = "R%02d" % R @@ -51,6 +53,7 @@ for R in xrange(3): PartitionPsets[rack] = PartitionPsets["%s-M0" % rack] + PartitionPsets["%s-M1" % rack] PartitionPsets["R00R01"] = PartitionPsets["R00"] + PartitionPsets["R01"] +PartitionPsets["LOFARTEST"] = PartitionPsets["R01-M0-N00-J00-16"] + PartitionPsets["R01-M0-N08-J00-16"] if __name__ == "__main__": from optparse import OptionParser,OptionGroup diff --git a/RTCP/Run/src/locations.sh.in b/RTCP/Run/src/locations.sh.in index 53929e9af088697e24b8370b8901fe6f08e611aa..1e4b06cc4fd4e3532fd78f0b7e5864f4b40b4554 100644 --- a/RTCP/Run/src/locations.sh.in +++ b/RTCP/Run/src/locations.sh.in @@ -102,6 +102,14 @@ fi function set_psetinfo() { + if [ "$PARTITION" == "LOFARTEST" ] + then + PSETS="10.170.1.1,10.170.1.33" + FIRSTPSET="10.170.1.1" + + return + fi + # list both the partition directly (small partitions) and recursively (large partitions) to get all -32 subpartitions # bghierarchy needs a valid stdin for some reason and will read from it, so provide a fake one if [ "$PARTITION" == "R00R01" ] diff --git a/SubSystems/CMakeLists.txt b/SubSystems/CMakeLists.txt index 13eca7f525610d405ea344a0a8dd1808e1c68cd3..d589bd2b6d646b9f9eb703212d6568c35bea768a 100644 --- a/SubSystems/CMakeLists.txt +++ b/SubSystems/CMakeLists.txt @@ -5,6 +5,7 @@ lofar_add_package(LCU_MAC) lofar_add_package(MCU_MAC) lofar_add_package(CN_MAC) lofar_add_package(Online_Storage) +lofar_add_package(Online_OutputProc) lofar_add_package(ST_MAC) lofar_add_package(Offline) lofar_add_package(SAS_OTDB) diff --git a/SubSystems/Online_OutputProc/CMakeLists.txt b/SubSystems/Online_OutputProc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..452ab8c7f565715c819e58875d079881e82714b8 --- /dev/null +++ b/SubSystems/Online_OutputProc/CMakeLists.txt @@ -0,0 +1,4 @@ +# $Id$ + +lofar_package(Online_OutputProc DEPENDS OutputProc MetaDataGatherer StaticMetaData) +