mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 08:55:43 +08:00
refs #199, integration with latest simulator context
* Fixed warning HRESULT hr = S_OK; uint/int warning * loadPlugins in constructor * init removed, wiring in runtime class * Using getRuntime to refer to other contexts * Fixed reading of plugins, with no exisiting "plugin" dir this did hang
This commit is contained in:
@@ -23,6 +23,7 @@ namespace BlackCore
|
|||||||
m_simulator(nullptr), m_updateTimer(nullptr)
|
m_simulator(nullptr), m_updateTimer(nullptr)
|
||||||
{
|
{
|
||||||
m_updateTimer = new QTimer(this);
|
m_updateTimer = new QTimer(this);
|
||||||
|
loadPlugins();
|
||||||
connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft);
|
connect(m_updateTimer, &QTimer::timeout, this, &CContextSimulator::updateOwnAircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,25 +41,11 @@ namespace BlackCore
|
|||||||
return m_ownAircraft;
|
return m_ownAircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextSimulator::init()
|
|
||||||
{
|
|
||||||
loadPlugins();
|
|
||||||
|
|
||||||
if (!m_contextNetwork)
|
|
||||||
{
|
|
||||||
m_contextNetwork = getRuntime()->getIContextNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_simulator)
|
|
||||||
connect(m_contextNetwork, SIGNAL(aircraftSituationUpdate(BlackMisc::Aviation::CCallsign,BlackMisc::Aviation::CAircraftSituation)),
|
|
||||||
m_simulator, SLOT(addAircraftSituation(BlackMisc::Aviation::CCallsign,BlackMisc::Aviation::CAircraftSituation)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CContextSimulator::updateOwnAircraft()
|
void CContextSimulator::updateOwnAircraft()
|
||||||
{
|
{
|
||||||
m_ownAircraft = m_simulator->getOwnAircraft();
|
m_ownAircraft = m_simulator->getOwnAircraft();
|
||||||
getNetworkContext()->updateOwnSituation(m_ownAircraft.getSituation());
|
getRuntime()->getIContextNetwork()->updateOwnSituation(m_ownAircraft.getSituation());
|
||||||
getNetworkContext()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
|
getRuntime()->getIContextNetwork()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextSimulator::setConnectionStatus(bool value)
|
void CContextSimulator::setConnectionStatus(bool value)
|
||||||
@@ -72,10 +59,14 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextSimulator::loadPlugins()
|
void CContextSimulator::loadPlugins()
|
||||||
{
|
{
|
||||||
m_pluginsDir = QDir(qApp->applicationDirPath());
|
m_pluginsDir = QDir(qApp->applicationDirPath().append("/plugins"));
|
||||||
m_pluginsDir.cd("plugins");
|
if (!m_pluginsDir.exists())
|
||||||
|
{
|
||||||
|
qWarning() << "No plugin directory" << m_pluginsDir;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (QString fileName, m_pluginsDir.entryList(QDir::Files))
|
foreach(QString fileName, m_pluginsDir.entryList(QDir::Files))
|
||||||
{
|
{
|
||||||
QPluginLoader loader(m_pluginsDir.absoluteFilePath(fileName));
|
QPluginLoader loader(m_pluginsDir.absoluteFilePath(fileName));
|
||||||
QObject *plugin = loader.instance();
|
QObject *plugin = loader.instance();
|
||||||
@@ -86,20 +77,14 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
m_simulator = factory->create(this);
|
m_simulator = factory->create(this);
|
||||||
connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool)));
|
connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool)));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << loader.errorString();
|
qDebug() << loader.errorString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
IContextNetwork *CContextSimulator::getNetworkContext()
|
|
||||||
{
|
|
||||||
Q_ASSERT(this->getRuntime()->getIContextNetwork());
|
|
||||||
return getRuntime()->getIContextNetwork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BlackCore
|
} // namespace BlackCore
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
void CSimulatorFSX::addRemoteAircraft(const CCallsign &callsign, const QString &type, const CAircraftSituation &initialSituation)
|
void CSimulatorFSX::addRemoteAircraft(const CCallsign &callsign, const QString &type, const CAircraftSituation &initialSituation)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
|
||||||
Q_UNUSED(type);
|
Q_UNUSED(type);
|
||||||
|
|
||||||
SIMCONNECT_DATA_INITPOSITION initialPosition;
|
SIMCONNECT_DATA_INITPOSITION initialPosition;
|
||||||
@@ -60,7 +59,8 @@ namespace BlackSimPlugin
|
|||||||
m_simConnectObjects.insert(callsign, simObj);
|
m_simConnectObjects.insert(callsign, simObj);
|
||||||
++m_nextObjID;
|
++m_nextObjID;
|
||||||
|
|
||||||
hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, "Boeing 737-800 Paint1", callsign.toQString().left(12).toLatin1().constData(), initialPosition, simObj.m_requestId);
|
HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, "Boeing 737-800 Paint1", callsign.toQString().left(12).toLatin1().constData(), initialPosition, simObj.m_requestId);
|
||||||
|
Q_UNUSED(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorFSX::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &situation)
|
void CSimulatorFSX::addAircraftSituation(const CCallsign &callsign, const CAircraftSituation &situation)
|
||||||
@@ -229,7 +229,7 @@ namespace BlackSimPlugin
|
|||||||
SimConnectObject simObject;
|
SimConnectObject simObject;
|
||||||
foreach (simObject, m_simConnectObjects)
|
foreach (simObject, m_simConnectObjects)
|
||||||
{
|
{
|
||||||
if (simObject.m_requestId == requestID)
|
if (simObject.m_requestId == static_cast<int>(requestID))
|
||||||
{
|
{
|
||||||
simObject.m_objectId = objectID;
|
simObject.m_objectId = objectID;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user