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
@@ -287,9 +290,8 @@ namespace BlackSimPlugin
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