mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Initial commit
This commit is contained in:
6
blacklib/samples/CMakeLists.txt
Normal file
6
blacklib/samples/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
ADD_SUBDIRECTORY(Logging)
|
||||
ADD_SUBDIRECTORY(com_server)
|
||||
ADD_SUBDIRECTORY(com_client)
|
||||
ADD_SUBDIRECTORY(Geodetic2Ecef)
|
||||
ADD_SUBDIRECTORY(interpolator)
|
||||
ADD_SUBDIRECTORY(config)
|
||||
6
blacklib/samples/Geodetic2Ecef/CMakeLists.txt
Normal file
6
blacklib/samples/Geodetic2Ecef/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB SRC *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(sample_Geodetic2Ecef ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_Geodetic2Ecef blackmisc blackcore ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_Geodetic2Ecef PROPERTIES PROJECT_LABEL "Samples - Geodetic to Ecef")
|
||||
53
blacklib/samples/Geodetic2Ecef/main.cpp
Normal file
53
blacklib/samples/Geodetic2Ecef/main.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QElapsedTimer>
|
||||
#include <blackmisc/debug.h>
|
||||
#include <iostream>
|
||||
#include <conio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <blackcore/ecef.h>
|
||||
#include <blackcore/vector_geo.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
|
||||
QElapsedTimer timer;
|
||||
qint64 duration;
|
||||
|
||||
double lat = 27.999999, lon = 86.999999, h = 8820.999999; // Mt Everest
|
||||
|
||||
BlackCore::CEcef mediumvec;
|
||||
BlackCore::CVectorGeo startVec(lat, lon, h);
|
||||
startVec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
BlackCore::CVectorGeo endVec;
|
||||
|
||||
timer.start();
|
||||
mediumvec = startVec.toCartesian();
|
||||
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
mediumvec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
timer.restart();
|
||||
endVec = mediumvec.toGeodetic();
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
endVec.print();
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
6
blacklib/samples/Logging/CMakeLists.txt
Normal file
6
blacklib/samples/Logging/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB SRC *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(sample_logging ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_logging blackmisc ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_logging PROPERTIES PROJECT_LABEL "Samples - Logging")
|
||||
18
blacklib/samples/Logging/main.cpp
Normal file
18
blacklib/samples/Logging/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <QCoreApplication>
|
||||
#include <blackmisc/debug.h>
|
||||
#include <blackcore/constants.h>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
|
||||
bInfo << "This is a Info log message";
|
||||
bWarning << "This is a bWarning log message";
|
||||
bError << "This is a bError log message";
|
||||
bDebug << "This is a bDebug log message";
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
9
blacklib/samples/com_client/CMakeLists.txt
Normal file
9
blacklib/samples/com_client/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
FILE(GLOB sample_com_client_SOURCES *.cpp)
|
||||
SET(sample_com_client_HEADERS client.h)
|
||||
|
||||
QT4_WRAP_CPP(sample_com_client_HEADERS_MOC ${sample_com_client_HEADERS})
|
||||
|
||||
ADD_EXECUTABLE(sample_com_client ${sample_com_client_SOURCES} ${sample_com_client_HEADERS_MOC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_com_client blackmisc ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_com_client PROPERTIES PROJECT_LABEL "Samples - Com client")
|
||||
36
blacklib/samples/com_client/client.cpp
Normal file
36
blacklib/samples/com_client/client.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <blackmisc/debug.h>
|
||||
#include "client.h"
|
||||
#include <blackmisc/message.h>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
Client::Client(QObject *parent) : QObject(parent)
|
||||
{
|
||||
connect(&comclient, SIGNAL(doError(QAbstractSocket::SocketError,QString)), this, SLOT(onError(QAbstractSocket::SocketError,QString)));
|
||||
connect(&comclient, SIGNAL(doConnected()), this, SLOT(onClientConnected()));
|
||||
|
||||
QString address = "127.0.0.1";
|
||||
comclient.connectTo(address, 6809);
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
}
|
||||
|
||||
void Client::onError(QAbstractSocket::SocketError error, QString message)
|
||||
{
|
||||
bWarning << "Socket error!";
|
||||
}
|
||||
|
||||
void Client::onClientConnected()
|
||||
{
|
||||
QByteArray message_data;
|
||||
QDataStream out(&message_data, QIODevice::WriteOnly);
|
||||
|
||||
IMessage* testmsg = new TestMessage();
|
||||
|
||||
*testmsg >> out;
|
||||
|
||||
comclient.sendMessage(testmsg->getID(), message_data);
|
||||
delete testmsg;
|
||||
}
|
||||
19
blacklib/samples/com_client/client.h
Normal file
19
blacklib/samples/com_client/client.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <blackmisc/message_system.h>
|
||||
#include <blackmisc/com_client.h>
|
||||
|
||||
class Client : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Client(QObject *parent = NULL);
|
||||
~Client();
|
||||
|
||||
protected slots:
|
||||
|
||||
void onError(QAbstractSocket::SocketError,QString);
|
||||
void onClientConnected();
|
||||
|
||||
private:
|
||||
BlackMisc::CComClient comclient;
|
||||
};
|
||||
16
blacklib/samples/com_client/main.cpp
Normal file
16
blacklib/samples/com_client/main.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include <blackmisc/context.h>
|
||||
#include "client.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Client client;
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
9
blacklib/samples/com_server/CMakeLists.txt
Normal file
9
blacklib/samples/com_server/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
FILE(GLOB sample_com_server_SOURCES *.cpp)
|
||||
SET(sample_com_server_HEADERS server.h)
|
||||
|
||||
QT4_WRAP_CPP(sample_com_server_HEADERS_MOC ${sample_com_server_HEADERS})
|
||||
|
||||
ADD_EXECUTABLE(sample_com_server ${sample_com_server_SOURCES} ${sample_com_server_HEADERS_MOC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_com_server blackmisc ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_com_server PROPERTIES PROJECT_LABEL "Samples - Com Server")
|
||||
16
blacklib/samples/com_server/main.cpp
Normal file
16
blacklib/samples/com_server/main.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include <blackmisc/context.h>
|
||||
#include "server.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Server server;
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
39
blacklib/samples/com_server/server.cpp
Normal file
39
blacklib/samples/com_server/server.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <blackmisc/debug.h>
|
||||
#include "server.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
Server::Server(QObject *parent) : QObject(parent)
|
||||
{
|
||||
QHostAddress local = QHostAddress(QHostAddress::LocalHost);
|
||||
|
||||
server.Host(local, 6809);
|
||||
|
||||
connect(&server, SIGNAL(doMessageReceived(QString &, QByteArray&)), this, SLOT(onData(QString &, QByteArray&)));
|
||||
|
||||
CMessageSystem myMessageSystem;
|
||||
|
||||
bInfo << "Com Server running. \n";
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
{
|
||||
}
|
||||
|
||||
void Server::onData(QString &messageID, QByteArray &message)
|
||||
{
|
||||
BlackMisc::IMessage* test = BlackMisc::CMessageFactory::getInstance().create(messageID);
|
||||
QDataStream stream(&message, QIODevice::ReadOnly);
|
||||
|
||||
bAssert (test);
|
||||
*test << stream;
|
||||
|
||||
CMessageDispatcher::getInstance().append(test);
|
||||
CMessageDispatcher::getInstance().dispatch();
|
||||
|
||||
}
|
||||
|
||||
void TestMessageHandler::onTestMessage(const TestMessage *testmessage)
|
||||
{
|
||||
bDebug << "Message ID: " << testmessage->getID() << " with text: " << testmessage->getTestString();
|
||||
}
|
||||
32
blacklib/samples/com_server/server.h
Normal file
32
blacklib/samples/com_server/server.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <blackmisc/message_system.h>
|
||||
#include <blackmisc/com_server.h>
|
||||
|
||||
class TestMessageHandler : public BlackMisc::CMessageHandler
|
||||
{
|
||||
public:
|
||||
TestMessageHandler()
|
||||
{
|
||||
registerMessageFunction(this, &TestMessageHandler::onTestMessage);
|
||||
}
|
||||
private:
|
||||
|
||||
void onTestMessage(const BlackMisc::TestMessage *testmessage);
|
||||
|
||||
};
|
||||
|
||||
class Server : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Server(QObject *parent = NULL);
|
||||
~Server();
|
||||
|
||||
protected slots:
|
||||
|
||||
void onData(QString &messageID, QByteArray& message);
|
||||
|
||||
private:
|
||||
BlackMisc::CComServer server;
|
||||
TestMessageHandler myHandler;
|
||||
};
|
||||
6
blacklib/samples/config/CMakeLists.txt
Normal file
6
blacklib/samples/config/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB SRC *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(sample_config ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_config blackmisc ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_config PROPERTIES PROJECT_LABEL "Samples - Config")
|
||||
0
blacklib/samples/config/config/config.ini
Normal file
0
blacklib/samples/config/config/config.ini
Normal file
3
blacklib/samples/config/config/position.cfg
Normal file
3
blacklib/samples/config/config/position.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
Longitude=48.999999
|
||||
Latitude=11.9999999
|
||||
Altitude=300
|
||||
2
blacklib/samples/config/config/test.cfg
Normal file
2
blacklib/samples/config/config/test.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
TestString = Hallo
|
||||
TestString2 = Welt
|
||||
27
blacklib/samples/config/main.cpp
Normal file
27
blacklib/samples/config/main.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <QCoreApplication>
|
||||
#include <blackmisc/debug.h>
|
||||
#include <blackmisc/config_manager.h>
|
||||
#include <blackmisc/config.h>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
|
||||
CConfigManager::getInstance().setConfigPath(QString("config"));
|
||||
if (!CConfigManager::getInstance().readConfig())
|
||||
{
|
||||
bWarning << "To run this sample, there must be a config folder";
|
||||
bWarning << "in the same directory, containing *.cfg files.";
|
||||
}
|
||||
|
||||
CConfig *myConfig = CConfigManager::getInstance().getConfig("position");
|
||||
bAssert(myConfig);
|
||||
myConfig->display();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
6
blacklib/samples/interpolator/CMakeLists.txt
Normal file
6
blacklib/samples/interpolator/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE(GLOB SRC *.cpp)
|
||||
|
||||
ADD_EXECUTABLE(sample_interpolator ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sample_interpolator blackmisc blackcore ${QT_LIBRARIES})
|
||||
SET_TARGET_PROPERTIES(sample_interpolator PROPERTIES PROJECT_LABEL "Samples - Interpolator")
|
||||
76
blacklib/samples/interpolator/main.cpp
Normal file
76
blacklib/samples/interpolator/main.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <blackcore/matrix_3d.h>
|
||||
#include <blackcore/vector_geo.h>
|
||||
#include <blackcore/vector_3d.h>
|
||||
#include <blackcore/interpolator.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace BlackCore;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
QElapsedTimer timer;
|
||||
|
||||
CVectorGeo myGeo(48.123, 11.75, 400);
|
||||
CVector3D vecNed(1, 0, 0);
|
||||
CVector3D vecEcef;
|
||||
|
||||
CInterpolator interpolator;
|
||||
|
||||
interpolator.initialize();
|
||||
|
||||
CVectorGeo vecGeo(48.340733, 11.750565, 100);
|
||||
CVectorGeo vecGeo2(48.344727, 11.805153, 100);
|
||||
|
||||
cout << "Start position: " << endl;
|
||||
vecGeo.print();
|
||||
|
||||
cout << "End position: " << endl;
|
||||
vecGeo2.print();
|
||||
|
||||
timer.start();
|
||||
|
||||
// CVectorGeo pos, double groundVelocity, double heading, double pitch, double bank
|
||||
interpolator.pushUpdate(vecGeo, 20, 80, 0, 0);
|
||||
interpolator.pushUpdate(vecGeo2, 20, 250, 0, 0);
|
||||
|
||||
double duration = timer.nsecsElapsed();
|
||||
|
||||
TPlaneState teststate;
|
||||
|
||||
timer.restart();
|
||||
interpolator.stateNow(&teststate);
|
||||
|
||||
CEcef pos = teststate.position;
|
||||
CVector3D vel = teststate.velocity;
|
||||
CNed ned = teststate.velNED;
|
||||
|
||||
duration = timer.nsecsElapsed();
|
||||
timer.restart();
|
||||
|
||||
CVectorGeo resultGeo = pos.toGeodetic();
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
cout << "End position: " << endl;
|
||||
resultGeo.print();
|
||||
cout << endl;
|
||||
|
||||
cout << "End velocity: " << endl;
|
||||
vel.print();
|
||||
cout << endl;
|
||||
|
||||
cout << "Heading: " << endl;
|
||||
cout << teststate.orientation.heading << endl;
|
||||
cout << endl;
|
||||
|
||||
cout << duration << " nanoseconds" << endl;
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user