Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Howto:Exposing Subsystems to Nasal

2,155 bytes added, 16:25, 7 February 2016
Patching
== Patching ==
For starters, we will just add some debugging statements to the event manager
<syntaxhighlight lang="diff">
diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx
index 2e4f7b7..eb892ad 100644
--- a/simgear/structure/event_mgr.cxx
+++ b/simgear/structure/event_mgr.cxx
@@ -24,9 +24,26 @@ void SGEventMgr::add(const std::string& name, SGCallback* cb,
SGTimerQueue* q = simtime ? &_simQueue : &_rtQueue;
+ SG_LOG(SG_GENERAL, SG_ALERT, "== Inserting timer into queue" <<
+ "\t type:" << name <<
+ "\t interval:" << interval <<
+ "\t delay:" << delay <<
+ "\t repeated:" << repeat <<
+ "\t simtime/realtime:" << simtime <<"/"<<!simtime
+ << std::endl);
+
+ info();
q->insert(t, delay);
}
+void info() {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Total Entries in queues" <<
+ "\t simtime queue:" << _simQueue->getQueueSize() << std::endl
+ "\t realtime queue:" << _rtQueue->getQueueSize() << std::endl
+ );
+}
+
+
SGTimer::~SGTimer()
{
delete callback;
diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx
index 699522b..0cab8b7 100644
--- a/simgear/structure/event_mgr.hxx
+++ b/simgear/structure/event_mgr.hxx
@@ -38,6 +38,9 @@ public:
double nextTime() { return -_table[0].pri; }
SGTimer* findByName(const std::string& name) const;
+ unsigned int getQueueSize() const {
+ return _numEntries;
+ }
private:
// The "priority" is stored as a negative time. This allows the
// implementation to treat the "top" of the heap as the largest
@@ -76,6 +79,7 @@ public:
virtual void update(double delta_time_sec);
virtual void unbind();
virtual void shutdown();
+ virtual void info(); // dumps queue info to the console
void setRealtimeProperty(SGPropertyNode* node) { _rtProp = node; }
@@ -120,6 +124,11 @@ public:
void removeTask(const std::string& name);
private:
+
+ typedef std::pair<std::string, int> CallbackInfo; //callback name & number of instances
+ typedef std::map<SGCallback*, CallbackInfo> CallbackMap;
+ CallbackMap _registeredCallbacks;
+
friend class SGTimer;
void add(const std::string& name, SGCallback* cb,
 
</syntaxhighlight>
18,232
edits

Navigation menu