refs #242, adjusted context simulator, updating to aircraft context

This commit is contained in:
Klaus Basan
2014-05-28 13:23:27 +02:00
parent b6afcefd59
commit f2888eefbe
2 changed files with 22 additions and 17 deletions

View File

@@ -4,11 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "context_simulator_impl.h"
#include "context_ownaircraft_impl.h"
#include "context_runtime.h"
#include "context_ownaircraft.h"
#include <QPluginLoader>
#include <QLibrary>
#include "context_runtime.h"
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
@@ -29,13 +28,6 @@ namespace BlackCore
asyncConnectTo();
}
void CContextSimulator::updateOwnAircraft()
{
Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getRuntime()->getCContextOwnAircraft());
this->getRuntime()->getCContextOwnAircraft()->updateOwnAircraft(this->m_simulator->getOwnAircraft(), IContextSimulator::InterfaceName());
}
CContextSimulator::~CContextSimulator()
{
disconnectFrom();
@@ -77,7 +69,7 @@ namespace BlackCore
{
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
if (!m_simulator || m_canConnectResult.isRunning()) return; // already checking
this->m_canConnectResult = QtConcurrent::run(this, &CContextSimulator::connectTo);
m_simulator->asyncConnectTo();
}
bool CContextSimulator::disconnectFrom()
@@ -116,7 +108,7 @@ namespace BlackCore
m_simulator = factory->create(this);
Q_ASSERT(m_simulator);
connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool)));
connect(m_simulator, SIGNAL(statusChanged(ISimulator::Status)), this, SLOT(setConnectionStatus(ISimulator::Status)));
return true;
}
@@ -128,13 +120,26 @@ namespace BlackCore
m_simulator = nullptr;
}
void CContextSimulator::setConnectionStatus(bool value)
void CContextSimulator::updateOwnAircraft()
{
if (value)
Q_ASSERT(this->getIContextOwnAircraft());
CAircraft aircraft = m_simulator->getOwnAircraft();
this->getIContextOwnAircraft()->updateOwnSituation(aircraft.getSituation(), IContextSimulator::InterfaceName());
this->getIContextOwnAircraft()->updateOwnCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder(), IContextSimulator::InterfaceName());
}
void CContextSimulator::setConnectionStatus(ISimulator::Status status)
{
if (status == ISimulator::Connected)
{
m_updateTimer->start(100);
emit connectionChanged(true);
}
else
{
m_updateTimer->stop();
emit connectionChanged(value);
emit connectionChanged(false);
}
}
void CContextSimulator::findSimulatorPlugins()
@@ -171,4 +176,4 @@ namespace BlackCore
}
}
} // namespace BlackCore
} // namespace

View File

@@ -81,7 +81,7 @@ namespace BlackCore
private slots:
//! \copydoc IContextSimulator::updateOwnAircraft()
void updateOwnAircraft();
virtual void updateOwnAircraft();
//! Set new connection status
void setConnectionStatus(ISimulator::Status status);