refs #349, housekeeping

* formatting
* tweaks (such as changing to new log style),
* Doxygen
* int instead of qint
This commit is contained in:
Klaus Basan
2014-12-02 17:25:58 +01:00
parent 7361ec8963
commit 78e4900243
16 changed files with 120 additions and 94 deletions

View File

@@ -64,7 +64,7 @@ namespace BlackCore
// TODO: This would need to come from somewhere (mappings) // TODO: This would need to come from somewhere (mappings)
// Own callsign, plane ICAO status, model used // Own callsign, plane ICAO status, model used
this->m_ownAircraft.setCallsign(CCallsign("BLACK")); this->m_ownAircraft.setCallsign(CCallsign("SWIFT"));
this->m_ownAircraft.setIcaoInfo(CAircraftIcao("C172", "L1P", "GA", "GA", "0000ff")); this->m_ownAircraft.setIcaoInfo(CAircraftIcao("C172", "L1P", "GA", "GA", "0000ff"));
// voice rooms // voice rooms

View File

@@ -18,4 +18,4 @@ namespace BlackCore
{ {
emit simulatorStatusChanged(isConnected(), isRunning(), isPaused()); emit simulatorStatusChanged(isConnected(), isRunning(), isPaused());
} }
} } // namespace

View File

@@ -127,9 +127,11 @@ namespace BlackGui
this->updateFrequencyDisplaysFromComSystems(com1, com2); this->updateFrequencyDisplaysFromComSystems(com1, com2);
// update transponder // update transponder
qint32 tc = transponder.getTransponderCode(); int tc = transponder.getTransponderCode();
if (tc != static_cast<qint32>(this->ui->sbp_ComPanelTransponder->value())) if (tc != this->ui->sbp_ComPanelTransponder->value())
{
this->ui->sbp_ComPanelTransponder->setValue(tc); this->ui->sbp_ComPanelTransponder->setValue(tc);
}
this->ui->cbp_ComPanelTransponderMode->setSelectedTransponderMode(transponder.getTransponderMode()); this->ui->cbp_ComPanelTransponderMode->setSelectedTransponderMode(transponder.getTransponderMode());

View File

@@ -121,10 +121,10 @@ namespace BlackGui
//! \copydoc QWidget::paintEvent //! \copydoc QWidget::paintEvent
virtual void paintEvent(QPaintEvent *event) override; virtual void paintEvent(QPaintEvent *event) override;
//! \copy QMainWindow::mouseMoveEvent //! \copydoc QMainWindow::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ; } virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ; }
//! \copy QMainWindow::mousePressEvent //! \copydoc QMainWindow::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); } } virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); } }
//! Contribute to menu //! Contribute to menu

View File

@@ -116,7 +116,7 @@ namespace BlackMisc
QString getTransponderCodeAndModeFormatted() const; QString getTransponderCodeAndModeFormatted() const;
//! Set transponder code //! Set transponder code
void setTransponderCode(qint32 transponderCode) { this->m_transponderCode = transponderCode; } void setTransponderCode(int transponderCode) { this->m_transponderCode = transponderCode; }
//! Set transponder code //! Set transponder code
void setTransponderCode(const QString &transponderCode); void setTransponderCode(const QString &transponderCode);

View File

@@ -81,7 +81,7 @@ namespace BlackSimPlugin
return situation; return situation;
} }
MPPositionVelocity aircraftSituationtoFS9(const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, double updateInterval) MPPositionVelocity aircraftSituationToFS9(const CAircraftSituation &oldSituation, const CAircraftSituation &newSituation, double updateInterval)
{ {
MPPositionVelocity positionVelocity; MPPositionVelocity positionVelocity;
@@ -137,7 +137,7 @@ namespace BlackSimPlugin
return positionVelocity; return positionVelocity;
} }
MPPositionSlewMode aircraftSituationtoFS9(const CAircraftSituation &situation) MPPositionSlewMode aircraftSituationToFS9(const CAircraftSituation &situation)
{ {
MPPositionSlewMode positionSlewMode; MPPositionSlewMode positionSlewMode;
@@ -208,7 +208,8 @@ namespace BlackSimPlugin
break; break;
} }
BlackMisc::CLogMessage().error(errorMessage); errorMessage = "DirectPlay: " + errorMessage;
BlackMisc::CLogMessage("swift.fs9.freefunctions").error(errorMessage);
return error; return error;
} }

