MOOS 0.2375
Classes | Defines | Typedefs | Functions | Variables
/home/toby/moos-ivp/MOOS-2375-Oct0611/Core/MOOSGenLib/MOOSGenLibGlobalHelper.cpp File Reference
#include "MOOSGenLibGlobalHelper.h"
#include "MOOSGenLib/MOOSAssert.h"
#include <algorithm>
#include <iterator>
#include <cctype>
#include <string>
#include <memory>
#include <cstring>
#include <map>
#include <time.h>
#include <stdarg.h>
#include <math.h>
#include <unistd.h>
#include <sys/times.h>
#include <sys/time.h>
#include <termios.h>
#include <dirent.h>
#include <errno.h>
#include <pthread.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <iomanip>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <stdio.h>
Include dependency graph for MOOSGenLibGlobalHelper.cpp:

Go to the source code of this file.

Classes

struct  CompareInsensitive

Defines

#define ENABLE_WIN32_HPMOOSTIME   0
#define MAX_TIME_WARP   100
#define TWO_PI   6.28318530717

Typedefs

typedef std::map< pthread_t, boolTHREAD2TRACE_MAP

Functions

void SetMOOSSkew (double dfSkew)
double GetMOOSSkew ()
bool IsLittleEndian ()
bool SetWin32HighPrecisionTiming (bool bEnable)
double MOOSLocalTime (bool bApplyTimeWarping)
double HPMOOSTime (bool bApplyTimeWarping)
double MOOSTime (bool bApplyTimeWarping)
double GetMOOSTimeWarp ()
bool SetMOOSTimeWarp (double dfWarp)
void MOOSPause (int nMS, bool bApplyTimeWarping)
string MOOSChomp (string &sStr, const string &sTk, bool bInsensitive)
size_t MOOSStrFind (const std::string &sSource, const std::string &sToken, bool bInsensitive)
bool MOOSValFromString (string &sVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (unsigned int &nVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (int &nVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (long &nVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (bool &bVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (double &dfVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSValFromString (float &fVal, const string &sStr, const string &sTk, bool bInsensitive)
bool MOOSVectorFromString (const string &sStr, std::vector< double > &dfValVec, int &nRows, int &nCols)
bool MOOSVectorFromString (const string &sStr, std::vector< float > &fValVec, int &nRows, int &nCols)
bool MOOSVectorFromString (const string &sStr, std::vector< unsigned int > &nValVec, int &nRows, int &nCols)
bool MOOSValFromString (std::vector< double > &dfValVec, int &nRows, int &nCols, const std::string &sStr, const std::string &sToken, bool bInsensitive)
bool MOOSValFromString (std::vector< unsigned int > &nValVec, int &nRows, int &nCols, const std::string &sStr, const std::string &sToken, bool bInsensitive)
bool MOOSValFromString (long long &nVal, const string &sStr, const string &sTk, bool bInsensitive)
bool GetNextAlogLineByMessageName (std::istream &Input, const std::string &sMessageName, double &dfTime, std::string &sSource, std::string &sPayload)
double MOOS_ANGLE_WRAP (double dfAng)
bool MOOSAbsLimit (double &dfVal, double dfLimit)
bool MOOSStrCmp (string s1, string s2)
string MOOSGetDate ()
bool MOOSWildCmp (const std::string &sPattern, const std::string &sString)
string MOOSGetTimeStampString ()
void MOOSToUpper (string &str)
bool MOOSIsNumeric (string str)
void MOOSTrimWhiteSpace (string &str)
void MOOSRemoveChars (string &sStr, const string &sTok)
int MOOSGetch ()
string MOOSFormat (const char *FmtStr,...)
bool MOOSFail (const char *FmtStr,...)
void InhibitMOOSTraceInThisThread (bool bInhibit)
void MOOSTrace (string sStr)
void MOOSTrace (const char *FmtStr,...)
double MOOSDeg2Rad (double dfDeg)
double MOOSRad2Deg (double dfRad)
bool MOOSGetValueFromToken (STRING_LIST &sParams, const string &sToken, string &sVal)
string MOOSThirdPartyStatusString (string sStatusCommand)
string MOOSThirdPartyActuationString (double *pdfRudder, double *pdfElevator, double *pdfThrust)
double MOOSNormalInv (double dfArea)
double MOOSUniformRandom (double dfMin, double dfMax)
int MOOSDiscreteUniform (int nMin, int nMax)
double MOOSWhiteNoise (double Sigma)
void Progress (double dfPC)
std::string DoubleVector2String (const std::vector< double > &V)
std::stringstream & Write (std::stringstream &os, const std::vector< double > &Vec)
std::stringstream & Write (std::stringstream &os, const std::vector< int > &Vec)
bool GetDirectoryContents (const std::string &sPath, std::list< std::string > &sContents, bool bFiles)

Variables

double gdfMOOSTimeWarp = 1.0
double gdfMOOSSkew = 0.0
bool gbWin32HPTiming = true
THREAD2TRACE_MAP gThread2TraceMap

Define Documentation

#define ENABLE_WIN32_HPMOOSTIME   0

Definition at line 79 of file MOOSGenLibGlobalHelper.cpp.

#define MAX_TIME_WARP   100

Definition at line 80 of file MOOSGenLibGlobalHelper.cpp.

#define TWO_PI   6.28318530717

Definition at line 88 of file MOOSGenLibGlobalHelper.cpp.


Typedef Documentation

typedef std::map<pthread_t,bool> THREAD2TRACE_MAP

Definition at line 94 of file MOOSGenLibGlobalHelper.cpp.


Function Documentation

std::string DoubleVector2String ( const std::vector< double > &  V)

formats a vector of doubles into standard MOOS format

Definition at line 1326 of file MOOSGenLibGlobalHelper.cpp.

bool GetDirectoryContents ( const std::string &  sPath,
std::list< std::string > &  sContents,
bool  bFiles 
)

returns a string list of directories or files in a specified location exludes . and ..

splits a fully qualified path into parts -path, filestem and extension

Definition at line 1382 of file MOOSGenLibGlobalHelper.cpp.

double GetMOOSSkew ( )

return the offset between DB time and client time

Definition at line 109 of file MOOSGenLibGlobalHelper.cpp.

double GetMOOSTimeWarp ( )

return the current time warp factor

Definition at line 238 of file MOOSGenLibGlobalHelper.cpp.

bool GetNextAlogLineByMessageName ( std::istream &  Input,
const std::string &  sMessageName,
double &  dfTime,
std::string &  sSource,
std::string &  sPayload 
)

Definition at line 702 of file MOOSGenLibGlobalHelper.cpp.

double HPMOOSTime ( bool  bApplyTimeWarping = true)

return high precision timestamp - time since unix in seconds only has high precision in win32

Definition at line 228 of file MOOSGenLibGlobalHelper.cpp.

void InhibitMOOSTraceInThisThread ( bool  bInhibit = true)

Inhibit (enable) MOOSTracing in the calling thread

Definition at line 1067 of file MOOSGenLibGlobalHelper.cpp.

bool IsLittleEndian ( )

returns true if architecture is LittleEndian (true for x86 Architectures) Note after first call it remembers answer in a static so v. littel overhead in calling this function frequently

Definition at line 119 of file MOOSGenLibGlobalHelper.cpp.

double MOOS_ANGLE_WRAP ( double  dfAng)

Bound angle to +/-PI

Definition at line 734 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSAbsLimit ( double &  dfVal,
double  dfLimit 
)

limit dfVal to lie between +/- dfLimit)

Definition at line 756 of file MOOSGenLibGlobalHelper.cpp.

string MOOSChomp ( string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 275 of file MOOSGenLibGlobalHelper.cpp.

double MOOSDeg2Rad ( double  dfDeg)

convert deg to rad

Definition at line 1145 of file MOOSGenLibGlobalHelper.cpp.

int MOOSDiscreteUniform ( int  nMin,
int  nMax 
)

generates uniform noise in integers between interval nMin->nMax

Definition at line 1247 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSFail ( const char *  FmtStr,
  ... 
)

like MOOSTrace but returns false - useful for return statements

Definition at line 1030 of file MOOSGenLibGlobalHelper.cpp.

string MOOSFormat ( const char *  FmtStr,
  ... 
)

return a formatted string (with printf-like format codes

Definition at line 992 of file MOOSGenLibGlobalHelper.cpp.

int MOOSGetch ( )

useful keyboard trap

Definition at line 954 of file MOOSGenLibGlobalHelper.cpp.

string MOOSGetDate ( )

get the current date formatted nicely

Definition at line 781 of file MOOSGenLibGlobalHelper.cpp.

string MOOSGetTimeStampString ( )

return nicely formatted time stamp string

Definition at line 873 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSGetValueFromToken ( STRING_LIST sParams,
const string &  sToken,
string &  sVal 
)

Definition at line 1156 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSIsNumeric ( string  str)

Definition at line 910 of file MOOSGenLibGlobalHelper.cpp.

double MOOSLocalTime ( bool  bApplyTimeWarping = true)

Return time as a double (time since unix in seconds). This returns the time as reported by the local clock. It will *not* return time at the Comms Server, as MOOSTime tries to do.

Definition at line 149 of file MOOSGenLibGlobalHelper.cpp.

double MOOSNormalInv ( double  dfArea)

returns x for probablity mass such p(v<=x) = dfArea)

Definition at line 1216 of file MOOSGenLibGlobalHelper.cpp.

void MOOSPause ( int  nMS,
bool  bApplyTimeWarping = true 
)

pause for nMS milliseconds

Definition at line 255 of file MOOSGenLibGlobalHelper.cpp.

double MOOSRad2Deg ( double  dfRad)

convert rad 2 deg

Definition at line 1150 of file MOOSGenLibGlobalHelper.cpp.

void MOOSRemoveChars ( string &  sStr,
const string &  sTok 
)

Definition at line 938 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSStrCmp ( string  s1,
string  s2 
)

Definition at line 771 of file MOOSGenLibGlobalHelper.cpp.

size_t MOOSStrFind ( const std::string &  sSource,
const std::string &  sToken,
bool  bInsensitive 
)

Definition at line 306 of file MOOSGenLibGlobalHelper.cpp.

string MOOSThirdPartyActuationString ( double *  pdfRudder,
double *  pdfElevator,
double *  pdfThrust 
)

Definition at line 1190 of file MOOSGenLibGlobalHelper.cpp.

string MOOSThirdPartyStatusString ( string  sStatusCommand)

Definition at line 1180 of file MOOSGenLibGlobalHelper.cpp.

double MOOSTime ( bool  bApplyTimeWarping = true)

return time as a double (time since unix in seconds). This will also apply a skew to this time so that all processes connected to a MOOSCommsServer (often in the shap of a DB) will have a unified time. Of course if your process isn't using MOOSComms at all this funtion works just fine and returns the unadulterated time as you would expect

Definition at line 233 of file MOOSGenLibGlobalHelper.cpp.

void MOOSToUpper ( string &  str)

Definition at line 900 of file MOOSGenLibGlobalHelper.cpp.

void MOOSTrace ( string  sStr)

Definition at line 1079 of file MOOSGenLibGlobalHelper.cpp.

void MOOSTrace ( const char *  FmtStr,
  ... 
)

print a formatted string (with printf-like format codes) and to debug window in DevStudio

Definition at line 1085 of file MOOSGenLibGlobalHelper.cpp.

void MOOSTrimWhiteSpace ( string &  str)

Definition at line 920 of file MOOSGenLibGlobalHelper.cpp.

double MOOSUniformRandom ( double  dfMin,
double  dfMax 
)

generates uniform noise in interval dfMin-dfMax

Definition at line 1241 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( int &  nVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 383 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( std::vector< double > &  dfValVec,
int &  nRows,
int &  nCols,
const std::string &  sStr,
const std::string &  sToken,
bool  bInsensitive 
)

Definition at line 654 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( bool bVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 431 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( double &  dfVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 450 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( float &  fVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 475 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( long &  nVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 407 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( std::vector< unsigned int > &  nValVec,
int &  nRows,
int &  nCols,
const std::string &  sStr,
const std::string &  sToken,
bool  bInsensitive 
)

Definition at line 670 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( long long &  nVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 688 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( string &  sVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 329 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSValFromString ( unsigned int &  nVal,
const string &  sStr,
const string &  sTk,
bool  bInsensitive 
)

Definition at line 373 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSVectorFromString ( const string &  sStr,
std::vector< unsigned int > &  nValVec,
int &  nRows,
int &  nCols 
)

Definition at line 603 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSVectorFromString ( const string &  sStr,
std::vector< double > &  dfValVec,
int &  nRows,
int &  nCols 
)

Definition at line 500 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSVectorFromString ( const string &  sStr,
std::vector< float > &  fValVec,
int &  nRows,
int &  nCols 
)

Definition at line 551 of file MOOSGenLibGlobalHelper.cpp.

double MOOSWhiteNoise ( double  Sigma)

returns sample fom Gaussian process strength Sigma mena zero

Definition at line 1264 of file MOOSGenLibGlobalHelper.cpp.

bool MOOSWildCmp ( const std::string &  sPattern,
const std::string &  sString 
)

pattern matching using * and ?. returns true if sPattern matches sString

Definition at line 811 of file MOOSGenLibGlobalHelper.cpp.

void Progress ( double  dfPC)

prints a "progress bar" upto 40 characters long dfPC is the fraction complete - ie 0:1

Definition at line 1307 of file MOOSGenLibGlobalHelper.cpp.

void SetMOOSSkew ( double  dfSkew)

Definition at line 100 of file MOOSGenLibGlobalHelper.cpp.

bool SetMOOSTimeWarp ( double  dfWarp)

set the rate at which time is accelerated (from start of unix time)

Definition at line 244 of file MOOSGenLibGlobalHelper.cpp.

bool SetWin32HighPrecisionTiming ( bool  bEnable)

call this to disable or anble high precision windows timers. By default they are on and always used in calls to MOOSTime()

Definition at line 137 of file MOOSGenLibGlobalHelper.cpp.

std::stringstream& Write ( std::stringstream &  os,
const std::vector< double > &  Vec 
)

formats a vector of doubles into standard MOOS format

Definition at line 1334 of file MOOSGenLibGlobalHelper.cpp.

std::stringstream& Write ( std::stringstream &  os,
const std::vector< int > &  Vec 
)

formats a vector of ints into standard MOOS format

Definition at line 1361 of file MOOSGenLibGlobalHelper.cpp.


Variable Documentation

Definition at line 136 of file MOOSGenLibGlobalHelper.cpp.

double gdfMOOSSkew = 0.0

Definition at line 98 of file MOOSGenLibGlobalHelper.cpp.

double gdfMOOSTimeWarp = 1.0

Definition at line 97 of file MOOSGenLibGlobalHelper.cpp.

Definition at line 1065 of file MOOSGenLibGlobalHelper.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines