122 lines
4.0 KiB
C++
122 lines
4.0 KiB
C++
#ifndef DASHBOARDPAGE_H
|
|
#define DASHBOARDPAGE_H
|
|
|
|
#include "../services/productionworker.h"
|
|
|
|
#include <QWidget>
|
|
#include <QVector>
|
|
#include <QPointer>
|
|
|
|
class QTableWidget;
|
|
class QGroupBox;
|
|
class QResizeEvent;
|
|
class QLabel;
|
|
class QPushButton;
|
|
class QTimer;
|
|
class QThread;
|
|
class VisionService;
|
|
class QDialog;
|
|
|
|
namespace Ui { class DashboardPage; }
|
|
|
|
class DashboardPage : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DashboardPage(QWidget *parent = nullptr);
|
|
~DashboardPage();
|
|
void addLog(const QString &type, const QString &module, const QString &content,
|
|
const QString &status);
|
|
void attachVisionService(VisionService *service);
|
|
|
|
signals:
|
|
void systemStateChanged(const QString &state);
|
|
void currentStepChanged(const QString &step);
|
|
void currentOrderChanged(const QString &orderNo);
|
|
void currentWorkpieceChanged(const QString &workpiece);
|
|
void deviceStatusChanged(const DeviceStatus &status);
|
|
void deviceCommunicationError(const QString &error);
|
|
void visionCycleChanged(const QJsonObject &cycle);
|
|
void visionProductionActiveChanged(bool active, bool maintenanceAllowed);
|
|
void recoveryDecisionSubmitted(const QJsonObject &decision);
|
|
void logRequested(const QString &type, const QString &module, const QString &action,
|
|
const QString &content, const QString &status);
|
|
|
|
private slots:
|
|
void onProductionSnapshot(const ProductionService::Snapshot &snapshot);
|
|
void startProduction();
|
|
void pauseProduction();
|
|
void stopProduction();
|
|
void clearAlarm();
|
|
void onProductionStateChanged(ProductionService::State state,
|
|
const QString &name);
|
|
void onCurrentWorkpieceChanged(int workpieceId, const QString &barcode);
|
|
void onCurrentWorkpieceSnapshotChanged(const Workpiece &workpiece);
|
|
void onCurrentPositionChanged(int trayNo, int slotNo);
|
|
void onProductionError(const QString &error);
|
|
void onProductionFinished(int orderId);
|
|
void onDeviceStatusChanged(const DeviceStatus &status);
|
|
void onProcessElapsedChanged(const QString &processStep, int elapsedMs);
|
|
void onTimeoutRecoveryRequired(const QString &state, const QString &message);
|
|
void onRecoveryCompleted(const QString &mode);
|
|
void recoverProduction();
|
|
void onRecoveryDecisionRequired(const QJsonObject &context);
|
|
void onRecoveryBusyChanged(bool busy);
|
|
void markWorkpieceNg();
|
|
|
|
protected:
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
private:
|
|
void loadCurrentOrder();
|
|
void updateProductionStats();
|
|
void updateRackSummary();
|
|
void updateRackSize();
|
|
void updateRecoveryButtons();
|
|
QString controlOperationContext(QString *identity) const;
|
|
bool confirmControlOperation(const QString &title, const QString &effect);
|
|
void refreshProcessRecords();
|
|
void updateCurrentProcessDuration(int elapsedMs);
|
|
static QString formatDuration(int elapsedMs);
|
|
|
|
Ui::DashboardPage *ui;
|
|
QGroupBox *rackBox;
|
|
QVector<QLabel *> rackTrayCells;
|
|
QLabel *deviceStatusLabel;
|
|
QLabel *inspectionMachineCell;
|
|
QLabel *robotCell;
|
|
QLabel *robotControlCabinetCell;
|
|
QLabel *mainControlCabinetCell;
|
|
QLabel *safetyDoor1Cell;
|
|
QLabel *safetyDoor2Cell;
|
|
QLabel *safetyDoor3Cell;
|
|
QLabel *alarmCell;
|
|
QPushButton *markNgButton;
|
|
QPushButton *stopButton;
|
|
QGroupBox *processBox;
|
|
QLabel *currentProcessLabel;
|
|
QLabel *processElapsedLabel;
|
|
QLabel *processTotalElapsedLabel;
|
|
QTableWidget *processTable;
|
|
QTimer *processRefreshTimer;
|
|
int currentProcessElapsedMs;
|
|
QThread *productionThread;
|
|
ProductionWorker *productionWorker;
|
|
ProductionService::State productionState;
|
|
ProductionService::Snapshot productionSnapshot;
|
|
int selectedOrderId = 0;
|
|
int currentOrderId;
|
|
bool currentOrderStartable;
|
|
bool currentOrderResumable;
|
|
Workpiece productionWorkpiece;
|
|
int productionTrayNo;
|
|
int productionSlotNo;
|
|
bool visionRecoveryRequired = false;
|
|
bool recoveryBusy = false;
|
|
bool controlConfirmationOpen = false;
|
|
QPointer<QDialog> recoveryDialog;
|
|
};
|
|
|
|
#endif // DASHBOARDPAGE_H
|