mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
* Include only what is used * Use forward declaration when possible * Sorted includes refs #598
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
/* 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.
|
|
*/
|
|
|
|
#include "blackcore/simulator.h"
|
|
|
|
#include <QFlag>
|
|
#include <Qt>
|
|
#include <QtGlobal>
|
|
|
|
using namespace BlackMisc;
|
|
using namespace BlackMisc::Aviation;
|
|
using namespace BlackMisc::Simulation;
|
|
using namespace BlackMisc::PhysicalQuantities;
|
|
using namespace BlackMisc::Simulation;
|
|
|
|
namespace BlackCore
|
|
{
|
|
int ISimulator::getSimulatorStatus() const
|
|
{
|
|
int status =
|
|
(isConnected() ? Connected : static_cast<ISimulator::SimulatorStatus>(0))
|
|
| (isSimulating() ? Simulating : static_cast<ISimulator::SimulatorStatus>(0))
|
|
| (isPaused() ? Paused : static_cast<ISimulator::SimulatorStatus>(0));
|
|
return status;
|
|
}
|
|
|
|
QString ISimulator::statusToString(int status)
|
|
{
|
|
if (status > 0)
|
|
{
|
|
QString s;
|
|
if (status & Connected) { s.append("Connected"); }
|
|
if (status & Simulating) { if (!s.isEmpty()) { s.append(", "); } s.append("Simulating"); }
|
|
if (status & Paused) { if (!s.isEmpty()) { s.append(", "); } s.append("Paused"); }
|
|
return s;
|
|
}
|
|
else
|
|
{
|
|
return "Disconnected";
|
|
}
|
|
}
|
|
|
|
ISimulator::SimulatorStatus ISimulator::statusToEnum(int status)
|
|
{
|
|
return static_cast<SimulatorStatus>(status);
|
|
}
|
|
|
|
void ISimulator::emitSimulatorCombinedStatus(int oldStatus)
|
|
{
|
|
int newStatus = getSimulatorStatus();
|
|
if (oldStatus != newStatus)
|
|
{
|
|
emit simulatorStatusChanged(newStatus);
|
|
}
|
|
}
|
|
|
|
ISimulatorListener::ISimulatorListener(const CSimulatorPluginInfo &info) :
|
|
QObject(), m_info(info)
|
|
{
|
|
this->setObjectName("ISimulatorListener:" + info.toQString());
|
|
|
|
// stop listener after it reports simulator ready
|
|
bool s = connect(this, &ISimulatorListener::simulatorStarted, this, &ISimulatorListener::stop, Qt::QueuedConnection);
|
|
Q_ASSERT_X(s, Q_FUNC_INFO, "connect failed");
|
|
Q_UNUSED(s)
|
|
}
|
|
|
|
} // namespace
|