View File

@@ -7,6 +7,8 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
//! \file
#ifndef BLACKSIMPLUGIN_FREEFUNCTIONS_H #ifndef BLACKSIMPLUGIN_FREEFUNCTIONS_H
#define BLACKSIMPLUGIN_FREEFUNCTIONS_H #define BLACKSIMPLUGIN_FREEFUNCTIONS_H
@@ -51,18 +53,17 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAircraftSituation aircraftSituationfromFS9(const MPPositionVelocity &positionVelocity); BlackMisc::Aviation::CAircraftSituation aircraftSituationfromFS9(const MPPositionVelocity &positionVelocity);
//! Convert an aircraft situation to a FS9 struct //! Convert an aircraft situation to a FS9 struct
MPPositionVelocity aircraftSituationtoFS9(const BlackMisc::Aviation::CAircraftSituation &oldSituation, MPPositionVelocity aircraftSituationToFS9(const BlackMisc::Aviation::CAircraftSituation &oldSituation,
const BlackMisc::Aviation::CAircraftSituation &newSituation, const BlackMisc::Aviation::CAircraftSituation &newSituation,
double updateInterval); double updateInterval);
//! Convert an aircraft situation to a FS9 struct //! Convert an aircraft situation to a FS9 struct
MPPositionSlewMode aircraftSituationtoFS9(const BlackMisc::Aviation::CAircraftSituation &situation); MPPositionSlewMode aircraftSituationToFS9(const BlackMisc::Aviation::CAircraftSituation &situation);
//! Print the direct play error
HRESULT printDirectPlayError(HRESULT error); HRESULT printDirectPlayError(HRESULT error);
} }
} }
#endif //BLACKSIMPLUGIN_FREEFUNCTIONS_H #endif // guard

View File

