90 lines
2.2 KiB
C++
90 lines
2.2 KiB
C++
#ifndef CONFIGMANAGER_H
|
|
#define CONFIGMANAGER_H
|
|
|
|
#include "../db/dbconfig.h"
|
|
#include "../modbus/modbusconfig.h"
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QMap>
|
|
|
|
struct VisionConfig
|
|
{
|
|
bool enabled = false;
|
|
bool contractConfirmed = false;
|
|
bool photoPoseReadyConfirmed = false;
|
|
QString executablePath;
|
|
QString ipcName = "ssp_visionguide_v1";
|
|
int startupTimeoutMs = 15000;
|
|
int initializeTimeoutMs = 60000;
|
|
int requestTimeoutMs = 15000;
|
|
int robotAckTimeoutMs = 10000;
|
|
int photoPoseR = 40;
|
|
int graspPoseR = 60;
|
|
bool lowWordFirst = true;
|
|
int robotReceivedCoil = -1;
|
|
int photoRequestCoil = -1;
|
|
int comparingCoil = -1;
|
|
int comparisonErrorCoil = -1;
|
|
int comparisonPassedCoil = -1;
|
|
QString handshakeProtocol;
|
|
QStringList writableSignals;
|
|
QStringList actionNames;
|
|
QMap<int, int> trayMap;
|
|
|
|
bool isValid(QString *error = nullptr) const;
|
|
int visionTrayNo(int sspTrayNo) const;
|
|
};
|
|
|
|
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;
|
|
VisionConfig visionConfig() 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;
|
|
VisionConfig m_visionConfig;
|
|
bool m_simulationMode;
|
|
bool m_productionEnabled;
|
|
};
|
|
|
|
#endif // CONFIGMANAGER_H
|