mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #369, changed for own aircraft provider
* CLI client * test network * GUI/GUI components
This commit is contained in:
@@ -1,17 +1,29 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2015
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
*
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "blackcore/network_vatlib.h"
|
#include "blackcore/network_vatlib.h"
|
||||||
|
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
using namespace BlackCore;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
|
|
||||||
Client::Client(QObject *parent)
|
Client::Client(QObject *parent)
|
||||||
: QObject(parent), m_net(new BlackCore::CNetworkVatlib(this))
|
: QObject(parent), COwnAircraftProviderSupport(COwnAircraftProviderDummy::instance()),
|
||||||
|
m_net(new BlackCore::CNetworkVatlib(COwnAircraftProviderDummy::instance(), this))
|
||||||
{
|
{
|
||||||
using namespace BlackCore;
|
|
||||||
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
|
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
|
||||||
connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected);
|
connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected);
|
||||||
connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged);
|
connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged);
|
||||||
@@ -48,10 +60,7 @@ Client::Client(QObject *parent)
|
|||||||
connect(this, &Client::sendRealNameQuery, m_net, &INetwork::sendRealNameQuery);
|
connect(this, &Client::sendRealNameQuery, m_net, &INetwork::sendRealNameQuery);
|
||||||
connect(this, &Client::sendCapabilitiesQuery, m_net, &INetwork::sendCapabilitiesQuery);
|
connect(this, &Client::sendCapabilitiesQuery, m_net, &INetwork::sendCapabilitiesQuery);
|
||||||
connect(this, &Client::sendIcaoCodesQuery, m_net, &INetwork::sendIcaoCodesQuery);
|
connect(this, &Client::sendIcaoCodesQuery, m_net, &INetwork::sendIcaoCodesQuery);
|
||||||
connect(this, &Client::setOwnAircraft, m_net, &INetwork::setOwnAircraft);
|
connect(this, &Client::setOwnAircraftCockpit, COwnAircraftProviderDummy::instance(), &COwnAircraftProviderDummy::updateCockpit);
|
||||||
connect(this, &Client::setOwnAircraftPosition, m_net, &INetwork::setOwnAircraftPosition);
|
|
||||||
connect(this, &Client::setOwnAircraftSituation, m_net, &INetwork::setOwnAircraftSituation);
|
|
||||||
connect(this, &Client::setOwnAircraftCockpit, m_net, &INetwork::setOwnCockpit);
|
|
||||||
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
|
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
|
||||||
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
|
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
|
||||||
connect(this, &Client::sendWeatherDataQuery, m_net, &INetwork::sendWeatherDataQuery);
|
connect(this, &Client::sendWeatherDataQuery, m_net, &INetwork::sendWeatherDataQuery);
|
||||||
@@ -323,7 +332,8 @@ void Client::setOwnAircraftCmd(QTextStream &args)
|
|||||||
aircraft.setCom1System(BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())));
|
aircraft.setCom1System(BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())));
|
||||||
aircraft.setCom2System(BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())));
|
aircraft.setCom2System(BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())));
|
||||||
aircraft.setTransponder(BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode));
|
aircraft.setTransponder(BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode));
|
||||||
emit setOwnAircraft(aircraft);
|
|
||||||
|
ownAircraft().setAircraft(aircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setOwnAircraftPositionCmd(QTextStream &args)
|
void Client::setOwnAircraftPositionCmd(QTextStream &args)
|
||||||
@@ -332,8 +342,8 @@ void Client::setOwnAircraftPositionCmd(QTextStream &args)
|
|||||||
double lon;
|
double lon;
|
||||||
double alt;
|
double alt;
|
||||||
args >> lat >> lon >> alt;
|
args >> lat >> lon >> alt;
|
||||||
emit setOwnAircraftPosition(BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
ownAircraft().setPosition(CCoordinateGeodetic(lat, lon, 0));
|
||||||
BlackMisc::Aviation::CAltitude(alt, BlackMisc::Aviation::CAltitude::MeanSeaLevel, BlackMisc::PhysicalQuantities::CLengthUnit::ft()));
|
ownAircraft().setAltitude(CAltitude(alt, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::setOwnAircraftSituationCmd(QTextStream &args)
|
void Client::setOwnAircraftSituationCmd(QTextStream &args)
|
||||||
@@ -346,7 +356,7 @@ void Client::setOwnAircraftSituationCmd(QTextStream &args)
|
|||||||
double bank;
|
double bank;
|
||||||
double gs;
|
double gs;
|
||||||
args >> lat >> lon >> alt >> hdg >> pitch >> bank >> gs;
|
args >> lat >> lon >> alt >> hdg >> pitch >> bank >> gs;
|
||||||
emit setOwnAircraftSituation(BlackMisc::Aviation::CAircraftSituation(
|
ownAircraft().setSituation(BlackMisc::Aviation::CAircraftSituation(
|
||||||
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
||||||
BlackMisc::Aviation::CAltitude(alt, BlackMisc::Aviation::CAltitude::MeanSeaLevel, BlackMisc::PhysicalQuantities::CLengthUnit::ft()),
|
BlackMisc::Aviation::CAltitude(alt, BlackMisc::Aviation::CAltitude::MeanSeaLevel, BlackMisc::PhysicalQuantities::CLengthUnit::ft()),
|
||||||
BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
||||||
@@ -366,7 +376,8 @@ void Client::setOwnAircraftCockpitCmd(QTextStream &args)
|
|||||||
emit setOwnAircraftCockpit(
|
emit setOwnAircraftCockpit(
|
||||||
BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
|
BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
|
||||||
BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
|
BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
|
||||||
BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode)
|
BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode),
|
||||||
|
"testclient"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2013
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project Community / Contributors
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
*
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __BLACKSAMPLE_CLI_CLIENT_H__
|
//! \file
|
||||||
#define __BLACKSAMPLE_CLI_CLIENT_H__
|
|
||||||
|
#ifndef BLACKSAMPLE_CLI_CLIENT_H
|
||||||
|
#define BLACKSAMPLE_CLI_CLIENT_H
|
||||||
|
|
||||||
#include "blackcore/network.h"
|
#include "blackcore/network.h"
|
||||||
|
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class Client : public QObject
|
class Client : public QObject, BlackMisc::Simulation::COwnAircraftProviderSupport
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -76,11 +83,8 @@ signals: //to send to INetwork
|
|||||||
void sendRealNameQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
void sendRealNameQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
void sendCapabilitiesQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
void sendCapabilitiesQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
void sendIcaoCodesQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
void sendIcaoCodesQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
void setOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft);
|
|
||||||
void setOwnAircraftPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude);
|
|
||||||
void setOwnAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation);
|
|
||||||
void setOwnAircraftCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2,
|
void setOwnAircraftCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2,
|
||||||
const BlackMisc::Aviation::CTransponder &xpdr);
|
const BlackMisc::Aviation::CTransponder &xpdr, const QString &originator);
|
||||||
void sendPing(const BlackMisc::Aviation::CCallsign &callsign);
|
void sendPing(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
void sendMetarQuery(const QString &airportICAO);
|
void sendMetarQuery(const QString &airportICAO);
|
||||||
void sendWeatherDataQuery(const QString &airportICAO);
|
void sendWeatherDataQuery(const QString &airportICAO);
|
||||||
@@ -112,4 +116,4 @@ private:
|
|||||||
BlackCore::INetwork *m_net;
|
BlackCore::INetwork *m_net;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__BLACKSAMPLE_CLI_CLIENT_H__
|
#endif // guard
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; }
|
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; }
|
||||||
if (!CComSystem::isValidComFrequency(frequency)) { return; }
|
if (!CComSystem::isValidComFrequency(frequency)) { return; }
|
||||||
this->getIContextOwnAircraft()->updateComFrequency(frequency, static_cast<int>(unit), originator());
|
this->getIContextOwnAircraft()->updateActiveComFrequency(frequency, static_cast<int>(unit), originator());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAtcStationComponent::updateTreeView()
|
void CAtcStationComponent::updateTreeView()
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ namespace BlackGui
|
|||||||
ownAircraft.setCallsign(aircraftValues.ownCallsign);
|
ownAircraft.setCallsign(aircraftValues.ownCallsign);
|
||||||
|
|
||||||
// set latest ICAO, callsign
|
// set latest ICAO, callsign
|
||||||
this->getIContextOwnAircraft()->updateIcaoData(ownAircraft.getIcaoInfo(), loginOriginator());
|
this->getIContextOwnAircraft()->updateIcaoData(ownAircraft.getIcaoInfo());
|
||||||
this->getIContextOwnAircraft()->updateCallsign(ownAircraft.getCallsign(), loginOriginator());
|
this->getIContextOwnAircraft()->updateCallsign(ownAircraft.getCallsign());
|
||||||
|
|
||||||
// Login mode
|
// Login mode
|
||||||
INetwork::LoginMode mode = ui->gbp_LoginMode->getLoginMode();
|
INetwork::LoginMode mode = ui->gbp_LoginMode->getLoginMode();
|
||||||
@@ -214,7 +214,7 @@ namespace BlackGui
|
|||||||
currentServer = this->getCurrentOtherServer();
|
currentServer = this->getCurrentOtherServer();
|
||||||
}
|
}
|
||||||
this->ui->frp_CurrentServer->setServer(currentServer);
|
this->ui->frp_CurrentServer->setServer(currentServer);
|
||||||
this->getIContextOwnAircraft()->updatePilot(currentServer.getUser(), loginOriginator());
|
this->getIContextOwnAircraft()->updatePilot(currentServer.getUser());
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
msg = this->getIContextNetwork()->connectToNetwork(currentServer, static_cast<uint>(mode));
|
msg = this->getIContextNetwork()->connectToNetwork(currentServer, static_cast<uint>(mode));
|
||||||
@@ -338,7 +338,7 @@ namespace BlackGui
|
|||||||
bool simConnected = this->getIContextSimulator() && this->getIContextSimulator()->isSimulating();
|
bool simConnected = this->getIContextSimulator() && this->getIContextSimulator()->isSimulating();
|
||||||
if (simConnected)
|
if (simConnected)
|
||||||
{
|
{
|
||||||
CAircraftModel model = this->getIContextSimulator()->getOwnAircraftModel();
|
CAircraftModel model = this->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||||
this->ui->le_SimulatorModel->setText(model.getModelString());
|
this->ui->le_SimulatorModel->setText(model.getModelString());
|
||||||
this->setIcaoValuesIfEmpty(model.getIcao());
|
this->setIcaoValuesIfEmpty(model.getIcao());
|
||||||
|
|
||||||
@@ -437,13 +437,5 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &CLoginComponent::loginOriginator()
|
|
||||||
{
|
|
||||||
// string is generated once, the timestamp allows to use multiple
|
|
||||||
// components (as long as they are not generated at the same ms)
|
|
||||||
static const QString o = QString("LOGINCOMCOMPONENT:").append(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -139,9 +139,6 @@ namespace BlackGui
|
|||||||
//! Set ICAO values if fields are empty
|
//! Set ICAO values if fields are empty
|
||||||
void setIcaoValuesIfEmpty(const BlackMisc::Aviation::CAircraftIcao &icao);
|
void setIcaoValuesIfEmpty(const BlackMisc::Aviation::CAircraftIcao &icao);
|
||||||
|
|
||||||
//! Identifies sender of cockpit updates
|
|
||||||
static const QString &loginOriginator();
|
|
||||||
|
|
||||||
bool m_visible = false; //!< is this component selected?
|
bool m_visible = false; //!< is this component selected?
|
||||||
QScopedPointer<Ui::CLoginComponent> ui;
|
QScopedPointer<Ui::CLoginComponent> ui;
|
||||||
const int LogoffIntervalSeconds = 10;
|
const int LogoffIntervalSeconds = 10;
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ void SwiftGuiStd::setTestPosition(const QString &wgsLatitude, const QString &wgs
|
|||||||
|
|
||||||
this->m_ownAircraft.setPosition(coordinate);
|
this->m_ownAircraft.setPosition(coordinate);
|
||||||
this->m_ownAircraft.setAltitude(altitude);
|
this->m_ownAircraft.setAltitude(altitude);
|
||||||
this->getIContextOwnAircraft()->updatePosition(coordinate, altitude, SwiftGuiStd::swiftGuiStandardOriginator());
|
this->getIContextOwnAircraft()->updatePosition(coordinate, altitude);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,45 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
/* Copyright (C) 2014
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* swift project community / contributors
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
*
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKCORETEST_TESTNETWORK_H
|
#ifndef BLACKCORETEST_TESTNETWORK_H
|
||||||
#define BLACKCORETEST_TESTNETWORK_H
|
#define BLACKCORETEST_TESTNETWORK_H
|
||||||
|
|
||||||
#include "blackcore/network_vatlib.h"
|
#include "blackcore/network_vatlib.h"
|
||||||
|
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
namespace BlackCoreTest
|
namespace BlackCoreTest
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
//! INetwork implementation classes tests
|
||||||
* INetwork implementation classes tests
|
|
||||||
*/
|
|
||||||
class CTestNetwork : public QObject
|
class CTestNetwork : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Constructor.
|
||||||
* Constructor.
|
explicit CTestNetwork(QObject *parent = 0) :
|
||||||
* \param parent
|
QObject(parent), m_networkVatlib(BlackMisc::Simulation::COwnAircraftProviderDummy::instance(), parent) {}
|
||||||
*/
|
|
||||||
explicit CTestNetwork(QObject *parent = 0) : QObject(parent) {}
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/*!
|
//! Test the vatlib
|
||||||
* Test NetworkVatlib
|
|
||||||
*/
|
|
||||||
void networkVatlibTest() { networkTest(&m_networkVatlib); }
|
void networkVatlibTest() { networkTest(&m_networkVatlib); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
//! Common part used by all tests.
|
||||||
* Common part used by all tests.
|
|
||||||
*/
|
|
||||||
void networkTest(BlackCore::INetwork *);
|
void networkTest(BlackCore::INetwork *);
|
||||||
|
|
||||||
BlackCore::CNetworkVatlib m_networkVatlib;
|
BlackCore::CNetworkVatlib m_networkVatlib ;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace BlackCoreTest
|
} //namespace BlackCoreTest
|
||||||
|
|
||||||
#endif //BLACKCORETEST_TESTNETWORK_H
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user