@@ -10,6 +10,7 @@
#include "directplay_peer.h" #include "directplay_peer.h"
#include "multiplayer_packet_parser.h" #include "multiplayer_packet_parser.h"
#include "blacksimplugin_freefunctions.h" #include "blacksimplugin_freefunctions.h"
#include "blackmisc/logmessage.h"
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QFile> #include <QFile>
@@ -17,6 +18,8 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QMutexLocker> #include <QMutexLocker>
using namespace BlackMisc;
namespace BlackSimPlugin namespace BlackSimPlugin
{ {
namespace Fs9 namespace Fs9
@@ -48,36 +51,36 @@ namespace BlackSimPlugin
switch (messageId) switch (messageId)
{ {
case DPN_MSGID_CREATE_PLAYER: case DPN_MSGID_CREATE_PLAYER:
{ {
DPNMSG_CREATE_PLAYER* pCreatePlayerMsg = static_cast<DPNMSG_CREATE_PLAYER*>(msgBuffer); DPNMSG_CREATE_PLAYER *pCreatePlayerMsg = static_cast<DPNMSG_CREATE_PLAYER *>(msgBuffer);
HRESULT hr; HRESULT hr;
// Get the peer info and extract its name // Get the peer info and extract its name
DWORD dwSize = 0; DWORD dwSize = 0;
DPN_PLAYER_INFO* pdpPlayerInfo = nullptr; DPN_PLAYER_INFO *pdpPlayerInfo = nullptr;
hr = DPNERR_CONNECTING; hr = DPNERR_CONNECTING;
// GetPeerInfo might return DPNERR_CONNECTING when connecting, // GetPeerInfo might return DPNERR_CONNECTING when connecting,
// so just keep calling it if it does // so just keep calling it if it does
while( hr == DPNERR_CONNECTING ) while (hr == DPNERR_CONNECTING)
hr = m_directPlayPeer->GetPeerInfo( pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0 ); hr = m_directPlayPeer->GetPeerInfo(pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0);
if( hr == DPNERR_BUFFERTOOSMALL ) if (hr == DPNERR_BUFFERTOOSMALL)
{ {
QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]); QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]);
pdpPlayerInfo = reinterpret_cast<DPN_PLAYER_INFO*>(memPtr.data()); pdpPlayerInfo = reinterpret_cast<DPN_PLAYER_INFO *>(memPtr.data());
if( pdpPlayerInfo == nullptr) if (pdpPlayerInfo == nullptr)
{ {
break; break;
} }
ZeroMemory( pdpPlayerInfo, dwSize ); ZeroMemory(pdpPlayerInfo, dwSize);
pdpPlayerInfo->dwSize = sizeof(DPN_PLAYER_INFO); pdpPlayerInfo->dwSize = sizeof(DPN_PLAYER_INFO);
hr = m_directPlayPeer->GetPeerInfo( pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0 ); hr = m_directPlayPeer->GetPeerInfo(pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0);
if( SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
if (pdpPlayerInfo->dwPlayerFlags & DPNPLAYER_LOCAL) if (pdpPlayerInfo->dwPlayerFlags & DPNPLAYER_LOCAL)
m_playerLocal = pCreatePlayerMsg->dpnidPlayer; m_playerLocal = pCreatePlayerMsg->dpnidPlayer;
@@ -96,33 +99,33 @@ namespace BlackSimPlugin
break; break;
} }
case DPN_MSGID_RECEIVE: case DPN_MSGID_RECEIVE:
{ {
PDPNMSG_RECEIVE pReceiveMsg = static_cast<PDPNMSG_RECEIVE>(msgBuffer); PDPNMSG_RECEIVE pReceiveMsg = static_cast<PDPNMSG_RECEIVE>(msgBuffer);
// Proceeed only, if the sender is our local player // Proceeed only, if the sender is our local player
if (pReceiveMsg->dpnidSender == m_playerUser) if (pReceiveMsg->dpnidSender == m_playerUser)
{ {
QByteArray messageData = QByteArray((char*)pReceiveMsg->pReceiveData, pReceiveMsg->dwReceiveDataSize); QByteArray messageData = QByteArray((char *)pReceiveMsg->pReceiveData, pReceiveMsg->dwReceiveDataSize);
emit customPacketReceived(messageData); emit customPacketReceived(messageData);
} }
break; break;
} }
case DPN_MSGID_ENUM_HOSTS_RESPONSE: case DPN_MSGID_ENUM_HOSTS_RESPONSE:
{ {
PDPNMSG_ENUM_HOSTS_RESPONSE enumHostsResponseMsg = static_cast<PDPNMSG_ENUM_HOSTS_RESPONSE>(msgBuffer); PDPNMSG_ENUM_HOSTS_RESPONSE enumHostsResponseMsg = static_cast<PDPNMSG_ENUM_HOSTS_RESPONSE>(msgBuffer);
const DPN_APPLICATION_DESC *applicationDescription = enumHostsResponseMsg->pApplicationDescription; const DPN_APPLICATION_DESC *applicationDescription = enumHostsResponseMsg->pApplicationDescription;
QMutexLocker locker(&m_mutexHostList); QMutexLocker locker(&m_mutexHostList);
auto iterator = std::find_if(m_hostNodeList.begin(), m_hostNodeList.end(), [&] (const CHostNode &hostNode) auto iterator = std::find_if(m_hostNodeList.begin(), m_hostNodeList.end(), [&](const CHostNode & hostNode)
{ {
return applicationDescription->guidInstance == hostNode.getApplicationDesc().guidInstance; return applicationDescription->guidInstance == hostNode.getApplicationDesc().guidInstance;
}); });
if(iterator == m_hostNodeList.end()) if (iterator == m_hostNodeList.end())
{ {
// This host session is not in the list then so insert it. // This host session is not in the list then so insert it.
@@ -130,7 +133,7 @@ namespace BlackSimPlugin
HRESULT hr; HRESULT hr;
// Copy the Host Address // Copy the Host Address
if( FAILED( hr = enumHostsResponseMsg->pAddressSender->Duplicate( hostNode.getHostAddressPtr() ) ) ) if (FAILED(hr = enumHostsResponseMsg->pAddressSender->Duplicate(hostNode.getHostAddressPtr())))
{ {
qWarning() << "Failed to duplicate host address!"; qWarning() << "Failed to duplicate host address!";
return hr; return hr;
@@ -169,25 +172,25 @@ namespace BlackSimPlugin
CoInitializeEx(nullptr, COINIT_MULTITHREADED); CoInitializeEx(nullptr, COINIT_MULTITHREADED);
// Create the IDirectPlay8Peer Object // Create the IDirectPlay8Peer Object
if( FAILED( hr = CoCreateInstance(CLSID_DirectPlay8Peer, if (FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Peer,
nullptr, nullptr,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_IDirectPlay8Peer, IID_IDirectPlay8Peer,
reinterpret_cast<void **>(&m_directPlayPeer) ) ) ) reinterpret_cast<void **>(&m_directPlayPeer))))
{ {
qWarning() << "Failed to create DirectPlay8Peer object!"; qWarning() << "Failed to create DirectPlay8Peer object!";
return hr; return hr;
} }
// Init DirectPlay // Init DirectPlay
if( FAILED( hr = m_directPlayPeer->Initialize(&m_callbackWrapper, m_callbackWrapper.messageHandler, 0 ) ) ) if (FAILED(hr = m_directPlayPeer->Initialize(&m_callbackWrapper, m_callbackWrapper.messageHandler, 0)))
{ {
qWarning() << "Failed to initialize directplay peer!"; qWarning() << "Failed to initialize directplay peer!";
return hr; return hr;
} }
// Ensure that TCP/IP is a valid Service Provider // Ensure that TCP/IP is a valid Service Provider
if( !isServiceProviderValid( &CLSID_DP8SP_TCPIP ) ) if (!isServiceProviderValid(&CLSID_DP8SP_TCPIP))
{ {
hr = E_FAIL; hr = E_FAIL;
qWarning() << "Service provider is invalid!"; qWarning() << "Service provider is invalid!";
@@ -197,7 +200,7 @@ namespace BlackSimPlugin
return hr; return hr;
} }
bool CDirectPlayPeer::isServiceProviderValid(const GUID* /*pGuidSP*/) bool CDirectPlayPeer::isServiceProviderValid(const GUID * /*pGuidSP*/)
{ {
DWORD dwItems = 0; DWORD dwItems = 0;
DWORD dwSize = 0; DWORD dwSize = 0;
@@ -205,7 +208,7 @@ namespace BlackSimPlugin
// The first call is to retrieve the size of the DPN_SERVICE_PROVIDER_INFO array // The first call is to retrieve the size of the DPN_SERVICE_PROVIDER_INFO array
HRESULT hr = m_directPlayPeer->EnumServiceProviders(&CLSID_DP8SP_TCPIP, nullptr, nullptr, &dwSize, &dwItems, 0); HRESULT hr = m_directPlayPeer->EnumServiceProviders(&CLSID_DP8SP_TCPIP, nullptr, nullptr, &dwSize, &dwItems, 0);
if( hr != DPNERR_BUFFERTOOSMALL) if (hr != DPNERR_BUFFERTOOSMALL)
{ {
qWarning() << "Failed to enumerate service providers!"; qWarning() << "Failed to enumerate service providers!";
return false; return false;
@@ -214,18 +217,18 @@ namespace BlackSimPlugin
// Allocating an array with new DPN_SERVICE_PROVIDER_INFO[items] does not work, because the struct has // Allocating an array with new DPN_SERVICE_PROVIDER_INFO[items] does not work, because the struct has
// several pointers in it. Hence EnumServiceProviders tells us how much memory it exactly needs. // several pointers in it. Hence EnumServiceProviders tells us how much memory it exactly needs.
QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]); QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]);
DPN_SERVICE_PROVIDER_INFO* dpnSPInfo = reinterpret_cast<DPN_SERVICE_PROVIDER_INFO*>(memPtr.data()); DPN_SERVICE_PROVIDER_INFO *dpnSPInfo = reinterpret_cast<DPN_SERVICE_PROVIDER_INFO *>(memPtr.data());
if( FAILED( hr = m_directPlayPeer->EnumServiceProviders(&CLSID_DP8SP_TCPIP, nullptr, dpnSPInfo, &dwSize, &dwItems, 0 ) ) ) if (FAILED(hr = m_directPlayPeer->EnumServiceProviders(&CLSID_DP8SP_TCPIP, nullptr, dpnSPInfo, &dwSize, &dwItems, 0)))
{ {
qWarning() << "Failed to enumerate service providers!"; qWarning() << "Failed to enumerate service providers!";
return false; return false;
} }
// There are no items returned so the requested SP is not available // There are no items returned so the requested SP is not available
if( dwItems == 0) hr = E_FAIL; if (dwItems == 0) hr = E_FAIL;
if( SUCCEEDED(hr) ) return true; if (SUCCEEDED(hr)) return true;
else return false; else return false;
} }
@@ -234,17 +237,17 @@ namespace BlackSimPlugin
HRESULT hr = S_OK; HRESULT hr = S_OK;
// Create our IDirectPlay8Address Device Address // Create our IDirectPlay8Address Device Address
if( FAILED( hr = CoCreateInstance( CLSID_DirectPlay8Address, nullptr, if (FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_IDirectPlay8Address, IID_IDirectPlay8Address,
reinterpret_cast<void**>(&m_deviceAddress) ) ) ) reinterpret_cast<void **>(&m_deviceAddress))))
{ {
qWarning() << "Failed to create DirectPlay8Address instance!"; qWarning() << "Failed to create DirectPlay8Address instance!";
return hr; return hr;
} }
// Set the SP for our Device Address // Set the SP for our Device Address
if( FAILED( hr = m_deviceAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) if (FAILED(hr = m_deviceAddress->SetSP(&CLSID_DP8SP_TCPIP)))
{ {
qWarning() << "Failed to set SP!"; qWarning() << "Failed to set SP!";
return hr; return hr;
@@ -258,38 +261,37 @@ namespace BlackSimPlugin
HRESULT hr = S_OK; HRESULT hr = S_OK;
// Create our IDirectPlay8Address Device Address // Create our IDirectPlay8Address Device Address
if( FAILED( hr = CoCreateInstance( CLSID_DirectPlay8Address, nullptr, if (FAILED(hr = CoCreateInstance(CLSID_DirectPlay8Address, nullptr,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_IDirectPlay8Address, IID_IDirectPlay8Address,
reinterpret_cast<void**>(&m_deviceAddress) ) ) ) reinterpret_cast<void **>(&m_deviceAddress))))
return printDirectPlayError(hr); return printDirectPlayError(hr);
// Set the SP for our Device Address // Set the SP for our Device Address
if( FAILED( hr = m_deviceAddress->SetSP( &CLSID_DP8SP_TCPIP ) ) ) if (FAILED(hr = m_deviceAddress->SetSP(&CLSID_DP8SP_TCPIP)))
return printDirectPlayError(hr); return printDirectPlayError(hr);
return S_OK; return S_OK;
} }
HRESULT CDirectPlayPeer::sendMessage( const QByteArray &message) HRESULT CDirectPlayPeer::sendMessage(const QByteArray &message)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
DPN_BUFFER_DESC dpBufferDesc; DPN_BUFFER_DESC dpBufferDesc;
if( ( dpBufferDesc.dwBufferSize = message.size() ) == 0 ) return S_FALSE; if ((dpBufferDesc.dwBufferSize = message.size()) == 0) return S_FALSE;
dpBufferDesc.pBufferData = (BYTE*)message.data(); dpBufferDesc.pBufferData = (BYTE *)message.data();
// If m_playerUser is non zero, send it only to him // If m_playerUser is non zero, send it only to him
if( FAILED( hr = m_directPlayPeer->SendTo( m_playerUser, if (FAILED(hr = m_directPlayPeer->SendTo(m_playerUser,
&dpBufferDesc, &dpBufferDesc,
1, 0, 1, 0,
nullptr, nullptr, nullptr, nullptr,
DPNSEND_SYNC | DPNSEND_NOLOOPBACK ) ) ) DPNSEND_SYNC | DPNSEND_NOLOOPBACK)))
{ {
qWarning() << "Failed to send message!"; CLogMessage(this).warning("DirectPlay: Failed to send message!");
} }
return hr; return hr;
} }
} }

