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


Jump to: navigation, search

Howto:Exposing Subsystems to Nasal

1,545 bytes added, 21:31, 13 February 2016
To make the whole thing more useful, we will lower the logging priority and instead change the name of the added event to include the file name of the Nasal module and the line number where the settimer() call is invoked (which will be primarily useful in conjunction with the simgear patch above):
<syntaxhighlight lang="diff">
diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
index dcd9965..7f49b18 100644
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -1307,7 +1307,25 @@ void FGNasalSys::setTimer(naContext c, int argc, naRef* args)
t->gcKey = gcSave(handler);
t->nasal = this;
- globals->get_event_mgr()->addEvent("NasalTimer",
+ "Nasal timer registration via settimer():\n"
+ "\tfile: " << naStr_data(naGetSourceFile(c,0)) <<
+ "\tline: " << naGetLine(c,0) << std::endl
+ );
+ if(delta.num <= 0.1)
+ SG_LOG(SG_NASAL, SG_ALERT, "Warning: settimer() should rarely be used per-frame !!");
+ std::string timerName("NasalTimer: ");
+ std::stringstream line;
+ line << naGetLine(c,0);
+ timerName += std::string(naStr_data(naGetSourceFile(c,0))) +" via line:"+line.str() ;
+ globals->get_event_mgr()->addEvent(timerName,
t, &NasalTimer::timerExpired,
delta.num, simtime);
Next, we can explore logging everything via properties, i.e. so that all this info shows up in the property tree using property objects
=== Base Package ===

Navigation menu