Ref T410, preparation and UI adjustments

Foo
This commit is contained in:
Klaus Basan
2018-10-22 23:14:59 +02:00
parent 4a82621a1d
commit 35b8b29d10
10 changed files with 152 additions and 48 deletions

View File

@@ -1249,9 +1249,20 @@ namespace BlackCore
// Ref T297, // Ref T297,
const qint64 diff = qAbs(markerTs - oldTs); const qint64 diff = qAbs(markerTs - oldTs);
const qint64 offsetTime = (oldTs > 0 && diff > 0 && diff < CFsdSetup::c_interimPositionTimeOffsetMsec) ? qint64 offsetTime = CFsdSetup::c_positionTimeOffsetMsec;
CFsdSetup::c_interimPositionTimeOffsetMsec : static const qint64 thresholdMs = qRound(CFsdSetup::c_positionTimeOffsetMsec * 0.4);
CFsdSetup::c_positionTimeOffsetMsec; 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; m_lastOffsetTime[callsign] = offsetTime;
return offsetTime; return offsetTime;
} }

View File

@@ -56,10 +56,10 @@ namespace BlackMisc
Q_DECLARE_FLAGS(SendReceiveDetails, SendReceiveDetailsFlag) Q_DECLARE_FLAGS(SendReceiveDetails, SendReceiveDetailsFlag)
//! Offset times basically telling when to expect the next value from network plus some reserve //! 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 constexpr qint64 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_interimPositionTimeOffsetMsec = 1500; //!< offset time for received interim position updates Ref T297
//! @} //! @}
//! Default constructor. //! Default constructor.

View File

@@ -289,6 +289,7 @@ namespace BlackMisc
} }
else else
{ {
// newSituationsList.push_frontKeepLatestFirstIgnoreOverlapping(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign);
newSituationsList.push_frontKeepLatestFirstAdjustOffset(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign); newSituationsList.push_frontKeepLatestFirstAdjustOffset(situationCorrected, true, IRemoteAircraftProvider::MaxSituationsPerCallsign);
newSituationsList.setAdjustedSortHint(CAircraftSituationList::AdjustedTimestampLatestFirst); newSituationsList.setAdjustedSortHint(CAircraftSituationList::AdjustedTimestampLatestFirst);
newSituationsList.transferElevationForward(); // transfer elevations, will do nothing if elevations already exist newSituationsList.transferElevationForward(); // transfer elevations, will do nothing if elevations already exist

View File

@@ -13,12 +13,17 @@
#include "blackgui/overlaymessagesframe.h" #include "blackgui/overlaymessagesframe.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h" #include "blackcore/context/contextsimulator.h"
#include "blackconfig/buildconfig.h"
#include <QPointer>
#include <QTimer>
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Context; using namespace BlackCore::Context;
using namespace BlackGui; using namespace BlackGui;
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
using namespace BlackConfig;
namespace BlackSimPlugin namespace BlackSimPlugin
{ {
@@ -36,15 +41,20 @@ namespace BlackSimPlugin
connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged); connect(ui->cb_UseFsuipc, &QCheckBox::released, this, &CFsxSettingsComponent::onFsuipcChanged);
connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged); connect(ui->cb_SBOffsets, &QCheckBox::released, this, &CFsxSettingsComponent::onSBOffsetsChanged);
connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe); connect(ui->pb_CopyTerrainProbe, &QPushButton::released, this, &CFsxSettingsComponent::copyTerrainProbe);
connect(ui->pb_Refresh, &QPushButton::released, this, &CFsxSettingsComponent::refresh);
const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); if (sGui && sGui->getIContextSimulator())
if (fsx)
{ {
ui->cb_TraceSimConnectCalls->setChecked(fsx->isTracingSendId()); connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CFsxSettingsComponent::onSimulatorStatusChanged, Qt::QueuedConnection);
ui->cb_EnableTerrainProbe->setChecked(fsx->isUsingFsxTerrainProbe()); connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CFsxSettingsComponent::onSimulatorPluginChanged, Qt::QueuedConnection);
ui->cb_SBOffsets->setChecked(fsx->isUsingSbOffsetValues());
ui->cb_UseFsuipc->setChecked(fsx->isFsuipcConnected());
} }
QPointer<CFsxSettingsComponent> myself(this);
QTimer::singleShot(2000, this, [ = ]
{
if (!sGui || !myself || sGui->isShuttingDown()) { return; }
this->refresh();
});
} }
CFsxSettingsComponent::~CFsxSettingsComponent() CFsxSettingsComponent::~CFsxSettingsComponent()
@@ -52,36 +62,52 @@ namespace BlackSimPlugin
CSimulatorInfo CFsxSettingsComponent::getSimulator() const CSimulatorInfo CFsxSettingsComponent::getSimulator() const
{ {
const CSimulatorFsxCommon *fsx = this->getFsxSimulator(); const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
return fsx ? fsx->getSimulatorInfo() : m_simulator; 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() void CFsxSettingsComponent::onSimConnectTraceChanged()
{ {
CSimulatorFsxCommon *fsx = this->getFsxSimulator(); CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
if (!fsx) { return; } if (!fsxOrP3D) { return; }
fsx->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked()); fsxOrP3D->setTractingSendId(ui->cb_TraceSimConnectCalls->isChecked());
} }
void CFsxSettingsComponent::onEnableTerrainProbeChanged() void CFsxSettingsComponent::onEnableTerrainProbeChanged()
{ {
CSimulatorFsxCommon *fsx = this->getFsxSimulator(); CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
if (!fsx) { return; } if (!fsxOrP3D) { return; }
fsx->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked()); fsxOrP3D->setUsingFsxTerrainProbe(ui->cb_EnableTerrainProbe->isChecked());
} }
void CFsxSettingsComponent::onFsuipcChanged() void CFsxSettingsComponent::onFsuipcChanged()
{ {
CSimulatorFsxCommon *fsx = this->getFsxSimulator(); CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
if (!fsx) { return; } if (!fsxOrP3D) { return; }
fsx->useFsuipc(ui->cb_UseFsuipc->isChecked()); fsxOrP3D->useFsuipc(ui->cb_UseFsuipc->isChecked());
} }
void CFsxSettingsComponent::onSBOffsetsChanged() void CFsxSettingsComponent::onSBOffsetsChanged()
{ {
CSimulatorFsxCommon *fsx = this->getFsxSimulator(); CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator();
if (!fsx) { return; } if (!fsxOrP3D) { return; }
fsx->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked()); fsxOrP3D->setUsingSbOffsetValues(ui->cb_SBOffsets->isChecked());
} }
void CFsxSettingsComponent::copyTerrainProbe() void CFsxSettingsComponent::copyTerrainProbe()
@@ -94,7 +120,19 @@ namespace BlackSimPlugin
if (m_mf) { m_mf->showOverlayMessages(msgs); } 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; } if (!sGui || !sGui->getISimulator() || sGui->isShuttingDown()) { return nullptr; }
ISimulator *simulator = sGui->getISimulator(); ISimulator *simulator = sGui->getISimulator();

