Skip to content
Snippets Groups Projects
Commit 9ae4c978 authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

Task #4589: Merged latest trunk (r27378) into the branch

parents add4274c 0dcccca8
No related branches found
No related tags found
No related merge requests found
Showing
with 801 additions and 82 deletions
......@@ -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
......
......@@ -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.
......
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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")
......
......@@ -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:
......
......@@ -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+ \
......
# - 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)
......
......@@ -7,6 +7,7 @@ set(inst_HEADERS
LofarDirs.h
Observation.h
PosixTime.h
PVSSDatapointDefs.h
StationConfig.h
StationDatatypes.h
StationInfo.h)
......
This diff is collapsed.
......@@ -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
......
......@@ -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
//
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -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() &&
......
......@@ -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]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment