58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#ifndef CONFIGMANAGER_H
|
|
#define CONFIGMANAGER_H
|
|
|
|
#include "../db/dbconfig.h"
|
|
#include "../modbus/modbusconfig.h"
|
|
|
|
#include <QString>
|
|
|
|
struct ProductionConfig
|
|
{
|
|
int loadStep = 1;
|
|
int frontCheckStep = 2;
|
|
int backCheckStep = 3;
|
|
int unloadStep = 4;
|
|
int cycleCompleteStep = 5;
|
|
int okResult = 1;
|
|
int ngResult = 2;
|
|
int errorResult = 3;
|
|
int simulationResult = 1;
|
|
int timeoutWarningMs = 8000;
|
|
int stateTimeoutMs = 10000;
|
|
int maxRecoveryRetries = 1;
|
|
int simulationStepMs = 500;
|
|
bool usePlcErrorCode = false;
|
|
};
|
|
|
|
class ConfigManager
|
|
{
|
|
public:
|
|
static ConfigManager &instance();
|
|
|
|
bool load(const QString &filePath = QString());
|
|
QString filePath() const;
|
|
|
|
DbConfig databaseConfig() const;
|
|
ModbusConfig modbusConfig() const;
|
|
ProductionConfig productionConfig() const;
|
|
bool simulationMode() const;
|
|
bool productionEnabled() const;
|
|
bool validate(QString *error = nullptr) const;
|
|
|
|
private:
|
|
ConfigManager();
|
|
ConfigManager(const ConfigManager &) = delete;
|
|
ConfigManager &operator=(const ConfigManager &) = delete;
|
|
|
|
QString defaultFilePath() const;
|
|
|
|
QString m_filePath;
|
|
DbConfig m_databaseConfig;
|
|
ModbusConfig m_modbusConfig;
|
|
ProductionConfig m_productionConfig;
|
|
bool m_simulationMode;
|
|
bool m_productionEnabled;
|
|
};
|
|
|
|
#endif // CONFIGMANAGER_H
|