diff --git a/Cigarette/Cigarette.vcxproj.user b/Cigarette/Cigarette.vcxproj.user
index 633ab6d..02760dc 100644
--- a/Cigarette/Cigarette.vcxproj.user
+++ b/Cigarette/Cigarette.vcxproj.user
@@ -2,11 +2,11 @@
- C:\Qt\5.15.2\msvc2019_64
+ D:\Qt\5.15.2\msvc2019_64
PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)
- C:\Qt\5.15.2\msvc2019_64
+ D:\Qt\5.15.2\msvc2019_64
PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)
\ No newline at end of file
diff --git a/Cigarette/Cleanthread.cpp b/Cigarette/Cleanthread.cpp
index b0d274f..0ac1315 100644
--- a/Cigarette/Cleanthread.cpp
+++ b/Cigarette/Cleanthread.cpp
@@ -8,6 +8,8 @@
#include
#include "common.h"///
extern SysConf g_sys_conf;///
+extern ConfPath g_conf_path;
+
CleanWorkThread::CleanWorkThread(QObject* parent) : QObject(parent)
{
}
@@ -34,11 +36,20 @@ void CleanWorkThread::doWork()
{
qint64 spaceSize;
qint64 dirSize;
- QString iDriver = "D:/";
+ QString dirPath = g_conf_path.save_pics_path;
+ //QString iDriver = "D:/";
+ char drive[_MAX_DRIVE];
+ char dir_1[_MAX_DIR];
+ char fname[_MAX_FNAME];
+ char ext[_MAX_EXT];
+
+ _splitpath(dirPath.toStdString().c_str(), drive, dir_1, fname, ext);
+ QString iDriver = drive + QString("/");
LPCWSTR strDriver = (LPCWSTR)iDriver.utf16();
ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace;
qint64 gb = (1024 * 1024 * 1024);
- QString dir("D:/image");
+ //QString dir("D:/image");
+ QString dir(g_conf_path.save_pics_path + "/ALL");
if (delSelection == 2)
{
@@ -53,8 +64,8 @@ void CleanWorkThread::doWork()
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100/freeSize)) / (qint64)totalDiskSpace.QuadPart;
dirSize = DirFileSize(dir) / gb;
-
- while ((spaceSize < 1) && (delDays > 1)) { //磁盘剩余空间小于百分之十
+ delDays = g_sys_conf.save_days;
+ while ((spaceSize < 1) && (delDays >= 0)) { //磁盘剩余空间小于百分之十
CleanImageFile(dir, delDays--);
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100 / freeSize)) / (qint64)totalDiskSpace.QuadPart;
diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp
index 3798ef1..965fc5f 100644
--- a/Cigarette/alg_jd.cpp
+++ b/Cigarette/alg_jd.cpp
@@ -50,8 +50,8 @@ bool AlgJd::init(QString model_path, QString model_name)
//cv::Mat image = cv::imread("alg_jd.bmp");
cv::Mat image;
- if (g_sys_conf.jpg_path.length() > 0) {
- image = cv::imread(g_sys_conf.jpg_path.toStdString());
+ if (g_sys_conf.model_jpg_path.length() > 0) {
+ image = cv::imread(g_sys_conf.model_jpg_path.toStdString());
}
else {
image = cv::imread("D:/Release/alg_jd.bmp");
diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp
index 4c70618..7a66cf4 100644
--- a/Cigarette/cigarette.cpp
+++ b/Cigarette/cigarette.cpp
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include "exportData.h"
int g_op_time; //ԱȨʱĬ300룩
@@ -16,8 +17,10 @@ bool isNeedRotate[NumberOfSupportedCameras];
DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras];
+ConfPath g_conf_path;
SysConf g_sys_conf; //ϵͳò
ModbusConf g_modbus_conf; //modbusַ
+
PLCDevice * m_PLCDevice;
bool g_plc_dialog_open; //ǷplcöԻ
@@ -99,6 +102,29 @@ Cigarette::Cigarette(QWidget *parent)
{
ui.setupUi(this);
InitPtrMat();
+ read_conf(g_conf_path);
+ if (!g_conf_path.config_path.isEmpty()) {
+ // ǿ
+ QDir* dirinfo = new QDir(g_conf_path.config_path);
+ if (!dirinfo->exists()) {
+ // ļϢ
+ delete dirinfo, dirinfo = nullptr;
+ g_conf_path.config_path = "D:/conf";
+ g_conf_path.config_name = "conf.txt";
+ }
+
+ if (g_conf_path.config_name.isEmpty()) {
+ g_conf_path.config_name = "conf.txt";
+ }
+ delete dirinfo, dirinfo = nullptr;
+ }
+ else {
+ // ·
+ g_conf_path.config_path = "D:/conf";
+ if (g_conf_path.config_name.isEmpty())
+ g_conf_path.config_name = "conf.txt";
+ }
+
bool update_rotate = false;
if (!read_rotate_message()) {
update_rotate = true;
@@ -201,7 +227,13 @@ Cigarette::Cigarette(QWidget *parent)
quantity_stop_count = 0;
g_seconds = 0;
- read_sys_config(g_sys_conf); //ʼϵͳ
+ QString config_path;
+ if (g_conf_path.config_path.isEmpty() || g_conf_path.config_name.isEmpty()) {
+ g_conf_path.config_path = "D:/conf";
+ g_conf_path.config_name = "conf.txt";
+ }
+ config_path = g_conf_path.config_path + "/" + g_conf_path.config_name;
+ read_sys_config(g_sys_conf, config_path); //ʼϵͳ
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
g_modbus_conf.kick1 = 0; //1#ַͨ
@@ -741,6 +773,7 @@ void Cigarette::on_btn_setup_released()
dialog_setup->setModal(true);
dialog_setup->show();
dialog_setup->move((this->width() - dialog_setup->width()) / 2, (this->height() - dialog_setup->height()) / 2);
+
}
else {
QMessageBox::information(NULL, QStringLiteral("Ȩ"), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok);
@@ -983,7 +1016,7 @@ void Cigarette::OnKey(QKeyEvent* event)
char buf[256];
memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE, Num,Cnt);
- cfg_file.open(buf, ios::trunc | ofstream::out);
+ cfg_file.open(g_conf_path.config_path.toStdString() + "/" + buf, ios::trunc | ofstream::out);
if (!cfg_file.is_open())
{
std::cout << "Error: Open config file SelectRects.txt" << std::endl;
@@ -1130,7 +1163,7 @@ void Cigarette::DrawRect_init(int Num_Cnt) {
char buf[256];
memset(buf, 0, 256);
sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
- cfg_file.open(buf);
+ cfg_file.open(g_conf_path.config_path.toStdString() + "/" + buf);
if (!cfg_file.is_open())
{
std::cout << "Error: Open config file SelectRects"<" << str << std::endl;
system(str.c_str());
}
@@ -2281,13 +2317,42 @@ QString Cigarette::read_op_pswd()
cfg_file.close();
}
-bool Cigarette::read_sys_config(SysConf &conf)
+bool Cigarette::read_conf(ConfPath &conf_path) {
+ std::fstream conf_file;
+ conf_file.open(CONFPATH);
+ if (!conf_file.is_open()) {
+ std::cout << "Error: Open conf path file " << CONFPATH << std::endl;
+ return false;
+ }
+ while (!conf_file.eof()) {
+ char tmp[256] = "";
+ conf_file.getline(tmp, 256);
+ std::string line(tmp);
+ if (line.length() > 0) {
+ size_t pos = line.find('=');
+ std::string tmp_key = line.substr(0, pos);
+ if (tmp_key == "CONF_PATH") {
+ conf_path.config_path = line.substr(pos + 1).c_str();
+ }
+ else if (tmp_key == "CONF_NAME") {
+ conf_path.config_name = line.substr(pos + 1).c_str();
+ }
+ else if (tmp_key == "SAVE_PICS_PATH") {
+ conf_path.save_pics_path = line.substr(pos + 1).c_str();
+ }
+ }
+ }
+ conf_file.close();
+ return true;
+}
+
+bool Cigarette::read_sys_config(SysConf &conf, QString conf_path)
{
std::fstream cfg_file;
- cfg_file.open(CONFIGURE_FILE);
+ cfg_file.open(conf_path.toStdString());
if (!cfg_file.is_open())
{
- std::cout << "Error: Open config file " << CONFIGURE_FILE << std::endl;
+ std::cout << "Error: Open config file " << conf_path.toStdString() << std::endl;
return false;
}
while (!cfg_file.eof())
@@ -2383,7 +2448,7 @@ bool Cigarette::read_sys_config(SysConf &conf)
}
else if (tmp_key == "JPGPATH")
{
- conf.jpg_path = line.substr(pos + 1).c_str();
+ conf.model_jpg_path = line.substr(pos + 1).c_str();
}
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
else if (tmp_key == "EXPO1")
@@ -2670,7 +2735,7 @@ bool Cigarette::read_sys_config(SysConf &conf)
bool Cigarette::read_modbus_config(ModbusConf &conf)
{
std::fstream cfg_file;
- cfg_file.open(MODBUS_CONFIGURE_FILE);
+ cfg_file.open(g_conf_path.config_path.toStdString() + "/" + MODBUS_CONFIGURE_FILE);
if (!cfg_file.is_open())
{
std::cout << "Error: Open config file " << MODBUS_CONFIGURE_FILE << std::endl;
@@ -2775,7 +2840,8 @@ bool Cigarette::read_modbus_config(ModbusConf &conf)
bool Cigarette::read_rotate_message()
{
std::fstream cfg_file;
- cfg_file.open(ROTATE_FILE);
+ QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
+ cfg_file.open(rotate_file.toStdString());
if (!cfg_file.is_open())
{
std::cout << "Error: Open config file rotate.txt" << std::endl;
@@ -2811,7 +2877,8 @@ bool Cigarette::read_rotate_message()
bool Cigarette::save_rotate_message()
{
std::fstream cfg_file;
- cfg_file.open(ROTATE_FILE, ios::trunc | ofstream::out);
+ QString rotate_file = g_conf_path.config_path + "/" + ROTATE_FILE;
+ cfg_file.open(rotate_file.toStdString(), ios::trunc | ofstream::out);
if (!cfg_file.is_open())
{
std::cout << "Error: Open config file rotate.txt" << std::endl;
@@ -2893,7 +2960,7 @@ QImage Cigarette::cvMatToQImage(const cv::Mat& mat)
void Cigarette::read_plc_items()
{
std::fstream cfg_file;
- cfg_file.open(PLC_CONFIG_FILE);
+ cfg_file.open(g_conf_path.config_path.toStdString() + "/" + PLC_CONFIG_FILE);
if (!cfg_file.is_open())
{
std::cout << "Error: Open production file " << PLC_CONFIG_FILE << std::endl;
@@ -3736,9 +3803,14 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor
{
if (SingleCamInfo[i].IsOpen && quantity > 0) {
std::fstream cfg_file;
+ char str[256];
+ memset(str, 0, 256);
+ sprintf(str, STATISTIC_FILE, i);
char buf[256];
memset(buf, 0, 256);
- sprintf(buf, STATISTIC_FILE, i);
+ sprintf(buf, "%s/%s", g_conf_path.config_path, str);
+
+ std::cout<<"===buf>"<& files);
std::string SelectDirBRI();
std::string SelectFileOFN();
std::string SelectDirIFD();
+class ConfPath {
+public:
+ QString config_path; // ļ·
+ QString config_name; // ļ
+ QString save_pics_path; // ͼƬ洢·
+
+ ConfPath(){
+ config_path = "";
+ config_name = "";
+ save_pics_path = "";
+ }
+};
+
class SysConf
{
public:
@@ -77,7 +91,7 @@ public:
QString location; // ڵ
QString model_path; // ģļ·
QString model_name; // ģ
- QString jpg_path; // ͼƬ·
+ QString model_jpg_path; // ģͼƬ·
int timing_shift; //Ƿʱ࣬01
int expo[NumberOfSupportedCameras]; //عʱ䣬λ
int gain[NumberOfSupportedCameras]; //ģ棬Χ0~64
@@ -110,7 +124,7 @@ public:
location = "";
model_path = "";
model_name = "";
- jpg_path = "";
+ model_jpg_path = "";
shiftA.setHMS(0, 0, 0);
shiftB.setHMS(0, 0, 0);
shiftC.setHMS(0, 0, 0);
diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp
index 233ed49..1745c06 100644
--- a/Cigarette/dialogsetup.cpp
+++ b/Cigarette/dialogsetup.cpp
@@ -16,6 +16,7 @@
#include
#include "Cleanthread.h"
+extern ConfPath g_conf_path;
extern SysConf g_sys_conf; //系统配置参数
extern QString g_admin_pswd; //管理员密码
extern QString g_op_pswd; //操作员密码
@@ -28,7 +29,7 @@ void task_osk()
DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
ui.setupUi(this);
InitPtrMat();
- //this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动
+ this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动
for(int i=0;isetChecked(false);
}
+
+ if (!g_conf_path.config_path.isEmpty()) {
+ QDir* dirinfo = new QDir(g_conf_path.config_path);
+ if (!dirinfo->exists())
+ delete dirinfo, dirinfo = nullptr;
+ dirinfo->setNameFilters(QStringList("*.txt"));
+ QStringList fileList = dirinfo->entryList(QDir::Files);
+ fileList.removeOne(".");
+ fileList.removeOne("..");
+ ui.comboBox_config_path->clear();
+
+ ui.comboBox_config_path->addItems(fileList);
+ if (!g_conf_path.config_name.isEmpty())
+ ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
+ else {
+ g_conf_path.config_name = "conf.txt";
+ ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
+ }
+ // 更换选择文件
+ connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
+ delete dirinfo, dirinfo = nullptr;
+ }
+ else {
+ // 如果路径空
+ g_conf_path.config_path = "D:/conf";
+ if (!g_conf_path.config_name.isEmpty()) {
+ ui.comboBox_model_path->setCurrentText(g_conf_path.config_name);
+ }
+ else {
+ g_conf_path.config_name = "conf.txt";
+ ui.comboBox_model_path->addItem(g_conf_path.config_name);
+ }
+ }
if (!g_sys_conf.model_path.isEmpty()) {
// 如果曾经选择过模型文件夹
@@ -65,24 +99,49 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
QStringList fileList = dirinfo->entryList(QDir::Files);
fileList.removeOne(".");
fileList.removeOne("..");
- ui.comboBox->clear();
- ui.comboBox->addItems(fileList);
+ ui.comboBox_model_path->clear();
+ ui.comboBox_model_path->addItems(fileList);
if (!g_sys_conf.model_name.isEmpty()) {
// 如果曾选择过模型,则在comboBox显示选择模型的文件名
- ui.comboBox->setCurrentText(g_sys_conf.model_name);
+ ui.comboBox_model_path->setCurrentText(g_sys_conf.model_name);
}
// 更换模型事件
- connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
+ connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
else {
// 如果未曾选择过模型文件夹
if (!g_sys_conf.model_name.isEmpty()) {
// 如果曾经选择过模型文件
- ui.comboBox->addItem(g_sys_conf.model_name);
+ ui.comboBox_model_path->addItem(g_sys_conf.model_name);
}
}
+ if (!g_conf_path.save_pics_path.isEmpty()) {
+ // 如果配置文件里保存图片路径非空
+ QDir* dirinfo = new QDir(g_conf_path.save_pics_path);
+ if (!dirinfo->exists()) {
+ //delete dirinfo, dirinfo = nullptr;
+ dirinfo->mkdir(g_conf_path.save_pics_path);
+ }
+
+ ui.comboBox_save_pics_path->clear();
+ ui.comboBox_save_pics_path->addItem(g_conf_path.save_pics_path);
+
+ // 更换选择文件
+ connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
+ delete dirinfo, dirinfo = nullptr;
+ }
+ else {
+ QString dirPath = "D:/image";
+ QDir *dirinfo = new QDir(dirPath);
+ if (!dirinfo->exists())
+ delete dirinfo, dirinfo = nullptr;
+ ui.comboBox_save_pics_path->clear();
+ ui.comboBox_save_pics_path->setCurrentText(dirPath);
+ g_conf_path.save_pics_path = dirPath;
+ }
+
switch (g_sys_conf.save)
{
case 0:
@@ -108,10 +167,21 @@ DialogSetup::~DialogSetup() {
}
+void DialogSetup::onComboBoxPicsPathSelect(int index) {
+ QString cp = ui.comboBox_save_pics_path->currentText();
+ //QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
+ g_conf_path.save_pics_path = cp;
+}
+
+void DialogSetup::onComboBoxConfSelect(int index) {
+ QString cp = ui.comboBox_config_path->currentText();
+ //QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
+ g_conf_path.config_name = cp;
+}
+
void DialogSetup::onComboBoxSelect(int index) {
// 获取comboBox当前内容
- QString ct = ui.comboBox->currentText();
- /// QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为")+ct, NULL);
+ QString ct = ui.comboBox_model_path->currentText();
// 保存到配置文件中
g_sys_conf.model_name = ct;
}
@@ -264,6 +334,7 @@ void DialogSetup::on_pushButton_save_released()
g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt();
}
+ write_conf_path();
write_config();
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok);
}
@@ -288,7 +359,47 @@ void DialogSetup::on_pushButton_clear_pic_released()
handleThread->start();
}
-void DialogSetup::on_toolButton_choose_path_released() {
+void DialogSetup::on_toolButton_choose_config_path_released() {
+ QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择配置文件所在文件夹"), "./");
+ if (dirName.isEmpty()) {
+ // 点击取消按钮
+ if (g_conf_path.config_path.isEmpty())
+ dirName = "D:/conf";
+ else
+ dirName = g_conf_path.config_path;
+
+ ui.comboBox_config_path->addItem(dirName);
+
+ g_conf_path.config_path = dirName;
+ g_conf_path.config_name = "conf.txt";
+ }
+
+ QDir* dirinfo = new QDir(dirName);
+ if (!dirinfo->exists())
+ delete dirinfo, dirinfo = nullptr;
+ dirinfo->setNameFilters(QStringList("*.txt"));
+ QStringList fileList = dirinfo->entryList(QDir::Files);
+
+ if (fileList.count() == 0) {
+ g_conf_path.config_path = "D:/conf";
+ g_conf_path.config_name = "conf.txt";
+ }
+ else {
+ g_conf_path.config_path = dirName;
+ g_conf_path.config_name = ui.comboBox_config_path->currentText();
+ }
+
+ fileList.removeOne(".");
+ fileList.removeOne("..");
+
+ ui.comboBox_config_path->clear();
+ ui.comboBox_config_path->addItems(fileList);
+ connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
+
+ delete dirinfo, dirinfo = nullptr;
+}
+
+void DialogSetup::on_toolButton_choose_model_path_released() {
// 点击浏览文件按钮后触发的事件
QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择模型所在文件夹"), "./");
//std::cout << "dirName is " << dirName.toStdString().c_str() << std::endl;
@@ -296,27 +407,60 @@ void DialogSetup::on_toolButton_choose_path_released() {
//std::cout << "g_sys_conf.model_name is " << g_sys_conf.model_name.toStdString().c_str() << std::endl;
if (dirName.isEmpty()) {
- dirName = g_sys_conf.model_path;
- ui.comboBox->setCurrentText(g_sys_conf.model_name);
- return;
+ if (g_sys_conf.model_path.isEmpty())
+ dirName = "D:/model";
+ else
+ dirName = g_sys_conf.model_path;
+
+ ui.comboBox_model_path->addItem(dirName);
+ g_sys_conf.model_path = dirName;
+ g_sys_conf.model_name = "jd.weights";
}
QDir* dirinfo = new QDir(dirName);
- if (!dirinfo->exists()) {
+ if (!dirinfo->exists())
delete dirinfo, dirinfo = nullptr;
- }
dirinfo->setNameFilters(QStringList("*.weights"));
-
QStringList fileList = dirinfo->entryList(QDir::Files);
- if (fileList.count() == 0)
+ if (fileList.count() == 0) {
g_sys_conf.model_path = "D:/model";
+ g_sys_conf.model_name = "jd.weights";
+ }
else
g_sys_conf.model_path = dirName;
fileList.removeOne(".");
fileList.removeOne("..");
- ui.comboBox->clear();
- ui.comboBox->addItems(fileList);
+ ui.comboBox_model_path->clear();
+ ui.comboBox_model_path->addItems(fileList);
+ //g_sys_conf.model_name = ui.comboBox_model_path->currentText();
+ connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
+
+ delete dirinfo, dirinfo = nullptr;
+}
+
+void DialogSetup::on_toolButton_choose_save_pics_path_released() {
+ // 改变图片的存储路径
+ QString dirName = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择图片存储路径"), "./");
+ // 如果没有选择路径
+ if (dirName.isEmpty()) {
+ if (g_conf_path.save_pics_path.isEmpty())
+ dirName = "D:/image";
+ else
+ dirName = g_conf_path.save_pics_path;
+ ui.comboBox_save_pics_path->addItem(dirName);
+ //return;
+ }
+
+ QDir* dirinfo = new QDir(dirName);
+ if (!dirinfo->exists())
+ delete dirinfo, dirinfo = nullptr;
+
+ ui.comboBox_save_pics_path->clear();
+ ui.comboBox_save_pics_path->addItem(dirName);
+ //g_conf_path.save_pics_path = dirName;
+
+ connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
delete dirinfo, dirinfo = nullptr;
}
@@ -329,7 +473,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
else {
if (ui.comboBox_2->findText(JpgPath) == -1) {
ui.comboBox_2->addItem(JpgPath); // 在comboBox中显示文件路径
- g_sys_conf.jpg_path = JpgPath; // 将选择的路径写入conf配置文件中
+ g_sys_conf.model_jpg_path = JpgPath; // 将选择的路径写入conf配置文件中
}
}
}
@@ -360,10 +504,28 @@ void DialogSetup::write_pswd_op()
}
cfg_file.close();
}
+void DialogSetup::write_conf_path() {
+ std::fstream cfg_file;
+ cfg_file.open(CONFPATH, std::ios::out | std::ios::trunc);
+ if (cfg_file.good()) {
+ char buf[256];
+ memset(buf, 0, 256);
+ sprintf(buf, "CONF_PATH=%s\n", g_conf_path.config_path.toStdString().c_str());
+ cfg_file.write(buf, strlen(buf));
+ memset(buf, 0, 256);
+ sprintf(buf, "CONF_NAME=%s\n", g_conf_path.config_name.toStdString().c_str());
+ cfg_file.write(buf, strlen(buf));
+ memset(buf, 0, 256);
+ sprintf(buf, "SAVE_PICS_PATH=%s\n", g_conf_path.save_pics_path.toStdString().c_str());
+ cfg_file.write(buf, strlen(buf));
+ }
+ cfg_file.close();
+}
void DialogSetup::write_config()
{
std::fstream cfg_file;
- cfg_file.open("D:/conf/conf.txt", std::ios::out | std::ios::trunc);
+ QString cfg_path = g_conf_path.config_path + "/" + g_conf_path.config_name;
+ cfg_file.open(cfg_path.toStdString().c_str(), std::ios::out | std::ios::trunc);
if (cfg_file.good())
{
char buf[256];
@@ -419,7 +581,7 @@ void DialogSetup::write_config()
sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model_name.toStdString().c_str());
cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256);
- sprintf(buf, "JPGPATH=%s\n", g_sys_conf.jpg_path.toStdString().c_str());
+ sprintf(buf, "JPGPATH=%s\n", g_sys_conf.model_jpg_path.toStdString().c_str());
cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256);
sprintf(buf, "*****************************************\n");
diff --git a/Cigarette/dialogsetup.hpp b/Cigarette/dialogsetup.hpp
index c1033cd..572be98 100644
--- a/Cigarette/dialogsetup.hpp
+++ b/Cigarette/dialogsetup.hpp
@@ -23,8 +23,10 @@ private slots :
void on_pushButton_exit_released();
void on_pushButton_save_released();
void on_pushButton_close_released();
- void on_toolButton_choose_path_released();
+ void on_toolButton_choose_config_path_released();
+ void on_toolButton_choose_model_path_released();
void on_toolButton_choose_path_jpg_released();
+ void on_toolButton_choose_save_pics_path_released();
void on_pushButton_desktop_released();
void on_pushButton_image_released();
void on_pushButton_pswd_released();
@@ -43,6 +45,8 @@ private slots :
void recMsgFromDialogConfig(int ptr[][3]);
void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC);
void onComboBoxSelect(int index);
+ void onComboBoxConfSelect(int index);
+ void onComboBoxPicsPathSelect(int index);
#ifdef __DEBUG
void on_pushButton_testimg_released();
void on_pushButton_testimgs_released();
@@ -57,6 +61,7 @@ public:
static void write_pswd();
static void write_pswd_op();
static void write_config();
+ static void write_conf_path();
public:
camera_glue *m_camera_glue=NULL;
diff --git a/Cigarette/dialogsetup.ui b/Cigarette/dialogsetup.ui
index b29c2d2..500681b 100644
--- a/Cigarette/dialogsetup.ui
+++ b/Cigarette/dialogsetup.ui
@@ -6,8 +6,8 @@
0
0
- 690
- 830
+ 660
+ 992
@@ -29,8 +29,8 @@
0
0
- 690
- 830
+ 661
+ 1000
@@ -52,9 +52,9 @@
0
- -72
- 675
- 900
+ 0
+ 670
+ 977
@@ -136,7 +136,7 @@
10
- 510
+ 610
641
81
@@ -1027,7 +1027,7 @@
10
- 670
+ 770
641
148
@@ -1509,8 +1509,8 @@
- 120
- 820
+ 110
+ 930
131
51
@@ -1552,7 +1552,7 @@
10
- 590
+ 690
641
81
@@ -1728,8 +1728,8 @@
- 380
- 820
+ 370
+ 930
131
51
@@ -1815,7 +1815,7 @@
- 10
+ 40
460
101
41
@@ -1836,9 +1836,9 @@
- 120
- 460
- 111
+ 40
+ 560
+ 101
41
@@ -1857,9 +1857,9 @@
- 240
- 460
- 91
+ 40
+ 510
+ 101
41
@@ -1875,13 +1875,13 @@
产量统计
-
+
620
470
27
- 26
+ 25
@@ -1893,19 +1893,19 @@
...
-
+
- 340
+ 190
470
- 101
- 21
+ 171
+ 30
微软雅黑
- 10
+ 12
75
true
@@ -1913,19 +1913,23 @@
模型存储路径
+
+ Qt::AlignCenter
+
-
+
- 450
+ 370
470
- 161
- 25
+ 241
+ 30
微软雅黑
+ 10
@@ -1933,7 +1937,7 @@
340
- 970
+ 1020
91
21
@@ -1953,7 +1957,7 @@
440
- 970
+ 1020
171
25
@@ -1968,7 +1972,7 @@
620
- 970
+ 1020
27
26
@@ -2006,8 +2010,8 @@
- 530
- 820
+ 520
+ 930
131
21
@@ -2026,8 +2030,8 @@
- 530
- 850
+ 520
+ 960
131
21
@@ -2043,6 +2047,122 @@
测试多张图片
+
+
+
+ 190
+ 520
+ 171
+ 30
+
+
+
+
+ 微软雅黑
+ 12
+ 75
+ true
+
+
+
+ 配置文件存储路径
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 370
+ 520
+ 241
+ 30
+
+
+
+
+ 微软雅黑
+ 10
+
+
+
+
+
+
+ 620
+ 520
+ 27
+ 25
+
+
+
+
+ 微软雅黑
+
+
+
+ ...
+
+
+
+
+
+ 190
+ 570
+ 171
+ 30
+
+
+
+
+ 微软雅黑
+ 12
+ 75
+ true
+
+
+
+ 图片存储路径
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 370
+ 570
+ 241
+ 30
+
+
+
+
+ 微软雅黑
+ 10
+
+
+
+
+
+
+ 620
+ 570
+ 27
+ 25
+
+
+
+
+ 微软雅黑
+
+
+
+ ...
+
+
diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp
index b2d0c02..4e13b83 100644
--- a/Cigarette/exportData.cpp
+++ b/Cigarette/exportData.cpp
@@ -4,6 +4,7 @@
#include
extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue;
+extern ConfPath g_conf_path;
ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
{
@@ -13,15 +14,17 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
XMLError error;
pDocument[index] = new XMLDocument();
memset(xmlPath, 0, 256);
- sprintf(xmlPath, EXPORTDATA_FILE, index);
- error = pDocument[index]->LoadFile(xmlPath);
+ QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
+ //sprintf(xmlPath, EXPORTDATA_FILE, index);
+ QString filePath = g_conf_path.config_path + "/" + xmlPath;
+ error = pDocument[index]->LoadFile(filePath.toStdString().c_str());
if (error != XML_SUCCESS)
{
XMLDeclaration* declaration = pDocument[index]->NewDeclaration();
pDocument[index]->InsertFirstChild(declaration);
XMLElement* root = pDocument[0]->NewElement("Root");
pDocument[0]->InsertEndChild(root);
- pDocument[index]->SaveFile(xmlPath);
+ pDocument[index]->SaveFile(filePath.toStdString().c_str());
}
/*
_ExportDataInfo data;
@@ -53,15 +56,16 @@ void ExportDataThread::stop()
bool _ExportDataInfo::getAverageData(map &averageData, int index)
{
XMLDocument doc;
- char xmlPath[256];
+ //char xmlPath[256];
XMLError error;
map data;
-
- memset(xmlPath, 0, 256);
- sprintf(xmlPath, EXPORTDATA_FILE, index);
- error = doc.LoadFile(xmlPath);
+ //memset(xmlPath, 0, 256);
+ QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
+ //sprintf(xmlPath, EXPORTDATA_FILE, index);
+ QString filePath = g_conf_path.config_path + "/" + xmlPath;
+ error = doc.LoadFile(filePath.toStdString().c_str());
if (error != XML_SUCCESS)
- if (doc.LoadFile(xmlPath) != 0)
+ if (doc.LoadFile(filePath.toStdString().c_str()) != 0)
{
cout << "load xml file failed" << endl;
return false;
@@ -144,7 +148,9 @@ void ExportDataThread::run()
if (element.cameraId != -1) {
char buf[256];
memset(buf, 0, 256);
- sprintf(buf, EXPORTDATA_FILE, element.cameraId);
+ QString xmlPath = QString(EXPORTDATA_FILE).arg(element.cameraId);
+ QString filePath = g_conf_path.config_path + "/" + xmlPath;
+ sprintf(buf, filePath.toStdString().c_str(), element.cameraId);
insertXMLNode(buf, element);
}
}
diff --git a/Cigarette/exportData.h b/Cigarette/exportData.h
index daff5fb..6271dda 100644
--- a/Cigarette/exportData.h
+++ b/Cigarette/exportData.h
@@ -8,9 +8,9 @@
#include
#include "basecamera.h"
#include "tinyxml2.h"
+#include "common.h"
-
-#define EXPORTDATA_FILE "D:/conf/camera%d_data_info.xml"
+#define EXPORTDATA_FILE "camera%1_data_info.xml"
using namespace tinyxml2;
diff --git a/Cigarette/main.cpp b/Cigarette/main.cpp
index 6f928ed..05627df 100644
--- a/Cigarette/main.cpp
+++ b/Cigarette/main.cpp
@@ -21,8 +21,8 @@ int main(int argc, char *argv[])
splash.show();
a.processEvents();
Cigarette w;
- w.show();
- //w.showFullScreen();
+ //w.show();
+ w.showFullScreen();
splash.finish(&w);
return a.exec();
}
diff --git a/Cigarette/output_statistic.cpp b/Cigarette/output_statistic.cpp
index 5dddfbc..768fc86 100644
--- a/Cigarette/output_statistic.cpp
+++ b/Cigarette/output_statistic.cpp
@@ -2,14 +2,43 @@
#include "QtCore\qfile.h"
#include "QtCore\qtextstream.h"
#include "exportData.h"
-#include "common.h"
#include