-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormPlot.h
109 lines (78 loc) · 2.78 KB
/
FormPlot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef FORMPLOT_H
#define FORMPLOT_H
#include <QMainWindow>
#include <QCompleter>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <qcustomplot.h>
#define SERVER_IP "archiver.sesame.org.jo"
#define RETRIEVAL_PORT "17668"
#define MGMT_PORT "17665"
#define REQUEST_DATA_CSV "http://" SERVER_IP ":" RETRIEVAL_PORT "/retrieval/data/getData.csv?pv=%5_%4(%1)&from=%2&to=%3"
#define REQUEST_DATA_LIVE "http://" SERVER_IP ":" RETRIEVAL_PORT "/retrieval/data/getData.csv?pv=firstFill_1(%1)&from=%2&to=%3"
#define REQUEST_DATA_MAT "http://" SERVER_IP ":" RETRIEVAL_PORT "/retrieval/data/getData.mat?pv=%1&from=%2&to=%3"
#define REQUEST_PV_DETAILS "http://" SERVER_IP ":" MGMT_PORT "/mgmt/bpl/getPVDetails?pv=%1"
#define REQUEST_PVS_LIST "http://" SERVER_IP ":" MGMT_PORT "/mgmt/bpl/getAllPVs?limit=-1"
#define ISO_DATETIME "yyyy-MM-ddThh:mm:ss.zzzZ"
#define STANDARD_DATETIME "hh:mm:ss dd/MM/yyyy"
#define AXIS_COUNT 5
#define GRAPH_COUNT 16
#define LIVE_DATA_PERIOD 900
struct data_sample
{
int timestamp;
double value;
};
namespace Ui {
class FormPlot;
}
class FormPlot : public QMainWindow
{
Q_OBJECT
public:
explicit FormPlot(QStringList pvs, QDateTime from, QDateTime to, int sampling, QString processingMethod, QWidget *parent = nullptr);
~FormPlot();
void plotData();
void sendRequest();
QString getUnit(QString pv);
void fillPVList();
void setTickerFormat(uint duration, QSharedPointer<QCPAxisTickerDateTime> ticker);
void saveScreenShot();
private slots:
void networkReplyReceived(QNetworkReply *reply);
void on_btnPlot_clicked();
void on_btnAdd_clicked();
void on_btnResetAxis_clicked();
void on_btnResetGraph_clicked();
void on_btnScreenshot_clicked();
void onPlotDragFinished(QMouseEvent *event);
void onPlotZoomFinished(QWheelEvent* event);
void onMouseMove(QMouseEvent* event);
void onLegendClicked(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
void on_btnExportCSV_clicked();
void keyPressEvent(QKeyEvent* key);
void on_btnLive_clicked();
public slots:
void onLiveDataStart();
private:
Ui::FormPlot *ui;
int sampling;
int selectedIndex;
QStringList pvList;
QStringList allPVs;
QCompleter* completer;
QList<QList<data_sample>> pvData;
QNetworkAccessManager* network;
QNetworkRequest request;
QString processingMethod;
QColor colors[GRAPH_COUNT];
QMap<QString, QCPAxis*> axisMap;
QSharedPointer<QCPAxisTickerDateTime> dateTicker;
QString imageFileName;
QCPAbstractLegendItem* selectedItem;
QString selectedGraph;
QTimer* liveData;
QCPAxisRect* plotAxis;
};
#endif // FORMPLOT_H