mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-08 02:25:37 +08:00
committed by
Mathew Sutcliffe
parent
1f2a88e502
commit
ab17dabd5b
90
samples/blackcore/tool.cpp
Normal file
90
samples/blackcore/tool.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "tool.h"
|
||||
#include "blackcore/coreruntime.h"
|
||||
#include "blackmisc/valuemap.h"
|
||||
#include <QTextStream>
|
||||
#include <QString>
|
||||
#include <QFuture>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Start a new process
|
||||
*/
|
||||
QProcess *Tool::startNewProcess(const QString &executable, const QStringList &arguments, QObject *parent)
|
||||
{
|
||||
QProcess *process = new QProcess(parent);
|
||||
process->startDetached(executable, arguments);
|
||||
return process;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send data to testservice, this sends data to the slots on the server
|
||||
*/
|
||||
void Tool::serverLoop(const BlackCore::CCoreRuntime *core)
|
||||
{
|
||||
QThread::sleep(3); // let the client connect
|
||||
qDebug() << "Running on server here" << Tool::getPid();
|
||||
|
||||
//
|
||||
// Server loop
|
||||
//
|
||||
QTextStream qtin(stdin);
|
||||
QString line;
|
||||
while (line != "x")
|
||||
{
|
||||
const BlackCore::IContextNetwork *networkContext = core->getIContextNetwork();
|
||||
|
||||
// display current status
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC booked";
|
||||
qDebug() << networkContext->getAtcStationsBooked().toQString();
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC online";
|
||||
qDebug() << networkContext->getAtcStationsOnline().toQString();
|
||||
|
||||
// next round? Server
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "Connected with network: " << networkContext->isConnected();
|
||||
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "Key x to exit";
|
||||
qDebug() << "1 .. ATC booked";
|
||||
qDebug() << "2 .. ATC online";
|
||||
qDebug() << "3 .. Aircrafts in range";
|
||||
qDebug() << "4 .. my aircraft";
|
||||
|
||||
line = qtin.readLine();
|
||||
|
||||
if (line.startsWith("1"))
|
||||
{
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC booked";
|
||||
qDebug() << networkContext->getAtcStationsBooked().toFormattedQString();
|
||||
}
|
||||
else if (line.startsWith("2"))
|
||||
{
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "ATC online";
|
||||
qDebug() << networkContext->getAtcStationsOnline().toFormattedQString();
|
||||
}
|
||||
else if (line.startsWith("3"))
|
||||
{
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "aircrafts in range";
|
||||
qDebug() << networkContext->getAircraftsInRange().toFormattedQString();
|
||||
}
|
||||
else if (line.startsWith("4"))
|
||||
{
|
||||
qDebug() << "-------------";
|
||||
qDebug() << "my aircraft";
|
||||
qDebug() << networkContext->getOwnAircraft();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user