30 #include <QtCore/QDataStream>
31 #include <QtCore/QDir>
32 #include <QtCore/QFile>
33 #include <QtCore/QRegularExpression>
66 : fileName_(fileName),
67 fileNameAux_(fileNameAux),
73 vdbWrapperFileName_(
""),
100 vdbWrapperFileName_(
"")
209 "::importSession(): cannot find anything associated with the name \"" +
fileName_ +
210 "\". Please, check and do it again.");
235 "::performPia(): the automatic analysis is disabled by the command line argument");
312 QString fileName(fName);
313 QString fileName2(fName2);
319 QString currentVersion;
326 if (fileName.at(0) ==
'$')
327 fileName = fileName.mid(1);
328 l = fileName.length();
329 if (fileName2.size()>0 && fileName2.at(0) ==
'$')
330 fileName2 = fileName2.mid(1);
336 while (
inquireCat(fileName, ++v, str1, str2) != 0 && v<70)
342 "::setupCatsDbhFileNames(): the file " + fileName +
" does not exist in the catalog");
346 while (
inquireCat(fileName, ++v, str1, str2) == 0)
352 "::setupCatsDbhFileNames(): the file " + fileName +
" does not exist in the catalog");
355 fileName += QString(
"").sprintf(
"_V%03d", v);
358 else if (!(fileName.mid(l-5, 2) ==
"_V"))
361 "::setupCatsDbhFileNames(): the file " + fileName +
" is not a standard database name, "
362 "expecting: YYMMMDDBC_Vxxx");
366 baseName = fileName.mid(l-14, 7);
367 currentBand = fileName.mid(l-7, 1);
368 baseNetID = fileName.mid(l-6, 1);
369 currentVersion = fileName.mid(l-4, 4);
370 version = currentVersion.mid(1).toInt(&isOk);
374 "::setupCatsDbhFileNames(): cannot determine proper DBH version for the file " + fileName);
379 if (
inquireCat(baseName + currentBand + baseNetID, version, str1, str2) != 0)
382 "::setupCatsDbhFileNames(): got an error on the request to " +
387 l = str2.lastIndexOf(
"/");
395 l = fileName2.size();
403 while (
inquireCat(fileName2, ++v, str1, str2) != 0 && v<70)
409 "::setupCatsDbhFileNames(): cannot find the second file " + fileName2 +
" in the catalog");
413 while (
inquireCat(fileName2, ++v, str1, str2) == 0)
419 "::setupCatsDbhFileNames(): cannot find the second file " + fileName2 +
" in the catalog");
422 fileName2 += QString(
"").sprintf(
"_V%03d", v);
426 v = fileName2.mid(l-3, 3).toInt(&isOk);
430 isOk =
inquireCat(fileName2, v, str1, str2) == 0;
433 aBand = fileName2.mid(l-7, 1);
434 l = str2.lastIndexOf(
"/");
439 "::setupCatsDbhFileNames(): the second database file " + fileName2 +
440 " has been found in the catalog, band=[" + currentBand +
"], version=" +
441 QString(
"").setNum(v));
449 if (currentBand ==
"X")
453 isOk =
inquireCat(baseName + key + baseNetID, v--, str1, str2) == 0;
458 while (v<31 && !isOk)
459 isOk =
inquireCat(baseName + key + baseNetID, v++, str1, str2) == 0;
463 l = str2.lastIndexOf(
"/");
469 "::setupCatsDbhFileNames(): cannot find an opposite band, " + key +
", : " + str1);
474 if (
inquireCat(baseName + (currentBand==
"S"?
"X":currentBand) + baseNetID, version+1, str1, str2) == 0)
480 "::setupCatsDbhFileNames(): a database with the next version already exists in the catalog");
494 QString currentVersion;
496 int l = fileName.length();
499 if (fileName.mid(l-5, 2) ==
"_V")
502 currentBand = fileName.mid(l-7, 1);
503 baseNetID = fileName.mid(l-6, 1);
504 currentVersion = fileName.mid(l-4, 4);
506 l = fileName.lastIndexOf(
"/");
508 if (fileName.at(0) ==
'/')
511 str = fileName.mid(l+1);
516 str = fileName.mid(l+1);
519 baseName = str.left(7);
521 QStringList nameFilters;
523 nameFilters << baseName +
"?" + baseNetID +
"*";
525 nameFilters << baseName + currentBand + baseNetID +
"*";
526 QStringList nameList = dir.entryList(nameFilters,
527 QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase);
528 if (!nameList.size())
532 for (
int i=0; i<nameList.size(); i++)
534 l = nameList.at(i).length();
537 key = nameList.at(i).mid(l-7, 1);
544 else if (nameList.at(i).mid(l-4, 4) <= currentVersion)
560 QString sessionName(
"");
569 QRegularExpression reWrapperFileName(
".*\\.(wrp|wrap)$",
570 QRegularExpression::CaseInsensitiveOption);
571 QRegularExpression reOldDbName(
"^(\\d{2}[A-Z]{3}\\d{2}[A-Z0-9]{1,2}).*");
572 QRegularExpression reNewDbName(
"^(\\d{8})-([\\S]{2,12}).*");
574 QRegularExpression rePath2DatabaseV1(
"(.*)/(\\d{2}[A-Z]{3}\\d{2}[A-Z0-9]{1,2})/?$");
575 QRegularExpression rePath2DatabaseV2(
"(.*)/(\\d{8}-[\\S]{2,12})/?$");
579 if (reWrapperFileName.match(inpt).hasMatch())
583 sessionName, version);
586 "::setupVgosDbFileNames(): got a session " + sessionName +
" of version " +
587 QString(
"").setNum(version) +
" from \"" +
path2VdbFiles_ +
"\":\"" +
591 "::setupVgosDbFileNames(): cannot figure out a session from the input \"" + inpt +
"\"");
594 else if ( reOldDbName.match(inpt).hasMatch() ||
595 reNewDbName.match(inpt).hasMatch() )
603 "\" from \"" +
path2VdbFiles_ +
"\" for the session " + sessionName +
604 " of version " + QString(
"").setNum(version));
607 "::setupVgosDbFileNames(): cannot figure out a wrapper file from the input \"" + inpt +
"\"");
609 else if (rePath2DatabaseV1.match(inpt).hasMatch() ||
610 rePath2DatabaseV2.match(inpt).hasMatch() )
616 QRegularExpressionMatch match=rePath2DatabaseV1.match(inpt);
617 if (!match.hasMatch())
618 match=rePath2DatabaseV2.match(inpt);
619 QString sDir(match.captured(2));
620 QString sPath(match.captured(1));
627 "\" from \"" +
path2VdbFiles_ +
"\" for the session " + sessionName +
628 " of version " + QString(
"").setNum(version));
631 "::setupVgosDbFileNames(): cannot figure out a wrapper file from the directory \"" +
636 "::setupVgosDbFileNames(): the directory \"" + inpt +
"\" does not exist");
641 "::setupVgosDbFileNames(): cannot guess input data from \"" + inpt +
"\"");
655 file.setFileName(str);
664 file.setFileName(str);
679 for (QMap<QString, QString>::const_iterator i=
dbhNameByKey_.constBegin();
684 dbhFile.setFileName(path + i.value());
686 "::initSessionFromDbh(): reading file " + i.value() +
" in the directory \"" +
689 dbhFile.open(QIODevice::ReadOnly);
690 dbhStream.setDevice(&dbhFile);
691 dbhStream >> *dbhImage;
692 dbhStream.setDevice(NULL);
699 "::initSessionFromDbh(): absorbing data from the set of DBH images",
true);
715 (isOk?
" complete":
" failed"));
746 ") has been imported from " +
fileName_);
750 "::initSessionFromVda(): reading data from vgosDa file \"" +
fileName_ +
"\" failed");
763 ": exportDataIntoDbh(): saving data in DBH format has been canceled");
768 "::exportDataIntoDbh(): saving data in DBH format");
774 "::exportDataIntoDbh(): the session pointer is NULL");
783 "::exportDataIntoDbh(): the primary band pointer is NULL");
791 "::exportDataIntoDbh(): the dbhImage pointer is NULL");
796 bool isNewChain(
false);
798 QString sessionFileName, dbhFileName;
811 if (QFile::exists(dbhFileName))
813 if (have2NotifyCatalog)
817 "::exportDataIntoDbh(): the file " + dbhFileName +
" is already exist; remove it and try again");
822 dbhFileName += suffix;
824 "::exportDataIntoDbh(): the new version file is already exist; the name is altered to " +
825 sessionFileName + suffix);
831 if (have2NotifyCatalog)
838 "::exportDataIntoDbh(): the new version already exists in the catalog, remove it from the "
839 "catalog and try again");
846 QFile dbhFile(dbhFileName);
847 dbhFile.open(QIODevice::WriteOnly);
848 dbhStream.setDevice(&dbhFile);
849 dbhStream << *dbhImage;
850 dbhStream.setDevice(NULL);
853 "::exportDataIntoDbh(): the " + primaryBand->
getKey() +
"-band of the session " +
856 if (have2NotifyCatalog)
859 if (
notifyCat(dbhFileName, isNewChain, str1) != 0)
863 "::exportDataIntoDbh(): updating the catalog has failed; error: " + str1);
868 "::exportDataIntoDbh(): the catalog has been updated successfuly");
884 ": exportDataIntoVgosDb(): exporting of data into vgosDb tree has been canceled");
901 QString dir2Save(
"");
907 "::exportDataIntoVgosDb(): gpt a user specified path: \"" + dir2Save +
"\"");
915 "::exportDataIntoVgosDb(): vgosDb object has been created");
919 "::exportDataIntoVgosDb(): the vgosDb object has been prepared to save the new session in "
923 if (dir.exists(dir2Save))
928 "::exportDataIntoVgosDb(): the output path has been adjusted to \"" + dir2Save +
"\"");
929 if (dir.exists(dir2Save))
936 "::exportDataIntoVgosDb(): the output path has been readjusted to \"" + dir2Save +
"\"");
945 "::exportDataIntoVgosDb(): export of data into vgosDb tree has been " + (isOk?
"complete":
"failed"));
950 "::exportDataIntoVgosDb(): vgosDb object has been destroyed.");
954 "::exportDataIntoVgosDb(): exporting of data into vgosDb tree has been" +
955 (isOk?
" complete":
" failed"));
964 QString& str1, QString& str2)
970 QString tmpFileName(
"/tmp/nuSolve-Catalog.");
975 databaseName +
" " + QString(
"").setNum(version) +
" " + tmpFileName;
976 rc = system(qPrintable(execStr));
979 complain =
"An error occured executing the system call [" + execStr +
"]; RC is " +
980 QString(
"").setNum(rc);
982 "::inquireCat(): " + complain,
true);
985 f.setFileName(tmpFileName);
986 f.open(QIODevice::ReadOnly);
989 if (str1 !=
"0 success")
997 if (str2.length() < 14)
999 "::inquireCat(): the length of the received string, " + str2 +
1000 ", is less than a properly formed database name");
1016 QString tmpFileName(
"/tmp/nuSolve-Catalog.");
1018 QString descriptionOfKey(
"1234"), descriptionOfEntry(
"");
1042 f.setFileName(tmpFileName);
1043 if (f.open(QIODevice::WriteOnly))
1046 s << descriptionOfKey .left(36) << endl;
1047 s << descriptionOfEntry.left(80) << endl;
1054 "::notifyCat(): cannot open for writting the communication file");
1060 fileName +
" " + (isNew?
"create":
"update") +
" " + tmpFileName;
1063 rc = system(qPrintable(execStr));
1066 complain =
"An error occured executing the system call [" + execStr +
"]; RC is " +
1067 QString(
"").setNum(rc);
1069 "::notifyCat(): " + complain,
true);
1073 f.setFileName(tmpFileName);
1074 if (f.open(QIODevice::ReadOnly))
1077 str1 = s.readLine();
1081 if (str1 !=
"0 success")
1088 "::notifyCat(): cannot open for reading the communication file");
1102 QDir d(splflDirName);
1104 isOk = d.mkpath(
"./");
1108 "::generateReport(): cannot create directory \"" + splflDirName +
"\"; report failed");
1111 d.setPath(obsStatDirName);
1113 isOk = d.mkpath(
"./");
1117 "::generateReport(): cannot create directory \"" + obsStatDirName +
"\"; saving report failed");
1126 "::generateReport(): spoolfile output has been saved in the " + fileName +
" file");
1132 d.setPath(rptrDirName);
1134 isOk = d.mkpath(
"./");
1138 "::generateReport(): cannot create directory " + rptrDirName +
"; saving report failed");
1143 if (QFile::exists(rptrDirName +
"/" + str) && !QFile(rptrDirName +
"/" + str).remove())
1146 "::generateReport(): cannot remove the file " + rptrDirName +
"/" + str +
1147 "; saving report failed");
1150 if (QFile::copy(splflDirName +
"/" + fileName, rptrDirName +
"/" + str))
1152 "::generateReport(): spoolfile output has been copied as " + rptrDirName +
"/" + str +
1156 "::generateReport(): copying of " + splflDirName +
"/" + fileName +
" as " + rptrDirName +
1157 "/" + str +
" filed");
1170 QDir d(splflDirName);
1172 isOk = d.mkpath(
"./");
1176 "::generateMyReport(): cannot create directory \"" + splflDirName +
"\"; report failed");
1179 d.setPath(obsStatDirName);
1181 isOk = d.mkpath(
"./");
1185 "::generateMyReport(): cannot create directory \"" + obsStatDirName +
"\"; saving report failed");
1194 "::generateMyReport(): report has been saved in the " + fileName +
" file");
1206 if (dbName.at(0) ==
'$')
1207 dbName.remove(0, 1);
1209 outputDirName +=
"/" + dbName;
1212 "::generateReport4StcPars(): stochastic parameter estimaitons were saved in \"" + outputDirName +
1224 if (dbName.at(0) ==
'$')
1225 dbName.remove(0, 1);
1226 outputDirName +=
"/" + dbName;
1230 "::generateReport4Tzds(): total zenith delays were saved in \"" + outputDirName +
1234 "::generateReport4Tzds(): saving total zenith delays in \"" + outputDirName +
1235 "\" direcory has been failed");
1247 QDir d(splflDirName);
1249 isOk = d.mkpath(
"./");
1253 "::generateAposterioriFiles(): cannot create directory " + splflDirName +
"; report failed");
1259 if (fileName.at(0) ==
'$')
1260 fileName.remove(0, 1);
1263 "::generateAposterioriFiles(): a posteriori files were saved with \"" + fileName +
"\" basename");
1275 ": exportDataToNgs(): exporting of data into NGS card format has been canceled");
1284 isOk = d.mkpath(
"./");
1289 "::exportDataToNgs(): the session has been exported as NGS file in the directory " + dirName);
1293 "::exportDataToNgs(): cannot create directory " + dirName +
"; NGS export failed");
1304 ": exportDataIntoVgosDa(): saving data in vgosDa format has been canceled");
1308 QString dir2Save(
"");
1309 QString file2Save(
"");
1314 dir.setPath(output);
1323 if (-1 < (idx=output.lastIndexOf(
'/')))
1325 dir2Save = output.left(idx);
1326 file2Save = output.mid(idx + 1);
1338 dir.setPath(dir2Save);
1340 isOk = dir.mkpath(
"./");
1345 "::exportDataIntoVgosDa(): the session has been saved as an vgosDa file in the directory \"" +
1349 "::exportDataIntoVgosDa(): export data in a vgosDa file failed; directory to store: \"" +
1350 dir2Save +
"\", file to store: \"" + file2Save +
"\"");
1354 "::exportDataIntoVgosDa(): cannot create directory " + dir2Save +
1355 "; storing data in vgosDa format has failed");
SgVersion nuSolveVersion("nuSolve", 0, 8, 2, "Dark Hollow Falls (rc2)", SgMJD(2023, 4, 3, 10, 59))
SgVersion libraryVersion("SgLib", 0, 8, 2, "Compton Peak (rc2)", SgMJD(2023, 4, 3, 10, 59))
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