[swift] Fix coding style
This commit is contained in:
parent
d78b19546a
commit
cdacea1315
5 changed files with 93 additions and 62 deletions
|
@ -65,27 +65,24 @@ double FGAISwiftAircraft::getGroundElevation(const SGGeod& pos) const
|
|||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
void FGAISwiftAircraft::setPlaneSurface(double gear, double flaps, double spoilers, double speedBrake, double slats,
|
||||
double wingSweeps, double thrust, double elevator, double rudder, double aileron,
|
||||
bool landingLight, bool taxiLight, bool beaconLight, bool strobeLight, bool navLight,
|
||||
int lightPattern)
|
||||
void FGAISwiftAircraft::setPlaneSurface(const AircraftSurfaces& surfaces)
|
||||
{
|
||||
m_gearNode->setDoubleValue(gear);
|
||||
m_flapsIdentNode->setDoubleValue(flaps);
|
||||
m_spoilerNode->setDoubleValue(spoilers);
|
||||
m_speedBrakeNode->setDoubleValue(speedBrake);
|
||||
m_landLightNode->setBoolValue(landingLight);
|
||||
m_taxiLightNode->setBoolValue(taxiLight);
|
||||
m_beaconLightNode->setBoolValue(beaconLight);
|
||||
m_strobeLightNode->setBoolValue(strobeLight);
|
||||
m_navLightNode->setBoolValue(navLight);
|
||||
m_gearNode->setDoubleValue(surfaces.gear);
|
||||
m_flapsIdentNode->setDoubleValue(surfaces.flaps);
|
||||
m_spoilerNode->setDoubleValue(surfaces.spoilers);
|
||||
m_speedBrakeNode->setDoubleValue(surfaces.spoilers);
|
||||
m_landLightNode->setBoolValue(surfaces.landingLight);
|
||||
m_taxiLightNode->setBoolValue(surfaces.taxiLight);
|
||||
m_beaconLightNode->setBoolValue(surfaces.beaconLight);
|
||||
m_strobeLightNode->setBoolValue(surfaces.strobeLight);
|
||||
m_navLightNode->setBoolValue(surfaces.navLight);
|
||||
}
|
||||
|
||||
void FGAISwiftAircraft::setPlaneTransponder(int code, bool modeC, bool ident)
|
||||
void FGAISwiftAircraft::setPlaneTransponder(const AircraftTransponder& transponder)
|
||||
{
|
||||
m_transponderCodeNode->setIntValue(code);
|
||||
m_transponderCModeNode->setBoolValue(modeC);
|
||||
m_transponderIdentNode->setBoolValue(ident);
|
||||
m_transponderCodeNode->setIntValue(transponder.code);
|
||||
m_transponderCModeNode->setBoolValue(transponder.modeC);
|
||||
m_transponderIdentNode->setBoolValue(transponder.ident);
|
||||
}
|
||||
|
||||
void FGAISwiftAircraft::initProps()
|
||||
|
@ -95,22 +92,16 @@ void FGAISwiftAircraft::initProps()
|
|||
m_transponderCModeNode = _getProps()->getNode("swift/transponder/c-mode", true);
|
||||
m_transponderIdentNode = _getProps()->getNode("swift/transponder/ident", true);
|
||||
|
||||
m_gearNode = _getProps()->getNode("controls/gear/gear-down", true);
|
||||
m_flapsIdentNode = _getProps()->getNode("controls/flight/flaps", true);
|
||||
m_spoilerNode = _getProps()->getNode("controls/flight/spoilers", true);
|
||||
m_speedBrakeNode = _getProps()->getNode("controls/flight/speedbrake", true);
|
||||
m_landLightNode = _getProps()->getNode("controls/lighting/landing-lights", true);
|
||||
m_gearNode = _getProps()->getNode("swift/gear/gear-down", true);
|
||||
m_flapsIdentNode = _getProps()->getNode("swift/flight/flaps", true);
|
||||
m_spoilerNode = _getProps()->getNode("swift/flight/spoilers", true);
|
||||
m_speedBrakeNode = _getProps()->getNode("swift/flight/speedbrake", true);
|
||||
|
||||
// Untie NavLight property for explicit control (tied within FGAIBase)
|
||||
m_navLightNode = _getProps()->getNode("controls/lighting/nav-lights", true);
|
||||
if(m_navLightNode)
|
||||
{
|
||||
m_navLightNode->untie();
|
||||
}
|
||||
|
||||
m_taxiLightNode = _getProps()->getNode("controls/lighting/taxi-light", true);
|
||||
m_beaconLightNode = _getProps()->getNode("controls/lighting/beacon", true);
|
||||
m_strobeLightNode = _getProps()->getNode("controls/lighting/strobe", true);
|
||||
m_landLightNode = _getProps()->getNode("swift/lighting/landing-lights", true);
|
||||
m_navLightNode = _getProps()->getNode("swift/lighting/nav-lights", true);
|
||||
m_taxiLightNode = _getProps()->getNode("swift/lighting/taxi-light", true);
|
||||
m_beaconLightNode = _getProps()->getNode("swift/lighting/beacon", true);
|
||||
m_strobeLightNode = _getProps()->getNode("swift/lighting/strobe", true);
|
||||
}
|
||||
|
||||
FGAISwiftAircraft::~FGAISwiftAircraft() = default;
|
||||
|
|
|
@ -23,9 +23,51 @@
|
|||
|
||||
#include "AIBase.hxx"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using charPtr = const char*;
|
||||
|
||||
struct AircraftTransponder
|
||||
{
|
||||
AircraftTransponder(std::string callsign, int code, bool modeC, bool ident)
|
||||
: callsign(std::move(callsign)), code(code), modeC(modeC), ident(ident)
|
||||
{}
|
||||
|
||||
std::string callsign;
|
||||
int code;
|
||||
bool modeC;
|
||||
bool ident;
|
||||
};
|
||||
|
||||
struct AircraftSurfaces
|
||||
{
|
||||
AircraftSurfaces(std::string callsign, double gear, double flaps, double spoilers, double speedBrake, double slats, double wingSweeps,
|
||||
double thrust, double elevator, double rudder, double aileron, bool landingLight, bool taxiLight, bool beaconLight,
|
||||
bool strobeLight, bool navLight, int lightPattern)
|
||||
: callsign(std::move(callsign)), gear(gear), flaps(flaps), spoilers(spoilers), speedBrake(speedBrake), slats(slats), wingSweeps(wingSweeps),
|
||||
thrust(thrust), elevator(elevator), rudder(rudder), aileron(aileron), landingLight(landingLight), taxiLight(taxiLight), beaconLight(beaconLight),
|
||||
strobeLight(strobeLight), navLight(navLight), lightPattern(lightPattern){}
|
||||
|
||||
std::string callsign;
|
||||
double gear;
|
||||
double flaps;
|
||||
double spoilers;
|
||||
double speedBrake;
|
||||
double slats;
|
||||
double wingSweeps;
|
||||
double thrust;
|
||||
double elevator;
|
||||
double rudder;
|
||||
double aileron;
|
||||
bool landingLight;
|
||||
bool taxiLight;
|
||||
bool beaconLight;
|
||||
bool strobeLight;
|
||||
bool navLight;
|
||||
int lightPattern;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class FGAISwiftAircraft : public FGAIBase
|
||||
{
|
||||
|
@ -36,11 +78,8 @@ public:
|
|||
void update(double dt) override;
|
||||
double getGroundElevation(const SGGeod& pos) const;
|
||||
void initProps();
|
||||
void setPlaneSurface(double gear, double flaps, double spoilers, double speedBrake, double slats,
|
||||
double wingSweeps, double thrust, double elevator, double rudder, double aileron,
|
||||
bool landingLight, bool taxiLight, bool beaconLight, bool strobeLight, bool navLight,
|
||||
int lightPattern);
|
||||
void setPlaneTransponder(int code, bool modeC, bool ident);
|
||||
void setPlaneSurface(const AircraftSurfaces& surfaces);
|
||||
void setPlaneTransponder(const AircraftTransponder& transponder);
|
||||
|
||||
const char* getTypeString() const override { return "swift"; }
|
||||
|
||||
|
|
|
@ -126,33 +126,26 @@ double FGSwiftAircraftManager::getElevationAtPosition(const std::string &callsig
|
|||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
void FGSwiftAircraftManager::setPlanesTransponders(std::vector<std::string> callsigns, std::vector<int> codes, std::vector<bool> modeCs, std::vector<bool> idents)
|
||||
void FGSwiftAircraftManager::setPlanesTransponders(const std::vector<AircraftTransponder>& transponders)
|
||||
{
|
||||
for (long unsigned int i = 0; i < callsigns.size(); i++)
|
||||
for (const auto & transponder : transponders)
|
||||
{
|
||||
auto it = aircraftByCallsign.find(callsigns.at(i));
|
||||
auto it = aircraftByCallsign.find(transponder.callsign);
|
||||
if(it != aircraftByCallsign.end())
|
||||
{
|
||||
it->second->setPlaneTransponder(codes.at(i), modeCs.at(i), idents.at(i));
|
||||
it->second->setPlaneTransponder(transponder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FGSwiftAircraftManager::setPlanesSurfaces(std::vector<std::string> callsigns, std::vector<double> gears, std::vector<double> flaps,
|
||||
std::vector<double> spoilers ,std::vector<double> speedBrakes, std::vector<double> slats,
|
||||
std::vector<double> wingSweeps, std::vector<double> thrusts, std::vector<double> elevators,
|
||||
std::vector<double> rudders, std::vector<double> ailerons, std::vector<bool> landLights,
|
||||
std::vector<bool> taxiLights, std::vector<bool> beaconLights, std::vector<bool> strobeLights,
|
||||
std::vector<bool> navLights, std::vector<int> lightPatterns)
|
||||
void FGSwiftAircraftManager::setPlanesSurfaces(const std::vector<AircraftSurfaces>& surfaces)
|
||||
{
|
||||
for (long unsigned int i = 0; i < callsigns.size(); i++)
|
||||
for (const auto & surface : surfaces)
|
||||
{
|
||||
auto it = aircraftByCallsign.find(callsigns.at(i));
|
||||
auto it = aircraftByCallsign.find(surface.callsign);
|
||||
if(it != aircraftByCallsign.end())
|
||||
{
|
||||
it->second->setPlaneSurface(gears.at(i), flaps.at(i), spoilers.at(i), speedBrakes.at(i), slats.at(i), wingSweeps.at(i), thrusts.at(i), elevators.at(i),
|
||||
rudders.at(i), ailerons.at(i), landLights.at(i), taxiLights.at(i), beaconLights.at(i), strobeLights.at(i), navLights.at(i),
|
||||
lightPatterns.at(i));
|
||||
it->second->setPlaneSurface(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,10 @@ public:
|
|||
std::vector<double>& elevationsM, std::vector<double>& verticalOffsets) const;
|
||||
void removePlane(const std::string& callsign);
|
||||
void removeAllPlanes();
|
||||
void setPlanesTransponders(std::vector<std::string> callsigns, std::vector<int> codes, std::vector<bool> modeCs, std::vector<bool> idents);
|
||||
void setPlanesTransponders(const std::vector<AircraftTransponder>& transponders);
|
||||
double getElevationAtPosition(const std::string &callsign, const SGGeod& pos) const;
|
||||
bool isInitialized() const;
|
||||
void setPlanesSurfaces(std::vector<std::string> callsigns, std::vector<double> gears, std::vector<double> flaps,
|
||||
std::vector<double> spoilers ,std::vector<double> speedBrakes, std::vector<double> slats,
|
||||
std::vector<double> wingSweeps, std::vector<double> thrusts, std::vector<double> elevators,
|
||||
std::vector<double> rudders, std::vector<double> ailerons, std::vector<bool> landLights,
|
||||
std::vector<bool> taxiLights, std::vector<bool> beaconLights, std::vector<bool> strobeLights,
|
||||
std::vector<bool> navLights, std::vector<int> lightPatterns);
|
||||
void setPlanesSurfaces(const std::vector<AircraftSurfaces>& surfaces);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, FGAISwiftAircraft*> aircraftByCallsign;
|
||||
|
|
|
@ -241,9 +241,15 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
|||
message.getArgument(codes);
|
||||
message.getArgument(modeCs);
|
||||
message.getArgument(idents);
|
||||
std::vector<AircraftTransponder> transponders;
|
||||
transponders.reserve(callsigns.size());
|
||||
for(long unsigned int i = 0; i < callsigns.size(); i++)
|
||||
{
|
||||
transponders.emplace_back(callsigns.at(i), codes.at(i), modeCs.at(i), idents.at(i));
|
||||
}
|
||||
queueDBusCall([ = ]()
|
||||
{
|
||||
acm->setPlanesTransponders(callsigns, codes, modeCs, idents);
|
||||
acm->setPlanesTransponders(transponders);
|
||||
});
|
||||
} else if (message.getMethodName() == "setPlanesSurfaces")
|
||||
{
|
||||
|
@ -283,10 +289,17 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
|||
message.getArgument(strobeLights);
|
||||
message.getArgument(navLights);
|
||||
message.getArgument(lightPatterns);
|
||||
std::vector<AircraftSurfaces> surfaces;
|
||||
surfaces.reserve(callsigns.size());
|
||||
for(long unsigned int i = 0; i < callsigns.size(); i++)
|
||||
{
|
||||
surfaces.emplace_back(callsigns.at(i), gears.at(i), flaps.at(i), spoilers.at(i), speedBrakes.at(i), slats.at(i),
|
||||
wingSweeps.at(i), thrusts.at(i), elevators.at(i), rudders.at(i), ailerons.at(i),
|
||||
landLights.at(i), taxiLights.at(i), beaconLights.at(i), strobeLights.at(i), navLights.at(i), lightPatterns.at(i));
|
||||
}
|
||||
queueDBusCall([ = ]()
|
||||
{
|
||||
acm->setPlanesSurfaces(callsigns, gears, flaps, spoilers, speedBrakes, slats, wingSweeps, thrusts, elevators,
|
||||
rudders, ailerons, landLights, taxiLights, beaconLights, strobeLights, navLights, lightPatterns);
|
||||
acm->setPlanesSurfaces(surfaces);
|
||||
});
|
||||
} else {
|
||||
// Unknown message. Tell DBus that we cannot handle it
|
||||
|
|
Loading…
Reference in a new issue