mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
[XSwiftBus] Convert setPlanesTransponders to list setter
ref T374
This commit is contained in:
committed by
Klaus Basan
parent
65d00dca6e
commit
616cc241f4
@@ -115,9 +115,11 @@ namespace BlackSimPlugin
|
||||
planesSurfaces.navLights, planesSurfaces.lightPatterns);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident)
|
||||
void CXSwiftBusTrafficProxy::setPlanesTransponders(const PlanesTransponders &planesTransponders)
|
||||
{
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlaneTransponder"), callsign, code, modeC, ident);
|
||||
m_dbusInterface->callDBus(QLatin1String("setPlanesTransponders"),
|
||||
planesTransponders.callsigns, planesTransponders.codes,
|
||||
planesTransponders.modeCs, planesTransponders.idents);
|
||||
}
|
||||
|
||||
void CXSwiftBusTrafficProxy::setInterpolatorMode(const QString &callsign, bool spline)
|
||||
|
||||
@@ -87,6 +87,18 @@ namespace BlackSimPlugin
|
||||
QList<int> lightPatterns; //!< List of lightPatterns
|
||||
};
|
||||
|
||||
//! Plane Transponders
|
||||
struct PlanesTransponders
|
||||
{
|
||||
//! Is empty?
|
||||
bool isEmpty() const { return callsigns.isEmpty(); }
|
||||
|
||||
QStringList callsigns;
|
||||
QList<int> codes;
|
||||
QList<bool> modeCs;
|
||||
QList<bool> idents;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Proxy object connected to a real XSwiftBus::CTraffic object via DBus
|
||||
*/
|
||||
@@ -172,8 +184,8 @@ namespace BlackSimPlugin
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanesSurfaces
|
||||
void setPlanesSurfaces(const PlanesSurfaces &planesSurfaces);
|
||||
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlaneTransponder
|
||||
void setPlaneTransponder(const QString &callsign, int code, bool modeC, bool ident);
|
||||
//! \copydoc XSwiftBus::CTraffic::setPlanesTransponders
|
||||
void setPlanesTransponders(const PlanesTransponders &planesTransponders);
|
||||
|
||||
//! \deprecated XSwiftBus::CTraffic::setInterpolatorMode
|
||||
void setInterpolatorMode(const QString &callsign, bool spline);
|
||||
|
||||
@@ -64,11 +64,11 @@ R"(<node>
|
||||
<arg name="navLights" type="ab" direction="in"/>
|
||||
<arg name="lightPatterns" type="ai" direction="in"/>
|
||||
</method>
|
||||
<method name="setPlaneTransponder">
|
||||
<arg name="callsign" type="s" direction="in"/>
|
||||
<arg name="code" type="i" direction="in"/>
|
||||
<arg name="modeC" type="b" direction="in"/>
|
||||
<arg name="ident" type="b" direction="in"/>
|
||||
<method name="setPlanesTransponders">
|
||||
<arg name="callsigns" type="as" direction="in"/>
|
||||
<arg name="codes" type="ai" direction="in"/>
|
||||
<arg name="modeCs" type="ab" direction="in"/>
|
||||
<arg name="idents" type="ab" direction="in"/>
|
||||
</method>
|
||||
<method name="getRemoteAircraftData">
|
||||
<arg name="callsigns" type="as" direction="in"/>
|
||||
|
||||
@@ -370,18 +370,22 @@ namespace XSwiftBus
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::setPlaneTransponder(const std::string &callsign, int code, bool modeC, bool ident)
|
||||
void CTraffic::setPlanesTransponders(const std::vector<std::string> &callsigns, const std::vector<int> &codes, const std::vector<bool> &modeCs, const std::vector<bool> &idents)
|
||||
{
|
||||
auto planeIt = m_planesByCallsign.find(callsign);
|
||||
if (planeIt == m_planesByCallsign.end()) { return; }
|
||||
for (size_t i = 0; i < callsigns.size(); i++)
|
||||
{
|
||||
auto planeIt = m_planesByCallsign.find(callsigns.at(i));
|
||||
if (planeIt == m_planesByCallsign.end()) { return; }
|
||||
|
||||
Plane *plane = planeIt->second;
|
||||
if (!plane) { return; }
|
||||
plane->hasXpdr = true;
|
||||
plane->xpdr.code = code;
|
||||
if (ident) { plane->xpdr.mode = xpmpTransponderMode_ModeC_Ident; }
|
||||
else if (modeC) { plane->xpdr.mode = xpmpTransponderMode_ModeC; }
|
||||
else { plane->xpdr.mode = xpmpTransponderMode_Standby; }
|
||||
Plane *plane = planeIt->second;
|
||||
if (!plane) { return; }
|
||||
|
||||
plane->hasXpdr = true;
|
||||
plane->xpdr.code = codes.at(i);
|
||||
if (idents.at(i)) { plane->xpdr.mode = xpmpTransponderMode_ModeC_Ident; }
|
||||
else if (modeCs.at(i)) { plane->xpdr.mode = xpmpTransponderMode_ModeC; }
|
||||
else { plane->xpdr.mode = xpmpTransponderMode_Standby; }
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::getRemoteAircraftData(std::vector<std::string> &callsigns, std::vector<double> &latitudesDeg, std::vector<double> &longitudesDeg,
|
||||
@@ -642,21 +646,21 @@ namespace XSwiftBus
|
||||
rudders, ailerons, landLights, beaconLights, strobeLights, navLights, lightPatterns);
|
||||
});
|
||||
}
|
||||
else if (message.getMethodName() == "setPlaneTransponder")
|
||||
else if (message.getMethodName() == "setPlanesTransponders")
|
||||
{
|
||||
maybeSendEmptyDBusReply(wantsReply, sender, serial);
|
||||
std::string callsign;
|
||||
int code = 0;
|
||||
bool modeC = false;
|
||||
bool ident = false;
|
||||
std::vector<std::string> callsigns;
|
||||
std::vector<int> codes;
|
||||
std::vector<bool> modeCs;
|
||||
std::vector<bool> idents;
|
||||
message.beginArgumentRead();
|
||||
message.getArgument(callsign);
|
||||
message.getArgument(code);
|
||||
message.getArgument(modeC);
|
||||
message.getArgument(ident);
|
||||
message.getArgument(callsigns);
|
||||
message.getArgument(codes);
|
||||
message.getArgument(modeCs);
|
||||
message.getArgument(idents);
|
||||
queueDBusCall([ = ]()
|
||||
{
|
||||
setPlaneTransponder(callsign, code, modeC, ident);
|
||||
setPlanesTransponders(callsigns, codes, modeCs, idents);
|
||||
});
|
||||
}
|
||||
else if (message.getMethodName() == "getRemoteAircraftData")
|
||||
|
||||
@@ -105,8 +105,8 @@ namespace XSwiftBus
|
||||
const std::vector<double> &elevators, const std::vector<double> &rudders, const std::vector<double> &ailerons, const std::vector<bool> &landLights,
|
||||
const std::vector<bool> &beaconLights, const std::vector<bool> &strobeLights, const std::vector<bool> &navLights, const std::vector<int> &lightPatterns);
|
||||
|
||||
//! Set the transponder of a traffic aircraft
|
||||
void setPlaneTransponder(const std::string &callsign, int code, bool modeC, bool ident);
|
||||
//! Set the transponder of multiple traffic aircraft
|
||||
void setPlanesTransponders(const std::vector<std::string> &callsigns, const std::vector<int> &codes, const std::vector<bool> &modeCs, const std::vector<bool> &idents);
|
||||
|
||||
//! Get remote aircrafts data (lat, lon, elevation and CG)
|
||||
void getRemoteAircraftData(std::vector<std::string> &callsigns, std::vector<double> &latitudesDeg, std::vector<double> &longitudesDeg,
|
||||
|
||||
Reference in New Issue
Block a user