mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
* simulator common, many members now private (info -> read only) * renamed printDirectPlayError -> logDirectPlayError * (re)added ASSERT for FS9 * removed parent from listener (with parent no moveToThread) * removed QFuture / QConcurrent as we have agreed to do * unloading a plugin no longer automatically restarts all listeners this allows a user to set one particualar simulator in the GUI and ony wait for that * stop listener from own signal
74 lines
2.4 KiB
C++
74 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 "simulator.h"
|
|
#include "interpolator.h"
|
|
#include "blackmisc/logmessage.h"
|
|
#include "blackmisc/collection.h"
|
|
|
|
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
|