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)
// 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"));
// voice rooms

View File

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

View File

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

View File

@@ -121,10 +121,10 @@ namespace BlackGui
//! \copydoc QWidget::paintEvent
virtual void paintEvent(QPaintEvent *event) override;
//! \copy QMainWindow::mouseMoveEvent
//! \copydoc QMainWindow::mouseMoveEvent
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); } }
//! Contribute to menu

View File

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

View File

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

View File

@@ -7,6 +7,8 @@
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSIMPLUGIN_FREEFUNCTIONS_H
#define BLACKSIMPLUGIN_FREEFUNCTIONS_H
@@ -51,18 +53,17 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAircraftSituation aircraftSituationfromFS9(const MPPositionVelocity &positionVelocity);
//! 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,
double updateInterval);
//! 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);
}
}
#endif //BLACKSIMPLUGIN_FREEFUNCTIONS_H
#endif // guard

View File

@@ -10,6 +10,7 @@
#include "directplay_peer.h"
#include "multiplayer_packet_parser.h"
#include "blacksimplugin_freefunctions.h"
#include "blackmisc/logmessage.h"
#include <QDebug>
#include <QTimer>
#include <QFile>
@@ -17,6 +18,8 @@
#include <QScopedPointer>
#include <QMutexLocker>
using namespace BlackMisc;
namespace BlackSimPlugin
{
namespace Fs9
@@ -287,9 +290,8 @@ namespace BlackSimPlugin
nullptr, nullptr,
DPNSEND_SYNC | DPNSEND_NOLOOPBACK)))
{
qWarning() << "Failed to send message!";
CLogMessage(this).warning("DirectPlay: Failed to send message!");
}
return hr;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -514,12 +514,13 @@ namespace BlackSimPlugin
position.Heading = situation.getHeading().value(CAngleUnit::deg());
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;
DataDefinitionRemoteAircraftSituation ddAircraftSituation;
ddAircraftSituation.position = position;
//! \todo Gear handling with new protocol extension
DataDefinitionGearHandlePosition gearHandle;
gearHandle.gearHandlePosition = position.Altitude < 1000 ? 1 : 0;
@@ -563,11 +564,11 @@ namespace BlackSimPlugin
if (hr != S_OK)
{
qWarning() << "Sending time sync failed!";
CLogMessage(this).warning("Sending time sync failed!");
}
m_syncDeferredCounter = 5; // allow some time to sync
CLogMessage(this).info("Synchronized time to UTC: %1") << myTime.toString();
}
}
}
} // namespace
} // namespace

View File

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

View File

@@ -82,10 +82,10 @@ signals:
void currentMainInfoAreaChanged(const QWidget *currentWidget);
protected:
//! \copy QMainWindow::mouseMoveEvent
//! \copydoc QMainWindow::mouseMoveEvent
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); } }
//! \copydoc QMainWindow::closeEvent