2024-11-01 17:40:37 +08:00
|
|
|
#ifndef COALDISTRIBUTBARCHARTWIDGET_H
|
|
|
|
#define COALDISTRIBUTBARCHARTWIDGET_H
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QObject>
|
2024-11-05 17:48:05 +08:00
|
|
|
#include <QSettings>
|
2024-11-01 17:40:37 +08:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <QDateTimeAxis>
|
2024-11-04 18:11:55 +08:00
|
|
|
#include <QNetworkProxy>
|
|
|
|
#include <QTcpSocket>
|
2024-11-01 17:40:37 +08:00
|
|
|
#include <QtCharts/QBarSeries>
|
|
|
|
#include <QtCharts/QBarSet>
|
|
|
|
#include <QtCharts/QCategoryAxis>
|
|
|
|
#include <QtCharts/QChartView>
|
|
|
|
#include <QtCharts/QValueAxis>
|
|
|
|
|
|
|
|
QT_CHARTS_USE_NAMESPACE
|
|
|
|
|
|
|
|
class CoalDistributBarChartWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit CoalDistributBarChartWidget(QWidget* parent = nullptr);
|
2024-11-04 18:11:55 +08:00
|
|
|
~CoalDistributBarChartWidget();
|
2024-11-01 17:40:37 +08:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void updateChart();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initializeChart();
|
|
|
|
|
|
|
|
void setupTimer();
|
|
|
|
|
2024-11-04 18:11:55 +08:00
|
|
|
/**
|
|
|
|
* @brief connectTCPSocket 连接到TCP服务
|
|
|
|
*/
|
|
|
|
void connectTCPSocket();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getCoalRatioByTCPSocket通过TCP协议获取煤量占比
|
|
|
|
* @return 煤量占比
|
|
|
|
*/
|
|
|
|
int getCoalRatioByTCPSocket();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief createModbusTcpRequest 构建ModbusTCP报文
|
|
|
|
* @return 返回报文
|
|
|
|
*/
|
|
|
|
QByteArray createModbusTcpRequest();
|
|
|
|
|
2024-11-01 17:40:37 +08:00
|
|
|
private:
|
|
|
|
QChart* m_chart;
|
|
|
|
QChartView* m_chartView;
|
|
|
|
QBarSeries* m_series;
|
|
|
|
QTimer* m_timer;
|
|
|
|
|
|
|
|
QDateTimeAxis* m_axisX;
|
|
|
|
|
2024-11-04 18:11:55 +08:00
|
|
|
QBarSet* m_set;
|
|
|
|
|
|
|
|
QTcpSocket* m_tcpSocket;
|
2024-11-05 17:48:05 +08:00
|
|
|
|
|
|
|
QSettings* m_systemSetting;
|
2024-11-01 17:40:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COALDISTRIBUTBARCHARTWIDGET_H
|