v1.6.t6
The crashing problems may have started after switching my test machine to to multiple config file setup. I'll test this theory by completely removing the multiple config file feasure and see if it crashes again. I'll figure out a better solution for multi config files in the next round of deveoplment.
This commit is contained in:
parent
6ffe80b672
commit
4758b62275
|
@ -13,13 +13,8 @@ of this app can be used to operate multiple cameras.
|
|||
Usage: mow <argument>
|
||||
|
||||
-h : display usage information about this application.
|
||||
-c : path to the config file(s).
|
||||
-c : path to the config file.
|
||||
-v : display the current version.
|
||||
|
||||
note: multiple -c config files can be passed, reading from left
|
||||
to right. any conflicting values between the files will
|
||||
have the latest value from the latest file overwrite the
|
||||
the earliest.
|
||||
```
|
||||
|
||||
### Config File ###
|
||||
|
|
|
@ -193,7 +193,7 @@ void rdLine(const string ¶m, const string &line, string *value)
|
|||
{
|
||||
if (line.rfind(param.c_str(), 0) == 0)
|
||||
{
|
||||
*value = line.substr(param.size());
|
||||
*value = trim(line).substr(param.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ void rdLine(const string ¶m, const string &line, int *value)
|
|||
{
|
||||
if (line.rfind(param.c_str(), 0) == 0)
|
||||
{
|
||||
*value = strtol(line.substr(param.size()).c_str(), NULL, 10);
|
||||
*value = strtol(trim(line).substr(param.size()).c_str(), NULL, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ bool rdConf(const string &filePath, shared_t *share)
|
|||
{
|
||||
share->retCode = ENOENT;
|
||||
|
||||
cout << "wrn: config file: " << filePath << " does not exists or lack read permissions." << endl;
|
||||
cerr << "err: config file: " << filePath << " does not exists or lack read permissions." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -284,18 +284,11 @@ bool rdConf(shared_t *share)
|
|||
share->detSuffix = ".det.";
|
||||
share->recSuffix = ".rec.";
|
||||
|
||||
auto ret = false;
|
||||
|
||||
for (auto &&confPath: share->conf)
|
||||
{
|
||||
if (rdConf(confPath, share)) ret = true;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
if (rdConf(share->conf, share))
|
||||
{
|
||||
if (share->camName.empty())
|
||||
{
|
||||
share->camName = path(share->conf.back()).filename();
|
||||
share->camName = path(share->conf).filename();
|
||||
}
|
||||
|
||||
if (share->detectUrl.empty())
|
||||
|
@ -307,7 +300,6 @@ bool rdConf(shared_t *share)
|
|||
share->buffDir = cleanDir(share->buffDir) + "/" + share->camName;
|
||||
share->recLogPath = share->outDir + "/rec_log_lines.html";
|
||||
share->detLogPath = share->outDir + "/det_log_lines.html";
|
||||
share->vidExt = trim(share->vidExt);
|
||||
share->detSuffix += share->vidExt;
|
||||
share->recSuffix += share->vidExt;
|
||||
|
||||
|
@ -324,43 +316,33 @@ bool rdConf(shared_t *share)
|
|||
createDirTree(cleanDir(share->buffDir));
|
||||
createDirTree(share->outDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "err: none of the expected config files could be read." << endl;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return share->retCode == 0;
|
||||
}
|
||||
|
||||
vector<string> parseForList(const string &arg, int argc, char** argv, bool argOnly, int count)
|
||||
string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int &offs)
|
||||
{
|
||||
auto argPresent = false;
|
||||
auto argCount = 0;
|
||||
auto ret = vector<string>();
|
||||
auto ret = string();
|
||||
|
||||
for (auto i = 1; i < argc; ++i)
|
||||
for (; offs < argc; ++offs)
|
||||
{
|
||||
auto argInParams = string(argv[i]);
|
||||
auto argInParams = string(argv[offs]);
|
||||
|
||||
if (argPresent)
|
||||
if (arg.compare(argInParams) == 0)
|
||||
{
|
||||
ret.push_back(argInParams);
|
||||
|
||||
argPresent = false;
|
||||
if (!argOnly)
|
||||
{
|
||||
offs++;
|
||||
// check ahead, make sure offs + 1 won't cause out-of-range exception
|
||||
if (offs <= (argc - 1))
|
||||
{
|
||||
ret = string(argv[offs]);
|
||||
}
|
||||
else if (arg.compare(argInParams) == 0)
|
||||
{
|
||||
argPresent = true; argCount++;
|
||||
}
|
||||
|
||||
if (argPresent && argOnly)
|
||||
else
|
||||
{
|
||||
ret.push_back(string("true"));
|
||||
ret = string("true");
|
||||
}
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
if (argCount >= count) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,16 +351,9 @@ vector<string> parseForList(const string &arg, int argc, char** argv, bool argOn
|
|||
|
||||
string parseForParam(const string &arg, int argc, char** argv, bool argOnly)
|
||||
{
|
||||
auto params = parseForList(arg, argc, argv, argOnly, 1);
|
||||
auto notUsed = 0;
|
||||
|
||||
if (params.empty())
|
||||
{
|
||||
return string();
|
||||
}
|
||||
else
|
||||
{
|
||||
return params[0];
|
||||
}
|
||||
return parseForParam(arg, argc, argv, argOnly, notUsed);
|
||||
}
|
||||
|
||||
void waitForDetThreads(shared_t *share)
|
||||
|
|
|
@ -37,16 +37,16 @@ using namespace cv;
|
|||
using namespace std;
|
||||
using namespace std::filesystem;
|
||||
|
||||
#define APP_VER "1.6.t5"
|
||||
#define APP_VER "1.6.t6"
|
||||
#define APP_NAME "Motion Watch"
|
||||
#define TRIM_REMOVE " \n\r\t\f\v."
|
||||
|
||||
struct shared_t
|
||||
{
|
||||
vector<thread> detThreads;
|
||||
vector<string> conf;
|
||||
ofstream recLogFile;
|
||||
ofstream detLogFile;
|
||||
string conf;
|
||||
string recLogPath;
|
||||
string detLogPath;
|
||||
string recordUrl;
|
||||
|
@ -93,6 +93,7 @@ string trim(const string &str);
|
|||
string genDstFile(const string &dirOut, const char *fmt, const string &ext);
|
||||
string genTimeStr(const char *fmt);
|
||||
string cleanDir(const string &path);
|
||||
string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int &offs);
|
||||
string parseForParam(const string &arg, int argc, char** argv, bool argOnly);
|
||||
bool createDir(const string &dir);
|
||||
bool createDirTree(const string &full_path);
|
||||
|
@ -103,7 +104,6 @@ void rdLine(const string ¶m, const string &line, int *value);
|
|||
void statOut(shared_t *share);
|
||||
void waitForDetThreads(shared_t *share);
|
||||
bool rdConf(shared_t *share);
|
||||
vector<string> parseForList(const string &arg, int argc, char** argv, bool argOnly = false, int count = 0);
|
||||
vector<string> lsFilesInDir(const string &path, const string &ext = string());
|
||||
vector<string> lsDirsInDir(const string &path);
|
||||
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -267,19 +267,15 @@ int main(int argc, char** argv)
|
|||
sigaction(SIGFPE, &act, NULL);
|
||||
sigaction(SIGBUS, &act, NULL);
|
||||
|
||||
sharedRes.conf = parseForList("-c", argc, argv);
|
||||
sharedRes.conf = parseForParam("-c", argc, argv, false);
|
||||
|
||||
if (parseForParam("-h", argc, argv, true) == "true")
|
||||
{
|
||||
cout << "Motion Watch " << APP_VER << endl << endl;
|
||||
cout << "Usage: mow <argument>" << endl << endl;
|
||||
cout << "-h : display usage information about this application." << endl;
|
||||
cout << "-c : path to a config file." << endl;
|
||||
cout << "-c : path to the config file." << endl;
|
||||
cout << "-v : display the current version." << endl << endl;
|
||||
cout << "note: multiple -c config files can be passed, reading from left" << endl;
|
||||
cout << " to right. any conflicting values between the files will" << endl;
|
||||
cout << " have the latest value from the latest file overwrite the" << endl;
|
||||
cout << " the earliest." << endl;
|
||||
}
|
||||
else if (parseForParam("-v", argc, argv, true) == "true")
|
||||
{
|
||||
|
@ -287,7 +283,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
else if (sharedRes.conf.empty())
|
||||
{
|
||||
cerr << "err: no config file(s) were given in -c" << endl;
|
||||
cerr << "err: config file not given in -c" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user