31 #include <QtCore/QCoreApplication>
32 #include <QtCore/QDir>
33 #include <QtCore/QFileInfo>
34 #include <QtCore/QList>
35 #include <QtCore/QSettings>
36 #include <QtCore/QString>
37 #include <QtCore/QStringList>
68 QMap<QString, AntcalOutputData>
80 static int parse_opt(
int key,
char *arg,
struct argp_state *state)
104 ": parse_opt(): option \"-b\": cannot convert \"" + str +
"\" to epoch");
120 ": option \"-e\": cannot convert \"" + str +
"\" to epoch");
132 options->
stationKey = QString(arg).leftJustified(8,
' ');
140 ": option \"-t\": added type of data: \"" + str +
"\"");
145 ": option \"-t\": unknown type of data: \"" + str +
"\"");
155 n = str.toInt(&isOk);
163 ": option \"-v\": the log level is set to " + QString(
"").setNum(options->
logLevel));
167 ": option \"-v\": the level " + str +
" is out of range [0..3]");
171 ": option \"-v\": cannot convert \"" + str +
"\" to int");
181 if (state->arg_num >= 2)
188 if (state->arg_num < 1)
192 return ARGP_ERR_UNKNOWN;
211 int main(
int argc,
char** argv)
215 QString userCommand(
"");
216 QString logDirName(
"./");
244 for (
int i=0; i<argc; i++)
245 userCommand += QString(argv[i]) +
" ";
250 struct argp_option argp_options[] =
252 {0, 0, 0, 0,
"General options:", 10},
253 {
"station-name",
's',
"STRING", 0,
254 "Set a name of a station to STRING"},
256 {0, 0, 0, 0,
"Input control:", 11},
257 {
"DBBC3-dump",
'3',
"STRING", 0,
258 "Use a file STRING as a DBBC3 dump file"},
260 {0, 0, 0, 0,
"Output control:", 12},
261 {
"compress",
'c',
"STRING", 0,
262 "Use a compressor STRING (gzip or bzip2) to squeeze output ANTCAL file"},
263 {
"output",
'o',
"STRING", 0,
264 "Set a name of output ANTCAL file to STRING"},
266 {0, 0, 0, 0,
"Time interval options:", 13},
267 {
"t-begin",
'b',
"STRING", 0,
268 "Set an epoch of the first observation to STRING, data before STRING will be ignored"},
269 {
"t-end",
'e',
"STRING", 0,
270 "Set an epoch of the last observation to STRING, data after STRING will be ignored"},
272 {0, 0, 0, 0,
"Data filter:", 14},
274 "Report all collected data (i.e., both data_valid on and off intervals)"},
275 {
"data-type",
't',
"STRING", 0,
276 "Extract only the specified type of data. STRING can be: "
277 "cbl (cable calibration), "
278 "dat (data=on/off), "
280 "met (meteorological parameters), "
281 "phc (phase calibration), "
282 "sefd (SEFD evaluation), "
286 "There can be more than one \"-t\" option, e.g.: -t dat -t tsys"},
287 {
"strip-unused-sensors",
'u', 0, 0,
288 "Do not output sensors that are not in a log file for some particular time"},
290 {0, 0, 0, 0,
"Debug output:", -2},
291 {
"verbose",
'v',
"NUM", 0,
292 "Set a level of log output to NUM: 0 (errors only), 1 (+warnings), 2 (+info) and "
293 "3 (+debug output). Default is 1"},
294 {
"log-file",
'l',
"STRING", 0,
295 "Store log2ant's output in a file STRING, the default is \"log2ant.log\""},
297 {0, 0, 0, 0,
"Operation modes:", -1},
298 {
"version",
'V', 0, 0,
299 "Print program version"},
303 QString salute(
"A program that extracts various data from a Field System "
304 "log file, FS_LOG_FILE, and stores them in an ANTCAL file.\v");
311 QString(
"\n\nThe utility log2ant is a part of nuSolve package. See datails in "
312 "\"log2ant User Guide\", a part of nuSolve distribution. You can get the latest version of "
313 "nuSolve at\n\t\thttps://sourceforge.net/projects/nusolve");
315 struct argp argp={argp_options,
parse_opt,
"FS_LOG_FILE", salute.toLatin1()};
317 argp_parse (&argp, argc, argv, 0, 0, &options);
334 logDirName = fi.absolutePath();
365 ": User command: \"" + userCommand +
"\"");
394 ": reading of the DBBC3 dump file \"" + options.
dbbc3InputFileName +
"\" failed for station");
401 ": extracted data were successfully stored in an ANTCAL file for station \"" +
405 ": data storing in an ANTCAL file has failed for station \"" + options.
stationKey +
"\"");
409 ": extracting data from the log file \"" + options.
inputFileName +
"\" failed");
413 ": the elapsed time to process log file \"" + options.
inputFileName +
"\" is: " +
415 QString(
"").sprintf(
"%.2f", (finisEpoch - startEpoch)*86400.0) +
" sec)",
true);
QString interval2Str(double days)
const SgMJD tZero(1957, 10, 4)
const SgMJD tInf(2100, 1, 1)
SgVersion libraryVersion("SgLib", 0, 7, 5, "Tuscarora (rc1)", SgMJD(2022, 2, 18, 17, 34))
const QString & getUserEmailAddress() const
const QString & getMachineMachineName() const
const QString & getMachineRelease() const
const QString & getMachineNodeName() const
const QString & getUserName() const
const QString & getMachineSysName() const
virtual void write(LogLevel, quint32, const QString &, bool=false)
void setIsStoreInFile(bool isStoreInFile)
void setLogFacility(LogLevel lvl, quint32 f)
void setFileName(const QString &fileName)
void setIsNeedTimeMark(bool isNeedTimeMark)
void setDirName(const QString &dirName)
bool fromString(Format format, const QString &str, bool isReset=true)
@ F_FS_LOG
Another version from spoolfile format: 2012.01.20-09:32:00.960.
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
@ F_DDMonYYYY
Date: 2010 Apr 02.
@ F_SOLVE_SPLFL_V3
Another spoolfile represenation of epoch: 2012.01.20-09:14:28.0.
QString toString(Format format=F_Verbose) const
static SgMJD currentMJD()
void setAntcalOutputData(int outputData)
const QString & getStationName() const
bool readDbbc3DumpFile(const QString &fileName)
bool createAntCalFile(const QString &stnKey, const QString &outputFileName, bool have2owrt, bool reportAllReadings, bool supressNonUsedSensors, const QString &ext4compress)
bool readLogFile(const QString &fileName, const QString &stnName, const SgMJD &tFirst, const SgMJD &tLast, const QString &orderOfMeteo)
void setUserCommand(const QString &str)
const SgMJD & getReleaseEpoch() const
QString name(NameFormat fmt=NF_Human) const
SgVersion log2antVersion("log2ant", 0, 0, 3, "Reichs Ford", SgMJD(2022, 2, 27, 16, 28))
int main(int argc, char **argv)
const char * argp_program_bug_address
static int parse_opt(int key, char *arg, struct argp_state *state)
bool supressNonUsedSensors
QString dbbc3InputFileName
QMap< QString, AntcalOutputData > knownWishedData