-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.cpp
More file actions
217 lines (173 loc) · 6.58 KB
/
main.cpp
File metadata and controls
217 lines (173 loc) · 6.58 KB
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
/*
* VieSched++ Very Long Baseline Interferometry (VLBI) Scheduling Software
* Copyright (C) 2018 Matthias Schartner
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <chrono>
// clang-format off
#include "VieSchedpp.h"
// clang-format on
#include "Input/LogParser.h"
#include "Input/SkdParser.h"
#ifdef SIMULATOR_MODE
#include "Simulator/Solver.h"
#endif
/**
* @file main.cpp
* @brief main file
*
* @author Matthias Schartner
* @date 21.06.2017
*/
/**
* @namespace VieVS
* @brief namespace VieVS is used for all defined classes.
* @author Matthias Schartner
*/
/**
* @brief welcome message
* @author Matthias Schartner
*
* Displays a welcome message in case you did not pass any arguments
*/
void welcome();
///**
// * @brief error message in case of termination
// * @author Matthias Schartner
// */
//void VieSchedppTerminate() {
// std::cerr << "VieSched++ crashed. Check the log file for more information. In case you cannot solve the issue "
// "yourself contact matthias.schartner@geo.tuwien.ac.at\n";
//}
/**
* @brief main function
* @author Matthias Schartner
*
* pass path to VieSchedpp.xml file as argument.
* This file will then be processed
*
* @param argc number of arguments
* @param argv argument list
* @return return type
*/
int main( int argc, char *argv[] ) {
// std::set_terminate( VieSchedppTerminate );
if ( argc == 1 ) {
welcome();
return 0;
} else if ( argc == 2 ) {
std::string arg = argv[1];
if ( arg == "--version" || arg == "-v" ) {
std::string versionNr = VieVS::util::version();
std::cout << versionNr << std::endl;
return 0;
}
if ( arg == "--help" || arg == "-h" ) {
std::cout << "pass path to a VieSchedpp.xml file as first input argument" << std::endl;
std::cout << "e.g. \"./VieSchedpp path/to/VieSchedpp.xml\"" << std::endl;
return 0;
}
// main scheduling program
auto start = std::chrono::high_resolution_clock::now();
// V1: standard usage:
std::cout << "Processing file: " << arg << "\n";
VieVS::VieSchedpp mainScheduler( arg );
mainScheduler.run();
auto finish = std::chrono::high_resolution_clock::now();
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>( finish - start );
long long int usec = microseconds.count();
std::string t = "execution time: " + VieVS::util::milliseconds2string( usec );
#ifdef VIESCHEDPP_LOG
BOOST_LOG_TRIVIAL( info ) << t;
#else
std::cout << "[info] " << t;
#endif
std::cout << std::endl;
} else if ( argc == 3 ) {
std::string flag = argv[1];
std::string file = argv[2];
if ( flag == "--snr" ) {
VieVS::SkdParser mySkdParser( file );
mySkdParser.read();
VieVS::Scheduler sched = mySkdParser.createScheduler();
VieVS::Output out(sched);
out.writeSnrTable();
}
if (flag == "--txt") {
VieVS::SkdParser mySkdParser( file );
mySkdParser.read();
VieVS::Scheduler sched = mySkdParser.createScheduler();
VieVS::Output out( sched );
out.writeOperationsNotes();
}
if ( flag == "--ngs" ) {
VieVS::SkdParser mySkdParser( file );
mySkdParser.read();
VieVS::Scheduler sched = mySkdParser.createScheduler();
VieVS::Output out( sched );
out.writeNGS();
}
} else if (argc == 4) {
std::string xml = argv[1];
std::string flag = argv[2];
std::string file = argv[3];
if (flag == "--sim") {
#ifdef SIMULATOR_MODE
VieVS::SkdParser mySkdParser(file);
mySkdParser.read();
boost::property_tree::ptree tree;
std::ifstream is(xml);
boost::property_tree::read_xml(is, tree, boost::property_tree::xml_parser::trim_whitespace);
VieVS::Scheduler sched = mySkdParser.createScheduler(tree);
VieVS::Output out( sched );
VieVS::Simulator simulator( out );
simulator.start();
VieVS::Solver solver( simulator );
solver.start();
solver.simSummary();
#else
std::cout << "VieSched++ was compiled without simulations. "
"You cannot run simulations. Recompile it without SIMULATOR_MODE.\n";
#endif
}
if ( flag == "--sat" ) {
VieVS::SkdParser mySkdParser( file );
mySkdParser.read();
boost::property_tree::ptree tree;
std::ifstream is( xml );
boost::property_tree::read_xml( is, tree, boost::property_tree::xml_parser::trim_whitespace );
VieVS::Scheduler sched = mySkdParser.createScheduler( tree );
VieVS::Initializer initializer( xml );
std::ofstream dummy;
initializer.createSatellitesToAvoid( dummy );
sched.checkSatelliteAvoidance();
}
}
return 0;
}
void welcome() {
std::cout << " __ ___ ____ _ _ \n"
" \\ \\ / (_) ___/ ___| ___| |__ ___ __| | _ _ \n"
" \\ \\ / /| |/ _ \\___ \\ / __| '_ \\ / _ \\/ _` |_| |_ _| |_ \n"
" \\ V / | | __/___) | (__| | | | __/ (_| |_ _|_ _|\n"
" \\_/ |_|\\___|____/ \\___|_| |_|\\___|\\__,_| |_| |_| \n"
" \n"
"Welcome to VieSched++ " << VieVS::util::version() << "\n\n"
"In case this was a test to verify the connection between the GUI and VieSched++ then you were "
"successful!\n"
"In case you want to run VieSched++ from a terminal pass the path to the VieSchedpp.xml file as an "
"argument to the executable. \n"
"e.g.: ./VieSchedpp path/to/VieSchedpp.xml\n";
}