2025-08-27 23:10:36 +08:00
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include <QCoreApplication>
|
2025-09-10 00:31:27 +08:00
|
|
|
|
#include <QDir>
|
|
|
|
|
|
#include <QFile>
|
2025-08-27 23:10:36 +08:00
|
|
|
|
#include "BeltTearingPresenter.h"
|
2025-09-10 00:31:27 +08:00
|
|
|
|
#include "PathManager.h"
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "VrLog.h"
|
2025-08-27 23:10:36 +08:00
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
|
{
|
|
|
|
|
|
QCoreApplication app(argc, argv);
|
|
|
|
|
|
|
2025-09-10 00:31:27 +08:00
|
|
|
|
// 设置应用程序信息
|
|
|
|
|
|
app.setApplicationName(BELT_TEARING_SERVER_PRODUCT_NAME);
|
|
|
|
|
|
app.setApplicationVersion(BELT_TEARING_SERVER_VERSION_STRING);
|
|
|
|
|
|
app.setOrganizationName(BELT_TEARING_SERVER_COMPANY_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
// 打印启动横幅
|
|
|
|
|
|
LOG_DEBUG("===========================================\n");
|
|
|
|
|
|
LOG_INFO(" %s\n", BELT_TEARING_SERVER_PRODUCT_NAME);
|
|
|
|
|
|
LOG_INFO(" %s\n", BELT_TEARING_SERVER_DESCRIPTION);
|
|
|
|
|
|
LOG_INFO(" %s\n", BELT_TEARING_SERVER_COPYRIGHT);
|
|
|
|
|
|
LOG_DEBUG("===========================================\n");
|
|
|
|
|
|
|
2025-08-27 23:10:36 +08:00
|
|
|
|
// 创建并初始化Presenter
|
|
|
|
|
|
BeltTearingPresenter presenter;
|
|
|
|
|
|
|
2025-09-10 00:31:27 +08:00
|
|
|
|
// 获取配置文件路径
|
|
|
|
|
|
QString configFilePath = PathManager::GetConfigFilePath();
|
|
|
|
|
|
|
|
|
|
|
|
// 加载配置文件
|
|
|
|
|
|
if (!presenter.loadConfiguration(configFilePath)) {
|
|
|
|
|
|
LOG_WARN("Warning: Failed to load configuration file. Using default settings.\n");
|
|
|
|
|
|
LOG_INFO("Config file location: %s\n", configFilePath.toStdString().c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 启动TCP服务器(使用配置文件中的端口,如果配置加载失败则使用默认端口)
|
|
|
|
|
|
quint16 serverPort = presenter.getServerPort();
|
|
|
|
|
|
if (serverPort == 0) {
|
|
|
|
|
|
serverPort = 5900; // 默认端口
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!presenter.startServer(serverPort)) {
|
|
|
|
|
|
LOG_ERROR("Failed to start server on port %d\n", serverPort);
|
2025-08-27 23:10:36 +08:00
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-10 00:31:27 +08:00
|
|
|
|
// 启动相机
|
|
|
|
|
|
presenter.startCamera();
|
2025-08-27 23:10:36 +08:00
|
|
|
|
|
2025-09-10 00:31:27 +08:00
|
|
|
|
// 输出系统信息
|
|
|
|
|
|
LOG_INFO("=== BeltTearing Server Started ===\n");
|
|
|
|
|
|
LOG_DEBUG("===================================\n");
|
|
|
|
|
|
LOG_INFO("Server is running. Press Ctrl+C to exit.\n");
|
2025-08-27 23:10:36 +08:00
|
|
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
|
|
}
|