Skip to content

Commit

Permalink
Merge branch 'refs/heads/devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
pmnewman committed Jul 11, 2014
2 parents 7f8daa8 + b58d389 commit d13be4b
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 54 deletions.
3 changes: 2 additions & 1 deletion Core/libMOOS/App/MOOSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ bool CMOOSApp::GetFlagFromCommandLineOrConfigurationFile(std::string sOption,boo
}
if(bF)
{
//std::cerr<<"found in config file:"<<sOption<<"\n";
return bFlag;
}
return false;
Expand Down Expand Up @@ -671,7 +672,7 @@ void CMOOSApp::DoBanner()

if(GetMOOSTimeWarp()!=1.0)
MOOSTrace("\t|-Time Warp @ %.1f \n",GetMOOSTimeWarp());
if(m_Comms.GetCommsControlTimeWarpScaleFactor()>0.0)
if(m_Comms.GetCommsControlTimeWarpScaleFactor()>0.0 && GetMOOSTimeWarp()>1.0)
MOOSTrace("\t|-Time Warp delay @ %.1f ms \n",m_Comms.GetCommsControlTimeWarpScaleFactor()*GetMOOSTimeWarp());


Expand Down
9 changes: 8 additions & 1 deletion Core/libMOOS/App/include/MOOS/libMOOS/App/MOOSApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,14 @@ class CMOOSApp
response times. It is not recommended for general use*/
bool UseMailCallBack();


/**
* look for a parameter in the mission file and on the command line. If found in both command line
* wins. It is (default) assumed "--" is prepended on command line. So foo=xx in mission file appears as
* --foo=xx on command line
* @param sOption name of parameter
* @param var variable to be returned
* @param bPrependMinusMinusForCommandLine if true then add "--" to command line
*/
template <class T>
bool GetParameterFromCommandLineOrConfigurationFile(std::string sOption, T & var,bool bPrependMinusMinusForCommandLine=true);

Expand Down
11 changes: 10 additions & 1 deletion Core/libMOOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,22 @@ IF (DETECT_CLOCK_DRIFT)
ENDIF (DETECT_CLOCK_DRIFT)
MARK_AS_ADVANCED(DETECT_CLOCK_DRIFT)

# Removed the extra field that was added to the MOOS message protocol in October 2009.
# Remove the extra field that was added to the MOOS message protocol in October 2009.
OPTION(DISABLE_AUX_SOURCE "Disable the AUX_SRC field in MOOS messages. Only change this if you know what it is!" OFF)
IF (DISABLE_AUX_SOURCE)
ADD_DEFINITIONS(-DDISABLE_AUX_SOURCE)
ENDIF (DISABLE_AUX_SOURCE)
MARK_AS_ADVANCED(DISABLE_AUX_SOURCE)


set(TIME_WARP_AGGLOMERATION_CONSTANT 0.0 CACHE STRING "comms agglomeration scale factor for high time warps")
IF (${TIME_WARP_AGGLOMERATION_CONSTANT} GREATER 0.0)
ADD_DEFINITIONS(-DTIME_WARP_AGGLOMERATION_CONSTANT=${TIME_WARP_AGGLOMERATION_CONSTANT})
ENDIF ()
MARK_AS_ADVANCED(TIME_WARP_AGGLOMERATION_CONSTANT)



OPTION(ENABLE_V10_COMPATIBILITY "Enable compatibility for source which includes pre V10 headers " OFF)
OPTION(ENABLE_V10_IVP_COMPATIBILITY "Enable compatibility for source which includes pre V10 headers as expected by IvP " OFF)
MARK_AS_ADVANCED(ENABLE_V10_IVP_COMPATIBILITY)
Expand Down
8 changes: 6 additions & 2 deletions Core/libMOOS/Comms/MOOSAsyncCommClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "MOOS/libMOOS/Comms/MOOSAsyncCommClient.h"
#include "MOOS/libMOOS/Comms/XPCTcpSocket.h"



