1 | // %pacpus:license{
|
---|
2 | // This file is part of the PACPUS framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %pacpus:license}
|
---|
5 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
6 | /// @version $Id: main.cpp 81 2013-01-11 22:31:02Z kurdejma $
|
---|
7 |
|
---|
8 | #include <QApplication>
|
---|
9 |
|
---|
10 | #include "ui/pacpusmainwindow.h"
|
---|
11 | #include <Pacpus/kernel/ComponentManager.h>
|
---|
12 | #include <Pacpus/kernel/Log.h>
|
---|
13 | #include <Pacpus/kernel/PacpusApplication.h>
|
---|
14 | #include <QThread>
|
---|
15 | #ifdef WIN32
|
---|
16 | # define NOMINMAX
|
---|
17 | # include <windows.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | using namespace pacpus;
|
---|
21 | using namespace std;
|
---|
22 |
|
---|
23 | DECLARE_STATIC_LOGGER("pacpus.core.Sensor");
|
---|
24 |
|
---|
25 | static const string kDefaultXmlConfigFilePath = "PACPUS.xml";
|
---|
26 |
|
---|
27 | int main(int argc, char * argv[])
|
---|
28 | {
|
---|
29 | LogConfigurator::configureLoggerWithFile("PacpusSensor_%N.log");
|
---|
30 |
|
---|
31 | PacpusApplication app(argc, argv);
|
---|
32 |
|
---|
33 | // faire une boucle pour charger tous les plugins
|
---|
34 | // il faudrait faire une classe supplementaire integree a PacpusLib /home/gdherbom/dev/pacpus/pacpusbase/pacpusbin/trunk/
|
---|
35 | /* QPluginLoader loader("libVelodyneHDL64S2.so");
|
---|
36 | qDebug() << loader.errorString();
|
---|
37 | qDebug() << loader.load();
|
---|
38 | qDebug() << loader.errorString();
|
---|
39 | QObject * plugin = loader.instance();
|
---|
40 |
|
---|
41 | qDebug() << "Loading plugin:" << qobject_cast<PacpusPluginInterface*>(plugin)->name() << "associated to file:" << loader.fileName();
|
---|
42 | qDebug() << loader.errorString();
|
---|
43 | */
|
---|
44 | ComponentManager * mgr = ComponentManager::getInstance();
|
---|
45 | LOG_DEBUG("main : " << mgr);
|
---|
46 |
|
---|
47 | #ifdef WIN32
|
---|
48 | timeBeginPeriod(1);
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | string configFilePath;
|
---|
52 | if (argc > 1) {
|
---|
53 | configFilePath = argv[1];
|
---|
54 | } else {
|
---|
55 | configFilePath = kDefaultXmlConfigFilePath;
|
---|
56 | LOG_WARN("no XML config file specified. Using default: " << configFilePath.c_str());
|
---|
57 | }
|
---|
58 | LOG_INFO("loading file '" << configFilePath.c_str() << "'");
|
---|
59 | mgr->loadComponents(configFilePath.c_str());
|
---|
60 |
|
---|
61 | PacpusMainWindow window;
|
---|
62 | window.show();
|
---|
63 | LOG_INFO("Current Thread " << QThread::currentThread());
|
---|
64 | // save application exit status
|
---|
65 | int exitStatus = app.exec();
|
---|
66 | // stop all components before exiting app
|
---|
67 | mgr->stop();
|
---|
68 |
|
---|
69 | mgr->destroy();
|
---|
70 |
|
---|
71 | #ifdef WIN32
|
---|
72 | timeEndPeriod(1);
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | // return application exit status
|
---|
76 | return exitStatus;
|
---|
77 | }
|
---|