General Purpose Geodetic Library
vgosDbMake.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of vgosDbMake. vgosDbMake is a part of CALC/SOLVE
4  * system and is designed to convert correlator output data into VgosDb format.
5  * Copyright (C) 2015-2020 Sergei Bolotin.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 
23 #include <argp.h>
24 #include <signal.h>
25 #include <unistd.h>
26 
27 
28 
29 #include <QtCore/QCoreApplication>
30 #include <QtCore/QDir>
31 #include <QtCore/QFileInfo>
32 #include <QtCore/QList>
33 #include <QtCore/QSettings>
34 #include <QtCore/QString>
35 #include <QtCore/QStringList>
36 
37 
38 #if QT_VERSION >= 0x050000
39 # include <QtWidgets/QApplication>
40 #else
41 # include <QtGui/QApplication>
42 #endif
43 
44 
45 #include <SgIdentities.h>
46 #include <SgKombFormat.h>
47 #include <SgLogger.h>
48 #include <SgVgosDb.h>
49 #include <SgVlbiSession.h>
50 
51 
52 
53 #include "vgosDbMake.h"
54 #include "VmStartupWizard.h"
55 
56 
57 
58 void loadSettings(QSettings&);
59 void saveSettings(QSettings&, bool shouldInvokeSystemWideWizard);
60 
61 
62 
64 
65 const QString origOrgName("NASA GSFC");
66 const QString origDmnName("gsfc.nasa.gov");
67 const QString origAppName("vgosDbMake");
68 
69 // HOPS's whims:
70 char progname[80];
71 int msglev = 2;
72 
73 
74 // for ARGP parser:
75 const char *argp_program_bug_address = "Sergei Bolotin <sergei.bolotin@nasa.gov>";
76 
78 {
79  QSettings *settings;
80  QString altSetupName;
81  QString altSetupAppName;
82  QString inputArg;
83  QString mapFileName;
84  QString altOutputDir;
85  QString altDatabaseName;
93  bool isDryRun;
97 };
98 
99 
100 //
101 // a parser for ARGP:
102 static int parse_opt(int key, char *arg, struct argp_state *state)
103 {
104  int n;
105  bool is;
106  QString str("");
107  struct vdbmOptions *options=(struct vdbmOptions*)state->input;
108  //
109  switch (key)
110  {
111  case 'a':
112  options->altSetupName = QString(arg);
113  if (!options->altSetupName.contains("/..")) // are there any other elements of path that we should avoid?
114  {
115  options->altSetupAppName = origAppName + "-" + options->altSetupName;
116  options->have2UseAltSetup = true;
117  }
118  else
119  {
121  ": parse_opt(): it is dangerous to use a string \"" + options->altSetupName +
122  "\" as an alternative config name");
124  ": parse_opt(): you can overwrite another file (un)intentionally");
125  delete options->settings;
126  exit(22);
127  };
128  break;
129  case 'd':
130  options->altDatabaseName = QString(arg);
131  break;
132  case 'e':
133  options->fringeErrorCodes2Skip << QString(arg).toUpper();
134  break;
135  case 'l':
136  options->useStdLocale = true;
137  break;
138  case 'm':
139  options->mapFileName = QString(arg);
140  break;
141  case 'O':
142  options->have2SaveAltOutputDir = true;
143  options->altOutputDir = QString(arg);
144  break;
145  case 'o':
146  options->altOutputDir = QString(arg);
147  break;
148  case 'p':
149  loadSettings(*options->settings);
151  exit(0);
152  break;
153  case 'q':
154  options->isDryRun = true;
155  break;
156  case 'r':
157  options->altCorrelatorName = QString(arg);
158  break;
159  case 's':
160  n = QString(arg).toInt(&is);
161  if (is)
162  options->altExpSerialNumber = n;
163  else
164  {
166  ": parse_opt(): cannot convert \"" + arg + "\" to int");
167  options->altExpSerialNumber = 0;
168  };
169  break;
170  case 't':
171  options->correlatorReportFileName = QString(arg);
172  break;
173  case 'x':
174  options->need2correctRefClocks = true;
175  break;
176 
177  //
178  case 'W':
179  options->shouldInvokeSystemWideWizard = true;
180  break;
181  case 'w':
182  options->have2ForceWizard = true;
183  break;
184  //
185  case 'V':
186  std::cout << qPrintable(vgosDbMakeVersion.name(SgVersion::NF_Petrov)) << "\n";
187  exit(0);
188  break;
189  //
190  case ARGP_KEY_ARG:
191  if (1 < state->arg_num)
192  {
193  argp_usage(state);
194  };
195  options->inputArg = QString(arg);
196  break;
197  case ARGP_KEY_END:
198  if (state->arg_num < 1 &&
199  !(options->have2ForceWizard || options->shouldInvokeSystemWideWizard))
200  argp_usage(state);
201  break;
202  default:
203  return ARGP_ERR_UNKNOWN;
204  break;
205  };
206  return 0;
207 };
208 //
209 
210 
211 
212 
213 
214 //
215 QCoreApplication* createApplication(int &argc, char *argv[], bool isGuiEnabled)
216 {
217  if (isGuiEnabled)
218  return new QApplication(argc, argv);
219  else
220  return new QCoreApplication(argc, argv);
221 };
222 
223 
224 
225 
226 
227 SgVlbiSessionInfo::OriginType determineInputType(const QString& path2data);
228 
229 
230 /***===================================================================================================*/
236 int main(int argc, char** argv)
237 {
238  struct vdbmOptions options;
240  QString userCommand("");
241  SgLogger *alHistory;
242  SgLogger *alDriver;
243 
244 #ifdef SWCONFIG
245  const QString path2SystemWideConfig(SWCONFIG "/xdg");
246 #else
247  const QString path2SystemWideConfig("");
248 #endif
249  int rc;
250  bool isGuiEnabled;
251  bool isFirstRun;
252  const char* envDisplay=NULL;
253 
254  rc = 0;
255  options.settings = NULL;
256  options.altSetupAppName = QString("");
257  options.altSetupName = QString("");
258  options.inputArg = QString("");
259  options.mapFileName = QString("");
260  options.altOutputDir = QString("");
261  options.altDatabaseName = QString("");
262  options.altCorrelatorName = QString("");
263  options.correlatorReportFileName = QString("");
264  options.fringeErrorCodes2Skip.clear();
265  options.altExpSerialNumber = 0;
266  options.have2UseAltSetup = false;
267  options.have2ForceWizard = false;
268  options.shouldInvokeSystemWideWizard = false;
269  options.isDryRun = false;
270  options.useStdLocale = false;
271  options.need2correctRefClocks = false;
272  options.have2SaveAltOutputDir = false;
273 
274 
275  //
276  // init:
277  QCoreApplication::setOrganizationName(origOrgName);
278  QCoreApplication::setOrganizationDomain(origDmnName);
279  QCoreApplication::setApplicationName(origAppName);
280  //
281  // set up path to the system wide settings:
282  QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, path2SystemWideConfig);
283  //
284  options.settings = new QSettings;
285  //
286  isGuiEnabled = (envDisplay=getenv("DISPLAY"))!=NULL && strlen(envDisplay)>0;
287  //
288  QScopedPointer<QCoreApplication>
289  app(createApplication(argc, argv, isGuiEnabled));
290  if (qobject_cast<QApplication *>(app.data()))
291  {
292  // do something with GUI
293  }
294  else
295  {
296  // do something for non-GUI
297  };
298 
299  //
300  // especially for HOPS:
301  strcpy(progname, qPrintable("HOPS (on behalf of " + vgosDbMakeVersion.getSoftwareName() + ")"));
302  //
303  setup.setUpBinaryIdentities(QString(argv[0]));
304  for (int i=0; i<argc; i++)
305  userCommand += QString(argv[i]) + " ";
306  userCommand.chop(1);
307 
308 
309  //
310  // ARGP setup:
311  //
312  struct argp_option argp_options[] =
313  {
314  {0, 0, 0, 0, "General options:", 10},
315  {"std-locale", 'l', 0, 0,
316  "Use the standard locale"},
317  {"output-dir", 'o', "STRING", 0,
318  "Use an alternative path STRING to save files in vgosDb format"},
319 
320  {0, 0, 0, 0, "Configuration control:", 11},
321  {"alt", 'a', "STRING", 0,
322  "Use an alternative configuration STRING"},
323 
324  {0, 0, 0, 0, "Database edit options:", 12},
325  {"database", 'd', "STRING", 0,
326  "Set database name to STRING"},
327  {"correlator", 'r', "STRING", 0,
328  "Set correlator name to STRING"},
329  {"exp-sn", 's', "NUM", 0,
330  "Set experiment serial number to NUM"},
331 
332  {0, 0, 0, 0, "Data extraction control:", 13},
333  {"exclude", 'e', "CHAR", 0,
334  "exclude observations with fringe error code CHAR. If CHAR is \"*\" only observations that have "
335  "no fringe error code will be extracted. There can be more than one \"-e\" option, "
336  "e.g.: -eA -eB."},
337  {"map", 'm', "STRING", 0,
338  "Set a name map file to STRING"},
339  {"report", 't', "STRING", 0,
340  "Set a correlator report file to STRING"},
341  {"adjust-ref-stn", 'x', 0, 0,
342  "KOMB files input only: adjust delays and rates for a reference station clock offset "
343  "(experimental mode)"},
344 
345  {0, 0, 0, 0, "Invocation of startup wizard:", 25},
346  {"sys-wide-wizard", 'W', 0, 0,
347  "Run startup wizard for the system-wide settings"},
348  {"wizard", 'w', 0, 0,
349  "Force call of the startup wizard"},
350 
351  {0, 0, 0, 0, "Operation modes:", -1},
352  {"print-setup", 'p', 0, 0,
353  "Print set up and exit"},
354  {"dry-mode", 'q', 0, 0,
355  "Process in a \"dry run\" mode: files will not be created, instead names of the files "
356  "will be printed"},
357  {"version", 'V', 0, 0,
358  "Print program version"},
359  //
360  {0}
361  };
362  QString salute("vgosDbMake is a program that extracts data from fringe or "
363  "KOMB files and stores obtained info in vgosDb database. The mandatory argument INPUT_DIR is a "
364  "name of a directory where the software searches the correlator files.\v");
365 
366  salute += "The current version is:\n\t" + vgosDbMakeVersion.name() + " released on " +
368  "\n\t" + libraryVersion.name() + " released on " +
370  salute +=
371  QString("\n\nThe utility vgosDbMake is a part of nuSolve package. See the datails in "
372  "\"vgosDbMake User Guide\", a part of nuSolve distribution. You can get the latest version of "
373  "nuSolve at\n\t\thttps://sourceforge.net/projects/nusolve");
374 
375  struct argp argp={argp_options, parse_opt, "INPUT_DIR", salute.toLatin1()};
376 
377  argp_parse (&argp, argc, argv, 0, 0, &options);
378 
379  isFirstRun = options.settings->allKeys().size()>0 ? false : true;
380  //
381  //
382  if (options.have2UseAltSetup)
383  {
385  ": using alternative config name \"" + options.altSetupName + "\"");
386  QSettings *altSettings=new QSettings(origOrgName, options.altSetupAppName);
387  loadSettings(*altSettings);
388  delete options.settings;
389  options.settings = altSettings;
390  }
391  else
392  loadSettings(*options.settings);
393  //
394  //
395  //
396  if (isGuiEnabled)
397  {
398  if (options.have2ForceWizard || options.shouldInvokeSystemWideWizard ||
399  options.settings->value("Version/StartUpWizard", 0).toInt() < VmStartupWizard::serialNumber())
400  {
401  if (options.shouldInvokeSystemWideWizard)
402  {
403  if (!options.have2UseAltSetup)
404  {
405  QSettings *swSettings =
406  new QSettings(QSettings::SystemScope, origOrgName, origAppName);
407  if (!swSettings->isWritable())
408  {
410  ": Cannot write system wide config");
411  delete swSettings;
412  return 2;
413  };
414  delete options.settings;
415  options.settings = swSettings;
416  }
417  else
419  ": Using an alternative config name, system wide config edit request ignored");
420  };
421  //
422  VmStartupWizard startup(isFirstRun, options.have2ForceWizard,
423  options.shouldInvokeSystemWideWizard, options.settings);
424  if ((rc=startup.exec())==0)
425  {
426  delete options.settings;
427  logger->clearSpool();
428  return rc;
429  };
430  //
431  // save if user pressed "Finish":
432  options.settings->setValue("Version/StartUpWizard", startup.serialNumber());
434  //
435  // it is ok, exitting:
436  if (!options.inputArg.size())
437  {
438  delete options.settings;
439  logger->clearSpool();
440  return 0;
441  };
442  };
443  }
444  else if (options.have2ForceWizard || options.shouldInvokeSystemWideWizard)
445  {
447  ": cannot run graphical application.");
448  delete options.settings;
449  logger->clearSpool();
450  return 1;
451  };
452 
453  // alternate output directory:
454  if (options.altOutputDir.size())
455  {
458  ": using the directory \"" + setup.getPath2VgosDbFiles() + "\" for output");
459  if (options.have2SaveAltOutputDir)
460  {
461  options.settings->setValue("Setup/Path2VgosDbFiles",
464  ": the default output direcory was changed to \"" + setup.getPath2VgosDbFiles() + "\"");
465  };
466  };
467  //
468  //===================== begin here: =====================
469  //
470  // if input is not an absolute directory:
471  if (options.inputArg.at(0) != QChar('/'))
472  options.inputArg = setup.path2(setup.getPath2InputFiles()) + "/" + options.inputArg;
473 
474  QFileInfo fInfo(options.inputArg);
475  if (!fInfo.exists())
476  {
478  ": the provided input direcory, " + options.inputArg + ", does not exist");
479  logger->clearSpool();
480  return 1;
481  };
482  if (!fInfo.isDir())
483  {
485  ": the provided input is a file, not a directory.");
486  logger->clearSpool();
487  return 1;
488  };
489  if (!fInfo.isReadable())
490  {
492  ": the provided input direcory is unreadable.");
493  logger->clearSpool();
494  return 1;
495  };
496  //
497  //
498  //
499  alDriver = new SgLogger(800, setup.getHave2SavePerSessionLog(), "drv-unnamed.log");
501  alDriver->setIsNeedTimeMark(true);
502  alDriver->setIsMute(true);
503  alDriver->setLogFacility(SgLogger::ERR, 0xFFFFFFFF);
504  alDriver->setLogFacility(SgLogger::WRN, 0xFFFFFFFF);
505  alDriver->setLogFacility(SgLogger::INF, 0xFFFFFFFF);
506  alDriver->setLogFacility(SgLogger::DBG, 0);
508  logger->attachSupplementLog("Driver", alDriver);
509  //
510  alHistory = new SgLogger(0, false, "");
511  alHistory->setIsNeedTimeMark(false);
512  alHistory->setIsMute(true);
513  alHistory->setLogFacility(SgLogger::ERR, 0xFFFFFFFF);
514  alHistory->setLogFacility(SgLogger::WRN, 0xFFFFFFFF);
515  alHistory->setLogFacility(SgLogger::INF, 0xFFFFFFFF);
516  alHistory->setLogFacility(SgLogger::DBG, 0);
517  //
518  bool isOk(false);
519  SgVgosDb *vgosDb;
520  SgVlbiSession session;
521  //
523  ": starting");
525  //
526  //
527  inputType = determineInputType(options.inputArg);
528  if (inputType == SgVlbiSessionInfo::OT_UNKNOWN)
529  {
531  ": directory \"" + options.inputArg + "\": unable to determine the type of input files");
532  logger->clearSpool();
533  return 1;
534  }
535  else if (inputType!=SgVlbiSessionInfo::OT_MK4 && inputType!=SgVlbiSessionInfo::OT_KOMB)
536  {
538  ": directory \"" + options.inputArg + "\": unsupported type of input files");
539  logger->clearSpool();
540  return 1;
541  };
542  //
543  // adjust correlator input file name (if it is not an absolute path):
544  if (options.correlatorReportFileName.size() && options.correlatorReportFileName.at(0) != QChar('/'))
546  options.correlatorReportFileName;
547  //
548  //------------------------------------------------------------------------------------------
549  logger->attachSupplementLog("History", alHistory);
551  ": Library ID: " + libraryVersion.name() + " released on " +
554  ": Driver ID: " + vgosDbMakeVersion.name() + " released on " +
556 
558  ": Host ID: " + setup.identities().getMachineNodeName() +
559  " (Hw: " + setup.identities().getMachineMachineName() +
560  "; Sw: " + setup.identities().getMachineRelease() +
561  " version of " + setup.identities().getMachineSysName() + ")");
562 
564  ": User ID: " + setup.identities().getUserName() +
567  ": User command: \"" + userCommand + "\"");
569  ": Input data : \"" + options.inputArg + "\"");
570  //
571  if (options.altExpSerialNumber)
572  {
575  ": session serial number was mannualy set to " +
576  QString("").sprintf("%d", session.getExperimentSerialNumber()));
577  };
578 
579  QString sLang(""), sLcAll("");
580  if (!setup.getUseLocalLocale() || options.useStdLocale)
581  {
582  if (getenv("LANG"))
583  sLang = QString(getenv("LANG"));
584  setenv("LANG", "C", 1);
585  if (getenv("LC_ALL"))
586  sLcAll = QString(getenv("LC_ALL"));
587  setenv("LC_ALL", "C", 1);
589  ": the env.variable LANG was set to \"C\"");
591  ": the env.variable LC_ALL was set to \"C\"");
592  };
593 
594  SgMJD startEpoch=SgMJD::currentMJD();
595  if ((isOk=inputType==SgVlbiSessionInfo::OT_MK4?
596  session.getDataFromFringeFiles(options.inputArg, options.altDatabaseName,
597  options.altCorrelatorName, options.correlatorReportFileName, options.mapFileName,
598  options.fringeErrorCodes2Skip) :
599  session.getDataFromKombFiles(options.inputArg, options.altDatabaseName,
600  options.altCorrelatorName, options.correlatorReportFileName, options.mapFileName,
601  options.need2correctRefClocks)))
602  {
603  alDriver->setFileName(session.getName() + ".log");
604  alDriver->rmLogFile();
605 
607  ": the session " + session.getSessionCode() + " (" + session.getName() +
608  ") has been imported from fringes files");
609  vgosDb = new SgVgosDb(&setup.identities(), &vgosDbMakeVersion);
611  ": vgosDb object has been created");
612 
613  vgosDb->init(&session);
615  ": the vgosDb object has been prepared to save the new session in vgosDb format");
616 
618  QString("").sprintf("%04d", session.getTStart().calcYear()) + "/" + session.getName());
620  ": the path was set to " + vgosDb->getPath2RootDir());
621 
623  ": ______________________________________________________________________");
624  if (options.isDryRun)
626  isOk = session.putDataIntoVgosDb(vgosDb);
628  ": export of data into vgosDb tree has been " + (isOk?"complete":"failed"));
630  ": ______________________________________________________________________");
631 
632  SgMJD finisEpoch=SgMJD::currentMJD();
634  ": the elapsed time to process " + QString("").setNum(session.observations().size()) +
635  " observations is: " + interval2Str(finisEpoch - startEpoch) +
636  " (" + QString("").sprintf("%.2f", (finisEpoch - startEpoch)*86400.0) + " sec)", true);
637 
638  delete vgosDb;
640  ": vgosDb object has been destroyed.");
641  }
642  else
644  ": import data from \"" + options.inputArg + "\" failed");
645 
646  if (!setup.getUseLocalLocale() || options.useStdLocale)
647  {
648  setenv("LANG", qPrintable(sLang), 1);
649  setenv("LC_ALL", qPrintable(sLcAll), 1);
651  ": the env.variable LANG was set to \"" + sLang + "\"");
653  ": the env.variable LC_ALL was set to \"" + sLcAll + "\"");
654  };
655 
656 
657  alDriver->clearSpool();
658  logger->detachSupplementLog("Driver");
659  logger->detachSupplementLog("History");
660  delete alHistory;
661  delete alDriver;
662  delete options.settings;
663  logger->clearSpool();
664  return rc;
665 };
666 
667 
668 
669 //
670 void loadSettings(QSettings& settings)
671 {
672  int logLevel;
673  //
674  // setup.identities:
676  settings.value("Identities/UserName",
677  setup.identities().getUserName()).toString());
679  settings.value("Identities/UserEmailAddress",
680  setup.identities().getUserEmailAddress()).toString());
682  settings.value("Identities/UserDefaultInitials",
683  setup.identities().getUserDefaultInitials()).toString());
685  settings.value("Identities/AcFullName",
686  setup.identities().getAcFullName()).toString());
688  settings.value("Identities/AcAbbreviatedName",
689  setup.identities().getAcAbbrevName()).toString());
691  settings.value("Identities/AcShortAbbreviatedName",
692  setup.identities().getAcAbbName()).toString());
693 
694  // setup:
695  // Pathes:
697  settings.value("Setup/Path2Home",
698  setup.getPath2Home()).toString());
700  settings.value("Setup/Path2InputFiles",
701  setup.getPath2InputFiles()).toString());
703  settings.value("Setup/Path2VgosDbFiles",
704  setup.getPath2VgosDbFiles()).toString());
706  settings.value("Setup/Path2MasterFiles",
707  setup.getPath2MasterFiles()).toString());
709  settings.value("Setup/Path2AuxLogs",
710  setup.getPath2AuxLogs()).toString());
712  settings.value("Setup/Have2SavePerSessionLog",
713  setup.getHave2SavePerSessionLog()).toBool());
715  settings.value("Setup/UseLocalLocale",
716  setup.getUseLocalLocale()).toBool());
717  //
718  // adjust the logger:
720  settings.value("Logger/FileName",
721  "vgosDbMake.log").toString());
724  settings.value("Logger/Capacity", 400).toInt());
726  settings.value("Logger/IsStoreInFile", logger->getIsStoreInFile()).toBool());
728  settings.value("Logger/IsNeedTimeMark", logger->getIsNeedTimeMark()).toBool());
729  logLevel = settings.value("Logger/LogLevel", 2).toInt();
730  logger->setLogFacility(SgLogger::ERR, logLevel>=0?0xFFFFFFFF:0);
731  logger->setLogFacility(SgLogger::WRN, logLevel>=1?0xFFFFFFFF:0);
732  logger->setLogFacility(SgLogger::INF, logLevel>=2?0xFFFFFFFF:0);
733  logger->setLogFacility(SgLogger::DBG, logLevel==3?0xFFFFFFFF:0);
734  //
735 };
736 
737 
738 
739 //
740 void saveSettings(QSettings& settings, bool shouldInvokeSystemWideWizard)
741 {
742  // setup.identities:
743  if (!shouldInvokeSystemWideWizard)
744  {
745  settings.setValue("Identities/UserName",
747  settings.setValue("Identities/UserEmailAddress",
749  settings.setValue("Identities/UserDefaultInitials",
751  };
752  settings.setValue("Identities/AcFullName",
754  settings.setValue("Identities/AcAbbreviatedName",
756  settings.setValue("Identities/AcShortAbbreviatedName",
758  // setup:
759  // Pathes:
760  if (!shouldInvokeSystemWideWizard)
761  {
762  settings.setValue("Setup/Path2Home",
763  setup.getPath2Home());
764  };
765  settings.setValue("Setup/Path2InputFiles",
767  settings.setValue("Setup/Path2VgosDbFiles",
769  settings.setValue("Setup/Path2MasterFiles",
771  settings.setValue("Setup/Path2AuxLogs",
773  settings.setValue("Setup/Have2SavePerSessionLog",
775  settings.setValue("Setup/UseLocalLocale",
777  //
778  // store logger's config:
779  settings.setValue("Logger/FileName",
780  logger->getFileName());
781  // logger->getDirName();
782  settings.setValue("Logger/Capacity",
783  logger->getCapacity());
784  settings.setValue("Logger/IsStoreInFile",
786  settings.setValue("Logger/IsNeedTimeMark",
788  //
789 };
790 
791 
792 
793 //
795 {
796  QDir dir(path2data);
797  QList<QString> files2read;
798  QStringList entryList;
799  QRegExp reKombFileName("B[0-9]{2,}");
800  QRegExp reScanDirName("[0-9]{3}-[0-9]{4}[a-zA-Z]{0,1}");
801  //
802  // first, test for typical KOMB data set:
803  files2read = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot, QDir::Name);
804  for (int i=0; i<files2read.size(); i++)
805  if (files2read.at(i).contains(reKombFileName))
806  entryList << files2read.at(i);
807  if (entryList.size() >= 3)
808  {
810  "determineInputType(): directory " + path2data + ": looks like KOMB output");
812  };
813  //
814  // then, test for typical MK4 data set:
815  files2read.clear();
816  entryList.clear();
817  files2read = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name);
818  for (int i=0; i<files2read.size(); i++)
819 // if (dirList.at(i).contains(reScanDirName)) // sometimes, they send nonstandard names
820  entryList << files2read.at(i);
821  if (entryList.size() >= 0)
822  {
824  "determineInputType(): directory " + path2data + ": looks like FRINGE output");
826  };
827  //
828  // else...
830 };
831 /*=====================================================================================================*/
832 
833 
834 
835 
836 
837 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
QString interval2Str(double days)
Definition: SgMJD.cpp:1370
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
const QString & getAcAbbrevName() const
Definition: SgIdentities.h:247
const QString & getAcAbbName() const
Definition: SgIdentities.h:255
void setAcAbbrevName(const QString &)
Definition: SgIdentities.h:367
void setAcFullName(const QString &)
Definition: SgIdentities.h:359
const QString & getUserEmailAddress() const
Definition: SgIdentities.h:223
void setAcAbbName(const QString &)
Definition: SgIdentities.h:375
const QString & getMachineMachineName() const
Definition: SgIdentities.h:303
const QString & getMachineRelease() const
Definition: SgIdentities.h:319
const QString & getMachineNodeName() const
Definition: SgIdentities.h:295
const QString & getUserDefaultInitials() const
Definition: SgIdentities.h:231
const QString & getAcFullName() const
Definition: SgIdentities.h:239
void setUserDefaultInitials(const QString &)
Definition: SgIdentities.h:351
void setUserEmailAddress(const QString &)
Definition: SgIdentities.h:343
void setUserName(const QString &)
Definition: SgIdentities.h:335
const QString & getUserName() const
Definition: SgIdentities.h:215
const QString & getMachineSysName() const
Definition: SgIdentities.h:311
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
bool getIsStoreInFile() const
Definition: SgLogger.h:137
void attachSupplementLog(const QString &name, SgLogger *auxLogger)
Definition: SgLogger.cpp:172
void setIsStoreInFile(bool isStoreInFile)
Definition: SgLogger.h:127
void setLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:131
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
void setIsNeedTimeMark(bool isNeedTimeMark)
Definition: SgLogger.h:129
void setDirName(const QString &dirName)
Definition: SgLogger.h:124
@ SESSION
Definition: SgLogger.h:77
virtual void clearSpool()
Definition: SgLogger.cpp:116
void setCapacity(int capacity)
Definition: SgLogger.h:126
bool getIsNeedTimeMark() const
Definition: SgLogger.h:139
const QString & getFileName() const
Definition: SgLogger.h:135
int getCapacity() const
Definition: SgLogger.h:136
void setIsMute(bool is)
Definition: SgLogger.h:130
void detachSupplementLog(const QString &name)
Definition: SgLogger.cpp:187
void rmLogFile()
Definition: SgLogger.cpp:148
Definition: SgMJD.h:59
@ F_DDMonYYYY
Date: 2010 Apr 02.
Definition: SgMJD.h:87
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1007
static SgMJD currentMJD()
Definition: SgMJD.cpp:118
int calcYear() const
Definition: SgMJD.cpp:204
@ OM_DRY_RUN
Definition: SgNetCdf.h:325
@ NF_Petrov
Definition: SgVersion.h:59
const SgMJD & getReleaseEpoch() const
Definition: SgVersion.h:294
const QString & getSoftwareName() const
Definition: SgVersion.h:254
QString name(NameFormat fmt=NF_Human) const
Definition: SgVersion.cpp:54
void setOperationMode(SgNetCdf::OperationMode om)
Definition: SgVgosDb.h:344
void setPath2RootDir(const QString &path)
Definition: SgVgosDb.h:316
bool init(const QString path, const QString fileName)
Definition: SgVgosDb.cpp:533
const QString & getPath2RootDir() const
Definition: SgVgosDb.h:272
const QString & getName() const
const SgMJD & getTStart() const
@ OT_MK4
observations are from Mk4-compatible correlator output;
@ OT_KOMB
observations are from KOMB output (generated by NICT, Japan);
@ OT_UNKNOWN
unknown (=all others) source of import;
int getExperimentSerialNumber() const
void setExperimentSerialNumber(int sn)
const QString & getSessionCode() const
bool getDataFromFringeFiles(const QString &path2, const QString &altDatabaseName, const QString &altCorrelatorName, const QString &historyFileName, const QString &mapFileName, const QList< QString > &)
bool getDataFromKombFiles(const QString &path2, const QString &altDatabaseName, const QString &altCorrelatorName, const QString &historyFileName, const QString &mapFileName, bool need2correctRefClocks)
QList< SgVlbiObservation * > & observations()
void setPath2Masterfile(const QString &)
bool putDataIntoVgosDb(SgVgosDb *vgosDb)
void setPath2VgosDbFiles(const QString &)
Definition: VmSetup.h:264
bool getUseLocalLocale() const
Definition: VmSetup.h:91
const QString & getPath2InputFiles() const
Definition: VmSetup.h:206
QString path2(const QString &) const
Definition: VmSetup.h:312
const QString & getPath2Home() const
Definition: VmSetup.h:190
void setPath2Home(const QString &)
Definition: VmSetup.h:256
const QString & getPath2VgosDbFiles() const
Definition: VmSetup.h:198
SgIdentities & identities()
Definition: VmSetup.h:246
void setPath2MasterFiles(const QString &)
Definition: VmSetup.h:280
void setUpBinaryIdentities(const QString &)
Definition: VmSetup.cpp:69
void setPath2InputFiles(const QString &)
Definition: VmSetup.h:272
void setUseLocalLocale(bool use)
Definition: VmSetup.h:128
const QString & getPath2AuxLogs() const
Definition: VmSetup.h:222
bool getHave2SavePerSessionLog() const
Definition: VmSetup.h:230
void setPath2AuxLogs(const QString &)
Definition: VmSetup.h:288
void setHave2SavePerSessionLog(bool)
Definition: VmSetup.h:296
const QString & getPath2MasterFiles() const
Definition: VmSetup.h:214
void print2stdOut()
Definition: VmSetup.cpp:81
static int serialNumber()
bool need2correctRefClocks
Definition: vgosDbMake.cpp:95
QString altDatabaseName
Definition: vgosDbMake.cpp:85
QString altCorrelatorName
Definition: vgosDbMake.cpp:86
bool shouldInvokeSystemWideWizard
Definition: vgosDbMake.cpp:92
QString inputArg
Definition: vgosDbMake.cpp:82
bool have2SaveAltOutputDir
Definition: vgosDbMake.cpp:96
bool have2UseAltSetup
Definition: vgosDbMake.cpp:90
QSettings * settings
Definition: vgosDbMake.cpp:79
QString altOutputDir
Definition: vgosDbMake.cpp:84
QString mapFileName
Definition: vgosDbMake.cpp:83
bool have2ForceWizard
Definition: vgosDbMake.cpp:91
QString altSetupAppName
Definition: vgosDbMake.cpp:81
QList< QString > fringeErrorCodes2Skip
Definition: vgosDbMake.cpp:88
QString correlatorReportFileName
Definition: vgosDbMake.cpp:87
int altExpSerialNumber
Definition: vgosDbMake.cpp:89
QString altSetupName
Definition: vgosDbMake.cpp:80
bool useStdLocale
Definition: vgosDbMake.cpp:94
SgVlbiSessionInfo::OriginType determineInputType(const QString &path2data)
Definition: vgosDbMake.cpp:794
void loadSettings(QSettings &)
Definition: vgosDbMake.cpp:670
QCoreApplication * createApplication(int &argc, char *argv[], bool isGuiEnabled)
Definition: vgosDbMake.cpp:215
const QString origOrgName("NASA GSFC")
char progname[80]
Definition: vgosDbMake.cpp:70
int main(int argc, char **argv)
Definition: vgosDbMake.cpp:236
const QString origDmnName("gsfc.nasa.gov")
const char * argp_program_bug_address
Definition: vgosDbMake.cpp:75
static int parse_opt(int key, char *arg, struct argp_state *state)
Definition: vgosDbMake.cpp:102
int msglev
Definition: vgosDbMake.cpp:71
VmSetup setup
Definition: vgosDbMake.cpp:63
void saveSettings(QSettings &, bool shouldInvokeSystemWideWizard)
Definition: vgosDbMake.cpp:740
const QString origAppName("vgosDbMake")
SgVersion vgosDbMakeVersion