-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathQBatchProcess.cpp
225 lines (207 loc) · 7.59 KB
/
QBatchProcess.cpp
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#include "QBatchProcess.h"
QBatchProcess::QBatchProcess(QString files_path, QTextEdit *pQTextEdit, QString Method, QString Satsystem, QString TropDelay,
double CutAngle, bool isKinematic, QString Smooth_Str, bool isBackBatch, QString products, QString pppmodel_t)
{
// GNSS configure
mp_QTextEdit = pQTextEdit;
m_Method = Method;
m_Satsystem = Satsystem;
m_TropDelay = TropDelay;
m_CutAngle = CutAngle;
m_Product = products;
QString pre_name = "Final_";
if(products.contains("igs", Qt::CaseInsensitive))
pre_name = "Final_";
else
pre_name = "RT_";
// store data
M_ObsFiles_Path = files_path;
m_mkdir_name = pre_name + "allStations";
m_isRuned = false;
m_isKinematic = isKinematic;
m_Smooth_Str = Smooth_Str;
m_isBackBatch = isBackBatch;
m_PPPModel_Str = pppmodel_t;
}
QBatchProcess::~QBatchProcess()
{
}
//isDisplayEveryEpoch represent is disply every epoch information?(ENU or XYZ)
bool QBatchProcess::Run(bool isDisplayEveryEpoch)
{
if(m_isRuned) return false;
// clear data
m_AllStationsData.clear();
// distibute multiply .O files to destin_floder
QString mkdir = m_mkdir_name + PATHSEG;
QString destin_floder = M_ObsFiles_Path + PATHSEG + mkdir;
if(!distribute(M_ObsFiles_Path, destin_floder))
{
QString erro_info = "QBatchProcess::Run: distribute files Bad!";
ErroTrace(erro_info);
return false;
}
// ppp, Multiple sation PPP
// get and print floders path
QString multiple_station_floder = destin_floder;
QString disPlayQTextEdit = "Run multiply floder: " + multiple_station_floder;
autoScrollTextEdit(mp_QTextEdit, disPlayQTextEdit);// display for QTextEdit
// run batch PPP
QDir stations_floder(multiple_station_floder);
stations_floder.setFilter(QDir::Dirs);
// get floder path
QFileInfoList list_info = stations_floder.entryInfoList();
QStringList floder_list;
for(int i = 0; i < list_info.length(); i++)
{
QFileInfo file_info = list_info.at(i);
if(file_info.fileName() == "." || file_info.fileName() == "..") continue;
if(file_info.isDir())
floder_list.append(file_info.absoluteFilePath());
}
// get and save floders name
QStringList AllStations = stations_floder.entryList();
disPlayQTextEdit.clear();
for(int i = 0; i < AllStations.length(); i++ )
{
if(AllStations.at(i) == "." || AllStations.at(i) == "..") continue;
m_AllStations.append(AllStations.at(i));
disPlayQTextEdit += AllStations.at(i) + ", ";
}
// display floders name
disPlayQTextEdit = ENDLINE + "Stations Names: " + ENDLINE + disPlayQTextEdit + ENDLINE;
autoScrollTextEdit(mp_QTextEdit, disPlayQTextEdit);// display for QTextEdit
// juge is equal
if(m_AllStations.length() != floder_list.length())
{
QString erro_info = "QBatchProcess::Run: m_AllStations.length() != floder_list.length()";
ErroTrace(erro_info);
return false;
}
// run all stations
double allTime = 0;
int allStations_len = floder_list.length();
for(int i = 0;i < allStations_len; i++)
{
QString ppp_path = floder_list.at(i);
disPlayQTextEdit = "****** Will use PPP process station: " + m_AllStations.at(i) +
+ " ( " + QString::number(i+1) + "/" + QString::number(allStations_len) + " ) ******" +ENDLINE;
autoScrollTextEdit(mp_QTextEdit, disPlayQTextEdit);// display for QTextEdit
// run single station
QTime myTime;
myTime.start();//start the timer
PlotGUIData single_data;// get single station data
if(m_isBackBatch)
{
QPPPBackSmooth myPPP(ppp_path, mp_QTextEdit, m_Method, m_Satsystem, m_TropDelay, m_CutAngle, m_isKinematic, m_Smooth_Str, m_Product, m_PPPModel_Str);
myPPP.Run(isDisplayEveryEpoch);
myPPP.getRunResult(single_data);
m_AllStationsData.append(single_data);
}
else
{
QPPPModel myPPP(ppp_path, mp_QTextEdit, m_Method, m_Satsystem, m_TropDelay, m_CutAngle, m_isKinematic, m_Smooth_Str, m_Product, m_PPPModel_Str);
myPPP.Run(isDisplayEveryEpoch);
myPPP.getRunResult(single_data);
m_AllStationsData.append(single_data);
}
float m_diffTime = myTime.elapsed() / 1000.0;
// display time
disPlayQTextEdit = "Batch Process The Elapse Time: " + QString::number(m_diffTime) + "s" + ENDLINE;
autoScrollTextEdit(mp_QTextEdit, disPlayQTextEdit);// display for QTextEdit
allTime += m_diffTime;
}
allTime = allTime / 60; // transfer senconds to minutes
disPlayQTextEdit = "Good luck to you, all file success processed! use time: " + QString::number(allTime)
+ " minutes" + ENDLINE;
autoScrollTextEdit(mp_QTextEdit, disPlayQTextEdit);// display for QTextEdit
m_isRuned = true;
return true;
}
QStringList QBatchProcess::getStationNames()
{
QStringList temp;
if(m_isRuned)
return m_AllStations;
else
return temp;
}
void QBatchProcess::getStoreAllData(QVector< PlotGUIData > &all_SationData)
{// use pointer store for External data
all_SationData = m_AllStationsData;
}
// The edit box automatically scrolls, adding one row or more lines at a time.
void QBatchProcess::autoScrollTextEdit(QTextEdit *textEdit,QString &add_text)
{
if(textEdit == NULL) return ;
int m_Display_Max_line = 99999;
//Add line character and refresh edit box.
QString insertText = add_text + ENDLINE;
textEdit->insertPlainText(insertText);
//Keep the editor in the last line of the cursor.
QTextCursor cursor=textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(cursor);
textEdit->repaint();
//If you exceed a certain number of lines, empty it.
if(textEdit->document()->lineCount() > m_Display_Max_line)
{
textEdit->clear();
}
}
bool QBatchProcess::isDirExist(QString fullPath)
{
QDir dir(fullPath);
if(dir.exists())
{
return true;
}
else
{
bool ok = dir.mkpath(fullPath);//Create a multi-level directory
return ok;
}
return false;
}
bool QBatchProcess::isFileExist(QString fullFileName)
{
QFileInfo fileinfo(fullFileName);
if(fileinfo.isFile())
return true;
else
return false;
}
bool QBatchProcess::distribute(QString ofile_path, QString destin_floder)
{
if(!isDirExist(destin_floder))
return false;
QDir path_dir(ofile_path);
QStringList m_fliterList;
m_fliterList.clear();
m_fliterList.append("*.*o");
path_dir.setFilter(QDir::Files | QDir::NoSymLinks);
QStringList ObsFileNameList = path_dir.entryList(m_fliterList);
for(int i = 0; i < ObsFileNameList.length();i++)
{
QString obs_file_name = ObsFileNameList.at(i),
obs_file_path = ofile_path + PATHSEG + obs_file_name,
floder_path = destin_floder + ObsFileNameList.at(i) + PATHSEG,
destin_file_name = floder_path + obs_file_name;
if(!isDirExist(floder_path))
{
QString erro_info = "QBatchProcess::distribute: make dir error. " + PATHSEG + floder_path;
ErroTrace(erro_info);
return false;
}
if(!isFileExist(destin_file_name))
{
if(!QFile::copy(obs_file_path, destin_file_name))
{
QString erro_info = "QBatchProcess::distribute: move file error." + obs_file_path;
ErroTrace(erro_info);
return false;
}
}
}
return true;
}