Revision: 7817
http://playerstage.svn.sourceforge.net/playerstage/?rev=7817&view=rev
Author: gbiggs
Date: 2009-06-08 06:52:18 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
Applied patch #2802535
Modified Paths:
--------------
code/player/trunk/server/drivers/localization/fakelocalize.cc
Modified: code/player/trunk/server/drivers/localization/fakelocalize.cc
===================================================================
--- code/player/trunk/server/drivers/localization/fakelocalize.cc
2009-06-08 06:44:41 UTC (rev 7816)
+++ code/player/trunk/server/drivers/localization/fakelocalize.cc
2009-06-08 06:52:18 UTC (rev 7817)
@@ -64,6 +64,12 @@
- Default: NULL
- Name of simulation model for which we're faking localization.
+...@par Properties
+
+- sleep_nsec (integer)
+ - Default: 100000000
+ - timespec value for nanosleep()
+
@par Example
@verbatim
@@ -100,8 +106,6 @@
#include <libplayercore/playercore.h>
-#define SLEEPTIME_NS 100000000
-
#if !defined (min)
#define min(x,y) ((x) < (y) ? (x) : (y))
#endif
@@ -110,6 +114,8 @@
#define strdup _strdup
#endif
+const int SLEEPTIME_NS = 100000000;
+
// Driver for computing the free c-space from a laser scan.
class FakeLocalize : public ThreadedDriver
{
@@ -132,6 +138,7 @@
private: player_devaddr_t localize_addr;
private: player_devaddr_t position2d_addr;
private: char* model;
+ private: IntProperty sleep_nsec;
};
// Initialization function
@@ -150,8 +157,17 @@
// Constructor
FakeLocalize::FakeLocalize( ConfigFile* cf, int section)
: ThreadedDriver(cf, section, true, PLAYER_MSGQUEUE_DEFAULT_MAXLEN),
- model (NULL)
+ model (NULL),
+ sleep_nsec("sleep_nsec", SLEEPTIME_NS, false)
{
+ RegisterProperty("sleep_nsec", &sleep_nsec, cf, section);
+ if (this->sleep_nsec.GetValue () < 0)
+ {
+ PLAYER_ERROR("invalid sleep_nsec value");
+ this->SetError(-1);
+ return;
+ }
+
// Must have an input sim
if (cf->ReadDeviceAddr(&this->sim_id, section, "requires",
PLAYER_SIMULATION_CODE, -1, NULL) != 0)
@@ -203,7 +219,6 @@
this->SetError(-1);
return;
}
-
return;
}
@@ -317,9 +332,12 @@
pthread_exit(NULL);
}
this->ProcessMessages();
- ts.tv_sec = 0;
- ts.tv_nsec = SLEEPTIME_NS;
- nanosleep(&ts, NULL);
+ if (this->sleep_nsec.GetValue () > 0)
+ {
+ ts.tv_sec = 0;
+ ts.tv_nsec = this->sleep_nsec;
+ nanosleep(&ts, NULL);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit