30 #include <QtCore/QDataStream>
31 #include <QtCore/QDir>
32 #include <QtCore/QFile>
65 : fileName_(fileName),
66 fileNameAux_(fileNameAux),
72 vdbWrapperFileName_(
""),
99 vdbWrapperFileName_(
"")
208 "::importSession(): cannot find anything associated with the name \"" +
fileName_ +
209 "\". Please, check and do it again.");
234 "::performPia(): the automatic analysis is disabled by the command line argument");
311 QString fileName(fName);
312 QString fileName2(fName2);
318 QString currentVersion;
325 if (fileName.at(0) ==
'$')
326 fileName = fileName.mid(1);
327 l = fileName.length();
328 if (fileName2.size()>0 && fileName2.at(0) ==
'$')
329 fileName2 = fileName2.mid(1);
335 while (
inquireCat(fileName, ++v, str1, str2) != 0 && v<70)
341 "::setupCatsDbhFileNames(): the file " + fileName +
" does not exist in the catalog");
345 while (
inquireCat(fileName, ++v, str1, str2) == 0)
351 "::setupCatsDbhFileNames(): the file " + fileName +
" does not exist in the catalog");
354 fileName += QString(
"").sprintf(
"_V%03d", v);
357 else if (!(fileName.mid(l-5, 2) ==
"_V"))
360 "::setupCatsDbhFileNames(): the file " + fileName +
" is not a standard database name, "
361 "expecting: YYMMMDDBC_Vxxx");
365 baseName = fileName.mid(l-14, 7);
366 currentBand = fileName.mid(l-7, 1);
367 baseNetID = fileName.mid(l-6, 1);
368 currentVersion = fileName.mid(l-4, 4);
369 version = currentVersion.mid(1).toInt(&isOk);
373 "::setupCatsDbhFileNames(): cannot determine proper DBH version for the file " + fileName);
378 if (
inquireCat(baseName + currentBand + baseNetID, version, str1, str2) != 0)
381 "::setupCatsDbhFileNames(): got an error on the request to " +
386 l = str2.lastIndexOf(
"/");
394 l = fileName2.size();
402 while (
inquireCat(fileName2, ++v, str1, str2) != 0 && v<70)
408 "::setupCatsDbhFileNames(): cannot find the second file " + fileName2 +
" in the catalog");
412 while (
inquireCat(fileName2, ++v, str1, str2) == 0)
418 "::setupCatsDbhFileNames(): cannot find the second file " + fileName2 +
" in the catalog");
421 fileName2 += QString(
"").sprintf(
"_V%03d", v);
425 v = fileName2.mid(l-3, 3).toInt(&isOk);
429 isOk =
inquireCat(fileName2, v, str1, str2) == 0;
432 aBand = fileName2.mid(l-7, 1);
433 l = str2.lastIndexOf(
"/");
438 "::setupCatsDbhFileNames(): the second database file " + fileName2 +
439 " has been found in the catalog, band=[" + currentBand +
"], version=" +
440 QString(
"").setNum(v));
448 if (currentBand ==
"X")
452 isOk =
inquireCat(baseName + key + baseNetID, v--, str1, str2) == 0;
457 while (v<31 && !isOk)
458 isOk =
inquireCat(baseName + key + baseNetID, v++, str1, str2) == 0;
462 l = str2.lastIndexOf(
"/");
468 "::setupCatsDbhFileNames(): cannot find an opposite band, " + key +
", : " + str1);
473 if (
inquireCat(baseName + (currentBand==
"S"?
"X":currentBand) + baseNetID, version+1, str1, str2) == 0)
479 "::setupCatsDbhFileNames(): a database with the next version already exists in the catalog");
493 QString currentVersion;
495 int l = fileName.length();
498 if (fileName.mid(l-5, 2) ==
"_V")
501 currentBand = fileName.mid(l-7, 1);
502 baseNetID = fileName.mid(l-6, 1);
503 currentVersion = fileName.mid(l-4, 4);
505 l = fileName.lastIndexOf(
"/");
507 if (fileName.at(0) ==
'/')
510 str = fileName.mid(l+1);
515 str = fileName.mid(l+1);
518 baseName = str.left(7);
520 QStringList nameFilters;
522 nameFilters << baseName +
"?" + baseNetID +
"*";
524 nameFilters << baseName + currentBand + baseNetID +
"*";
525 QStringList nameList = dir.entryList(nameFilters,
526 QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase);
527 if (!nameList.size())
531 for (
int i=0; i<nameList.size(); i++)
533 l = nameList.at(i).length();
536 key = nameList.at(i).mid(l-7, 1);
543 else if (nameList.at(i).mid(l-4, 4) <= currentVersion)
559 QString sessionName(
"");
563 QRegExp reWrapperFileName(
".*\\.(wrp|wrap)$", Qt::CaseInsensitive);
564 QRegExp reDatabaseName(
"^[0-9]{2}[A-Z]{3}[0-9]{2}[A-Z0-9]{1,2}$");
565 QRegExp reDatabaseVersionName(
"^[0-9]{2}[A-Z]{3}[0-9]{2}[A-Z0-9]{1,2}_V[0-9]{3}$");
566 QRegExp rePath2Database(
"(.*)([0-9]{2}[A-Z]{3}[0-9]{2}[A-Z0-9]{1,2})/?$");
569 if (reWrapperFileName.indexIn(inpt) != -1)
573 sessionName, version);
576 "::setupVgosDbFileNames(): got a session " + sessionName +
" of version " +
577 QString(
"").setNum(version) +
" from \"" +
path2VdbFiles_ +
"\":\"" +
581 "::setupVgosDbFileNames(): cannot figure out a session from the input \"" + inpt +
"\"");
584 else if (reDatabaseName.exactMatch(inpt) || reDatabaseVersionName.exactMatch(inpt))
592 "\" from \"" +
path2VdbFiles_ +
"\" for the session " + sessionName +
593 " of version " + QString(
"").setNum(version));
596 "::setupVgosDbFileNames(): cannot figure out a wrapper file from the input \"" + inpt +
"\"");
598 else if (-1 < rePath2Database.indexIn(inpt))
604 if (rePath2Database.indexIn(dir.canonicalPath()) == -1)
607 "::setupVgosDbFileNames(): converting input \"" + inpt +
"\" to the absolute path \"" +
608 dir.canonicalPath() +
"\" has failed");
611 QString sDir(rePath2Database.cap(2));
612 QString sPath(rePath2Database.cap(1));
619 "\" from \"" +
path2VdbFiles_ +
"\" for the session " + sessionName +
620 " of version " + QString(
"").setNum(version));
623 "::setupVgosDbFileNames(): cannot figure out a wrapper file from the directory \"" +
628 "::setupVgosDbFileNames(): the directory \"" + inpt +
"\" does not exist");
632 "::setupVgosDbFileNames(): cannot guess input data from \"" + inpt +
"\"");
645 file.setFileName(str);
654 file.setFileName(str);
669 for (QMap<QString, QString>::const_iterator i=
dbhNameByKey_.constBegin();
674 dbhFile.setFileName(path + i.value());
676 "::initSessionFromDbh(): reading file " + i.value() +
" in the directory \"" +
679 dbhFile.open(QIODevice::ReadOnly);
680 dbhStream.setDevice(&dbhFile);
681 dbhStream >> *dbhImage;
682 dbhStream.setDevice(NULL);
689 "::initSessionFromDbh(): absorbing data from the set of DBH images",
true);
705 (isOk?
" complete":
" failed"));
736 ") has been imported from " +
fileName_);
740 "::initSessionFromVda(): reading data from vgosDa file \"" +
fileName_ +
"\" failed");
753 ": exportDataIntoDbh(): saving data in DBH format has been canceled");
758 "::exportDataIntoDbh(): saving data in DBH format");
764 "::exportDataIntoDbh(): the session pointer is NULL");
773 "::exportDataIntoDbh(): the primary band pointer is NULL");
781 "::exportDataIntoDbh(): the dbhImage pointer is NULL");
786 bool isNewChain(
false);
788 QString sessionFileName, dbhFileName;
801 if (QFile::exists(dbhFileName))
803 if (have2NotifyCatalog)
807 "::exportDataIntoDbh(): the file " + dbhFileName +
" is already exist; remove it and try again");
812 dbhFileName += suffix;
814 "::exportDataIntoDbh(): the new version file is already exist; the name is altered to " +
815 sessionFileName + suffix);
821 if (have2NotifyCatalog)
828 "::exportDataIntoDbh(): the new version already exists in the catalog, remove it from the "
829 "catalog and try again");
836 QFile dbhFile(dbhFileName);
837 dbhFile.open(QIODevice::WriteOnly);
838 dbhStream.setDevice(&dbhFile);
839 dbhStream << *dbhImage;
840 dbhStream.setDevice(NULL);
843 "::exportDataIntoDbh(): the " + primaryBand->
getKey() +
"-band of the session " +
846 if (have2NotifyCatalog)
849 if (
notifyCat(dbhFileName, isNewChain, str1) != 0)
853 "::exportDataIntoDbh(): updating the catalog has failed; error: " + str1);
858 "::exportDataIntoDbh(): the catalog has been updated successfuly");
874 ": exportDataIntoVgosDb(): exporting of data into vgosDb tree has been canceled");
891 QString dir2Save(
"");
897 "::exportDataIntoVgosDb(): gpt a user specified path: \"" + dir2Save +
"\"");
905 "::exportDataIntoVgosDb(): vgosDb object has been created");
909 "::exportDataIntoVgosDb(): the vgosDb object has been prepared to save the new session in "
913 if (dir.exists(dir2Save))
918 "::exportDataIntoVgosDb(): the output path has been adjusted to \"" + dir2Save +
"\"");
919 if (dir.exists(dir2Save))
926 "::exportDataIntoVgosDb(): the output path has been readjusted to \"" + dir2Save +
"\"");
935 "::exportDataIntoVgosDb(): export of data into vgosDb tree has been " + (isOk?
"complete":
"failed"));
940 "::exportDataIntoVgosDb(): vgosDb object has been destroyed.");
944 "::exportDataIntoVgosDb(): exporting of data into vgosDb tree has been" +
945 (isOk?
" complete":
" failed"));
954 QString& str1, QString& str2)
960 QString tmpFileName(
"/tmp/nuSolve-Catalog.");
965 databaseName +
" " + QString(
"").setNum(version) +
" " + tmpFileName;
966 rc = system(qPrintable(execStr));
969 complain =
"An error occured executing the system call [" + execStr +
"]; RC is " +
970 QString(
"").setNum(rc);
972 "::inquireCat(): " + complain,
true);
975 f.setFileName(tmpFileName);
976 f.open(QIODevice::ReadOnly);
979 if (str1 !=
"0 success")
987 if (str2.length() < 14)
989 "::inquireCat(): the length of the received string, " + str2 +
990 ", is less than a properly formed database name");
1006 QString tmpFileName(
"/tmp/nuSolve-Catalog.");
1008 QString descriptionOfKey(
"1234"), descriptionOfEntry(
"");
1032 f.setFileName(tmpFileName);
1033 if (f.open(QIODevice::WriteOnly))
1036 s << descriptionOfKey .left(36) << endl;
1037 s << descriptionOfEntry.left(80) << endl;
1044 "::notifyCat(): cannot open for writting the communication file");
1050 fileName +
" " + (isNew?
"create":
"update") +
" " + tmpFileName;
1053 rc = system(qPrintable(execStr));
1056 complain =
"An error occured executing the system call [" + execStr +
"]; RC is " +
1057 QString(
"").setNum(rc);
1059 "::notifyCat(): " + complain,
true);
1063 f.setFileName(tmpFileName);
1064 if (f.open(QIODevice::ReadOnly))
1067 str1 = s.readLine();
1071 if (str1 !=
"0 success")
1078 "::notifyCat(): cannot open for reading the communication file");
1092 QDir d(splflDirName);
1094 isOk = d.mkpath(
"./");
1098 "::generateReport(): cannot create directory \"" + splflDirName +
"\"; report failed");
1101 d.setPath(obsStatDirName);
1103 isOk = d.mkpath(
"./");
1107 "::generateReport(): cannot create directory \"" + obsStatDirName +
"\"; saving report failed");
1116 "::generateReport(): spoolfile output has been saved in the " + fileName +
" file");
1122 d.setPath(rptrDirName);
1124 isOk = d.mkpath(
"./");
1128 "::generateReport(): cannot create directory " + rptrDirName +
"; saving report failed");
1133 if (QFile::exists(rptrDirName +
"/" + str) && !QFile(rptrDirName +
"/" + str).remove())
1136 "::generateReport(): cannot remove the file " + rptrDirName +
"/" + str +
1137 "; saving report failed");
1140 if (QFile::copy(splflDirName +
"/" + fileName, rptrDirName +
"/" + str))
1142 "::generateReport(): spoolfile output has been copied as " + rptrDirName +
"/" + str +
1146 "::generateReport(): copying of " + splflDirName +
"/" + fileName +
" as " + rptrDirName +
1147 "/" + str +
" filed");
1160 QDir d(splflDirName);
1162 isOk = d.mkpath(
"./");
1166 "::generateMyReport(): cannot create directory \"" + splflDirName +
"\"; report failed");
1169 d.setPath(obsStatDirName);
1171 isOk = d.mkpath(
"./");
1175 "::generateMyReport(): cannot create directory \"" + obsStatDirName +
"\"; saving report failed");
1184 "::generateMyReport(): report has been saved in the " + fileName +
" file");
1196 if (dbName.at(0) ==
'$')
1197 dbName.remove(0, 1);
1199 outputDirName +=
"/" + dbName;
1202 "::generateReport4StcPars(): stochastic parameter estimaitons were saved in \"" + outputDirName +
1214 if (dbName.at(0) ==
'$')
1215 dbName.remove(0, 1);
1216 outputDirName +=
"/" + dbName;
1220 "::generateReport4Tzds(): total zenith delays were saved in \"" + outputDirName +
1224 "::generateReport4Tzds(): saving total zenith delays in \"" + outputDirName +
1225 "\" direcory has been failed");
1237 QDir d(splflDirName);
1239 isOk = d.mkpath(
"./");
1243 "::generateAposterioriFiles(): cannot create directory " + splflDirName +
"; report failed");
1249 if (fileName.at(0) ==
'$')
1250 fileName.remove(0, 1);
1253 "::generateAposterioriFiles(): a posteriori files were saved with \"" + fileName +
"\" basename");
1265 ": exportDataToNgs(): exporting of data into NGS card format has been canceled");
1274 isOk = d.mkpath(
"./");
1279 "::exportDataToNgs(): the session has been exported as NGS file in the directory " + dirName);
1283 "::exportDataToNgs(): cannot create directory " + dirName +
"; NGS export failed");
1294 ": exportDataIntoVgosDa(): saving data in vgosDa format has been canceled");
1298 QString dir2Save(
"");
1299 QString file2Save(
"");
1304 dir.setPath(output);
1313 if (-1 < (idx=output.lastIndexOf(
'/')))
1315 dir2Save = output.left(idx);
1316 file2Save = output.mid(idx + 1);
1328 dir.setPath(dir2Save);
1330 isOk = dir.mkpath(
"./");
1335 "::exportDataIntoVgosDa(): the session has been saved as an vgosDa file in the directory \"" +
1340 "::exportDataIntoVgosDa(): cannot create directory " + dir2Save +
1341 "; storing data in vgosDa format has failed");
SgVersion nuSolveVersion("nuSolve", 0, 7, 5, "Carroll Creek (rc)", SgMJD(2022, 2, 18, 17, 34))
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
QString vdbWrapperFileName_
const SgParametersDescriptor * parametersDescriptor() const
void setupVgosDaFileNames(const QString &fileName)
SgSolutionReporter * reporter_
int inquireCat(const QString &, int, QString &, QString &)
void generateReport(bool isExtended=false)
QMap< QString, SgDbhImage * > dbhImageByKey_
void generateAposterioriFiles()
bool importSession(bool guiExpected)
bool exportDataIntoVgosDb(QString output=QString(""))
bool initSessionFromDbh(bool guiExpected)
void addUserComment(const QString &comment)
bool initSessionFromOdb(bool guiExpected)
void setupDogsDbhFileNames(const QString &fileName)
void generateReport4Tzds()
QMap< QString, QString > dbhNameByKey_
QMap< QString, QString > dbhPathByKey_
SgVlbiSessionInfo::OriginType oType_
void setupCatsDbhFileNames(const QString &fName, const QString &fName2)
int notifyCat(const QString &, bool, QString &)
SgParametersDescriptor * parametersDescriptor_
QString className() const
bool exportDataIntoVgosDa(QString output=QString(""))
bool initSessionFromVda(bool guiExpected)
void changeActiveBand(int idx)
NsSessionHandler(const QString &fileName, const QString &fileNameAux, SgTaskConfig *, SgParametersDescriptor *, SgVlbiSessionInfo::OriginType)
virtual ~NsSessionHandler()
void setupVgosDbFileNames(const QString &fileName)
void generateReport4StcPars()
const QString & catnuGetDbInfo() const
QString path2(const QString &) const
bool getHave2SkipAutomaticProcessing() const
const QString & getPath2ReportOutput() const
const QString & getPath2CatNuInterfaceExec() const
const QString & getPath2MasterFiles() const
const QString & getPath2SpoolFileOutput() const
bool getHave2AutoloadAllBands() const
bool getHave2MaskSessionCode() const
SgIdentities & identities()
bool getHave2KeepSpoolFileReports() const
bool getHave2LoadImmatureSession() const
const QString & getPath2APrioriFiles() const
const QString & getPath2VgosDaFiles() const
bool getHave2UpdateCatalog() const
const QString & getPath2DbhFiles() const
const QString & getPath2VgosDbFiles() const
const QString & getPath2NgsOutput() const
const QString & getPath2NotUsedObsFileOutput() const
const QString & catnuSetDbInfo() const
bool isAttr(uint a) const
int currentVersion() const
void alterCode(const QString &c)
const QString & getAcAbbrevName() const
const QString & getAcAbbName() const
const QString & getUserDefaultInitials() const
const QString & getUserName() const
virtual void write(LogLevel, quint32, const QString &, bool=false)
@ F_SOLVE_SPLFL_LONG
Another version from spoolfile format: 12/01/20 00:02.
@ F_yyyymmdd
Date in digits: 2010 04 02.
@ F_INTERNAL
Digits, date and time: 20100402.71.
QString toString(Format format=F_Verbose) const
static SgMJD currentMJD()
const QString & getKey() const
bool reportTotalZenithDelays(const QString &path)
void report2aposterioriFiles(const QString &path, const QString &fileNameBase)
void report2MyFile(const QString &path, const QString &fileName)
void addUserComment(const QString &coment)
void setPath2APrioriFiles(const QString &path)
void report2spoolFile(const QString &path, const QString &path2obsStatus, const QString &fileName, bool=false)
void reportStochasticEstimations(const QString &path)
void setDoWeightCorrection(bool)
void setActiveBandIdx(int)
void setUseDelayType(VlbiDelayType)
void setOpAction(OutliersProcessingAction)
const QString & getSoftwareName() const
void setPath2RootDir(const QString &path)
bool init(const QString path, const QString fileName)
const QString & getPath2RootDir() const
SgVlbiHistory & history()
const QString & getFirstRecordFromUser() const
const QString & getName() const
const SgMJD & getTStart() const
@ OT_DBH
observations are from database files provided by correlators;
@ OT_AGV
observations are in AGV format;
@ OT_VDB
observations are from vgosDb data tree;
@ OT_UNKNOWN
unknown (=all others) source of import;
@ Attr_PRE_PROCESSED
the observations has been prepared for analysis;
@ Attr_FF_AUTOPROCESSED
automatic data processing performed successfully;
const QString & getOfficialName() const
void setNetworkSuffix(const QString &suffix)
const QString & getNetworkSuffix() const
const QString & getSessionCode() const
void setOriginType(OriginType type)
SgVlbiBand * primaryBand()
bool getDataFromVgosDb(SgVgosDb *vgosDb, bool have2LoadImmatureSession, bool guiExpected)
bool getDataFromDbhImages(QMap< QString, SgDbhImage * > &images, bool have2LoadImmatureSession, bool guiExpected)
void calculateIonoCorrections(const SgTaskConfig *)
void setParametersDescriptor(SgParametersDescriptor *parametersDescriptor)
bool exportDataIntoNgsFile(const QString &fileName)
void process(bool haveProcessAllBands, bool interactWithGui)
static bool guessSessionByWrapperFileName(const QString &inputArg, const QString &path2VgosDb, QString &path2wrapperFile, QString &wrapperFileName, QString &sessionName, int &version)
bool putDataIntoAgvFile(const QString &dirName, const QString &fileName, SgIdentities *ids, SgVersion *driverVersion)
bool putDataIntoDbhImage(SgDbhImage *image)
bool getDataFromAgvFile(const QString &fileName, SgIdentities *ids, SgVersion *driverVersion)
static bool guessWrapperFileNameBySession(const QString &inputArg, const QString &path2VgosDb, const QString &acAbbName, QString &path2wrapperFile, QString &wrapperFileName, QString &sessionName, int &version, bool noYears=false)
void zerofyIonoCorrections(const SgTaskConfig *)
void setPath2Masterfile(const QString &)
void setPath2APrioriFiles(const QString &)
bool putDataIntoVgosDb(SgVgosDb *vgosDb)
void setConfig(SgTaskConfig *cfg)
SgVersion * driverVersion
SgParametersDescriptor parametersDescriptor