first commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
#ifndef PRODUCTIONREPOSITORY_H
|
||||
#define PRODUCTIONREPOSITORY_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
struct ProductionRunSnapshot
|
||||
{
|
||||
int id = 0;
|
||||
int orderId = 0;
|
||||
int currentWorkpieceId = 0;
|
||||
QString runState;
|
||||
QString productionState;
|
||||
QString processStep;
|
||||
QString timeoutState;
|
||||
int recoveryRetryCount = 0;
|
||||
QString lastError;
|
||||
};
|
||||
|
||||
struct WorkpieceProcessRecord
|
||||
{
|
||||
QString processStep;
|
||||
int attemptNo = 0;
|
||||
QString processState;
|
||||
QString resultState;
|
||||
int durationMs = -1;
|
||||
QDateTime startedAt;
|
||||
QDateTime completedAt;
|
||||
};
|
||||
|
||||
class ProductionRepository
|
||||
{
|
||||
public:
|
||||
int createRun(int orderId, const QString &productionState,
|
||||
const QString &processStep, QString *error = nullptr);
|
||||
bool updateRun(int runId, const QString &runState,
|
||||
const QString &productionState, const QString &processStep,
|
||||
int currentWorkpieceId, const QString &timeoutState,
|
||||
int recoveryRetryCount, const QString &lastError,
|
||||
QString *error = nullptr);
|
||||
bool finishRun(int runId, const QString &runState,
|
||||
const QString &lastError = QString(),
|
||||
QString *error = nullptr);
|
||||
bool heartbeatRun(int runId, QString *error = nullptr);
|
||||
bool findActiveRun(ProductionRunSnapshot *run, QString *error = nullptr);
|
||||
|
||||
bool insertStateHistory(int runId, int orderId, int workpieceId,
|
||||
const QString &fromState, const QString &toState,
|
||||
const QString &processStep, const QString &source,
|
||||
const QString &reason, const QString &message,
|
||||
QString *error = nullptr);
|
||||
|
||||
bool startWorkpieceProcess(int orderId, int workpieceId,
|
||||
const QString &processStep, int plcStep,
|
||||
const QString &source, QString *error = nullptr);
|
||||
bool finishWorkpieceProcess(int workpieceId, const QString &processStep,
|
||||
const QString &resultState, int durationMs,
|
||||
QString *error = nullptr);
|
||||
QList<WorkpieceProcessRecord> listProcessRecords(
|
||||
int workpieceId, QString *error = nullptr);
|
||||
|
||||
bool insertInspection(int orderId, int workpieceId,
|
||||
const QString &side, int rawResult,
|
||||
const QString &resultState, int plcStep,
|
||||
const QString &source, const QString &message,
|
||||
QString *error = nullptr);
|
||||
|
||||
bool insertAlarm(const QString &code, const QString &message,
|
||||
int orderId, int workpieceId,
|
||||
const QString &fallbackLevel,
|
||||
const QString &fallbackSource,
|
||||
QString *error = nullptr);
|
||||
bool clearActiveAlarms(const QString &code = QString(),
|
||||
const QString &clearedBy = "OPERATOR",
|
||||
QString *error = nullptr);
|
||||
|
||||
bool insertDeviceStatus(const QString &deviceCode, bool plcConnected,
|
||||
bool plcReady, bool robotReady,
|
||||
bool safetyDoorClosed, bool emergencyStop,
|
||||
int currentStep, int checkResult, int errorCode,
|
||||
QString *error = nullptr);
|
||||
};
|
||||
|
||||
#endif // PRODUCTIONREPOSITORY_H
|
||||
Reference in New Issue
Block a user