Files
ssp/pages/dashboardpage.h
T

135 lines
4.6 KiB
C++
Raw Normal View History

2026-08-18 09:40:43 +08:00
#ifndef DASHBOARDPAGE_H
#define DASHBOARDPAGE_H
2026-08-20 11:22:55 +08:00
#include "../services/productionworker.h"
2026-08-18 09:40:43 +08:00
#include <QWidget>
#include <QVector>
#include <QPointer>
2026-08-18 09:40:43 +08:00
class QTableWidget;
class QGroupBox;
class QResizeEvent;
2026-11-11 10:44:12 +08:00
class QEvent;
2026-08-18 09:40:43 +08:00
class QLabel;
class QPushButton;
class QTimer;
2026-08-20 11:22:55 +08:00
class QThread;
2026-10-27 22:16:55 +08:00
class VisionService;
class QDialog;
2026-08-18 09:40:43 +08:00
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);
2026-10-27 22:16:55 +08:00
void attachVisionService(VisionService *service);
2026-08-18 09:40:43 +08:00
signals:
void systemStateChanged(const QString &state);
void currentStepChanged(const QString &step);
2026-08-24 17:28:59 +08:00
void currentOrderChanged(const QString &orderNo);
void currentWorkpieceChanged(const QString &workpiece);
void deviceStatusChanged(const DeviceStatus &status);
void deviceCommunicationError(const QString &error);
2026-10-27 22:16:55 +08:00
void visionCycleChanged(const QJsonObject &cycle);
void visionProductionActiveChanged(bool active, bool maintenanceAllowed);
void recoveryDecisionSubmitted(const QJsonObject &decision);
void productionDataChanged();
2026-08-18 09:40:43 +08:00
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);
2026-08-18 09:40:43 +08:00
void startProduction();
void pauseProduction();
void stopProduction();
void clearAlarm();
void onResetContextReady(const QJsonObject &context);
void onAlarmOperationBusyChanged(bool busy);
void onAlarmOperationFinished(bool resetRequested, bool success, const QString &message);
2026-08-18 09:40:43 +08:00
void onProductionStateChanged(ProductionService::State state,
const QString &name);
void onCurrentWorkpieceChanged(int workpieceId, const QString &barcode);
2026-08-20 11:22:55 +08:00
void onCurrentWorkpieceSnapshotChanged(const Workpiece &workpiece);
void onCurrentPositionChanged(int trayNo, int slotNo);
2026-08-18 09:40:43 +08:00
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);
2026-08-18 09:40:43 +08:00
void markWorkpieceNg();
protected:
2026-11-11 10:44:12 +08:00
bool eventFilter(QObject *watched, QEvent *event) override;
2026-08-18 09:40:43 +08:00
void resizeEvent(QResizeEvent *event) override;
private:
2026-10-19 11:17:12 +08:00
void loadCurrentOrder();
2026-08-18 09:40:43 +08:00
void updateProductionStats();
2026-08-24 17:28:59 +08:00
void updateRackSummary();
2026-11-11 10:44:12 +08:00
void updateDeviceLayout();
2026-08-18 09:40:43 +08:00
void updateRecoveryButtons();
2026-10-30 16:43:24 +08:00
QString controlOperationContext(QString *identity) const;
bool confirmControlOperation(const QString &title, const QString &effect);
2026-08-18 09:40:43 +08:00
void refreshProcessRecords();
void updateCurrentProcessDuration(int elapsedMs);
static QString formatDuration(int elapsedMs);
Ui::DashboardPage *ui;
2026-11-11 10:44:12 +08:00
QWidget *layoutCanvas;
QLabel *layoutBackground;
2026-08-18 09:40:43 +08:00
QGroupBox *rackBox;
QVector<QLabel *> rackTrayCells;
QLabel *deviceStatusLabel;
2026-08-24 17:28:59 +08:00
QLabel *inspectionMachineCell;
QLabel *robotCell;
QLabel *robotControlCabinetCell;
QLabel *mainControlCabinetCell;
QLabel *safetyDoor1Cell;
QLabel *safetyDoor2Cell;
QLabel *alarmCell;
2026-08-18 09:40:43 +08:00
QPushButton *markNgButton;
QPushButton *stopButton;
QGroupBox *processBox;
QLabel *currentProcessLabel;
QLabel *processElapsedLabel;
QLabel *processTotalElapsedLabel;
QTableWidget *processTable;
QTimer *processRefreshTimer;
int currentProcessElapsedMs;
2026-08-20 11:22:55 +08:00
QThread *productionThread;
ProductionWorker *productionWorker;
ProductionService::State productionState;
ProductionService::Snapshot productionSnapshot;
int selectedOrderId = 0;
2026-10-19 11:17:12 +08:00
int currentOrderId;
bool currentOrderStartable;
bool currentOrderResumable;
2026-11-09 18:16:54 +08:00
DeviceStatus deviceStatus;
2026-08-20 11:22:55 +08:00
Workpiece productionWorkpiece;
int productionTrayNo;
int productionSlotNo;
2026-10-27 22:16:55 +08:00
bool visionRecoveryRequired = false;
bool recoveryBusy = false;
2026-10-30 16:43:24 +08:00
bool controlConfirmationOpen = false;
bool alarmContextPending = false;
bool alarmRequestPending = false;
bool alarmOperationBusy = false;
bool closing = false;
QPointer<QDialog> alarmDialog;
QPointer<QDialog> recoveryDialog;
2026-08-18 09:40:43 +08:00
};
#endif // DASHBOARDPAGE_H