mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T410, preparation and UI adjustments
Foo
This commit is contained in:
@@ -1249,9 +1249,20 @@ namespace BlackCore
|
||||
|
||||
// Ref T297,
|
||||
const qint64 diff = qAbs(markerTs - oldTs);
|
||||
const qint64 offsetTime = (oldTs > 0 && diff > 0 && diff < CFsdSetup::c_interimPositionTimeOffsetMsec) ?
|
||||
CFsdSetup::c_interimPositionTimeOffsetMsec :
|
||||
CFsdSetup::c_positionTimeOffsetMsec;
|
||||
qint64 offsetTime = CFsdSetup::c_positionTimeOffsetMsec;
|
||||
static const qint64 thresholdMs = qRound(CFsdSetup::c_positionTimeOffsetMsec * 0.4);
|
||||
if (oldTs > 0 && diff > 0)
|
||||
{
|
||||
if (diff < CFsdSetup::c_interimPositionTimeOffsetMsec)
|
||||
{
|
||||
offsetTime = CFsdSetup::c_interimPositionTimeOffsetMsec;
|
||||
}
|
||||
else if (diff < thresholdMs)
|
||||
{
|
||||
offsetTime = qRound(diff * 1.1);
|
||||
}
|
||||
}
|
||||
|
||||
m_lastOffsetTime[callsign] = offsetTime;
|
||||
return offsetTime;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ namespace BlackMisc
|
||||
Q_DECLARE_FLAGS(SendReceiveDetails, SendReceiveDetailsFlag)
|
||||
|
||||
//! Offset times basically telling when to expect the next value from network plus some reserve
|
||||
//! \remark copies of CNetworkVatlib::c_updatePostionIntervalMsec / c_updateInterimPostionIntervalMsec
|
||||
//! \remark related to CNetworkVatlib::c_updatePostionIntervalMsec / c_updateInterimPostionIntervalMsec
|
||||
//! @{
|
||||
static qint64 constexpr c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates Ref T297
|
||||
static qint64 constexpr c_interimPositionTimeOffsetMsec = 2000; //!< offset time for received interim position updates Ref T297
|
||||
static constexpr qint64 c_positionTimeOffsetMsec = 6000; //!< offset time for received position updates Ref T297
|
||||
static constexpr qint64 c_interimPositionTimeOffsetMsec = 1500; //!< offset time for received interim position updates Ref T297
|
||||
//! @}
|
||||
|
||||
//! Default constructor.
|
||||
|
||||
@@ -289,6 +289,7 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
// newSituationsList.push_frontKeepLatestFirstIgnoreOverlapping(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
newSituationsList.push_frontKeepLatestFirstAdjustOffset(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign);
|
||||
newSituationsList.setAdjustedSortHint(CAircraftSituationList::AdjustedTimestampLatestFirst);
|
||||
newSituationsList.transferElevationForward(); // transfer elevations, will do nothing if elevations already exist
|
||||
|
||||
@@ -13,12 +13,17 @@
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackConfig;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -36,15 +41,20 @@ namespace BlackSimPlugin
|
||||
connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged);
|
||||
connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged);
|
||||
connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe);
|
||||
connect(ui->pb_Refresh, &QPushButton::released, this, &CFsxSettingsComponent::refresh);
|
||||
|
||||
const CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
if (fsx)
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
{
|
||||
ui->cb_TraceSimConnectCalls->setChecked(fsx->isTracingSendId());
|
||||
ui->cb_EnableTerrainProbe->setChecked(fsx->isUsingFsxTerrainProbe());
|
||||
ui->cb_SBOffsets->setChecked(fsx->isUsingSbOffsetValues());
|
||||
ui->cb_UseFsuipc->setChecked(fsx->isFsuipcConnected());
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CFsxSettingsComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CFsxSettingsComponent::onSimulatorPluginChanged, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QPointer<CFsxSettingsComponent> myself(this);
|
||||
QTimer::singleShot(2000, this, [ = ]
|
||||
{
|
||||
if (!sGui || !myself || sGui->isShuttingDown()) { return; }
|
||||
this->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
CFsxSettingsComponent::~CFsxSettingsComponent()
|
||||
@@ -52,36 +62,52 @@ namespace BlackSimPlugin
|
||||
|
||||
CSimulatorInfo CFsxSettingsComponent::getSimulator() const
|
||||
{
|
||||
const CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
return fsx ? fsx->getSimulatorInfo() : m_simulator;
|
||||
const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
return fsxOrP3D ? fsxOrP3D->getSimulatorInfo() : m_simulator;
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::refresh()
|
||||
{
|
||||
const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
if (fsxOrP3D)
|
||||
{
|
||||
ui->cb_TraceSimConnectCalls->setChecked(fsxOrP3D->isTracingSendId());
|
||||
ui->cb_EnableTerrainProbe->setChecked(fsxOrP3D->isUsingFsxTerrainProbe());
|
||||
ui->cb_SBOffsets->setChecked(fsxOrP3D->isUsingSbOffsetValues());
|
||||
ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcConnected());
|
||||
}
|
||||
|
||||
const bool terrainProbe = CBuildConfig::isRunningOnWindowsNtPlatform() && (CBuildConfig::buildWordSize() == 32);
|
||||
ui->cb_EnableTerrainProbe->setEnabled(terrainProbe);
|
||||
ui->pb_CopyTerrainProbe->setVisible(terrainProbe);
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::onSimConnectTraceChanged()
|
||||
{
|
||||
CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
if (!fsx) { return; }
|
||||
fsx->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked());
|
||||
CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
if (!fsxOrP3D) { return; }
|
||||
fsxOrP3D->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked());
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::onEnableTerrainProbeChanged()
|
||||
{
|
||||
CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
if (!fsx) { return; }
|
||||
fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked());
|
||||
CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
if (!fsxOrP3D) { return; }
|
||||
fsxOrP3D->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked());
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::onFsuipcChanged()
|
||||
{
|
||||
CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
if (!fsx) { return; }
|
||||
fsx->useFsuipc(ui->cb_UseFsuipc->isChecked());
|
||||
CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
if (!fsxOrP3D) { return; }
|
||||
fsxOrP3D->useFsuipc(ui->cb_UseFsuipc->isChecked());
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::onSBOffsetsChanged()
|
||||
{
|
||||
CSimulatorFsxCommon *fsx = this->getFsxSimulator();
|
||||
if (!fsx) { return; }
|
||||
fsx->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked());
|
||||
CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
|
||||
if (!fsxOrP3D) { return; }
|
||||
fsxOrP3D->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked());
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::copyTerrainProbe()
|
||||
@@ -94,7 +120,19 @@ namespace BlackSimPlugin
|
||||
if (m_mf) { m_mf->showOverlayMessages(msgs); }
|
||||
}
|
||||
|
||||
CSimulatorFsxCommon *CFsxSettingsComponent::getFsxSimulator() const
|
||||
void CFsxSettingsComponent::onSimulatorStatusChanged(int status)
|
||||
{
|
||||
Q_UNUSED(status);
|
||||
this->refresh();
|
||||
}
|
||||
|
||||
void CFsxSettingsComponent::onSimulatorPluginChanged(const CSimulatorPluginInfo &info)
|
||||
{
|
||||
Q_UNUSED(info);
|
||||
this->refresh();
|
||||
}
|
||||
|
||||
CSimulatorFsxCommon *CFsxSettingsComponent::getFsxOrP3DSimulator() const
|
||||
{
|
||||
if (!sGui || !sGui->getISimulator() || sGui->isShuttingDown()) { return nullptr; }
|
||||
ISimulator *simulator = sGui->getISimulator();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKSIMPLUGIN_FSXCOMMON_FSXSETTINGSCOMPONENT_H
|
||||
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
@@ -42,6 +43,9 @@ namespace BlackSimPlugin
|
||||
//! Represented simulator
|
||||
BlackMisc::Simulation::CSimulatorInfo getSimulator() const;
|
||||
|
||||
//! Update the values
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
//! Trace checkbox changed
|
||||
void onSimConnectTraceChanged();
|
||||
@@ -58,8 +62,14 @@ namespace BlackSimPlugin
|
||||
//! Copy the terrain probe
|
||||
void copyTerrainProbe();
|
||||
|
||||
//! Status has been changed
|
||||
void onSimulatorStatusChanged(int status);
|
||||
|
||||
//! Plugin changed
|
||||
void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
//! Access the concrete implementation
|
||||
CSimulatorFsxCommon *getFsxSimulator() const;
|
||||
CSimulatorFsxCommon *getFsxOrP3DSimulator() const;
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" };
|
||||
BlackGui::COverlayMessagesFrame *m_mf = nullptr;
|
||||
|
||||
@@ -6,14 +6,47 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>180</width>
|
||||
<height>121</height>
|
||||
<width>254</width>
|
||||
<height>147</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FSX/P3D settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Settings" columnstretch="0,1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="wi_Buttons" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_CopyTerrainProbe">
|
||||
<property name="text">
|
||||
<string>copy terrain probe</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_Refresh">
|
||||
<property name="text">
|
||||
<string>refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Buttons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_TraceSimConnectCalls">
|
||||
<property name="text">
|
||||
@@ -41,14 +74,17 @@
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lbl_SBOffsets">
|
||||
<property name="text">
|
||||
<string>Enable SB SimConnect offsets</string>
|
||||
<string>Enable SB SimConnect offsets. Those are needed to detect "Ident" and "Standby" from your transponder (supported by some vendors as PMDG).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbl_TraceTerrainProbe">
|
||||
<property name="text">
|
||||
<string>Use the terrain probe</string>
|
||||
<string>Use the terrain probe (32bit only)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -59,13 +95,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="cb_SBOffsets">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lbl_UseFsuipc">
|
||||
<property name="text">
|
||||
@@ -73,10 +102,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="pb_CopyTerrainProbe">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="cb_SBOffsets">
|
||||
<property name="text">
|
||||
<string> copy terrain probe </string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -87,7 +116,6 @@
|
||||
<tabstop>cb_UseFsuipc</tabstop>
|
||||
<tabstop>cb_SBOffsets</tabstop>
|
||||
<tabstop>cb_EnableTerrainProbe</tabstop>
|
||||
<tabstop>pb_CopyTerrainProbe</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -164,9 +164,11 @@ namespace BlackSimPlugin
|
||||
};
|
||||
|
||||
//! The whole SB data area
|
||||
//! \remark vPilot SB area https://forums.vatsim.net/viewtopic.php?p=519580
|
||||
//! \remark SB offsets http://www.squawkbox.ca/doc/sdk/fsuipc.php
|
||||
struct DataDefinitionClientAreaSb
|
||||
{
|
||||
byte data[128] {}; //!< 128 bytes of data, offsets http://www.squawkbox.ca/doc/sdk/fsuipc.php
|
||||
byte data[128] {}; //!< 128 bytes of data, offsets
|
||||
|
||||
//! Standby = 1, else 0
|
||||
byte getTransponderMode() const { return data[17]; }
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/network/client.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QtPlugin>
|
||||
@@ -272,15 +273,20 @@ namespace BlackSimPlugin
|
||||
//! Register help
|
||||
static void registerHelp();
|
||||
|
||||
//! Word size @{
|
||||
static bool is32bit() { return (BlackConfig::CBuildConfig::buildWordSize() == 32); }
|
||||
static bool is64bit() { return (BlackConfig::CBuildConfig::buildWordSize() == 64); }
|
||||
//! @}
|
||||
|
||||
static constexpr qint64 AutoTraceOffsetMs = 10 * 1000; //!< how long do we trace?
|
||||
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
|
||||
DispatchProc m_dispatchProc = &CSimulatorFsxCommon::SimConnectProc; //!< called function for dispatch, can be overriden by specialized P3D function
|
||||
CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids
|
||||
|
||||
// probes
|
||||
bool m_useFsxTerrainProbe = true; //!< Use FSX Terrain probe?
|
||||
bool m_initFsxTerrainProbes = false; //!< initialized terrain probes
|
||||
int m_addedProbes = 0; //!< added probes
|
||||
bool m_useFsxTerrainProbe = is32bit(); //!< Use FSX Terrain probe?
|
||||
bool m_initFsxTerrainProbes = false; //!< initialized terrain probes
|
||||
int m_addedProbes = 0; //!< added probes
|
||||
QMap<DWORD, BlackMisc::Aviation::CCallsign> m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<ui version="4.0">
|
||||
<class>CSimulatorFsxConfigWindow</class>
|
||||
<widget class="QWidget" name="CSimulatorFsxConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>525</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (!simulatorFsxP3D->m_useSbOffsets) { break; }
|
||||
const SIMCONNECT_RECV_CLIENT_DATA *clientData = static_cast<SIMCONNECT_RECV_CLIENT_DATA *>(pData);
|
||||
if (simulatorFsxP3D->m_useSbOffsets && clientData->dwRequestID == CSimConnectDefinitions::RequestSbData)
|
||||
if (clientData->dwRequestID == CSimConnectDefinitions::RequestSbData)
|
||||
{
|
||||
//! \fixme FSUIPC vs SimConnect why is offset 19 ident 2/0? In FSUIPC it is 0/1, according to documentation it is 0/1 but I receive 2/0 here. Whoever knows, add comment or fix if wrong
|
||||
const DataDefinitionClientAreaSb *sbData = reinterpret_cast<const DataDefinitionClientAreaSb *>(&clientData->dwData);
|
||||
|
||||
Reference in New Issue
Block a user