swift cleanup
This commit is contained in:
parent
7a0be3f000
commit
9ec7d6b855
25 changed files with 1496 additions and 1558 deletions
|
@ -25,8 +25,11 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/math/SGVec3.hxx>
|
||||||
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
class FGAIBase;
|
class FGAIBase;
|
||||||
class FGAIThermal;
|
class FGAIThermal;
|
||||||
|
|
|
@ -33,7 +33,7 @@ FGAISwiftAircraft::FGAISwiftAircraft(const std::string& callsign, const std::str
|
||||||
_searchOrder = ModelSearchOrder::PREFER_AI;
|
_searchOrder = ModelSearchOrder::PREFER_AI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAISwiftAircraft::updatePosition(SGGeod& position, SGVec3<double>& orientation, double groundspeed, bool initPos)
|
void FGAISwiftAircraft::updatePosition(const SGGeod &position, const SGVec3<double> &orientation, double groundspeed, bool initPos)
|
||||||
{
|
{
|
||||||
m_initPos = initPos;
|
m_initPos = initPos;
|
||||||
_setLatitude(position.getLatitudeDeg());
|
_setLatitude(position.getLatitudeDeg());
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
#include "AIBaseAircraft.hxx"
|
#include "AIBaseAircraft.hxx"
|
||||||
|
|
||||||
using charPtr = const char*;
|
|
||||||
|
|
||||||
struct AircraftTransponder
|
struct AircraftTransponder
|
||||||
{
|
{
|
||||||
AircraftTransponder(std::string callsign, int code, bool modeC, bool ident)
|
AircraftTransponder(std::string callsign, int code, bool modeC, bool ident)
|
||||||
|
@ -76,7 +74,7 @@ public:
|
||||||
string_view getTypeString() const override { return "swift"; }
|
string_view getTypeString() const override { return "swift"; }
|
||||||
void update(double dt) override;
|
void update(double dt) override;
|
||||||
|
|
||||||
void updatePosition(SGGeod& position, SGVec3<double>& orientation, double groundspeed, bool initPos);
|
void updatePosition(const SGGeod &position, const SGVec3<double> &orientation, double groundspeed, bool initPos);
|
||||||
double getGroundElevation(const SGGeod& pos) const;
|
double getGroundElevation(const SGGeod& pos) const;
|
||||||
void initProps();
|
void initProps();
|
||||||
void setPlaneSurface(const AircraftSurfaces& surfaces);
|
void setPlaneSurface(const AircraftSurfaces& surfaces);
|
||||||
|
|
|
@ -49,14 +49,11 @@ bool FGSwiftAircraftManager::addPlane(const std::string& callsign, const std::st
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGSwiftAircraftManager::updatePlanes(std::vector<std::string> callsigns, std::vector<SGGeod> positions, std::vector<SGVec3d> orientations, std::vector<double> groundspeeds, std::vector<bool> onGrounds)
|
void FGSwiftAircraftManager::updatePlanes(const std::vector<std::string>& callsigns, const std::vector<SGGeod>& positions, const std::vector<SGVec3d>& orientations, const std::vector<double>& groundspeeds, const std::vector<bool>& onGrounds)
|
||||||
{
|
|
||||||
|
|
||||||
for (long unsigned int i = 0; i < callsigns.size(); i++)
|
|
||||||
{
|
{
|
||||||
|
for (long unsigned int i = 0; i < callsigns.size(); i++) {
|
||||||
auto it = aircraftByCallsign.find(callsigns.at(i));
|
auto it = aircraftByCallsign.find(callsigns.at(i));
|
||||||
if(it != aircraftByCallsign.end())
|
if (it != aircraftByCallsign.end()) {
|
||||||
{
|
|
||||||
it->second->updatePosition(positions.at(i), orientations.at(i), groundspeeds.at(i), true);
|
it->second->updatePosition(positions.at(i), orientations.at(i), groundspeeds.at(i), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,8 +96,7 @@ void FGSwiftAircraftManager::getRemoteAircraftData(std::vector<std::string>& cal
|
||||||
void FGSwiftAircraftManager::removePlane(const std::string& callsign)
|
void FGSwiftAircraftManager::removePlane(const std::string& callsign)
|
||||||
{
|
{
|
||||||
auto it = aircraftByCallsign.find(callsign);
|
auto it = aircraftByCallsign.find(callsign);
|
||||||
if(it != aircraftByCallsign.end())
|
if (it != aircraftByCallsign.end()) {
|
||||||
{
|
|
||||||
it->second->setDie(true);
|
it->second->setDie(true);
|
||||||
aircraftByCallsign.erase(it);
|
aircraftByCallsign.erase(it);
|
||||||
}
|
}
|
||||||
|
@ -108,8 +104,7 @@ void FGSwiftAircraftManager::removePlane(const std::string& callsign)
|
||||||
|
|
||||||
void FGSwiftAircraftManager::removeAllPlanes()
|
void FGSwiftAircraftManager::removeAllPlanes()
|
||||||
{
|
{
|
||||||
for(auto it = aircraftByCallsign.begin(); it!= aircraftByCallsign.end();)
|
for (auto it = aircraftByCallsign.begin(); it != aircraftByCallsign.end();) {
|
||||||
{
|
|
||||||
it->second->setDie(true);
|
it->second->setDie(true);
|
||||||
it = aircraftByCallsign.erase(it);
|
it = aircraftByCallsign.erase(it);
|
||||||
}
|
}
|
||||||
|
@ -118,8 +113,7 @@ void FGSwiftAircraftManager::removeAllPlanes()
|
||||||
double FGSwiftAircraftManager::getElevationAtPosition(const std::string& callsign, const SGGeod& pos) const
|
double FGSwiftAircraftManager::getElevationAtPosition(const std::string& callsign, const SGGeod& pos) const
|
||||||
{
|
{
|
||||||
auto it = aircraftByCallsign.find(callsign);
|
auto it = aircraftByCallsign.find(callsign);
|
||||||
if(it != aircraftByCallsign.end())
|
if (it != aircraftByCallsign.end()) {
|
||||||
{
|
|
||||||
return it->second->getGroundElevation(pos);
|
return it->second->getGroundElevation(pos);
|
||||||
}
|
}
|
||||||
// Aircraft not found in list
|
// Aircraft not found in list
|
||||||
|
@ -128,11 +122,9 @@ double FGSwiftAircraftManager::getElevationAtPosition(const std::string &callsig
|
||||||
|
|
||||||
void FGSwiftAircraftManager::setPlanesTransponders(const std::vector<AircraftTransponder>& transponders)
|
void FGSwiftAircraftManager::setPlanesTransponders(const std::vector<AircraftTransponder>& transponders)
|
||||||
{
|
{
|
||||||
for (const auto & transponder : transponders)
|
for (const auto& transponder : transponders) {
|
||||||
{
|
|
||||||
auto it = aircraftByCallsign.find(transponder.callsign);
|
auto it = aircraftByCallsign.find(transponder.callsign);
|
||||||
if(it != aircraftByCallsign.end())
|
if (it != aircraftByCallsign.end()) {
|
||||||
{
|
|
||||||
it->second->setPlaneTransponder(transponder);
|
it->second->setPlaneTransponder(transponder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,11 +132,9 @@ void FGSwiftAircraftManager::setPlanesTransponders(const std::vector<AircraftTra
|
||||||
|
|
||||||
void FGSwiftAircraftManager::setPlanesSurfaces(const std::vector<AircraftSurfaces>& surfaces)
|
void FGSwiftAircraftManager::setPlanesSurfaces(const std::vector<AircraftSurfaces>& surfaces)
|
||||||
{
|
{
|
||||||
for (const auto & surface : surfaces)
|
for (const auto& surface : surfaces) {
|
||||||
{
|
|
||||||
auto it = aircraftByCallsign.find(surface.callsign);
|
auto it = aircraftByCallsign.find(surface.callsign);
|
||||||
if(it != aircraftByCallsign.end())
|
if (it != aircraftByCallsign.end()) {
|
||||||
{
|
|
||||||
it->second->setPlaneSurface(surface);
|
it->second->setPlaneSurface(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include <Scenery/scenery.hxx>
|
|
||||||
#include <AIModel/AISwiftAircraft.h>
|
|
||||||
#include <AIModel/AIManager.hxx>
|
#include <AIModel/AIManager.hxx>
|
||||||
|
#include <AIModel/AISwiftAircraft.h>
|
||||||
|
#include <Scenery/scenery.hxx>
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef FGSWIFTAIRCRAFTMANAGER_H
|
#ifndef FGSWIFTAIRCRAFTMANAGER_H
|
||||||
#define FGSWIFTAIRCRAFTMANAGER_H
|
#define FGSWIFTAIRCRAFTMANAGER_H
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
FGSwiftAircraftManager();
|
FGSwiftAircraftManager();
|
||||||
~FGSwiftAircraftManager();
|
~FGSwiftAircraftManager();
|
||||||
bool addPlane(const std::string& callsign, const std::string& modelString);
|
bool addPlane(const std::string& callsign, const std::string& modelString);
|
||||||
void updatePlanes(std::vector<std::string> callsigns, std::vector<SGGeod> positions, std::vector<SGVec3d> orientations, std::vector<double> groundspeeds, std::vector<bool> onGrounds);
|
void updatePlanes(const std::vector<std::string>& callsigns, const std::vector<SGGeod>& positions, const std::vector<SGVec3d>& orientations, const std::vector<double>& groundspeeds, const std::vector<bool>& onGrounds);
|
||||||
void getRemoteAircraftData(std::vector<std::string>& callsigns, std::vector<double>& latitudesDeg, std::vector<double>& longitudesDeg,
|
void getRemoteAircraftData(std::vector<std::string>& callsigns, std::vector<double>& latitudesDeg, std::vector<double>& longitudesDeg,
|
||||||
std::vector<double>& elevationsM, std::vector<double>& verticalOffsets) const;
|
std::vector<double>& elevationsM, std::vector<double>& verticalOffsets) const;
|
||||||
void removePlane(const std::string& callsign);
|
void removePlane(const std::string& callsign);
|
||||||
|
@ -48,6 +48,5 @@ public:
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, FGAISwiftAircraftPtr> aircraftByCallsign;
|
std::unordered_map<std::string, FGAISwiftAircraftPtr> aircraftByCallsign;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -23,8 +23,7 @@
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class DBusAsyncCallbacks
|
class DBusAsyncCallbacks
|
||||||
|
@ -35,7 +34,8 @@ namespace FGSwiftBus
|
||||||
const std::function<void(T*)>& remove,
|
const std::function<void(T*)>& remove,
|
||||||
const std::function<void(T*)>& toggled)
|
const std::function<void(T*)>& toggled)
|
||||||
: m_addHandler(add), m_removeHandler(remove), m_toggledHandler(toggled)
|
: m_addHandler(add), m_removeHandler(remove), m_toggledHandler(toggled)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static dbus_bool_t add(T* watch, void* refcon)
|
static dbus_bool_t add(T* watch, void* refcon)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,6 @@ namespace FGSwiftBus
|
||||||
};
|
};
|
||||||
//! \endcond
|
//! \endcond
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
// dbusconnection.cpp
|
// dbusconnection.cpp
|
||||||
//
|
//
|
||||||
// Copyright (C) 2019 - swift Project Community / Contributors (http://swift-project.org/)
|
// Copyright (C) 2019 - swift Project Community / Contributors (http://swift-project.org/)
|
||||||
|
@ -26,8 +24,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
CDBusConnection::CDBusConnection()
|
CDBusConnection::CDBusConnection()
|
||||||
{
|
{
|
||||||
|
@ -57,14 +54,12 @@ namespace FGSwiftBus
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
|
|
||||||
DBusBusType dbusBusType;
|
DBusBusType dbusBusType;
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case SessionBus: dbusBusType = DBUS_BUS_SESSION; break;
|
case SessionBus: dbusBusType = DBUS_BUS_SESSION; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connection.reset(dbus_bus_get_private(dbusBusType, &error));
|
m_connection.reset(dbus_bus_get_private(dbusBusType, &error));
|
||||||
if (dbus_error_is_set(&error))
|
if (dbus_error_is_set(&error)) {
|
||||||
{
|
|
||||||
m_lastError = CDBusError(&error);
|
m_lastError = CDBusError(&error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -144,9 +139,9 @@ namespace FGSwiftBus
|
||||||
void CDBusConnection::dispatch()
|
void CDBusConnection::dispatch()
|
||||||
{
|
{
|
||||||
dbus_connection_ref(m_connection.get());
|
dbus_connection_ref(m_connection.get());
|
||||||
if (dbus_connection_get_dispatch_status(m_connection.get()) == DBUS_DISPATCH_DATA_REMAINS)
|
if (dbus_connection_get_dispatch_status(m_connection.get()) == DBUS_DISPATCH_DATA_REMAINS) {
|
||||||
{
|
while (dbus_connection_dispatch(m_connection.get()) == DBUS_DISPATCH_DATA_REMAINS)
|
||||||
while (dbus_connection_dispatch(m_connection.get()) == DBUS_DISPATCH_DATA_REMAINS);
|
;
|
||||||
}
|
}
|
||||||
dbus_connection_unref(m_connection.get());
|
dbus_connection_unref(m_connection.get());
|
||||||
}
|
}
|
||||||
|
@ -155,8 +150,7 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
if (dbus_connection_get_is_connected(connection) == FALSE) { return; }
|
if (dbus_connection_get_is_connected(connection) == FALSE) { return; }
|
||||||
|
|
||||||
switch (status)
|
switch (status) {
|
||||||
{
|
|
||||||
case DBUS_DISPATCH_DATA_REMAINS:
|
case DBUS_DISPATCH_DATA_REMAINS:
|
||||||
//m_dispatcher->add(this);
|
//m_dispatcher->add(this);
|
||||||
break;
|
break;
|
||||||
|
@ -181,10 +175,8 @@ namespace FGSwiftBus
|
||||||
DBusError err;
|
DBusError err;
|
||||||
dbus_error_init(&err);
|
dbus_error_init(&err);
|
||||||
|
|
||||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
|
if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||||
{
|
for (auto it = obj->m_disconnectedCallbacks.begin(); it != obj->m_disconnectedCallbacks.end(); ++it) {
|
||||||
for (auto it = obj->m_disconnectedCallbacks.begin(); it != obj->m_disconnectedCallbacks.end(); ++it)
|
|
||||||
{
|
|
||||||
it->second();
|
it->second();
|
||||||
}
|
}
|
||||||
return DBUS_HANDLER_RESULT_HANDLED;
|
return DBUS_HANDLER_RESULT_HANDLED;
|
||||||
|
@ -192,4 +184,4 @@ namespace FGSwiftBus
|
||||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -20,19 +20,18 @@
|
||||||
#ifndef BLACKSIM_FGSWIFTBUS_DBUSCONNECTION_H
|
#ifndef BLACKSIM_FGSWIFTBUS_DBUSCONNECTION_H
|
||||||
#define BLACKSIM_FGSWIFTBUS_DBUSCONNECTION_H
|
#define BLACKSIM_FGSWIFTBUS_DBUSCONNECTION_H
|
||||||
|
|
||||||
#include "dbusmessage.h"
|
|
||||||
#include "dbuserror.h"
|
|
||||||
#include "dbuscallbacks.h"
|
#include "dbuscallbacks.h"
|
||||||
#include "dbusdispatcher.h"
|
#include "dbusdispatcher.h"
|
||||||
|
#include "dbuserror.h"
|
||||||
|
#include "dbusmessage.h"
|
||||||
|
|
||||||
#include <event2/event.h>
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
#include <event2/event.h>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
class CDBusObject;
|
class CDBusObject;
|
||||||
|
|
||||||
|
@ -103,8 +102,7 @@ namespace FGSwiftBus
|
||||||
static void setDispatchStatus(DBusConnection* connection, DBusDispatchStatus status, void* data);
|
static void setDispatchStatus(DBusConnection* connection, DBusDispatchStatus status, void* data);
|
||||||
static DBusHandlerResult filterDisconnectedFunction(DBusConnection* connection, DBusMessage* message, void* data);
|
static DBusHandlerResult filterDisconnectedFunction(DBusConnection* connection, DBusMessage* message, void* data);
|
||||||
|
|
||||||
struct DBusConnectionDeleter
|
struct DBusConnectionDeleter {
|
||||||
{
|
|
||||||
void operator()(DBusConnection* obj) const { dbus_connection_unref(obj); }
|
void operator()(DBusConnection* obj) const { dbus_connection_unref(obj); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,6 +112,6 @@ namespace FGSwiftBus
|
||||||
std::unordered_map<CDBusObject*, DisconnectedCallback> m_disconnectedCallbacks;
|
std::unordered_map<CDBusObject*, DisconnectedCallback> m_disconnectedCallbacks;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -24,18 +24,17 @@
|
||||||
namespace { // anonymosu namespace
|
namespace { // anonymosu namespace
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
std::unique_ptr<T> our_make_unique(Args&&... args) {
|
std::unique_ptr<T> our_make_unique(Args&&... args)
|
||||||
|
{
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
//! Functor struct deleteing an event
|
//! Functor struct deleteing an event
|
||||||
struct EventDeleter
|
struct EventDeleter {
|
||||||
{
|
|
||||||
//! Delete functor
|
//! Delete functor
|
||||||
void operator()(event* obj) const
|
void operator()(event* obj) const
|
||||||
{
|
{
|
||||||
|
@ -151,8 +150,7 @@ namespace FGSwiftBus
|
||||||
std::function<void()> m_func;
|
std::function<void()> m_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
CDBusDispatcher::CDBusDispatcher() :
|
CDBusDispatcher::CDBusDispatcher() : m_eventBase(event_base_new())
|
||||||
m_eventBase(event_base_new())
|
|
||||||
{
|
{
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
m_watchCallbacks = WatchCallbacks(std::bind(&CDBusDispatcher::dbusAddWatch, this, _1),
|
m_watchCallbacks = WatchCallbacks(std::bind(&CDBusDispatcher::dbusAddWatch, this, _1),
|
||||||
|
@ -196,8 +194,7 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
if (m_dispatchList.empty()) { return; }
|
if (m_dispatchList.empty()) { return; }
|
||||||
|
|
||||||
for (IDispatchable *dispatchable : m_dispatchList)
|
for (IDispatchable* dispatchable : m_dispatchList) {
|
||||||
{
|
|
||||||
dispatchable->dispatch();
|
dispatchable->dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,17 +210,22 @@ namespace FGSwiftBus
|
||||||
|
|
||||||
void CDBusDispatcher::dbusRemoveWatch(DBusWatch* watch)
|
void CDBusDispatcher::dbusRemoveWatch(DBusWatch* watch)
|
||||||
{
|
{
|
||||||
for (auto it = m_watchers.begin(); it != m_watchers.end();)
|
for (auto it = m_watchers.begin(); it != m_watchers.end();) {
|
||||||
{
|
if (it->second->getWatch() == watch) {
|
||||||
if (it->second->getWatch() == watch) { it = m_watchers.erase(it); }
|
it = m_watchers.erase(it);
|
||||||
else { ++it; }
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDBusDispatcher::dbusWatchToggled(DBusWatch* watch)
|
void CDBusDispatcher::dbusWatchToggled(DBusWatch* watch)
|
||||||
{
|
{
|
||||||
if (dbus_watch_get_enabled(watch) == TRUE) { dbusAddWatch(watch); }
|
if (dbus_watch_get_enabled(watch) == TRUE) {
|
||||||
else { dbusRemoveWatch(watch); }
|
dbusAddWatch(watch);
|
||||||
|
} else {
|
||||||
|
dbusRemoveWatch(watch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_bool_t CDBusDispatcher::dbusAddTimeout(DBusTimeout* timeout)
|
dbus_bool_t CDBusDispatcher::dbusAddTimeout(DBusTimeout* timeout)
|
||||||
|
@ -235,8 +237,7 @@ namespace FGSwiftBus
|
||||||
|
|
||||||
void CDBusDispatcher::dbusRemoveTimeout(DBusTimeout* timeout)
|
void CDBusDispatcher::dbusRemoveTimeout(DBusTimeout* timeout)
|
||||||
{
|
{
|
||||||
auto predicate = [timeout](const std::unique_ptr<TimeoutHandler> &ptr)
|
auto predicate = [timeout](const std::unique_ptr<TimeoutHandler>& ptr) {
|
||||||
{
|
|
||||||
return ptr->getTimeout() == timeout;
|
return ptr->getTimeout() == timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -251,4 +252,4 @@ namespace FGSwiftBus
|
||||||
dbusRemoveTimeout(timeout);
|
dbusRemoveTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -22,15 +22,14 @@
|
||||||
|
|
||||||
#include "dbuscallbacks.h"
|
#include "dbuscallbacks.h"
|
||||||
|
|
||||||
#include <event2/event.h>
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
#include <event2/event.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
class TimeoutHandler;
|
class TimeoutHandler;
|
||||||
|
@ -83,8 +82,7 @@ namespace FGSwiftBus
|
||||||
friend class CDBusConnection;
|
friend class CDBusConnection;
|
||||||
friend class CDBusServer;
|
friend class CDBusServer;
|
||||||
|
|
||||||
struct EventBaseDeleter
|
struct EventBaseDeleter {
|
||||||
{
|
|
||||||
void operator()(event_base* obj) const { event_base_free(obj); }
|
void operator()(event_base* obj) const { event_base_free(obj); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,6 +107,6 @@ namespace FGSwiftBus
|
||||||
|
|
||||||
std::vector<IDispatchable*> m_dispatchList;
|
std::vector<IDispatchable*> m_dispatchList;
|
||||||
};
|
};
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
|
|
||||||
#include "dbuserror.h"
|
#include "dbuserror.h"
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
CDBusError::CDBusError(const DBusError* error)
|
CDBusError::CDBusError(const DBusError* error)
|
||||||
: m_name(error->name), m_message(error->message)
|
: m_name(error->name), m_message(error->message)
|
||||||
{ }
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -23,16 +23,14 @@
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
//! DBus error
|
//! DBus error
|
||||||
class CDBusError
|
class CDBusError
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Error type
|
//! Error type
|
||||||
enum ErrorType
|
enum ErrorType {
|
||||||
{
|
|
||||||
NoError,
|
NoError,
|
||||||
Other
|
Other
|
||||||
};
|
};
|
||||||
|
@ -52,6 +50,6 @@ namespace FGSwiftBus
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
|
|
||||||
#include "dbusmessage.h"
|
#include "dbusmessage.h"
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
CDBusMessage::CDBusMessage(DBusMessage* message)
|
CDBusMessage::CDBusMessage(DBusMessage* message)
|
||||||
{
|
{
|
||||||
|
@ -133,8 +132,7 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
dbus_message_iter_open_container(&m_messageIterator, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &arrayIterator);
|
dbus_message_iter_open_container(&m_messageIterator, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &arrayIterator);
|
||||||
for (const auto &i : array)
|
for (const auto& i : array) {
|
||||||
{
|
|
||||||
const char* ptr = i.c_str();
|
const char* ptr = i.c_str();
|
||||||
dbus_message_iter_append_basic(&arrayIterator, DBUS_TYPE_STRING, &ptr);
|
dbus_message_iter_append_basic(&arrayIterator, DBUS_TYPE_STRING, &ptr);
|
||||||
}
|
}
|
||||||
|
@ -160,8 +158,11 @@ namespace FGSwiftBus
|
||||||
if (dbus_message_iter_get_arg_type(&m_messageIterator) != DBUS_TYPE_BOOLEAN) { return; }
|
if (dbus_message_iter_get_arg_type(&m_messageIterator) != DBUS_TYPE_BOOLEAN) { return; }
|
||||||
dbus_bool_t v;
|
dbus_bool_t v;
|
||||||
dbus_message_iter_get_basic(&m_messageIterator, &v);
|
dbus_message_iter_get_basic(&m_messageIterator, &v);
|
||||||
if (v == TRUE) { value = true; }
|
if (v == TRUE) {
|
||||||
else { value = false; }
|
value = true;
|
||||||
|
} else {
|
||||||
|
value = false;
|
||||||
|
}
|
||||||
dbus_message_iter_next(&m_messageIterator);
|
dbus_message_iter_next(&m_messageIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,14 +186,12 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_INT32) { return; }
|
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_INT32) { return; }
|
||||||
dbus_int32_t i;
|
dbus_int32_t i;
|
||||||
dbus_message_iter_get_basic(&arrayIterator, &i);
|
dbus_message_iter_get_basic(&arrayIterator, &i);
|
||||||
value.push_back(i);
|
value.push_back(i);
|
||||||
}
|
} while (dbus_message_iter_next(&arrayIterator));
|
||||||
while (dbus_message_iter_next(&arrayIterator));
|
|
||||||
dbus_message_iter_next(&m_messageIterator);
|
dbus_message_iter_next(&m_messageIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,15 +200,16 @@ namespace FGSwiftBus
|
||||||
if (dbus_message_iter_get_arg_type(&m_messageIterator) != DBUS_TYPE_ARRAY) { return; }
|
if (dbus_message_iter_get_arg_type(&m_messageIterator) != DBUS_TYPE_ARRAY) { return; }
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_BOOLEAN) { return; }
|
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_BOOLEAN) { return; }
|
||||||
dbus_bool_t b;
|
dbus_bool_t b;
|
||||||
dbus_message_iter_get_basic(&arrayIterator, &b);
|
dbus_message_iter_get_basic(&arrayIterator, &b);
|
||||||
if (b == TRUE) { value.push_back(true); }
|
if (b == TRUE) {
|
||||||
else { value.push_back(false); }
|
value.push_back(true);
|
||||||
|
} else {
|
||||||
|
value.push_back(false);
|
||||||
}
|
}
|
||||||
while (dbus_message_iter_next(&arrayIterator));
|
} while (dbus_message_iter_next(&arrayIterator));
|
||||||
dbus_message_iter_next(&m_messageIterator);
|
dbus_message_iter_next(&m_messageIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,14 +217,12 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_DOUBLE) { return; }
|
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_DOUBLE) { return; }
|
||||||
double d;
|
double d;
|
||||||
dbus_message_iter_get_basic(&arrayIterator, &d);
|
dbus_message_iter_get_basic(&arrayIterator, &d);
|
||||||
value.push_back(d);
|
value.push_back(d);
|
||||||
}
|
} while (dbus_message_iter_next(&arrayIterator));
|
||||||
while (dbus_message_iter_next(&arrayIterator));
|
|
||||||
dbus_message_iter_next(&m_messageIterator);
|
dbus_message_iter_next(&m_messageIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,14 +230,12 @@ namespace FGSwiftBus
|
||||||
{
|
{
|
||||||
DBusMessageIter arrayIterator;
|
DBusMessageIter arrayIterator;
|
||||||
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
dbus_message_iter_recurse(&m_messageIterator, &arrayIterator);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_STRING) { return; }
|
if (dbus_message_iter_get_arg_type(&arrayIterator) != DBUS_TYPE_STRING) { return; }
|
||||||
const char* str = nullptr;
|
const char* str = nullptr;
|
||||||
dbus_message_iter_get_basic(&arrayIterator, &str);
|
dbus_message_iter_get_basic(&arrayIterator, &str);
|
||||||
value.push_back(std::string(str));
|
value.push_back(std::string(str));
|
||||||
}
|
} while (dbus_message_iter_next(&arrayIterator));
|
||||||
while (dbus_message_iter_next(&arrayIterator));
|
|
||||||
dbus_message_iter_next(&m_messageIterator);
|
dbus_message_iter_next(&m_messageIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,4 +256,4 @@ namespace FGSwiftBus
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -24,8 +24,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
//! DBus Message
|
//! DBus Message
|
||||||
class CDBusMessage
|
class CDBusMessage
|
||||||
|
@ -108,6 +107,6 @@ namespace FGSwiftBus
|
||||||
dbus_uint32_t m_serial = 0;
|
dbus_uint32_t m_serial = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include "dbusobject.h"
|
#include "dbusobject.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
CDBusObject::CDBusObject()
|
CDBusObject::CDBusObject()
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CDBusObject::~CDBusObject()
|
CDBusObject::~CDBusObject()
|
||||||
{
|
{
|
||||||
|
@ -61,8 +61,7 @@ namespace FGSwiftBus
|
||||||
|
|
||||||
void CDBusObject::maybeSendEmptyDBusReply(bool wantsReply, const std::string& destination, dbus_uint32_t serial)
|
void CDBusObject::maybeSendEmptyDBusReply(bool wantsReply, const std::string& destination, dbus_uint32_t serial)
|
||||||
{
|
{
|
||||||
if (wantsReply)
|
if (wantsReply) {
|
||||||
{
|
|
||||||
CDBusMessage reply = CDBusMessage::createReply(destination, serial);
|
CDBusMessage reply = CDBusMessage::createReply(destination, serial);
|
||||||
m_dbusConnection->sendMessage(reply);
|
m_dbusConnection->sendMessage(reply);
|
||||||
}
|
}
|
||||||
|
@ -77,8 +76,7 @@ namespace FGSwiftBus
|
||||||
void CDBusObject::invokeQueuedDBusCalls()
|
void CDBusObject::invokeQueuedDBusCalls()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
while (m_qeuedDBusCalls.size() > 0)
|
while (m_qeuedDBusCalls.size() > 0) {
|
||||||
{
|
|
||||||
m_qeuedDBusCalls.front()();
|
m_qeuedDBusCalls.front()();
|
||||||
m_qeuedDBusCalls.pop_front();
|
m_qeuedDBusCalls.pop_front();
|
||||||
}
|
}
|
||||||
|
@ -103,4 +101,4 @@ namespace FGSwiftBus
|
||||||
return obj->dbusMessageHandler(dbusMessage);
|
return obj->dbusMessageHandler(dbusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -21,11 +21,10 @@
|
||||||
#define BLACKSIM_FGSWIFTBUS_DBUSOBJECT_H
|
#define BLACKSIM_FGSWIFTBUS_DBUSOBJECT_H
|
||||||
|
|
||||||
#include "dbusconnection.h"
|
#include "dbusconnection.h"
|
||||||
#include <mutex>
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
//! DBus base object
|
//! DBus base object
|
||||||
class CDBusObject
|
class CDBusObject
|
||||||
{
|
{
|
||||||
|
@ -103,6 +102,6 @@ namespace FGSwiftBus
|
||||||
const DBusObjectPathVTable m_dbusObjectPathVTable = {dbusObjectPathUnregisterFunction, dbusObjectPathMessageFunction, nullptr, nullptr, nullptr, nullptr};
|
const DBusObjectPathVTable m_dbusObjectPathVTable = {dbusObjectPathUnregisterFunction, dbusObjectPathMessageFunction, nullptr, nullptr, nullptr, nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -19,15 +19,14 @@
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "dbusserver.h"
|
|
||||||
#include "dbusobject.h"
|
#include "dbusobject.h"
|
||||||
|
#include "dbusserver.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
CDBusServer::CDBusServer()
|
CDBusServer::CDBusServer()
|
||||||
{
|
{
|
||||||
|
@ -45,8 +44,7 @@ namespace FGSwiftBus
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
m_server.reset(dbus_server_listen(address.c_str(), &error));
|
m_server.reset(dbus_server_listen(address.c_str(), &error));
|
||||||
|
|
||||||
if (! m_server)
|
if (!m_server) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,4 +96,4 @@ namespace FGSwiftBus
|
||||||
obj->onNewConnection(server, conn);
|
obj->onNewConnection(server, conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
|
@ -20,21 +20,20 @@
|
||||||
#ifndef BLACKSIM_FGSWIFTBUS_DBUSSERVER_H
|
#ifndef BLACKSIM_FGSWIFTBUS_DBUSSERVER_H
|
||||||
#define BLACKSIM_FGSWIFTBUS_DBUSSERVER_H
|
#define BLACKSIM_FGSWIFTBUS_DBUSSERVER_H
|
||||||
|
|
||||||
#include "dbusmessage.h"
|
|
||||||
#include "dbuserror.h"
|
|
||||||
#include "dbuscallbacks.h"
|
#include "dbuscallbacks.h"
|
||||||
#include "dbusdispatcher.h"
|
#include "dbusdispatcher.h"
|
||||||
|
#include "dbuserror.h"
|
||||||
|
#include "dbusmessage.h"
|
||||||
|
|
||||||
#include <event2/event.h>
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
#include <event2/event.h>
|
||||||
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
|
|
||||||
class CDBusObject;
|
class CDBusObject;
|
||||||
|
|
||||||
|
@ -78,8 +77,7 @@ namespace FGSwiftBus
|
||||||
void onNewConnection(DBusServer* server, DBusConnection* conn);
|
void onNewConnection(DBusServer* server, DBusConnection* conn);
|
||||||
static void onNewConnection(DBusServer* server, DBusConnection* conn, void* data);
|
static void onNewConnection(DBusServer* server, DBusConnection* conn, void* data);
|
||||||
|
|
||||||
struct DBusServerDeleter
|
struct DBusServerDeleter {
|
||||||
{
|
|
||||||
void operator()(DBusServer* obj) const { dbus_server_unref(obj); }
|
void operator()(DBusServer* obj) const { dbus_server_unref(obj); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,6 +87,6 @@ namespace FGSwiftBus
|
||||||
NewConnectionFunc m_newConnectionFunc;
|
NewConnectionFunc m_newConnectionFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
@ -23,17 +23,15 @@
|
||||||
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <cmath>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <simgear/structure/commands.hxx>
|
#include <simgear/structure/commands.hxx>
|
||||||
#include <simgear/structure/event_mgr.hxx>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
inline std::string fgswiftbusServiceName()
|
inline std::string fgswiftbusServiceName()
|
||||||
{
|
{
|
||||||
return std::string("org.swift-project.fgswiftbus");
|
return "org.swift-project.fgswiftbus";
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -79,17 +77,6 @@ void CPlugin::startServer()
|
||||||
SG_LOG(SG_NETWORK, SG_INFO, "FGSwiftBus started");
|
SG_LOG(SG_NETWORK, SG_INFO, "FGSwiftBus started");
|
||||||
}
|
}
|
||||||
|
|
||||||
float CPlugin::startServerDeferred(float, float, int, void* refcon)
|
|
||||||
{
|
|
||||||
auto plugin = static_cast<CPlugin*>(refcon);
|
|
||||||
if (!plugin->m_isRunning) {
|
|
||||||
plugin->startServer();
|
|
||||||
plugin->m_isRunning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPlugin::fastLoop()
|
void CPlugin::fastLoop()
|
||||||
{
|
{
|
||||||
this->m_dbusDispatcher.runOnce();
|
this->m_dbusDispatcher.runOnce();
|
||||||
|
|
|
@ -31,18 +31,16 @@
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "dbusconnection.h"
|
#include "dbusconnection.h"
|
||||||
#include "dbusdispatcher.h"
|
#include "dbusdispatcher.h"
|
||||||
#include "dbusserver.h"
|
#include "dbusserver.h"
|
||||||
#include "config.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace FGSwiftBus
|
namespace FGSwiftBus {
|
||||||
{
|
|
||||||
class CService;
|
class CService;
|
||||||
class CTraffic;
|
class CTraffic;
|
||||||
class CWeather;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Main plugin class
|
* Main plugin class
|
||||||
|
@ -55,7 +53,6 @@ namespace FGSwiftBus
|
||||||
void startServer();
|
void startServer();
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~CPlugin();
|
~CPlugin();
|
||||||
static float startServerDeferred(float, float, int, void* refcon);
|
|
||||||
void fastLoop();
|
void fastLoop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -69,6 +66,6 @@ namespace FGSwiftBus
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
bool m_shouldStop = false;
|
bool m_shouldStop = false;
|
||||||
};
|
};
|
||||||
}
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
#endif // guard
|
#endif // BLACKSIM_FGSWIFTBUS_PLUGIN_H
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <simgear/constants.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/structure/commands.hxx>
|
#include <simgear/structure/commands.hxx>
|
||||||
#include <simgear/constants.h>
|
|
||||||
|
|
||||||
#define FGSWIFTBUS_API_VERSION 3;
|
#define FGSWIFTBUS_API_VERSION 3;
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ CService::CService()
|
||||||
SG_LOG(SG_NETWORK, SG_INFO, "FGSwiftBus Service initialized");
|
SG_LOG(SG_NETWORK, SG_INFO, "FGSwiftBus Service initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& CService::InterfaceName() {
|
const std::string& CService::InterfaceName()
|
||||||
|
{
|
||||||
static const std::string s(FGSWIFTBUS_SERVICE_INTERFACENAME);
|
static const std::string s(FGSWIFTBUS_SERVICE_INTERFACENAME);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,8 @@
|
||||||
|
|
||||||
|
|
||||||
#include "dbusobject.h"
|
#include "dbusobject.h"
|
||||||
#include <chrono>
|
|
||||||
#include <string>
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
#include <chrono>
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/io/raw_socket.hxx>
|
#include <simgear/io/raw_socket.hxx>
|
||||||
|
@ -40,6 +39,7 @@
|
||||||
#include <simgear/structure/event_mgr.hxx>
|
#include <simgear/structure/event_mgr.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
//! \cond PRIVATE
|
//! \cond PRIVATE
|
||||||
|
@ -268,8 +268,6 @@ private:
|
||||||
SGPropertyNode_ptr m_yawRateNode;
|
SGPropertyNode_ptr m_yawRateNode;
|
||||||
SGPropertyNode_ptr m_com1VolumeNode;
|
SGPropertyNode_ptr m_com1VolumeNode;
|
||||||
SGPropertyNode_ptr m_com2VolumeNode;
|
SGPropertyNode_ptr m_com2VolumeNode;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace FGSwiftBus
|
} // namespace FGSwiftBus
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,10 @@
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "swift_connection.hxx"
|
#include "swift_connection.hxx"
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <simgear/compiler.h>
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
|
||||||
#include <simgear/io/raw_socket.hxx>
|
|
||||||
#include <simgear/misc/stdint.hxx>
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/commands.hxx>
|
#include <simgear/structure/commands.hxx>
|
||||||
#include <simgear/structure/event_mgr.hxx>
|
#include <simgear/structure/event_mgr.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/timing/timestamp.hxx>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
inline std::string fgswiftbusServiceName()
|
inline std::string fgswiftbusServiceName()
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "traffic.h"
|
#include "traffic.h"
|
||||||
#include "SwiftAircraftManager.h"
|
#include "SwiftAircraftManager.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -205,8 +207,7 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
||||||
reply.appendArgument(verticalOffsets);
|
reply.appendArgument(verticalOffsets);
|
||||||
sendDBusMessage(reply);
|
sendDBusMessage(reply);
|
||||||
});
|
});
|
||||||
} else if (message.getMethodName() == "getElevationAtPosition")
|
} else if (message.getMethodName() == "getElevationAtPosition") {
|
||||||
{
|
|
||||||
std::string callsign;
|
std::string callsign;
|
||||||
double latitudeDeg;
|
double latitudeDeg;
|
||||||
double longitudeDeg;
|
double longitudeDeg;
|
||||||
|
@ -216,8 +217,7 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
||||||
message.getArgument(latitudeDeg);
|
message.getArgument(latitudeDeg);
|
||||||
message.getArgument(longitudeDeg);
|
message.getArgument(longitudeDeg);
|
||||||
message.getArgument(altitudeMeters);
|
message.getArgument(altitudeMeters);
|
||||||
queueDBusCall([ = ]()
|
queueDBusCall([=]() {
|
||||||
{
|
|
||||||
SGGeod pos;
|
SGGeod pos;
|
||||||
pos.setLatitudeDeg(latitudeDeg);
|
pos.setLatitudeDeg(latitudeDeg);
|
||||||
pos.setLongitudeDeg(longitudeDeg);
|
pos.setLongitudeDeg(longitudeDeg);
|
||||||
|
@ -229,8 +229,7 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
||||||
reply.appendArgument(elevation);
|
reply.appendArgument(elevation);
|
||||||
sendDBusMessage(reply);
|
sendDBusMessage(reply);
|
||||||
});
|
});
|
||||||
} else if (message.getMethodName() == "setPlanesTransponders")
|
} else if (message.getMethodName() == "setPlanesTransponders") {
|
||||||
{
|
|
||||||
maybeSendEmptyDBusReply(wantsReply, sender, serial);
|
maybeSendEmptyDBusReply(wantsReply, sender, serial);
|
||||||
std::vector<std::string> callsigns;
|
std::vector<std::string> callsigns;
|
||||||
std::vector<int> codes;
|
std::vector<int> codes;
|
||||||
|
@ -243,16 +242,13 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
||||||
message.getArgument(idents);
|
message.getArgument(idents);
|
||||||
std::vector<AircraftTransponder> transponders;
|
std::vector<AircraftTransponder> transponders;
|
||||||
transponders.reserve(callsigns.size());
|
transponders.reserve(callsigns.size());
|
||||||
for(long unsigned int i = 0; i < callsigns.size(); i++)
|
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));
|
transponders.emplace_back(callsigns.at(i), codes.at(i), modeCs.at(i), idents.at(i));
|
||||||
}
|
}
|
||||||
queueDBusCall([ = ]()
|
queueDBusCall([=]() {
|
||||||
{
|
|
||||||
acm->setPlanesTransponders(transponders);
|
acm->setPlanesTransponders(transponders);
|
||||||
});
|
});
|
||||||
} else if (message.getMethodName() == "setPlanesSurfaces")
|
} else if (message.getMethodName() == "setPlanesSurfaces") {
|
||||||
{
|
|
||||||
maybeSendEmptyDBusReply(wantsReply, sender, serial);
|
maybeSendEmptyDBusReply(wantsReply, sender, serial);
|
||||||
std::vector<std::string> callsigns;
|
std::vector<std::string> callsigns;
|
||||||
std::vector<double> gears;
|
std::vector<double> gears;
|
||||||
|
@ -291,14 +287,12 @@ DBusHandlerResult CTraffic::dbusMessageHandler(const CDBusMessage& message_)
|
||||||
message.getArgument(lightPatterns);
|
message.getArgument(lightPatterns);
|
||||||
std::vector<AircraftSurfaces> surfaces;
|
std::vector<AircraftSurfaces> surfaces;
|
||||||
surfaces.reserve(callsigns.size());
|
surfaces.reserve(callsigns.size());
|
||||||
for(long unsigned int i = 0; i < callsigns.size(); i++)
|
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),
|
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),
|
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));
|
landLights.at(i), taxiLights.at(i), beaconLights.at(i), strobeLights.at(i), navLights.at(i), lightPatterns.at(i));
|
||||||
}
|
}
|
||||||
queueDBusCall([ = ]()
|
queueDBusCall([=]() {
|
||||||
{
|
|
||||||
acm->setPlanesSurfaces(surfaces);
|
acm->setPlanesSurfaces(surfaces);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "SwiftAircraftManager.h"
|
#include "SwiftAircraftManager.h"
|
||||||
#include "dbusobject.h"
|
#include "dbusobject.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue