2022-09-22 20:57:46 -04:00
|
|
|
#ifndef COMMON_H
|
|
|
|
#define COMMON_H
|
|
|
|
|
|
|
|
// This file is part of Motion Watch.
|
|
|
|
|
|
|
|
// Motion Watch is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Motion Watch is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDateTime>
|
2023-05-15 19:39:29 -04:00
|
|
|
#include <QThread>
|
2023-05-21 09:34:57 -04:00
|
|
|
#include <QTimer>
|
2023-05-26 16:12:53 -04:00
|
|
|
#include <QStringList>
|
2022-09-22 20:57:46 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2023-06-10 09:45:26 -04:00
|
|
|
#define APP_VER "3.0.t15"
|
2023-03-10 19:05:54 -05:00
|
|
|
#define APP_NAME "Motion Watch"
|
2023-05-17 15:06:58 -04:00
|
|
|
#define APP_BIN "mow"
|
2023-03-10 19:05:54 -05:00
|
|
|
#define REC_LOG_NAME "rec_log_lines.html"
|
|
|
|
#define DET_LOG_NAME "det_log_lines.html"
|
|
|
|
#define UPK_LOG_NAME "upk_log_lines.html"
|
2023-05-26 16:12:53 -04:00
|
|
|
#define DATETIME_FMT "yyyyMMddhhmmss"
|
|
|
|
#define STRFTIME_FMT "%Y%m%d%H%M%S"
|
2023-05-27 09:33:14 -04:00
|
|
|
#define MAX_IMAGES 1000
|
2023-06-09 16:24:32 -04:00
|
|
|
#define MAX_VIDEOS 1000
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-04-20 14:52:59 -04:00
|
|
|
struct evt_t
|
2023-03-05 16:07:07 -05:00
|
|
|
{
|
2023-05-26 16:12:53 -04:00
|
|
|
QDateTime timeStamp;
|
|
|
|
QString imgPath;
|
2023-06-09 16:24:32 -04:00
|
|
|
float score;
|
2023-03-05 16:07:07 -05:00
|
|
|
};
|
|
|
|
|
2022-09-22 20:57:46 -04:00
|
|
|
struct shared_t
|
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
QList<evt_t> recList;
|
|
|
|
QString conf;
|
|
|
|
QString recLog;
|
|
|
|
QString detLog;
|
|
|
|
QString recordUrl;
|
|
|
|
QString outDir;
|
|
|
|
QString postCmd;
|
|
|
|
QString camName;
|
|
|
|
QString webBg;
|
|
|
|
QString webTxt;
|
|
|
|
QString webFont;
|
|
|
|
QString webRoot;
|
|
|
|
bool skipCmd;
|
|
|
|
int evMaxSecs;
|
|
|
|
int postSecs;
|
|
|
|
int imgThresh;
|
|
|
|
int maxEvents;
|
|
|
|
int maxLogSize;
|
|
|
|
int retCode;
|
2023-02-07 23:19:41 -05:00
|
|
|
};
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
QString getParam(const QString &key, const QStringList &args);
|
|
|
|
QStringList lsFilesInDir(const QString &path, const QString &ext = QString());
|
|
|
|
QStringList lsDirsInDir(const QString &path);
|
2023-05-26 16:12:53 -04:00
|
|
|
QStringList listFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs, char dir);
|
|
|
|
QStringList backwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs);
|
|
|
|
QStringList forwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs);
|
2023-05-15 15:29:47 -04:00
|
|
|
bool rdConf(const QString &filePath, shared_t *share);
|
|
|
|
bool rdConf(shared_t *share);
|
|
|
|
void rdLine(const QString ¶m, const QString &line, QString *value);
|
|
|
|
void rdLine(const QString ¶m, const QString &line, int *value);
|
|
|
|
void enforceMaxEvents(shared_t *share);
|
2023-05-26 16:12:53 -04:00
|
|
|
void enforceMaxImages();
|
2023-06-09 16:24:32 -04:00
|
|
|
void enforceMaxVids();
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-05-17 15:06:58 -04:00
|
|
|
class MultiInstance : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QList<QProcess*> procList;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void instStdout();
|
|
|
|
void instStderr();
|
2023-05-17 15:40:09 -04:00
|
|
|
void procChanged(QProcess::ProcessState newState);
|
2023-05-17 15:06:58 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit MultiInstance(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
int start(const QStringList &args);
|
|
|
|
};
|
|
|
|
|
2022-09-22 20:57:46 -04:00
|
|
|
#endif // COMMON_H
|