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>
69 QMap<QString, AntcalOutputData>
81 static int parse_opt(
int key,
char *arg,
struct argp_state *state)
105 ": parse_opt(): option \"-b\": cannot convert \"" + str +
"\" to epoch");
121 ": option \"-e\": cannot convert \"" + str +
"\" to epoch");
133 options->
stationKey = QString(arg).leftJustified(8,
' ');
141 ": option \"-t\": added type of data: \"" + str +
"\"");
146 ": option \"-t\": unknown type of data: \"" + str +
"\"");
156 n = str.toInt(&isOk);
164 ": option \"-v\": the log level is set to " + QString(
"").setNum(options->
logLevel));
168 ": option \"-v\": the level " + str +
" is out of range [0..3]");
172 ": option \"-v\": cannot convert \"" + str +
"\" to int");
182 if (state->arg_num >= 2)
189 if (state->arg_num < 1)
193 return ARGP_ERR_UNKNOWN;
212 int main(
int argc,
char** argv)
217 QString userCommand(
"");
218 QString logDirName(
"./");
248 for (
int i=0; i<argc; i++)
249 userCommand += QString(argv[i]) +
" ";
254 struct argp_option argp_options[] =
256 {0, 0, 0, 0,
"General options:", 10},
257 {
"station-name",
's',
"STRING", 0,
258 "Set a name of a station to STRING"},
260 {0, 0, 0, 0,
"Input control:", 11},
261 {
"DBBC3-dump",
'3',
"STRING", 0,
262 "Use a file STRING as a DBBC3 dump file"},
264 {0, 0, 0, 0,
"Output control:", 12},
265 {
"compress",
'c',
"STRING", 0,
266 "Use a compressor STRING (gzip or bzip2) to squeeze output ANTCAL file"},
267 {
"output",
'o',
"STRING", 0,
268 "Set a name of output ANTCAL file to STRING"},
270 {0, 0, 0, 0,
"Time interval options:", 13},
271 {
"t-begin",
'b',
"STRING", 0,
272 "Set an epoch of the first observation to STRING, data before STRING will be ignored"},
273 {
"t-end",
'e',
"STRING", 0,
274 "Set an epoch of the last observation to STRING, data after STRING will be ignored"},
276 {0, 0, 0, 0,
"Data filter:", 14},
278 "Report all collected data (i.e., both data_valid on and off intervals)"},
279 {
"data-type",
't',
"STRING", 0,
280 "Extract only the specified type of data. STRING can be: "
281 "cbl (cable calibration), "
282 "dat (data=on/off), "
284 "met (meteorological parameters), "
285 "phc (phase calibration), "
286 "sefd (SEFD evaluation), "
290 "There can be more than one \"-t\" option, e.g.: -t dat -t tsys"},
291 {
"strip-unused-sensors",
'u', 0, 0,
292 "Do not output sensors that are not in a log file for some particular time"},
294 {0, 0, 0, 0,
"Debug output:", -2},
295 {
"verbose",
'v',
"NUM", 0,
296 "Set a level of log output to NUM: 0 (errors only), 1 (+warnings), 2 (+info) and "
297 "3 (+debug output). Default is 1"},
298 {
"log-file",
'l',
"STRING", 0,
299 "Store log2ant's output in a file STRING, the default is \"log2ant.log\""},
301 {0, 0, 0, 0,
"Operation modes:", -1},
302 {
"version",
'V', 0, 0,
303 "Print program version"},
307 QString salute(
"A program that extracts various data from a Field System "
308 "log file, FS_LOG_FILE, and stores them in an ANTCAL file.\v");
315 QString(
"\n\nThe utility log2ant is a part of nuSolve package. See datails in "
316 "\"log2ant User Guide\", a part of nuSolve distribution. You can get the latest version of "
317 "nuSolve at\n\t\thttps://sourceforge.net/projects/nusolve");
319 struct argp argp={argp_options,
parse_opt,
"FS_LOG_FILE", salute.toLatin1()};
321 argp_parse (&argp, argc, argv, 0, 0, &options);
338 logDirName = fi.absolutePath();
369 ": User command: \"" + userCommand +
"\"");
399 ": reading of the DBBC3 dump file \"" + options.
dbbc3InputFileName +
"\" failed for station");
406 ": extracted data were successfully stored in an ANTCAL file for station \"" +
412 ": data storing in an ANTCAL file has failed for station \"" + options.
stationKey +
"\"");
419 ": extracting data from the log file \"" + options.
inputFileName +
"\" failed");
426 ": the elapsed time to process log file \"" + options.
inputFileName +
"\" is: " +
428 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, 8, 2, "Compton Peak (rc2)", SgMJD(2023, 4, 3, 10, 59))
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, 1, 2, "Lands Run Falls (rc2)", SgMJD(2023, 4, 3, 11, 0))
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