View File

@@ -13,6 +13,7 @@
#define BLACKSIMPLUGIN_FSXCOMMON_FSXSETTINGSCOMPONENT_H #define BLACKSIMPLUGIN_FSXCOMMON_FSXSETTINGSCOMPONENT_H
#include "blackmisc/simulation/simulatorinfo.h" #include "blackmisc/simulation/simulatorinfo.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include <QFrame> #include <QFrame>
#include <QScopedPointer> #include <QScopedPointer>
@@ -42,6 +43,9 @@ namespace BlackSimPlugin
//! Represented simulator //! Represented simulator
BlackMisc::Simulation::CSimulatorInfo getSimulator() const; BlackMisc::Simulation::CSimulatorInfo getSimulator() const;
//! Update the values
void refresh();
private: private:
//! Trace checkbox changed //! Trace checkbox changed
void onSimConnectTraceChanged(); void onSimConnectTraceChanged();
@@ -58,8 +62,14 @@ namespace BlackSimPlugin
//! Copy the terrain probe //! Copy the terrain probe
void copyTerrainProbe(); void copyTerrainProbe();
//! Status has been changed
void onSimulatorStatusChanged(int status);
//! Plugin changed
void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
//! Access the concrete implementation //! Access the concrete implementation
CSimulatorFsxCommon *getFsxSimulator() const; CSimulatorFsxCommon *getFsxOrP3DSimulator() const;
BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" }; BlackMisc::Simulation::CSimulatorInfo m_simulator { "FSX" };
BlackGui::COverlayMessagesFrame *m_mf = nullptr; BlackGui::COverlayMessagesFrame *m_mf = nullptr;

View File