namespace MOOS {

#define TIMING_MESSAGE_PERIOD 1.0
Expand All @@ -67,7 +69,7 @@ MOOSAsyncCommClient::MOOSAsyncCommClient() {
m_dfOutGoingDelay = 0.0;
m_bPostNewestToFront = false;

SetCommsControlTimeWarpScaleFactor(0.1);
// SetCommsControlTimeWarpScaleFactor(0.0);
}
///default destructor
MOOSAsyncCommClient::~MOOSAsyncCommClient() {
Expand Down Expand Up @@ -312,6 +314,8 @@ bool MOOSAsyncCommClient::DoWriting() {

}



bool MOOSAsyncCommClient::MonitorAndLimitWriteSpeed()
{
double WarpDelayMS = 0.0;
Expand All @@ -320,7 +324,7 @@ bool MOOSAsyncCommClient::MonitorAndLimitWriteSpeed()
double TimeWarp =GetMOOSTimeWarp();
if(TimeWarp>1.0)
{
WarpDelayMS=TimeWarp*0.1;
WarpDelayMS=TimeWarp*GetCommsControlTimeWarpScaleFactor();
}
double TotalDelay = std::max(m_dfOutGoingDelay*1000,WarpDelayMS);
unsigned int sleep_ms =
Expand Down
18 changes: 14 additions & 4 deletions Core/libMOOS/Comms/MOOSCommClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ using namespace std;
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

#define MAX_TIME_WARP_AGGLOMERATION_CONSTANT 10.0
#ifndef TIME_WARP_AGGLOMERATION_CONSTANT
#define TIME_WARP_AGGLOMERATION_CONSTANT 0.2
#endif



Expand Down Expand Up @@ -123,7 +127,7 @@ CMOOSCommClient::CMOOSCommClient()
//assume an old DB
m_bDBIsAsynchronous = false;

SetCommsControlTimeWarpScaleFactor(0.0);
SetCommsControlTimeWarpScaleFactor(TIME_WARP_AGGLOMERATION_CONSTANT);

SetVerboseDebug(false);

Expand Down Expand Up @@ -1732,8 +1736,14 @@ bool CMOOSCommClient::UpdateMOOSSkew(double dfRqTime, double dfTxTime, double df

bool CMOOSCommClient::SetCommsControlTimeWarpScaleFactor(double dfSF)
{
if(dfSF<0.0|| dfSF>1.0)

if(dfSF<0.0|| dfSF>MAX_TIME_WARP_AGGLOMERATION_CONSTANT)
{
std::cerr<<MOOS::ConsoleColours::Red();
std::cerr<<"Warning: Comms Scale factor out of range (0:10.0\n";
std::cerr<<MOOS::ConsoleColours::reset();
return false;
}

m_dfOutGoingDelayTimeWarpScaleFactor = dfSF;
return true;
Expand Down Expand Up @@ -1780,15 +1790,15 @@ bool CMOOSCommClient::ControlClientCommsStatusMonitoring(bool bEnable)
return true;
}

bool CMOOSCommClient::GetClientCommsStatus(const std::string & sClient, MOOS::ClientCommsStatus & Status)
bool CMOOSCommClient::GetClientCommsStatus(const std::string & sClient, MOOS::ClientCommsStatus & TheStatus)
{
MOOS::ScopedLock L(m_ClientStatusLock);
std::map<std::string , MOOS::ClientCommsStatus>::iterator q = m_ClientStatuses.find(sClient);

if (q==m_ClientStatuses.end())
return false;

Status = q->second;
TheStatus = q->second;

return true;
}
Expand Down
63 changes: 47 additions & 16 deletions Core/libMOOS/Comms/XPCGetProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,75 @@
//
////////////////////////// END_GPL //////////////////////////////////
#include "MOOS/libMOOS/Comms/XPCGetProtocol.h"
#include "MOOS/libMOOS/Utils/MOOSScopedLock.h"

CMOOSLock _ProtocolLock;

XPCGetProtocol::XPCGetProtocol(const char *_sName)
{
MOOS::ScopedLock L(_ProtocolLock);

#ifdef UNIX
cIteratorFlag = 0;
#endif

// Retrieves the protocol structure by name
protocolPtr = getprotobyname(_sName);
if (protocolPtr == NULL)
{
XPCException exceptObject("Could Not Get Protocol By Name");
throw exceptObject;
return;
}

}

XPCGetProtocol::XPCGetProtocol(int _iProtocol)
{
MOOS::ScopedLock L(_ProtocolLock);

#ifdef UNIX
cIteratorFlag = 0;
#endif
#ifdef __linux
// Retrieves the protocol structure by number
char buf[1024];

getprotobynumber_r(_iProtocol,&protocol,
buf, sizeof(buf), &protocolPtr);


//protocolPtr = getprotobynumber_r(_iProtocol);//thread safe fix suggested by Mark Moseley
#else
// Retrieves the protocol structure by number
protocolPtr = getprotobynumber(_iProtocol);
#endif
if (protocolPtr == NULL)
{
XPCException exceptObject("Could Not Get Protocol By Number");
throw exceptObject;
return;
}
}

XPCGetProtocol::~XPCGetProtocol()
{
MOOS::ScopedLock L(_ProtocolLock);
#ifdef UNIX
endprotoent();
#endif
}


#ifdef UNIX
void XPCGetProtocol::vOpenProtocolDb()
{
MOOS::ScopedLock L(_ProtocolLock);

endprotoent();
cIteratorFlag = 1;
setprotoent(1);
}

// Iterates through the list of protocols
char XPCGetProtocol::cGetNextProtocol()
{
MOOS::ScopedLock L(_ProtocolLock);

if (cIteratorFlag == 1)
{
if ((protocolPtr = getprotoent()) == NULL)
return 0;
else
return 1;
}
return 0;
}
#endif



Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class CMOOSCommClient :public CMOOSCommObject
void EnableCommsStatusMonitoring(bool bEnable);

/** query the comms status of some other client*/
bool GetClientCommsStatus(const std::string & sClient, MOOS::ClientCommsStatus & Status);
bool GetClientCommsStatus(const std::string & sClient, MOOS::ClientCommsStatus & TheStatus);

/** get all client statuses */
void GetClientCommsStatuses(std::list<MOOS::ClientCommsStatus> & Statuses);
Expand Down
33 changes: 5 additions & 28 deletions Core/libMOOS/Comms/include/MOOS/libMOOS/Comms/XPCGetProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class XPCGetProtocol
{
#ifdef UNIX
char cIteratorFlag; // Protocol database iteration flag
#ifdef __linux
struct protoent protocol;
#endif
#endif
struct protoent *protocolPtr; // Pointer to protocol database entry
public:
Expand All @@ -61,35 +58,15 @@ class XPCGetProtocol
// Constructor. Returns the protoent structure given the protocol number
XPCGetProtocol(int _iProtocol);

// Desstructor closes the database connection
~XPCGetProtocol()
{
#ifdef UNIX
endprotoent();
#endif
}
// Destructor closes the database connection
~XPCGetProtocol();

// Opens the protocol database and sets the cIteratorFlag to true
#ifdef UNIX
void vOpenProtocolDb()
{
endprotoent();
cIteratorFlag = 1;
setprotoent(1);
}
// Opens the protocol database and sets the cIteratorFlag to true
void vOpenProtocolDb();

// Iterates through the list of protocols
char cGetNextProtocol()
{
if (cIteratorFlag == 1)
{
if ((protocolPtr = getprotoent()) == NULL)
return 0;
else
return 1;
}
return 0;
}
char cGetNextProtocol();
#endif

// Returns the protocol name
Expand Down

0 comments on commit d13be4b

Please sign in to comment.