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 #ifdef OLD_HOPS
71 char progname[80];
72 int msglev = 2;
73 #endif
74 
76 
77 // for ARGP parser:
78 const char *argp_program_bug_address = "Sergei Bolotin <sergei.bolotin@nasa.gov>";
79 
81 {
82  QSettings *settings;
83  QString altSetupName;
84  QString altSetupAppName;
85  QString inputArg;
86  QString mapFileName;
87  QString altOutputDir;
88  QString altDatabaseName;
97  bool isDryRun;
101 };
102 
103 
104 //
105 // a parser for ARGP:
106 static int parse_opt(int key, char *arg, struct argp_state *state)
107 {
108  int n;
109  bool is;
110  QString str("");
111  struct vdbmOptions *options=(struct vdbmOptions*)state->input;
112  //
113  switch (key)
114  {
115  case 'a':
116  options->altSetupName = QString(arg);
117  if (!options->altSetupName.contains("/..")) // are there any other elements of path that we should avoid?
118  {
119  options->altSetupAppName = origAppName + "-" + options->altSetupName;
120  options->have2UseAltSetup = true;
121  }
122  else
123  {
125  ": parse_opt(): it is dangerous to use a string \"" + options->altSetupName +
126  "\" as an alternative config name");
128  ": parse_opt(): you can overwrite another file (un)intentionally");
129  delete options->settings;
130  exit(22);
131  };
132  break;
133  case 'd':
134  options->altDatabaseName = QString(arg);
135  break;
136  case 'e':
137  options->fringeErrorCodes2Skip << QString(arg).toUpper();
138  break;
139  case 'f':
140  n = QString(arg).toInt(&is);
141  if (is)
142  {
143  if (n==1 || n==2)
144  options->expectedMasterfileVersion = n;
145  else
147  ": parse_opt(): masterfile format of version " + arg + " is not supported");
148  }
149  else
150  {
152  ": parse_opt(): cannot convert \"" + arg + "\" to int");
154  };
155  break;
156  case 'l':
157  options->useStdLocale = true;
158  break;
159  case 'm':
160  options->mapFileName = QString(arg);
161  break;
162  case 'O':
163  options->have2SaveAltOutputDir = true;
164  options->altOutputDir = QString(arg);
165  break;
166  case 'o':
167  options->altOutputDir = QString(arg);
168  break;
169  case 'p':
170  loadSettings(*options->settings);
172  exit(0);
173  break;
174  case 'q':
175  options->isDryRun = true;
176  break;
177  case 'r':
178  options->altCorrelatorName = QString(arg);
179  break;
180  case 's':
181  n = QString(arg).toInt(&is);
182  if (is)
183  options->altExpSerialNumber = n;
184  else
185  {
187  ": parse_opt(): cannot convert \"" + arg + "\" to int");
188  options->altExpSerialNumber = 0;
189  };
190  break;
191  case 't':
192  options->correlatorReportFileName = QString(arg);
193  break;
194  case 'x':
195  options->need2correctRefClocks = true;
196  break;
197 
198  //
199  case 'W':
200  options->shouldInvokeSystemWideWizard = true;
201  break;
202  case 'w':
203  options->have2ForceWizard = true;
204  break;
205  //
206  case 'V':
207  std::cout << qPrintable(vgosDbMakeVersion.name(SgVersion::NF_Petrov)) << "\n";
208  exit(0);
209  break;
210  //
211  case ARGP_KEY_ARG:
212  if (1 < state->arg_num)
213  {
214  argp_usage(state);
215  };
216  options->inputArg = QString(arg);
217  break;
218  case ARGP_KEY_END:
219  if (state->arg_num < 1 &&
220  !(options->have2ForceWizard || options->shouldInvokeSystemWideWizard))
221  argp_usage(state);
222  break;
223  default:
224  return ARGP_ERR_UNKNOWN;
225  break;
226  };
227  return 0;
228 };
229 //
230 
231 
232 
233 
234 
235 //
236 QCoreApplication* createApplication(int &argc, char *argv[], bool isGuiEnabled)
237 {
238  if (isGuiEnabled)
239  return new QApplication(argc, argv);
240  else
241  return new QCoreApplication(argc, argv);
242 };
243 
244 
245 
246 
247 
248 SgVlbiSessionInfo::OriginType determineInputType(const QString& path2data);
249 
250 
251 /***===================================================================================================*/
257 int main(int argc, char** argv)
258 {
259  struct vdbmOptions options;
261  QString userCommand("");
262  SgLogger *alHistory;
263  SgLogger *alDriver;
264 
265 #ifdef SWCONFIG
266  const QString path2SystemWideConfig(SWCONFIG "/xdg");
267 #else
268  const QString path2SystemWideConfig("");
269 #endif
270  int rc;
271  bool isGuiEnabled;
272  bool isFirstRun;
273  const char* envDisplay=NULL;
274 
275  rc = 0;
276  options.settings = NULL;
277  options.altSetupAppName = QString("");
278  options.altSetupName = QString("");
279  options.inputArg = QString("");
280  options.mapFileName = QString("");
281  options.altOutputDir = QString("");
282  options.altDatabaseName = QString("");
283  options.altCorrelatorName = QString("");
284  options.correlatorReportFileName = QString("");
285  options.fringeErrorCodes2Skip.clear();
286  options.altExpSerialNumber = 0;
288  options.have2UseAltSetup = false;
289  options.have2ForceWizard = false;
290  options.shouldInvokeSystemWideWizard = false;
291  options.isDryRun = false;
292  options.useStdLocale = false;
293  options.need2correctRefClocks = false;
294  options.have2SaveAltOutputDir = false;
295 
296 
297  //
298  // init:
299  QCoreApplication::setOrganizationName(origOrgName);
300  QCoreApplication::setOrganizationDomain(origDmnName);
301  QCoreApplication::setApplicationName(origAppName);
302  //
303  // set up path to the system wide settings:
304  QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, path2SystemWideConfig);
305  //
306  options.settings = new QSettings;
307  //
308  isGuiEnabled = (envDisplay=getenv("DISPLAY"))!=NULL && strlen(envDisplay)>0;
309  //
310  QScopedPointer<QCoreApplication>
311  app(createApplication(argc, argv, isGuiEnabled));
312  if (qobject_cast<QApplication *>(app.data()))
313  {
314  // do something with GUI
315  }
316  else
317  {
318  // do something for non-GUI
319  };
320 
321  //
322  // especially for HOPS:
323 #ifdef OLD_HOPS
324  strcpy(progname, qPrintable("HOPS (on behalf of " + vgosDbMakeVersion.getSoftwareName() + ")"));
325 #endif
326  //
327  setup.setUpBinaryIdentities(QString(argv[0]));
328  for (int i=0; i<argc; i++)
329  userCommand += QString(argv[i]) + " ";
330  userCommand.chop(1);
331 
332 
333  //
334  // ARGP setup:
335  //
336  struct argp_option argp_options[] =
337  {
338  {0, 0, 0, 0, "General options:", 10},
339  {"std-locale", 'l', 0, 0,
340  "Use the standard locale"},
341  {"output-dir", 'o', "STRING", 0,
342  "Use an alternative path STRING to save files in vgosDb format"},
343  {"mf-version", 'f', "NUM", 0,
344  "Set the expected masterfile format version to NUM. The possible format versions are 1 and 2."},
345 
346  {0, 0, 0, 0, "Configuration control:", 11},
347  {"alt", 'a', "STRING", 0,
348  "Use an alternative configuration STRING"},
349 
350  {0, 0, 0, 0, "Database edit options:", 12},
351  {"database", 'd', "STRING", 0,
352  "Set database name to STRING"},
353  {"correlator", 'r', "STRING", 0,
354  "Set correlator name to STRING"},
355  {"exp-sn", 's', "NUM", 0,
356  "Set experiment serial number to NUM"},
357 
358  {0, 0, 0, 0, "Data extraction control:", 13},
359  {"exclude", 'e', "CHAR", 0,
360  "exclude observations with fringe error code CHAR. If CHAR is \"*\" only observations that have "
361  "no fringe error code will be extracted. There can be more than one \"-e\" option, "
362  "e.g.: -eA -eB."},
363  {"map", 'm', "STRING", 0,
364  "Set a name map file to STRING"},
365  {"report", 't', "STRING", 0,
366  "Set a correlator report file to STRING"},
367  {"adjust-ref-stn", 'x', 0, 0,
368  "KOMB files input only: adjust delays and rates for a reference station clock offset "
369  "(experimental mode)"},
370 
371  {0, 0, 0, 0, "Invocation of startup wizard:", 25},
372  {"sys-wide-wizard", 'W', 0, 0,
373  "Run startup wizard for the system-wide settings"},
374  {"wizard", 'w', 0, 0,
375  "Force call of the startup wizard"},
376 
377  {0, 0, 0, 0, "Operation modes:", -1},
378  {"print-setup", 'p', 0, 0,
379  "Print set up and exit"},
380  {"dry-mode", 'q', 0, 0,
381  "Process in a \"dry run\" mode: files will not be created, instead names of the files "
382  "will be printed"},
383  {"version", 'V', 0, 0,
384  "Print program version"},
385  //
386  {0}
387  };
388  QString salute("vgosDbMake is a program that extracts data from fringe or "
389  "KOMB files and stores obtained info in vgosDb database. The mandatory argument INPUT_DIR is a "
390  "name of a directory where the software searches the correlator files.\v");
391 
392  salute += "The current version is:\n\t" + vgosDbMakeVersion.name() + " released on " +
394  "\n\t" + libraryVersion.name() + " released on " +
396  salute +=
397  QString("\n\nThe utility vgosDbMake is a part of nuSolve package. See the datails in "
398  "\"vgosDbMake User Guide\", a part of nuSolve distribution. You can get the latest version of "
399  "nuSolve at\n\t\thttps://sourceforge.net/projects/nusolve");
400 
401  struct argp argp={argp_options, parse_opt, "INPUT_DIR", salute.toLatin1()};
402 
403  argp_parse (&argp, argc, argv, 0, 0, &options);
404 
405  isFirstRun = options.settings->allKeys().size()>0 ? false : true;
406  //
407  //
408  if (options.have2UseAltSetup)
409  {
411  ": using alternative config name \"" + options.altSetupName + "\"");
412  QSettings *altSettings=new QSettings(origOrgName, options.altSetupAppName);
413  loadSettings(*altSettings);
414  delete options.settings;
415  options.settings = altSettings;
416  }
417  else
418  loadSettings(*options.settings);
419  //
420  //
421  //
422  if (isGuiEnabled)
423  {
424  if (options.have2ForceWizard || options.shouldInvokeSystemWideWizard ||
425  options.settings->value("Version/StartUpWizard", 0).toInt() < VmStartupWizard::serialNumber())
426  {
427  if (options.shouldInvokeSystemWideWizard)
428  {
429  if (!options.have2UseAltSetup)
430  {
431  QSettings *swSettings =
432  new QSettings(QSettings::SystemScope, origOrgName, origAppName);
433  if (!swSettings->isWritable())
434  {
436  ": Cannot write system wide config");
437  delete swSettings;
438  return 1;
439  };
440  delete options.settings;
441  options.settings = swSettings;
442  }
443  else
445  ": Using an alternative config name, system wide config edit request ignored");
446  };
447  //
448  VmStartupWizard startup(isFirstRun, options.have2ForceWizard,
449  options.shouldInvokeSystemWideWizard, options.settings);
450  if (startup.exec() == QDialog::Rejected)
451  {
452  delete options.settings;
453  logger->clearSpool();
454  return rc; // rc == 0, it is ok
455  };
456  //
457  // save if user pressed "Finish":
458  options.settings->setValue("Version/StartUpWizard", startup.serialNumber());
460  //
461  // it is ok, exitting:
462  if (!options.inputArg.size())
463  {
464  delete options.settings;
465  logger->clearSpool();
466  return rc;
467  };
468  };
469  }
470  else if (options.have2ForceWizard || options.shouldInvokeSystemWideWizard)
471  {
472  rc = 1;
474  ": cannot run graphical application.");
475  delete options.settings;
476  logger->clearSpool();
477  return rc;
478  };
479 
480  // alternate output directory:
481  if (options.altOutputDir.size())
482  {
485  ": using the directory \"" + setup.getPath2VgosDbFiles() + "\" for output");
486  if (options.have2SaveAltOutputDir)
487  {
488  options.settings->setValue("Setup/Path2VgosDbFiles",
491  ": the default output direcory was changed to \"" + setup.getPath2VgosDbFiles() + "\"");
492  };
493  };
494  //
495  //===================== begin here: =====================
496  //
497  // if input is not an absolute directory:
498  if (options.inputArg.at(0) != QChar('/'))
499  options.inputArg = setup.path2(setup.getPath2InputFiles()) + "/" + options.inputArg;
500 
501  QFileInfo fInfo(options.inputArg);
502  if (!fInfo.exists())
503  {
505  ": the provided input direcory, " + options.inputArg + ", does not exist");
506  logger->clearSpool();
507  return 1;
508  };
509  if (!fInfo.isDir())
510  {
512  ": the provided input is a file, not a directory.");
513  logger->clearSpool();
514  return 1;
515  };
516  if (!fInfo.isReadable())
517  {
519  ": the provided input direcory is unreadable.");
520  logger->clearSpool();
521  return 1;
522  };
523  //
524  //
525  //
526  alDriver = new SgLogger(800, setup.getHave2SavePerSessionLog(), "drv-unnamed.log");
528  alDriver->setIsNeedTimeMark(true);
529  alDriver->setIsMute(true);
530  alDriver->setLogFacility(SgLogger::ERR, 0xFFFFFFFF);
531  alDriver->setLogFacility(SgLogger::WRN, 0xFFFFFFFF);
532  alDriver->setLogFacility(SgLogger::INF, 0xFFFFFFFF);
533  alDriver->setLogFacility(SgLogger::DBG, 0);
535  logger->attachSupplementLog("Driver", alDriver);
536  //
537  alHistory = new SgLogger(0, false, "");
538  alHistory->setIsNeedTimeMark(false);
539  alHistory->setIsMute(true);
540  alHistory->setLogFacility(SgLogger::ERR, 0xFFFFFFFF);
541  alHistory->setLogFacility(SgLogger::WRN, 0xFFFFFFFF);
542  alHistory->setLogFacility(SgLogger::INF, 0xFFFFFFFF);
543  alHistory->setLogFacility(SgLogger::DBG, 0);
544  //
545  bool isOk(false);
546  SgVgosDb *vgosDb;
547  SgVlbiSession session;
548  //
550  ": starting");
552  //
553  //
554  inputType = determineInputType(options.inputArg);
555  if (inputType == SgVlbiSessionInfo::OT_UNKNOWN)
556  {
558  ": directory \"" + options.inputArg + "\": unable to determine the type of input files");
559  logger->clearSpool();
560  return 1;
561  }
562  else if (inputType!=SgVlbiSessionInfo::OT_MK4 && inputType!=SgVlbiSessionInfo::OT_KOMB)
563  {
565  ": directory \"" + options.inputArg + "\": unsupported type of input files");
566  logger->clearSpool();
567  return 1;
568  };
569  //
570  // adjust correlator input file name (if it is not an absolute path):
571  if (options.correlatorReportFileName.size() && options.correlatorReportFileName.at(0) != QChar('/'))
573  options.correlatorReportFileName;
574  //
575  //------------------------------------------------------------------------------------------
576  logger->attachSupplementLog("History", alHistory);
578  ": Library ID: " + libraryVersion.name() + " released on " +
581  ": Driver ID: " + vgosDbMakeVersion.name() + " released on " +
583 
585  ": Host ID: " + setup.identities().getMachineNodeName() +
586  " (Hw: " + setup.identities().getMachineMachineName() +
587  "; Sw: " + setup.identities().getMachineRelease() +
588  " version of " + setup.identities().getMachineSysName() + ")");
589 
591  ": User ID: " + setup.identities().getUserName() +
594  ": User command: \"" + userCommand + "\"");
596  ": Input data : \"" + options.inputArg + "\"");
597  //
598  if (options.altExpSerialNumber)
599  {
602  ": session serial number was mannualy set to " +
603  QString("").sprintf("%d", session.getExperimentSerialNumber()));
604  };
606 
607  QString sLang(""), sLcAll("");
608  if (!setup.getUseLocalLocale() || options.useStdLocale)
609  {
610  if (getenv("LANG"))
611  sLang = QString(getenv("LANG"));
612  setenv("LANG", "C", 1);
613  if (getenv("LC_ALL"))
614  sLcAll = QString(getenv("LC_ALL"));
615  setenv("LC_ALL", "C", 1);
617  ": the env.variable LANG was set to \"C\"");
619  ": the env.variable LC_ALL was set to \"C\"");
620  };
621 
622  SgMJD startEpoch=SgMJD::currentMJD();
623  if ((isOk=inputType==SgVlbiSessionInfo::OT_MK4?
624  session.getDataFromFringeFiles(options.inputArg, options.altDatabaseName,
625  options.altCorrelatorName, options.correlatorReportFileName, options.mapFileName,
626  options.fringeErrorCodes2Skip) :
627  session.getDataFromKombFiles(options.inputArg, options.altDatabaseName,
628  options.altCorrelatorName, options.correlatorReportFileName, options.mapFileName,
629  options.need2correctRefClocks)))
630  {
631  alDriver->setFileName(session.getName() + ".log");
632  alDriver->rmLogFile();
633 
635  ": the session " + session.getSessionCode() + " (" + session.getName() +
636  ") has been imported from fringes files");
637  vgosDb = new SgVgosDb(&setup.identities(), &vgosDbMakeVersion);
639  ": vgosDb object has been created");
640  // udjust a correlator name:
641  if (session.getCorrelatorName().size() == 0)
642  {
645  ": the empty correlator name was adjusted to \"" + session.getCorrelatorName() + "\"");
646  };
647 
648  if ((isOk=vgosDb->init(&session)))
649  {
651  ": the vgosDb object has been prepared to save the new session in vgosDb format");
652 
654  QString("").sprintf("%04d", session.getTStart().calcYear()) + "/" + session.getName());
656  ": the path was set to " + vgosDb->getPath2RootDir());
657 
658  if (options.isDryRun)
660 
661  // strore it in vgosDb format:
662  isOk = session.putDataIntoVgosDb(vgosDb);
664  ": export of data into vgosDb tree has been " + (isOk?"complete":"failed"));
665  if (!isOk)
666  rc = 1;
667  else
668  {
669  SgMJD finisEpoch=SgMJD::currentMJD();
671  ": the elapsed time to process " + QString("").setNum(session.observations().size()) +
672  " observations is: " + interval2Str(finisEpoch - startEpoch) +
673  " (" + QString("").sprintf("%.2f", (finisEpoch - startEpoch)*86400.0) + " sec)", true);
674  };
675  }
676  else
677  {
679  ": initializing of the vgosDb object has failed");
680  rc = 1;
681  };
682 
683  delete vgosDb;
685  ": vgosDb object has been destroyed.");
686  }
687  else
688  {
689  rc = 1;
691  ": import data from \"" + options.inputArg + "\" failed");
692  };
693 
694  if (!setup.getUseLocalLocale() || options.useStdLocale)
695  {
696  setenv("LANG", qPrintable(sLang), 1);
697  setenv("LC_ALL", qPrintable(sLcAll), 1);
699  ": the env.variable LANG was set to \"" + sLang + "\"");
701  ": the env.variable LC_ALL was set to \"" + sLcAll + "\"");
702  };
703 
704  alDriver->clearSpool();
705  logger->detachSupplementLog("Driver");
706  logger->detachSupplementLog("History");
707  delete alHistory;
708  delete alDriver;
709  delete options.settings;
710  logger->clearSpool();
711  return rc;
712 };
713 
714 
715 
716 //
717 void loadSettings(QSettings& settings)
718 {
719  int logLevel;
720  //
721  // setup.identities:
723  settings.value("Identities/UserName",
724  setup.identities().getUserName()).toString());
726  settings.value("Identities/UserEmailAddress",
727  setup.identities().getUserEmailAddress()).toString());
729  settings.value("Identities/UserDefaultInitials",
730  setup.identities().getUserDefaultInitials()).toString());
732  settings.value("Identities/AcFullName",
733  setup.identities().getAcFullName()).toString());
735  settings.value("Identities/AcAbbreviatedName",
736  setup.identities().getAcAbbrevName()).toString());
738  settings.value("Identities/AcShortAbbreviatedName",
739  setup.identities().getAcAbbName()).toString());
740 
741  // setup:
742  // Pathes:
744  settings.value("Setup/Path2Home",
745  setup.getPath2Home()).toString());
747  settings.value("Setup/Path2InputFiles",
748  setup.getPath2InputFiles()).toString());
750  settings.value("Setup/Path2VgosDbFiles",
751  setup.getPath2VgosDbFiles()).toString());
753  settings.value("Setup/Path2MasterFiles",
754  setup.getPath2MasterFiles()).toString());
756  settings.value("Setup/Path2AuxLogs",
757  setup.getPath2AuxLogs()).toString());
759  settings.value("Setup/Have2SavePerSessionLog",
760  setup.getHave2SavePerSessionLog()).toBool());
762  settings.value("Setup/UseLocalLocale",
763  setup.getUseLocalLocale()).toBool());
764  //
765  // adjust the logger:
767  settings.value("Logger/FileName",
768  "vgosDbMake.log").toString());
771  settings.value("Logger/Capacity", 400).toInt());
773  settings.value("Logger/IsStoreInFile", logger->getIsStoreInFile()).toBool());
775  settings.value("Logger/IsNeedTimeMark", logger->getIsNeedTimeMark()).toBool());
776  logLevel = settings.value("Logger/LogLevel", 2).toInt();
777  logger->setLogFacility(SgLogger::ERR, logLevel>=0?0xFFFFFFFF:0);
778  logger->setLogFacility(SgLogger::WRN, logLevel>=1?0xFFFFFFFF:0);
779  logger->setLogFacility(SgLogger::INF, logLevel>=2?0xFFFFFFFF:0);
780  logger->setLogFacility(SgLogger::DBG, logLevel==3?0xFFFFFFFF:0);
781  //
782 };
783 
784 
785 
786 //
787 void saveSettings(QSettings& settings, bool shouldInvokeSystemWideWizard)
788 {
789  // setup.identities:
790  if (!shouldInvokeSystemWideWizard)
791  {
792  settings.setValue("Identities/UserName",
794  settings.setValue("Identities/UserEmailAddress",
796  settings.setValue("Identities/UserDefaultInitials",
798  };
799  settings.setValue("Identities/AcFullName",
801  settings.setValue("Identities/AcAbbreviatedName",
803  settings.setValue("Identities/AcShortAbbreviatedName",
805  // setup:
806  // Pathes:
807  if (!shouldInvokeSystemWideWizard)
808  {
809  settings.setValue("Setup/Path2Home",
810  setup.getPath2Home());
811  };
812  settings.setValue("Setup/Path2InputFiles",
814  settings.setValue("Setup/Path2VgosDbFiles",
816  settings.setValue("Setup/Path2MasterFiles",
818  settings.setValue("Setup/Path2AuxLogs",
820  settings.setValue("Setup/Have2SavePerSessionLog",
822  settings.setValue("Setup/UseLocalLocale",
824  //
825  // store logger's config:
826  settings.setValue("Logger/FileName",
827  logger->getFileName());
828  // logger->getDirName();
829  settings.setValue("Logger/Capacity",
830  logger->getCapacity());
831  settings.setValue("Logger/IsStoreInFile",
833  settings.setValue("Logger/IsNeedTimeMark",
835  //
836 };
837 
838 
839 
840 //
842 {
843  QDir dir(path2data);
844  QList<QString> files2read;
845  QStringList entryList;
846  QRegExp reKombFileName("B[0-9]{2,}");
847  QRegExp reScanDirName("[0-9]{3}-[0-9]{4}[a-zA-Z]{0,1}");
848  //
849  // first, test for typical KOMB data set:
850  files2read = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot, QDir::Name);
851  for (int i=0; i<files2read.size(); i++)
852  if (files2read.at(i).contains(reKombFileName))
853  entryList << files2read.at(i);
854  if (entryList.size() >= 3)
855  {
857  "determineInputType(): directory " + path2data + ": looks like KOMB output");
859  };
860  //
861  // then, test for typical MK4 data set:
862  files2read.clear();
863  entryList.clear();
864  files2read = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name);
865  for (int i=0; i<files2read.size(); i++)
866 // if (dirList.at(i).contains(reScanDirName)) // sometimes, they send nonstandard names
867  entryList << files2read.at(i);
868  if (entryList.size() >= 0)
869  {
871  "determineInputType(): directory " + path2data + ": looks like FRINGE output");
873  };
874  //
875  // else...
877 };
878 /*=====================================================================================================*/
879 
880 
881 
882 
883 
884 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
QString interval2Str(double days)
Definition: SgMJD.cpp:1371
SgVersion libraryVersion("SgLib", 0, 8, 2, "Compton Peak (rc2)", SgMJD(2023, 4, 3, 10, 59))
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:1008
static SgMJD currentMJD()
Definition: SgMJD.cpp:119
int calcYear() const
Definition: SgMJD.cpp:205
@ 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:346
void setPath2RootDir(const QString &path)
Definition: SgVgosDb.h:318
bool init(const QString path, const QString fileName)
Definition: SgVgosDb.cpp:538
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;
const QString & getCorrelatorName() const
int getExperimentSerialNumber() const
void setExperimentSerialNumber(int sn)
void setCorrelatorName(const QString &name)
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 setExpectedMasterfileVersion(int v)
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:99
QString altDatabaseName
Definition: vgosDbMake.cpp:88
QString altCorrelatorName
Definition: vgosDbMake.cpp:89
bool shouldInvokeSystemWideWizard
Definition: vgosDbMake.cpp:96
QString inputArg
Definition: vgosDbMake.cpp:85
bool have2SaveAltOutputDir
Definition: vgosDbMake.cpp:100
bool have2UseAltSetup
Definition: vgosDbMake.cpp:94
QSettings * settings
Definition: vgosDbMake.cpp:82
QString altOutputDir
Definition: vgosDbMake.cpp:87
QString mapFileName
Definition: vgosDbMake.cpp:86
bool have2ForceWizard
Definition: vgosDbMake.cpp:95
QString altSetupAppName
Definition: vgosDbMake.cpp:84
QList< QString > fringeErrorCodes2Skip
Definition: vgosDbMake.cpp:91
QString correlatorReportFileName
Definition: vgosDbMake.cpp:90
int altExpSerialNumber
Definition: vgosDbMake.cpp:92
QString altSetupName
Definition: vgosDbMake.cpp:83
bool useStdLocale
Definition: vgosDbMake.cpp:98
int expectedMasterfileVersion
Definition: vgosDbMake.cpp:93
SgVlbiSessionInfo::OriginType determineInputType(const QString &path2data)
Definition: vgosDbMake.cpp:841
void loadSettings(QSettings &)
Definition: vgosDbMake.cpp:717
QCoreApplication * createApplication(int &argc, char *argv[], bool isGuiEnabled)
Definition: vgosDbMake.cpp:236
const QString origOrgName("NASA GSFC")
int main(int argc, char **argv)
Definition: vgosDbMake.cpp:257
const QString origDmnName("gsfc.nasa.gov")
const int defaultMasterfileVersion(1)
const char * argp_program_bug_address
Definition: vgosDbMake.cpp:78
static int parse_opt(int key, char *arg, struct argp_state *state)
Definition: vgosDbMake.cpp:106
VmSetup setup
Definition: vgosDbMake.cpp:63
void saveSettings(QSettings &, bool shouldInvokeSystemWideWizard)
Definition: vgosDbMake.cpp:787
const QString origAppName("vgosDbMake")
SgVersion vgosDbMakeVersion