@@ -6,14 +6,47 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>180</width> <width>254</width>
<height>121</height> <height>147</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>FSX/P3D settings</string> <string>FSX/P3D settings</string>
</property> </property>
<layout class="QGridLayout" name="gl_Settings" columnstretch="0,1"> <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"> <item row="0" column="0">
<widget class="QCheckBox" name="cb_TraceSimConnectCalls"> <widget class="QCheckBox" name="cb_TraceSimConnectCalls">
<property name="text"> <property name="text">
@@ -41,14 +74,17 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="lbl_SBOffsets"> <widget class="QLabel" name="lbl_SBOffsets">
<property name="text"> <property name="text">
<string>Enable SB SimConnect offsets</string> <string>Enable SB SimConnect offsets. Those are needed to detect &quot;Ident&quot; and &quot;Standby&quot; from your transponder (supported by some vendors as PMDG).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLabel" name="lbl_TraceTerrainProbe"> <widget class="QLabel" name="lbl_TraceTerrainProbe">
<property name="text"> <property name="text">
<string>Use the terrain probe</string> <string>Use the terrain probe (32bit only)</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -59,13 +95,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QCheckBox" name="cb_SBOffsets">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="lbl_UseFsuipc"> <widget class="QLabel" name="lbl_UseFsuipc">
<property name="text"> <property name="text">
@@ -73,10 +102,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="2" column="0">
<widget class="QPushButton" name="pb_CopyTerrainProbe"> <widget class="QCheckBox" name="cb_SBOffsets">
<property name="text"> <property name="text">
<string> copy terrain probe </string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
@@ -87,7 +116,6 @@
<tabstop>cb_UseFsuipc</tabstop> <tabstop>cb_UseFsuipc</tabstop>
<tabstop>cb_SBOffsets</tabstop> <tabstop>cb_SBOffsets</tabstop>
<tabstop>cb_EnableTerrainProbe</tabstop> <tabstop>cb_EnableTerrainProbe</tabstop>
<tabstop>pb_CopyTerrainProbe</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -164,9 +164,11 @@ namespace BlackSimPlugin
}; };
//! The whole SB data area //! 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 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 //! Standby = 1, else 0
byte getTransponderMode() const { return data[17]; } byte getTransponderMode() const { return data[17]; }

View File

@@ -27,6 +27,7 @@
#include "blackmisc/statusmessage.h" #include "blackmisc/statusmessage.h"
#include "blackmisc/network/client.h" #include "blackmisc/network/client.h"
#include "blackmisc/pixmap.h" #include "blackmisc/pixmap.h"
#include "blackconfig/buildconfig.h"
#include <QObject> #include <QObject>
#include <QtPlugin> #include <QtPlugin>
@@ -272,15 +273,20 @@ namespace BlackSimPlugin
//! Register help //! Register help
static void registerHelp(); 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? static constexpr qint64 AutoTraceOffsetMs = 10 * 1000; //!< how long do we trace?
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
DispatchProc m_dispatchProc = &CSimulatorFsxCommon::SimConnectProc; //!< called function for dispatch, can be overriden by specialized P3D function 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 CSimConnectObjects m_simConnectObjects; //!< AI objects and their object and request ids
// probes // probes
bool m_useFsxTerrainProbe = true; //!< Use FSX Terrain probe? bool m_useFsxTerrainProbe = is32bit(); //!< Use FSX Terrain probe?
bool m_initFsxTerrainProbes = false; //!< initialized terrain probes bool m_initFsxTerrainProbes = false; //!< initialized terrain probes
int m_addedProbes = 0; //!< added probes int m_addedProbes = 0; //!< added probes
QMap<DWORD, BlackMisc::Aviation::CCallsign> m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign QMap<DWORD, BlackMisc::Aviation::CCallsign> m_pendingProbeRequests; //!< pending elevation requests: requestId/aircraft callsign
private: private:

View File

@@ -2,6 +2,14 @@
<ui version="4.0"> <ui version="4.0">
<class>CSimulatorFsxConfigWindow</class> <class>CSimulatorFsxConfigWindow</class>
<widget class="QWidget" name="CSimulatorFsxConfigWindow"> <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"> <property name="minimumSize">
<size> <size>
<width>450</width> <width>450</width>

View File

@@ -382,7 +382,7 @@ namespace BlackSimPlugin
{ {
if (!simulatorFsxP3D->m_useSbOffsets) { break; } if (!simulatorFsxP3D->m_useSbOffsets) { break; }
const SIMCONNECT_RECV_CLIENT_DATA *clientData = static_cast<SIMCONNECT_RECV_CLIENT_DATA *>(pData); 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 //! \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); const DataDefinitionClientAreaSb *sbData = reinterpret_cast<const DataDefinitionClientAreaSb *>(&clientData->dwData);