mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-11 20:29:47 +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
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* 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 "blackcore/network_vatlib.h"
|
||||
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||
#include <iostream>
|
||||
#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)
|
||||
: 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::atcDisconnected, this, &Client::atcDisconnected);
|
||||
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::sendCapabilitiesQuery, m_net, &INetwork::sendCapabilitiesQuery);
|
||||
connect(this, &Client::sendIcaoCodesQuery, m_net, &INetwork::sendIcaoCodesQuery);
|
||||
connect(this, &Client::setOwnAircraft, m_net, &INetwork::setOwnAircraft);
|
||||
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::setOwnAircraftCockpit, COwnAircraftProviderDummy::instance(), &COwnAircraftProviderDummy::updateCockpit);
|
||||
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
|
||||
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
|
||||
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.setCom2System(BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())));
|
||||
aircraft.setTransponder(BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode));
|
||||
emit setOwnAircraft(aircraft);
|
||||
|
||||
ownAircraft().setAircraft(aircraft);
|
||||
}
|
||||
|
||||
void Client::setOwnAircraftPositionCmd(QTextStream &args)
|
||||
@@ -332,8 +342,8 @@ void Client::setOwnAircraftPositionCmd(QTextStream &args)
|
||||
double lon;
|
||||
double alt;
|
||||
args >> lat >> lon >> alt;
|
||||
emit setOwnAircraftPosition(BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
||||
BlackMisc::Aviation::CAltitude(alt, BlackMisc::Aviation::CAltitude::MeanSeaLevel, BlackMisc::PhysicalQuantities::CLengthUnit::ft()));
|
||||
ownAircraft().setPosition(CCoordinateGeodetic(lat, lon, 0));
|
||||
ownAircraft().setAltitude(CAltitude(alt, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
}
|
||||
|
||||
void Client::setOwnAircraftSituationCmd(QTextStream &args)
|
||||
@@ -346,14 +356,14 @@ void Client::setOwnAircraftSituationCmd(QTextStream &args)
|
||||
double bank;
|
||||
double gs;
|
||||
args >> lat >> lon >> alt >> hdg >> pitch >> bank >> gs;
|
||||
emit setOwnAircraftSituation(BlackMisc::Aviation::CAircraftSituation(
|
||||
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
||||
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::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
||||
BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
||||
BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())
|
||||
));
|
||||
ownAircraft().setSituation(BlackMisc::Aviation::CAircraftSituation(
|
||||
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, 0),
|
||||
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::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
||||
BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
|
||||
BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())
|
||||
));
|
||||
}
|
||||
|
||||
void Client::setOwnAircraftCockpitCmd(QTextStream &args)
|
||||
@@ -366,7 +376,8 @@ void Client::setOwnAircraftCockpitCmd(QTextStream &args)
|
||||
emit setOwnAircraftCockpit(
|
||||
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::CTransponder("Transponder", xpdrCode, xpdrMode)
|
||||
BlackMisc::Aviation::CTransponder("Transponder", xpdrCode, xpdrMode),
|
||||
"testclient"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* 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__
|
||||
#define __BLACKSAMPLE_CLI_CLIENT_H__
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSAMPLE_CLI_CLIENT_H
|
||||
#define BLACKSAMPLE_CLI_CLIENT_H
|
||||
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
#include <QMap>
|
||||
#include <functional>
|
||||
|
||||
class Client : public QObject
|
||||
class Client : public QObject, BlackMisc::Simulation::COwnAircraftProviderSupport
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -76,11 +83,8 @@ signals: //to send to INetwork
|
||||
void sendRealNameQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void sendCapabilitiesQuery(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,
|
||||
const BlackMisc::Aviation::CTransponder &xpdr);
|
||||
const BlackMisc::Aviation::CTransponder &xpdr, const QString &originator);
|
||||
void sendPing(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void sendMetarQuery(const QString &airportICAO);
|
||||
void sendWeatherDataQuery(const QString &airportICAO);
|
||||
@@ -112,4 +116,4 @@ private:
|
||||
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 (!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()
|
||||
|
||||
@@ -183,8 +183,8 @@ namespace BlackGui
|
||||
ownAircraft.setCallsign(aircraftValues.ownCallsign);
|
||||
|
||||
// set latest ICAO, callsign
|
||||
this->getIContextOwnAircraft()->updateIcaoData(ownAircraft.getIcaoInfo(), loginOriginator());
|
||||
this->getIContextOwnAircraft()->updateCallsign(ownAircraft.getCallsign(), loginOriginator());
|
||||
this->getIContextOwnAircraft()->updateIcaoData(ownAircraft.getIcaoInfo());
|
||||
this->getIContextOwnAircraft()->updateCallsign(ownAircraft.getCallsign());
|
||||
|
||||
// Login mode
|
||||
INetwork::LoginMode mode = ui->gbp_LoginMode->getLoginMode();
|
||||
@@ -214,7 +214,7 @@ namespace BlackGui
|
||||
currentServer = this->getCurrentOtherServer();
|
||||
}
|
||||
this->ui->frp_CurrentServer->setServer(currentServer);
|
||||
this->getIContextOwnAircraft()->updatePilot(currentServer.getUser(), loginOriginator());
|
||||
this->getIContextOwnAircraft()->updatePilot(currentServer.getUser());
|
||||
|
||||
// Login
|
||||
msg = this->getIContextNetwork()->connectToNetwork(currentServer, static_cast<uint>(mode));
|
||||
@@ -338,7 +338,7 @@ namespace BlackGui
|
||||
bool simConnected = this->getIContextSimulator() && this->getIContextSimulator()->isSimulating();
|
||||
if (simConnected)
|
||||
{
|
||||
CAircraftModel model = this->getIContextSimulator()->getOwnAircraftModel();
|
||||
CAircraftModel model = this->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||
this->ui->le_SimulatorModel->setText(model.getModelString());
|
||||
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
|
||||
|
||||
@@ -139,9 +139,6 @@ namespace BlackGui
|
||||
//! Set ICAO values if fields are empty
|
||||
void setIcaoValuesIfEmpty(const BlackMisc::Aviation::CAircraftIcao &icao);
|
||||
|
||||
//! Identifies sender of cockpit updates
|
||||
static const QString &loginOriginator();
|
||||
|
||||
bool m_visible = false; //!< is this component selected?
|
||||
QScopedPointer<Ui::CLoginComponent> ui;
|
||||
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.setAltitude(altitude);
|
||||
this->getIContextOwnAircraft()->updatePosition(coordinate, altitude, SwiftGuiStd::swiftGuiStandardOriginator());
|
||||
this->getIContextOwnAircraft()->updatePosition(coordinate, altitude);
|
||||
}
|
||||
|
||||
@@ -1,46 +1,45 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
/* Copyright (C) 2014
|
||||
* swift project community / contributors
|
||||
*
|
||||
* 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
|
||||
#define BLACKCORETEST_TESTNETWORK_H
|
||||
|
||||
#include "blackcore/network_vatlib.h"
|
||||
#include "blackmisc/simulation/simdirectaccessownaircraft.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace BlackCoreTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* INetwork implementation classes tests
|
||||
*/
|
||||
//! INetwork implementation classes tests
|
||||
class CTestNetwork : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param parent
|
||||
*/
|
||||
explicit CTestNetwork(QObject *parent = 0) : QObject(parent) {}
|
||||
//! Constructor.
|
||||
explicit CTestNetwork(QObject *parent = 0) :
|
||||
QObject(parent), m_networkVatlib(BlackMisc::Simulation::COwnAircraftProviderDummy::instance(), parent) {}
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
* Test NetworkVatlib
|
||||
*/
|
||||
//! Test the vatlib
|
||||
void networkVatlibTest() { networkTest(&m_networkVatlib); }
|
||||
|
||||
private:
|
||||
/*!
|
||||
* Common part used by all tests.
|
||||
*/
|
||||
//! Common part used by all tests.
|
||||
void networkTest(BlackCore::INetwork *);
|
||||
|
||||
BlackCore::CNetworkVatlib m_networkVatlib;
|
||||
BlackCore::CNetworkVatlib m_networkVatlib ;
|
||||
};
|
||||
|
||||
} //namespace BlackCoreTest
|
||||
|
||||
#endif //BLACKCORETEST_TESTNETWORK_H
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user