Skip to content

Commit 54a1b0d

Browse files
committed
Feat: ForeFlight send non-TCAS targets only
1 parent c84b4c8 commit 54a1b0d

File tree

6 files changed

+47
-30
lines changed

6 files changed

+47
-30
lines changed

Include/DataRefs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ enum SimTimeCtrlTy : int {
476476
STC_SIM_TIME_PLUS_BUFFER, ///< Send current sim time plus buffering period, so that the traffic, when it appears, matches up with current sim time
477477
};
478478

479+
/// Which amount of planes to send to ForeFlight?
480+
enum TrafficToSendTy : int {
481+
TTS_NONE = 0, ///< Don't send any traffic
482+
TTS_ALL, ///< Send all known planes
483+
TTS_NONTCAS_ONLY, ///< Send only planes that don't have a TCAS slot in X-Plane
484+
};
485+
479486
/// How to control weather?
480487
enum WeatherCtrlTy : int {
481488
WC_INIT = -1, ///< Initial value when not available in config file, then a default is determined in first flight loop depending if XP is using real weather
@@ -746,7 +753,7 @@ class DataRefs
746753
int ffListenPort = 63093; ///< UDP Port to listen to ForeFlight announcing itself, https://www.foreflight.com/connect/spec/
747754
int ffSendPort = 49002; ///< UDP Port to send simulator data to ForeFlight, https://www.foreflight.com/support/network-gps/
748755
int bffUserPlane = 1; // bool Send User plane data?
749-
int bffTraffic = 1; // bool Send traffic data?
756+
TrafficToSendTy ffTraffic=TTS_ALL; ///< Send traffic data? And which amount of traffic?
750757
int ffSendTrfcIntvl = 3; // [s] interval to broadcast traffic info
751758

752759
vecCSLPaths vCSLPaths; // list of paths to search for CSL packages

LiveTraffic.xcodeproj/xcuserdata/birger.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,4 @@
33
uuid = "C8095CDD-1C39-4D01-99B0-6AD4723390BD"
44
type = "1"
55
version = "2.0">
6-
<Breakpoints>
7-
<BreakpointProxy
8-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9-
<BreakpointContent
10-
uuid = "0E4F1846-5727-472D-A718-AD907A425A6E"
11-
shouldBeEnabled = "Yes"
12-
ignoreCount = "0"
13-
continueAfterRunningActions = "No"
14-
filePath = "Src/LTAutoATC.cpp"
15-
startingColumnNumber = "9223372036854775807"
16-
endingColumnNumber = "9223372036854775807"
17-
startingLineNumber = "125"
18-
endingLineNumber = "125"
19-
landmarkName = "AutoATCConnection::ProcessFetchedData()"
20-
landmarkType = "7">
21-
</BreakpointContent>
22-
</BreakpointProxy>
23-
</Breakpoints>
246
</Bucket>

Src/DataRefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ DataRefs::dataRefDefinitionT DATA_REFS_LT[CNT_DATAREFS_LT] = {
571571
{"livetraffic/channel/fore_flight/listen_port", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
572572
{"livetraffic/channel/fore_flight/send_port", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
573573
{"livetraffic/channel/fore_flight/user_plane", DataRefs::LTGetInt, DataRefs::LTSetBool, GET_VAR, true },
574-
{"livetraffic/channel/fore_flight/traffic", DataRefs::LTGetInt, DataRefs::LTSetBool, GET_VAR, true },
574+
{"livetraffic/channel/fore_flight/traffic", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
575575
{"livetraffic/channel/fore_flight/interval", DataRefs::LTGetInt, DataRefs::LTSetCfgValue, GET_VAR, true },
576576

577577
// channels, in ascending order of priority
@@ -670,7 +670,7 @@ void* DataRefs::getVarAddr (dataRefsLT dr)
670670
case DR_CFG_FF_LISTEN_PORT: return &ffListenPort;
671671
case DR_CFG_FF_SEND_PORT: return &ffSendPort;
672672
case DR_CFG_FF_SEND_USER_PLANE: return &bffUserPlane;
673-
case DR_CFG_FF_SEND_TRAFFIC: return &bffTraffic;
673+
case DR_CFG_FF_SEND_TRAFFIC: return &ffTraffic;
674674
case DR_CFG_FF_SEND_TRAFFIC_INTVL: return &ffSendTrfcIntvl;
675675

676676
default:

Src/LTForeFlight.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void ForeFlightSender::Main ()
195195
// Between any two broadcasts there is 20ms break.
196196
//
197197
const bool bSendUsersPlane = DataRefs::GetCfgBool(DR_CFG_FF_SEND_USER_PLANE);
198-
const bool bSendAITraffic = DataRefs::GetCfgBool(DR_CFG_FF_SEND_TRAFFIC);
198+
const TrafficToSendTy eSendAITraffic = TrafficToSendTy(DataRefs::GetCfgInt(DR_CFG_FF_SEND_TRAFFIC));
199199
bool bDidSendSomething = false;
200200

201201
// send user's plane at all?
@@ -227,7 +227,7 @@ void ForeFlightSender::Main ()
227227
// send traffic at all?
228228
// not yet send GPS/ATT?
229229
// time to send some traffic?
230-
if (bSendAITraffic && !bDidSendSomething &&
230+
if (eSendAITraffic && !bDidSendSomething &&
231231
now >= nextTraffic)
232232
{
233233
// from here on access to fdMap guarded by a mutex
@@ -241,7 +241,11 @@ void ForeFlightSender::Main ()
241241
// next key to send? (shall have an actual a/c)
242242
mapLTFlightDataTy::const_iterator mapIter;
243243
for (mapIter = mapFd.upper_bound(lastKey);
244-
mapIter != mapFd.cend() && !mapIter->second.hasAc();
244+
mapIter != mapFd.cend() && !( // continue while not reached end and NOT:
245+
mapIter->second.hasAc() && // has an actual a/c, AND
246+
(eSendAITraffic == TTS_ALL || // all traffic to be send, OR
247+
!mapIter->second.GetAircraft()->IsCurrentlyShownAsTcasTarget())// not currently a TCAS target
248+
);
245249
mapIter++);
246250

247251
// something left?
@@ -274,8 +278,8 @@ void ForeFlightSender::Main ()
274278
if (shallRun())
275279
{
276280
std::chrono::time_point<std::chrono::steady_clock> nextWakeup =
277-
bSendUsersPlane && bSendAITraffic ? std::min({nextListen, nextGPS, nextAtt, nextTraffic}) :
278-
bSendUsersPlane && !bSendAITraffic ? std::min({nextListen, nextGPS, nextAtt}) :
281+
bSendUsersPlane && eSendAITraffic ? std::min({nextListen, nextGPS, nextAtt, nextTraffic}) :
282+
bSendUsersPlane && !eSendAITraffic ? std::min({nextListen, nextGPS, nextAtt}) :
279283
std::min(nextListen, nextTraffic);
280284

281285
std::unique_lock<std::mutex> lk(FDThreadSynchMutex);

Src/SettingsUI.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,14 @@ void LTSettingsUI::buildInterface()
907907
sFilter, nOpCl))
908908
{
909909
ImGui::FilteredCfgCheckbox("Send user's position", sFilter, DR_CFG_FF_SEND_USER_PLANE, "Include your own plane's position in ForeFlight stream");
910-
ImGui::FilteredCfgCheckbox("Send traffic", sFilter, DR_CFG_FF_SEND_TRAFFIC, "Include live traffic in ForeFlight stream");
910+
if (ImGui::FilteredLabel("Send traffic", sFilter)) {
911+
int n = DATA_REFS_LT[DR_CFG_FF_SEND_TRAFFIC].getDatai();
912+
static float cbWidth = ImGui::CalcTextSize("Only non-TCAS target traffic_____").x;
913+
ImGui::SetNextItemWidth(cbWidth);
914+
if (ImGui::Combo("##FFSendTraffic", &n, "None\0All\0Only non-TCAS target traffic\0", 3))
915+
DATA_REFS_LT[DR_CFG_FF_SEND_TRAFFIC].setData(n);
916+
ImGui::TableNextCell();
917+
}
911918
ImGui::FilteredCfgNumber("Send traffic every", sFilter, DR_CFG_FF_SEND_TRAFFIC_INTVL, 1, 30, 1, "%d seconds");
912919

913920
if (!*sFilter) ImGui::TreePop();

docs/readme.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ <h3>v4.3.0</h3>
149149

150150
<ul>
151151
<li>
152-
Added AutoATC as a new channel to follow
152+
Added <b>AutoATC</b> as a new channel to follow
153153
<a href="https://autoatc.zem-solutions.com/Status.html">AutoATC's generated AI planes</a>.<br>
154154
<i>Note:</i> As always, there is a latency as per the
155155
<a href="https://twinfan.gitbook.io/livetraffic/setup/configuration/settings-advanced#aircraft-selection"><i>Buffering Period</i></a>,
@@ -160,15 +160,32 @@ <h3>v4.3.0</h3>
160160
cause unrealistic behaviour of live planes.
161161
</li>
162162
<li>
163-
Fixed <a href="https://github.com/TwinFan/LiveTraffic/issues/287">#287</a>: OpenGlider planes with hidden id, that
163+
<b>ForeFlight</b> output: Added an option to only output traffic, that
164+
is not also a "TCAS Target" to avoid duplicates with X-Plane's network output.<br>
165+
If you prefer X-Plane to output data to ForeFlight directly
166+
(via X-Plane's Networking settings) then X-Plane will output your
167+
own plane's position and also up to 63 traffic planes,
168+
the so-called <a href="https://developer.x-plane.com/article/overriding-tcas-and-providing-traffic-information/">TCAS targets</a>.
169+
When LiveTraffic has <a href="https://twinfan.gitbook.io/livetraffic/using-lt/menu-items#tcas-controlled">TCAS control</a>,
170+
those are the 63 nearest planes provided by LiveTraffic.
171+
Using the new "Only non-TCAS target traffic" option in the
172+
<a href="https://twinfan.gitbook.io/livetraffic/setup/installation/foreflight#livetraffic-settings">ForeFlight Output settings</a>
173+
prevents LiveTraffic from sending TCAS target traffic to ForeFlight.
174+
LiveTraffic will then only send planes that are not currently
175+
TCAS targets, ie. planes further away,
176+
that X-Plane has now knowledge about.
177+
</li>
178+
<li>
179+
Fixed <a href="https://github.com/TwinFan/LiveTraffic/issues/287">#287</a>:
180+
<b>OpenGlider</b> planes with hidden id, that
164181
duplicate planes from other channels, are no longer drawn,
165182
avoiding duplicate planes in the sky.<br>
166183
If you disabled OpenSky just because of those duplicate planes
167184
consider enabling it again. Especially in Europe, OpenSky adds
168185
to the immersion with its small planes, gliders, etc.
169186
</li>
170187
<li>Fixed <a href="https://github.com/TwinFan/LiveTraffic/issues/284">#284</a>: Allow a <i>Buffering Period</i> of more than
171-
100s with Realtraffic.</li>
188+
100s with <b>Realtraffic</b>.</li>
172189
<li>
173190
Fixed <a href="https://github.com/TwinFan/LiveTraffic/issues/289">#289</a>:
174191
Reduced forced output to <i>Message Window</i> so that you can

0 commit comments

Comments
 (0)