View File

@@ -85,7 +85,7 @@ namespace BlackSimPlugin
if (m_interpolator.hasEnoughAircraftSituations()) if (m_interpolator.hasEnoughAircraftSituations())
{ {
CAircraftSituation situation = m_interpolator.getCurrentSituation(); CAircraftSituation situation = m_interpolator.getCurrentSituation();
MPPositionSlewMode positionSlewMode = aircraftSituationtoFS9(situation); MPPositionSlewMode positionSlewMode = aircraftSituationToFS9(situation);
QByteArray positionMessage; QByteArray positionMessage;
MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_SLEWMODE); MultiPlayerPacketParser::writeType(positionMessage, CFs9Sdk::MULTIPLAYER_PACKET_ID_POSITION_SLEWMODE);

View File

@@ -14,12 +14,14 @@
#include "FSUIPC/FSUIPC_User.h" #include "FSUIPC/FSUIPC_User.h"
#include "blacksim/fscommon/bcdconversions.h" #include "blacksim/fscommon/bcdconversions.h"
#include "blackmisc/logmessage.h"
#include <QDebug> #include <QDebug>
#include <QLatin1Char> #include <QLatin1Char>
#include <QDateTime> #include <QDateTime>
using namespace BlackSim::FsCommon; using namespace BlackSim::FsCommon;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackMisc::Geo; using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
@@ -58,16 +60,14 @@ namespace BlackSimPlugin
.arg(QLatin1Char(48 + (0x0f & (FSUIPC_Version >> 16)))) .arg(QLatin1Char(48 + (0x0f & (FSUIPC_Version >> 16))))
.arg((FSUIPC_Version & 0xffff) ? "a" + (FSUIPC_Version & 0xff) - 1 : ""); .arg((FSUIPC_Version & 0xffff) ? "a" + (FSUIPC_Version & 0xff) - 1 : "");
this->m_fsuipcVersion = QString("FSUIPC %1 (%2)").arg(ver).arg(sim); this->m_fsuipcVersion = QString("FSUIPC %1 (%2)").arg(ver).arg(sim);
// KB_REMOVE: Remove this later CLogMessage(this).info("FSUIPC connected: %1") << this->m_fsuipcVersion;
qDebug() << "FSUIPC connected" << this->m_fsuipcVersion;
} }
else else
{ {
this->m_connected = false; this->m_connected = false;
int index = static_cast<int>(result); int index = static_cast<int>(result);
this->m_lastErrorMessage = CFsuipc::errorMessages().at(index); this->m_lastErrorMessage = CFsuipc::errorMessages().at(index);
// KB_REMOVE: Remove this later CLogMessage(this).info("FSUIPC not connected: %1") << this->m_lastErrorMessage;
qDebug() << "FSUIPC" << this->m_lastErrorMessage;
} }
return this->m_connected; return this->m_connected;
} }
@@ -174,16 +174,18 @@ namespace BlackSimPlugin
transponderCodeRaw = CBcdConversions::bcd2Dec(transponderCodeRaw); transponderCodeRaw = CBcdConversions::bcd2Dec(transponderCodeRaw);
xpdr.setTransponderCode(transponderCodeRaw); xpdr.setTransponderCode(transponderCodeRaw);
// Mode by SB3 // Mode by SB3
if (xpdrIdentSb3Raw > 0) if (xpdrIdentSb3Raw != 0)
{ {
// TODO: Reset value //! \todo Reset value for FSUIPC
xpdr.setTransponderMode(CTransponder::StateIdent); xpdr.setTransponderMode(CTransponder::StateIdent);
// qDebug() << "xpdr ident" << xpdrIdentSb3Raw;
} }
else else
{ {
xpdr.setTransponderMode( xpdr.setTransponderMode(
xpdrModeSb3Raw == 0 ? CTransponder::ModeC : CTransponder::StateStandby xpdrModeSb3Raw == 0 ? CTransponder::ModeC : CTransponder::StateStandby
); );
// qDebug() << "xpdr mode" << xpdrModeSb3Raw;
} }
this->m_aircraft.setCockpit(com1, com2, xpdr); this->m_aircraft.setCockpit(com1, com2, xpdr);
@@ -213,8 +215,6 @@ namespace BlackSimPlugin
situation.setGroundspeed(groundspeed); situation.setGroundspeed(groundspeed);
situation.setAltitude(altitude); situation.setAltitude(altitude);
this->m_aircraft.setSituation(situation); this->m_aircraft.setSituation(situation);
// qDebug() << m_aircraft;
} }
else else
{ {

View File

@@ -83,6 +83,9 @@ namespace BlackSimPlugin
return sims; return sims;
} }
//! Log message category
static QString getMessageCategory() { return "swift.fscommon.fsuipc"; }
private: private:
bool m_connected; bool m_connected;
bool m_validReadValues; bool m_validReadValues;

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / contributors /* Copyright (C) 2013
* This Source Code Form is subject to the terms of the Mozilla Public * swift Project Community / Contributors
* 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/. */ * 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 "simconnect_datadefinition.h" #include "simconnect_datadefinition.h"

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / contributors /* Copyright (C) 2013
* This Source Code Form is subject to the terms of the Mozilla Public * swift Project Community / Contributors
* 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/. */ * 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 "simconnect_object.h" #include "simconnect_object.h"
#include "blackcore/interpolator_linear.h" #include "blackcore/interpolator_linear.h"

