|
|
|
|
#ifndef COMMON_H
|
|
|
|
|
#define COMMON_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include "utils/Singleton.h"
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QMap>
|
|
|
|
|
#include "utils/interface.h"
|
|
|
|
|
#include "nlohmann/json.hpp"
|
|
|
|
|
#include "EasySpdLog.h"
|
|
|
|
|
|
|
|
|
|
class Common : public QObject, public Singleton<Common>
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
friend class Singleton<Common>;
|
|
|
|
|
public:
|
|
|
|
|
bool loadConfig(const QString& filePath);
|
|
|
|
|
bool saveConfig(const QMap<int, ProductConfig>& productsCfg, const QMap<int, ModeConfig>& workmodeCfg);
|
|
|
|
|
|
|
|
|
|
QString getHostAddress() const;
|
|
|
|
|
int getSrcPort() const;
|
|
|
|
|
int getDstPort() const;
|
|
|
|
|
|
|
|
|
|
QMap<int, ProductConfig> getProductConfigs();
|
|
|
|
|
void setProductConfig(const QMap<int, ProductConfig>& productsCfg);
|
|
|
|
|
QMap<int, ModeConfig> getWorkModeConfigs();
|
|
|
|
|
void setWorkModeConfigs(const QMap<int, ModeConfig>& workmodeCfg);
|
|
|
|
|
|
|
|
|
|
const QMap<QString, Mode>& getSelectedProducts() const;
|
|
|
|
|
|
|
|
|
|
int getCurrentWorkMode() const;
|
|
|
|
|
void setCurrentWorkMode(const int workMode);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Common();
|
|
|
|
|
bool saveConfig();
|
|
|
|
|
void FilterSelectedProducts();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_configFilePath{};
|
|
|
|
|
nlohmann::json m_configJson{};
|
|
|
|
|
QString m_currentWorkPath{}; // 当前工作路径
|
|
|
|
|
std::atomic<int> m_currentMode{ -1 }; // 当前正在进行的工作模式
|
|
|
|
|
QString m_ipAddr{};
|
|
|
|
|
int m_dstPort{};
|
|
|
|
|
int m_srcPort{};
|
|
|
|
|
QMap<int, ModeConfig> m_modeConfigs{}; // 模式配置
|
|
|
|
|
QMap<int, ProductConfig> m_productConfigs{}; // 产品配置
|
|
|
|
|
QMap<QString, Mode> m_selectedProduct{}; // 选择的产品
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // COMMON_H
|