source: trunk/FACT++/src/gcn.cc@ 19564

Last change on this file since 19564 was 19564, checked in by tbretz, 5 years ago
Make an entry in the Alert DB if a broken GCN package is received (broken means different formatting than what we expect)
File size: 26.6 KB
Line 
1#include <functional>
2#include <boost/algorithm/string/join.hpp>
3
4#include "Database.h"
5
6#include "Dim.h"
7#include "Event.h"
8#include "Shell.h"
9#include "StateMachineDim.h"
10#include "StateMachineAsio.h"
11#include "Connection.h"
12#include "LocalControl.h"
13#include "Configuration.h"
14#include "Console.h"
15#include "Converter.h"
16
17#include "tools.h"
18#include "../externals/nova.h"
19
20#include "HeadersGCN.h"
21#include "HeadersToO.h"
22
23#include <QtXml/QDomDocument>
24
25namespace ba = boost::asio;
26namespace bs = boost::system;
27namespace dummy = ba::placeholders;
28
29using namespace std;
30using namespace GCN;
31
32// ------------------------------------------------------------------------
33
34class ConnectionGCN : public Connection
35{
36private:
37 map<uint16_t, GCN::PaketType_t> fTypes;
38
39 vector<string> fEndPoints;
40 int fEndPoint;
41
42 bool fIsVerbose;
43 bool fDebugRx;
44
45 string fUri;
46
47 uint32_t fRxSize;
48 vector<char> fRxData;
49
50 Time fLastKeepAlive;
51
52 QString GetParamValue(const QDomElement &what, const string &name)
53 {
54 const QDomNodeList param = what.elementsByTagName("Param");
55 for (int i=0; i<param.count(); i++)
56 {
57 const QDomElement elem = param.at(i).toElement();
58 if (elem.attribute("name").toStdString()==name)
59 return elem.attribute("value");
60 }
61
62 return "";
63 }
64
65 GCN::PaketPtr GetType(const QDomElement &what)
66 {
67 const auto value = GetParamValue(what, "Packet_Type");
68 if (value.isEmpty())
69 return GCN::PaketTypes.end();
70
71 const uint16_t val = value.toUInt();
72
73 const auto it = GCN::PaketTypes.find(val);
74
75 if (it==GCN::PaketTypes.end())
76 Warn("Unknown paket type "+to_string(val)+".");
77
78 return it;
79
80 }
81
82 int ProcessXml(const QDomElement &root)
83 {
84 if (root.isNull())
85 return -255;
86
87 const string role = root.attribute("role", "").toStdString();
88 const string trn = root.tagName().toStdString();
89
90 // A full description can be found at http://voevent.dc3.com/schema/default.html
91
92 if (trn=="trn:Transport")
93 {
94 if (role=="iamalive")
95 {
96 const QDomElement orig = root.firstChildElement("Origin");
97 const QDomElement time = root.firstChildElement("TimeStamp");
98 if (orig.isNull() || time.isNull())
99 return -254;
100
101 fLastKeepAlive = Time(time.text().toStdString());
102
103 if (fIsVerbose)
104 {
105 Out() << Time().GetAsStr() << " ----- " << trn << " [" << role << "] -----" << endl;
106 Out() << " " << time.tagName().toStdString() << " = " << fLastKeepAlive.GetAsStr() << '\n';
107 Out() << " " << orig.tagName().toStdString() << " = " << orig.text().toStdString() << '\n';
108 Out() << endl;
109 }
110
111 return true;
112 }
113
114 return false;
115 }
116
117 ofstream fout("gcn.stream", ios::app);
118 fout << "------------------------------------------------------------------------------\n" << fRxData.data() << endl;
119
120 if (trn=="voe:VOEvent")
121 {
122 // WHAT: http://gcn.gsfc.nasa.gov/tech_describe.html
123 const QDomElement who = root.firstChildElement("Who");
124 const QDomElement what = root.firstChildElement("What");
125 const QDomElement when = root.firstChildElement("WhereWhen");
126 //const QDomElement how = root.firstChildElement("How");
127 //const QDomElement why = root.firstChildElement("Why");
128 //const QDomElement cite = root.firstChildElement("Citations");
129 //const QDomElement desc = root.firstChildElement("Description");
130 //const QDomElement ref = root.firstChildElement("Reference");
131 if (who.isNull() || what.isNull() || when.isNull())
132 return -253;
133
134 const auto ptype = GetType(what);
135
136 const QDomElement date = who.firstChildElement("Date");
137 const QDomElement author = who.firstChildElement("Author");
138 const QDomElement sname = author.firstChildElement("shortName");
139 const QDomElement desc = what.firstChildElement("Description");
140
141 const QDomElement obsdat = when.firstChildElement("ObsDataLocation");
142 const QDomElement obsloc = obsdat.firstChildElement("ObservationLocation");
143 const QDomElement coord = obsloc.firstChildElement("AstroCoords");
144
145 const QDomElement time = coord.firstChildElement("Time").firstChildElement("TimeInstant").firstChildElement("ISOTime");
146 const QDomElement pos2d = coord.firstChildElement("Position2D");
147 const QDomElement name1 = pos2d.firstChildElement("Name1");
148 const QDomElement name2 = pos2d.firstChildElement("Name2");
149 const QDomElement val2 = pos2d.firstChildElement("Value2");
150 const QDomElement c1 = val2.firstChildElement("C1");
151 const QDomElement c2 = val2.firstChildElement("C2");
152 const QDomElement errad = pos2d.firstChildElement("Error2Radius");
153
154 const auto &id = ptype->first;
155
156 if (id==0)
157 {
158 Warn("Packet ID = 0");
159 return -252;
160 }
161
162 // Gravitational wave event
163 const bool is_gw = id==150 || id==151 || id==152 || id==153 || id==164;
164
165 // Required keywords
166 vector<string> missing;
167 if (date.isNull())
168 missing.emplace_back("Date");
169 if (author.isNull())
170 missing.emplace_back("Author");
171 if (sname.isNull() && !is_gw)
172 missing.emplace_back("shortName");
173 if (obsdat.isNull())
174 missing.emplace_back("ObsDataLocation");
175 if (obsloc.isNull())
176 missing.emplace_back("ObservationLocation");
177 if (coord.isNull())
178 missing.emplace_back("AstroCoords");
179 if (time.isNull())
180 missing.emplace_back("Time/TimeInstant/ISOTime");
181 if (pos2d.isNull() && !is_gw)
182 missing.emplace_back("Position2D");
183 if (name1.isNull() && !is_gw)
184 missing.emplace_back("Name1");
185 if (name1.isNull() && !is_gw)
186 missing.emplace_back("Name2");
187 if (val2.isNull() && !is_gw)
188 missing.emplace_back("Value2");
189 if (c1.isNull() && !is_gw)
190 missing.emplace_back("C1");
191 if (c2.isNull() && !is_gw)
192 missing.emplace_back("C2");
193 if (errad.isNull() && !is_gw)
194 missing.emplace_back("Error2Radius");
195
196 if (!missing.empty())
197 {
198 Warn("Missing elements: "+boost::algorithm::join(missing, ", "));
199 return -id;
200 }
201
202 // 59/31: Konus LC / IPN raw [observation]
203 // 110: Fermi GBM (ART) [observation] (Initial) // Stop data taking
204 // 111: Fermi GBM (FLT) [observation] (after ~2s) // Start pointing/run
205 // 112: Fermi GBM (GND) [observation] (after 2-20s) // Refine pointing
206 // 115: Fermi GBM position [observation] (final ~hours)
207 //
208 // 51: Intergal pointdir [utility]
209 // 83: Swift pointdir [utility]
210 // 129: Fermi pointdir [utility]
211 //
212 // 2: Test coord ( 1) [test]
213 // 44: HETE test ( 41- 43) [test]
214 // 52: Integral SPIACS [test]
215 // 53: Integral Wakeup [test]
216 // 54: Integral refined [test]
217 // 55: Integral Offline [test]
218 // 56: Integral Weak [test]
219 // 82: BAT GRB pos test ( 61) [test]
220 // 109: AGILE GRB pos test (100-103) [test]
221 // 119: Fermi GRB pos test (111-113) [test]
222 // 124: Fermi LAT pos upd test (120-122) [test]
223 // 136: MAXI coord test ( 134) [test]
224 //
225 // Integral: RA=1.2343, Dec=2.3456
226 //
227
228 /*
229 54
230 ==
231 <Group name="Test_mpos" >
232 <Param name="Test_Notice" value="true" />
233 </Group>
234
235
236 82
237 ==
238 <Group name="Solution_Status" >
239 <Param name="Test_Submission" value="false" />
240 </Group>
241
242
243 115
244 ===
245 2013-07-20 19:04:13: TIME = 2013-07-20 02:46:40
246
247 <Group name="Trigger_ID" >
248 <Param name="Test_Submission" value="false" />
249 </Group>
250 */
251
252 // ----------------------------- Create Name ----------------------
253
254 const auto &paket = ptype->second;
255
256 string name;
257 bool prefix = true;
258
259 switch (id)
260 {
261 case 60:
262 case 61:
263 case 62:
264
265 case 110:
266 case 111:
267 case 112:
268 case 115:
269 name = GetParamValue(what, "TRIGGER_NUM").toStdString();
270 break;
271
272 case 123:
273 name = GetParamValue(what, "REF_NUM").toStdString();
274 break;
275
276 case 125:
277 name = GetParamValue(what, "SourceName").toStdString();
278 prefix = false;
279 break;
280
281 case 140:
282 name = GetParamValue(what, "TrigID").toStdString();
283 if (name[0]=='-')
284 name.erase(name.begin());
285 break;
286
287 case 157:
288 case 158:
289 {
290 const string event_id = GetParamValue(what, "event_id").toStdString();
291 const string run_id = GetParamValue(what, "run_id").toStdString();
292 name = event_id+"_"+run_id;
293 break;
294 }
295
296 // Missing ID
297 // case 51:
298 // case 83:
299 // case 119:
300 // case 129:
301 default:
302 name = GetParamValue(what, "TrigID").toStdString();
303 }
304
305 if (name.empty() || name=="0")
306 {
307 Warn("Missing ID... cannot create default source name... using date instead.");
308 name = Time().GetAsStr("%Y%m%d_%H%M%S");
309 prefix = true;
310 }
311
312 if (prefix)
313 name.insert(0, paket.instrument+"#");
314
315 // ----------------------------------------------------------------
316
317 const string unit = pos2d.attribute("unit").toStdString();
318
319 const double ra = c1.text().toDouble();
320 const double dec = c2.text().toDouble();
321 const double err = errad.text().toDouble();
322
323 const string n1 = name1.text().toStdString();
324 const string n2 = name2.text().toStdString();
325
326 const bool has_coordinates = n1=="RA" && n2=="Dec" && unit=="deg";
327
328 const std::set<int16_t> typelist =
329 {
330 51, // INTEGRAL_POINTDIR
331
332 53, // INTEGRAL_WAKEUP
333 54, // INTEGRAL_REFINED
334 55, // INTEGRAL_OFFLINE
335
336 // 56, // INTEGRAL_WEAK
337 // 59, // KONUS_LC
338
339 60, // SWIFT_BAT_GRB_ALERT
340 61, // SWIFT_BAT_GRB_POS_ACK
341 62, // SWIFT_BAT_GRB_POS_NACK
342
343 83, // SWIFT_POINTDIR
344
345 97, // SWIFT_BAT_QL_POS
346
347 100, // AGILE_GRB_WAKEUP
348 101, // AGILE_GRB_GROUND
349 102, // AGILE_GRB_REFINED
350
351 110, // FERMI_GBM_FLT_POS
352 111, // FERMI_GBM_GND_POS
353 112, // FERMI_GBM_LC
354 115, // FERMI_GBM_TRANS
355
356 123, // FERMI_LAT_TRANS
357 125, // FERMI_LAT_MONITOR
358
359 // 134, // MAXI_UNKNOWN
360 // 135, // MAXI_KNOWN
361 // 136, // MAXI_TEST
362
363 157, // AMON_ICECUBE_COINC
364 158, // AMON_ICECUBE_HESE
365
366 169, // AMON_ICECUBE_EHE
367 171, // HAWC_BURST_MONITOR
368 173, // ICECUBE_GOLD
369 174, // ICECUBE_BRONZE
370 };
371
372 const bool integral_test = role=="test" && id>=53 && id<=56;
373
374 const bool valid_id = typelist.find(id)!=typelist.end();
375
376 if (valid_id && has_coordinates && !integral_test)
377 {
378 const ToO::DataGRB data =
379 {
380 .type = id,
381 .ra = ra,
382 .dec = dec,
383 .err = err,
384 };
385
386 vector<char> dim(sizeof(ToO::DataGRB) + name.size() + 1);
387
388 memcpy(dim.data(), &data, sizeof(ToO::DataGRB));
389 memcpy(dim.data()+sizeof(ToO::DataGRB), name.c_str(), name.size());
390
391 Dim::SendCommandNB("SCHEDULER/GCN", dim);
392 Info("Sent ToO '"+name+"' ["+role+"]");
393 }
394
395 Out() << Time(date.text().toStdString()).GetAsStr() << " ----- " << sname.text().toStdString() << " [" << role << "]\n";
396 if (!desc.isNull())
397 Out() << "[" << desc.text().toStdString() << "]\n";
398 Out() << name << " [" << paket.name << ":" << id << "]: " << paket.description << endl;
399 Out() << left;
400 Out() << " " << setw(5) << "TIME" << "= " << Time(time.text().toStdString()).GetAsStr() << '\n';
401 Out() << " " << setw(5) << n1 << "= " << ra << unit << '\n';
402 Out() << " " << setw(5) << n2 << "= " << dec << unit << '\n';
403 Out() << " " << setw(5) << "ERR" << "= " << err << unit << '\n';
404 Out() << endl;
405
406 if (role=="observation")
407 {
408 return true;
409 }
410
411 if (role=="test")
412 {
413 return true;
414 }
415
416 if (role=="retraction")
417 {
418 return true;
419 }
420
421 if (role=="utility")
422 {
423 return true;
424 }
425
426 return false;
427 }
428
429 Out() << Time().GetAsStr() << " ----- " << trn << " [" << role << "] -----" << endl;
430
431 return false;
432 }
433
434 void HandleReceivedData(const bs::error_code& err, size_t bytes_received, int type)
435 {
436 // Do not schedule a new read if the connection failed.
437 if (bytes_received==0 || err)
438 {
439 if (err==ba::error::eof)
440 Warn("Connection closed by remote host (GCN).");
441
442 // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
443 // 125: Operation canceled
444 if (err && err!=ba::error::eof && // Connection closed by remote host
445 err!=ba::error::basic_errors::not_connected && // Connection closed by remote host
446 err!=ba::error::basic_errors::operation_aborted) // Connection closed by us
447 {
448 ostringstream str;
449 str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
450 Error(str);
451 }
452 PostClose(err!=ba::error::basic_errors::operation_aborted);
453 return;
454 }
455
456 if (type==0)
457 {
458 fRxSize = ntohl(fRxSize);
459 fRxData.assign(fRxSize+1, 0);
460 ba::async_read(*this, ba::buffer(fRxData, fRxSize),
461 boost::bind(&ConnectionGCN::HandleReceivedData, this,
462 dummy::error, dummy::bytes_transferred, 1));
463 return;
464 }
465
466 if (fDebugRx)
467 {
468 Out() << "------------------------------------------------------\n";
469 Out() << fRxData.data() << '\n';
470 Out() << "------------------------------------------------------" << endl;
471 }
472
473 QDomDocument doc;
474 if (!doc.setContent(QString(fRxData.data()), false))
475 {
476 Warn("Parsing of xml failed [0].");
477 Out() << "------------------------------------------------------\n";
478 Out() << fRxData.data() << '\n';
479 Out() << "------------------------------------------------------" << endl;
480 PostClose(true);
481 return;
482 }
483
484 if (fDebugRx)
485 Out() << "Parsed:\n-------\n" << doc.toString().toStdString() << endl;
486
487 const int rc = ProcessXml(doc.documentElement());
488 if (rc<0)
489 {
490 Warn("Parsing of xml failed [1].");
491 Out() << "------------------------------------------------------\n";
492 Out() << fRxData.data() << '\n';
493 Out() << "------------------------------------------------------" << endl;
494 //PostClose(false);
495
496 try
497 {
498 auto db = Database(fUri);
499
500 // Make an entry in the alter databse to issue a call
501 const string query =
502 "INSERT FlareTriggers SET\n"
503 " fTriggerInserted=Now(),\n"
504 " fNight="+to_string(Time().NightAsInt())+",\n"
505 " fRunID="+to_string(-rc)+",\n"
506 " fTriggerType=8";
507
508 auto q = db.query(query);
509 q.execute();
510 if (!q.info().empty())
511 Info(q.info());
512 }
513 catch (const mysqlpp::ConnectionFailed &e)
514 {
515 Error(e.what());
516 }
517
518 return;
519 }
520
521 if (!rc)
522 {
523 Out() << "------------------------------------------------------\n";
524 Out() << doc.toString().toStdString() << '\n';
525 Out() << "------------------------------------------------------" << endl;
526 }
527
528 StartRead();
529 }
530
531 void StartRead()
532 {
533 ba::async_read(*this, ba::buffer(&fRxSize, 4),
534 boost::bind(&ConnectionGCN::HandleReceivedData, this,
535 dummy::error, dummy::bytes_transferred, 0));
536 }
537
538 // This is called when a connection was established
539 void ConnectionEstablished()
540 {
541 StartRead();
542 }
543
544public:
545 ConnectionGCN(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
546 fIsVerbose(false), fDebugRx(false), fLastKeepAlive(Time::none)
547 {
548 SetLogStream(&imp);
549 }
550
551 void SetVerbose(bool b)
552 {
553 fIsVerbose = b;
554 }
555
556 void SetDebugRx(bool b)
557 {
558 fDebugRx = b;
559 Connection::SetVerbose(b);
560 }
561
562 void SetURI(const string &uri)
563 {
564 fUri = uri;
565 }
566
567 void SetEndPoints(const vector<string> &v)
568 {
569 fEndPoints = v;
570 fEndPoint = 0;
571 }
572
573 void StartConnect()
574 {
575 if (fEndPoints.size()>0)
576 SetEndpoint(fEndPoints[fEndPoint++%fEndPoints.size()]);
577 Connection::StartConnect();
578 }
579
580 bool IsValid()
581 {
582 return fLastKeepAlive.IsValid() ? Time()-fLastKeepAlive<boost::posix_time::minutes(2) : false;
583 }
584};
585
586// ------------------------------------------------------------------------
587
588#include "DimDescriptionService.h"
589
590class ConnectionDimGCN : public ConnectionGCN
591{
592private:
593
594public:
595 ConnectionDimGCN(ba::io_service& ioservice, MessageImp &imp) : ConnectionGCN(ioservice, imp)
596 {
597 }
598};
599
600// ------------------------------------------------------------------------
601
602template <class T, class S>
603class StateMachineGCN : public StateMachineAsio<T>
604{
605private:
606 S fGCN;
607
608 int Disconnect()
609 {
610 // Close all connections
611 fGCN.PostClose(false);
612
613 return T::GetCurrentState();
614 }
615
616 int Reconnect(const EventImp &evt)
617 {
618 // Close all connections to supress the warning in SetEndpoint
619 fGCN.PostClose(false);
620
621 // Now wait until all connection have been closed and
622 // all pending handlers have been processed
623 ba::io_service::poll();
624
625 if (evt.GetBool())
626 fGCN.SetEndpoint(evt.GetString());
627
628 // Now we can reopen the connection
629 fGCN.PostClose(true);
630
631 return T::GetCurrentState();
632 }
633
634 int Execute()
635 {
636 if (!fGCN.IsConnected())
637 return State::kDisconnected;
638
639 return fGCN.IsValid() ? State::kValid : State::kConnected;
640 }
641
642 bool CheckEventSize(size_t has, const char *name, size_t size)
643 {
644 if (has==size)
645 return true;
646
647 ostringstream msg;
648 msg << name << " - Received event has " << has << " bytes, but expected " << size << ".";
649 T::Fatal(msg);
650 return false;
651 }
652
653 int SetVerbosity(const EventImp &evt)
654 {
655 if (!CheckEventSize(evt.GetSize(), "SetVerbosity", 1))
656 return T::kSM_FatalError;
657
658 fGCN.SetVerbose(evt.GetBool());
659
660 return T::GetCurrentState();
661 }
662
663 int SetDebugRx(const EventImp &evt)
664 {
665 if (!CheckEventSize(evt.GetSize(), "SetDebugRx", 1))
666 return T::kSM_FatalError;
667
668 fGCN.SetDebugRx(evt.GetBool());
669
670 return T::GetCurrentState();
671 }
672
673public:
674 StateMachineGCN(ostream &out=cout) :
675 StateMachineAsio<T>(out, "GCN"), fGCN(*this, *this)
676 {
677 // State names
678 T::AddStateName(State::kDisconnected, "Disconnected",
679 "No connection to GCN.");
680 T::AddStateName(State::kConnected, "Connected",
681 "Connection to GCN established.");
682 T::AddStateName(State::kValid, "Valid",
683 "Connection valid (keep alive received within past 2min)");
684
685 // Verbosity commands
686 T::AddEvent("SET_VERBOSE", "B:1")
687 (bind(&StateMachineGCN::SetVerbosity, this, placeholders::_1))
688 ("set verbosity state"
689 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
690 T::AddEvent("SET_DEBUG_RX", "B:1")
691 (bind(&StateMachineGCN::SetDebugRx, this, placeholders::_1))
692 ("Set debux-rx state"
693 "|debug[bool]:dump received text and parsed text to console (yes/no)");
694
695
696 // Conenction commands
697 T::AddEvent("DISCONNECT", State::kConnected)
698 (bind(&StateMachineGCN::Disconnect, this))
699 ("disconnect from ethernet");
700 T::AddEvent("RECONNECT", "O", State::kDisconnected, State::kConnected)
701 (bind(&StateMachineGCN::Reconnect, this, placeholders::_1))
702 ("(Re)connect ethernet connection to FTM, a new address can be given"
703 "|[host][string]:new ethernet address in the form <host:port>");
704
705 fGCN.StartConnect();
706 }
707
708 void SetEndpoint(const string &url)
709 {
710 vector<string> v;
711 v.push_back(url);
712 fGCN.SetEndPoints(v);
713 }
714
715 int EvalOptions(Configuration &conf)
716 {
717 fGCN.SetVerbose(!conf.Get<bool>("quiet"));
718 fGCN.SetEndPoints(conf.Vec<string>("addr"));
719
720 fGCN.SetURI(conf.Get<string>("schedule-database"));
721
722 return -1;
723 }
724};
725
726// ------------------------------------------------------------------------
727
728#include "Main.h"
729
730template<class T, class S, class R>
731int RunShell(Configuration &conf)
732{
733 return Main::execute<T, StateMachineGCN<S, R>>(conf);
734}
735
736void SetupConfiguration(Configuration &conf)
737{
738 po::options_description control("FTM control options");
739 control.add_options()
740 ("no-dim", po_bool(), "Disable dim services")
741 ("addr,a", vars<string>(), "Network addresses of GCN server")
742 ("quiet,q", po_bool(true), "Disable printing contents of all received messages (except dynamic data) in clear text.")
743 ("schedule-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
744 ;
745
746 conf.AddOptions(control);
747}
748
749/*
750 Extract usage clause(s) [if any] for SYNOPSIS.
751 Translators: "Usage" and "or" here are patterns (regular expressions) which
752 are used to match the usage synopsis in program output. An example from cp
753 (GNU coreutils) which contains both strings:
754 Usage: cp [OPTION]... [-T] SOURCE DEST
755 or: cp [OPTION]... SOURCE... DIRECTORY
756 or: cp [OPTION]... -t DIRECTORY SOURCE...
757 */
758void PrintUsage()
759{
760 cout <<
761 "The gcn reads and evaluates alerts from the GCN network.\n"
762 "\n"
763 "The default is that the program is started without user intercation. "
764 "All actions are supposed to arrive as DimCommands. Using the -c "
765 "option, a local shell can be initialized. With h or help a short "
766 "help message about the usuage can be brought to the screen.\n"
767 "\n"
768 "Usage: gcn [-c type] [OPTIONS]\n"
769 " or: gcn [OPTIONS]\n";
770 cout << endl;
771}
772
773void PrintHelp()
774{
775 Main::PrintHelp<StateMachineGCN<StateMachine, ConnectionGCN>>();
776
777 /* Additional help text which is printed after the configuration
778 options goes here */
779
780 /*
781 cout << "bla bla bla" << endl << endl;
782 cout << endl;
783 cout << "Environment:" << endl;
784 cout << "environment" << endl;
785 cout << endl;
786 cout << "Examples:" << endl;
787 cout << "test exam" << endl;
788 cout << endl;
789 cout << "Files:" << endl;
790 cout << "files" << endl;
791 cout << endl;
792 */
793}
794
795int main(int argc, const char* argv[])
796{
797 Configuration conf(argv[0]);
798 conf.SetPrintUsage(PrintUsage);
799 Main::SetupConfiguration(conf);
800 SetupConfiguration(conf);
801
802 if (!conf.DoParse(argc, argv, PrintHelp))
803 return 127;
804
805 //try
806 {
807 // No console access at all
808 if (!conf.Has("console"))
809 {
810 if (conf.Get<bool>("no-dim"))
811 return RunShell<LocalStream, StateMachine, ConnectionGCN>(conf);
812 else
813 return RunShell<LocalStream, StateMachineDim, ConnectionDimGCN>(conf);
814 }
815 // Cosole access w/ and w/o Dim
816 if (conf.Get<bool>("no-dim"))
817 {
818 if (conf.Get<int>("console")==0)
819 return RunShell<LocalShell, StateMachine, ConnectionGCN>(conf);
820 else
821 return RunShell<LocalConsole, StateMachine, ConnectionGCN>(conf);
822 }
823 else
824 {
825 if (conf.Get<int>("console")==0)
826 return RunShell<LocalShell, StateMachineDim, ConnectionDimGCN>(conf);
827 else
828 return RunShell<LocalConsole, StateMachineDim, ConnectionDimGCN>(conf);
829 }
830 }
831 /*catch (std::exception& e)
832 {
833 cerr << "Exception: " << e.what() << endl;
834 return -1;
835 }*/
836
837 return 0;
838}
Note: See TracBrowser for help on using the repository browser.