View File

@@ -514,12 +514,13 @@ namespace BlackSimPlugin
position.Heading = situation.getHeading().value(CAngleUnit::deg()); position.Heading = situation.getHeading().value(CAngleUnit::deg());
position.Airspeed = situation.getGroundSpeed().value(CSpeedUnit::kts()); position.Airspeed = situation.getGroundSpeed().value(CSpeedUnit::kts());
// TODO: epic fail for helicopters and VTOPs! //! \todo : epic fail for helicopters and VTOPs!
position.OnGround = position.Airspeed < 30 ? 1 : 0; position.OnGround = position.Airspeed < 30 ? 1 : 0;
DataDefinitionRemoteAircraftSituation ddAircraftSituation; DataDefinitionRemoteAircraftSituation ddAircraftSituation;
ddAircraftSituation.position = position; ddAircraftSituation.position = position;
//! \todo Gear handling with new protocol extension
DataDefinitionGearHandlePosition gearHandle; DataDefinitionGearHandlePosition gearHandle;
gearHandle.gearHandlePosition = position.Altitude < 1000 ? 1 : 0; gearHandle.gearHandlePosition = position.Altitude < 1000 ? 1 : 0;
@@ -563,11 +564,11 @@ namespace BlackSimPlugin
if (hr != S_OK) if (hr != S_OK)
{ {
qWarning() << "Sending time sync failed!"; CLogMessage(this).warning("Sending time sync failed!");
} }
m_syncDeferredCounter = 5; // allow some time to sync m_syncDeferredCounter = 5; // allow some time to sync
CLogMessage(this).info("Synchronized time to UTC: %1") << myTime.toString(); CLogMessage(this).info("Synchronized time to UTC: %1") << myTime.toString();
} }
} } // namespace
} } // namespace

View File

@@ -1,7 +1,11 @@
/* Copyright (C) 2013 VATSIM Community / contributors /* Copyright (C) 2013
* This Source Code Form is subject to the terms of the Mozilla Public * swift Project Community / Contributors
* 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/. */ * 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_fsx.h" #include "simulator_fsx.h"
#include "simconnect_datadefinition.h" #include "simconnect_datadefinition.h"
@@ -48,8 +52,9 @@ namespace BlackSimPlugin
ex.sprintf("Exception=%d SendID=%d Index=%d cbData=%d", ex.sprintf("Exception=%d SendID=%d Index=%d cbData=%d",
static_cast<int>(exception->dwException), static_cast<int>(exception->dwSendID), static_cast<int>(exception->dwException), static_cast<int>(exception->dwSendID),
static_cast<int>(exception->dwIndex), static_cast<int>(cbData)); static_cast<int>(exception->dwIndex), static_cast<int>(cbData));
qDebug() << "Caught simConnect exception: " << CSimConnectUtilities::simConnectExceptionToString((SIMCONNECT_EXCEPTION)exception->dwException); CLogMessage(static_cast<CSimulatorFsx *>(nullptr)).error("Caught simConnect exception: %1 %2")
qDebug() << ex; << CSimConnectUtilities::simConnectExceptionToString((SIMCONNECT_EXCEPTION)exception->dwException)
<< ex;
break; break;
} }
case SIMCONNECT_RECV_ID_QUIT: case SIMCONNECT_RECV_ID_QUIT:
@@ -178,5 +183,8 @@ namespace BlackSimPlugin
break; break;
} // main switch } // main switch
} // method } // method
} // namespace
} // namespace
} }
} }

View File

@@ -82,10 +82,10 @@ signals:
void currentMainInfoAreaChanged(const QWidget *currentWidget); void currentMainInfoAreaChanged(const QWidget *currentWidget);
protected: protected:
//! \copy QMainWindow::mouseMoveEvent //! \copydoc QMainWindow::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QMainWindow::mouseMoveEvent(event); } ; } virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QMainWindow::mouseMoveEvent(event); } ; }
//! \copy QMainWindow::mousePressEvent //! \copydoc QMainWindow::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); } } virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); } }
//! \copydoc QMainWindow::closeEvent //! \copydoc QMainWindow::closeEvent