MOOS 0.2375
|
#include <MOOSCommClient.h>
Public Member Functions | |
CMOOSCommClient () | |
default constructor | |
virtual | ~CMOOSCommClient () |
default destructor | |
bool | Notify (const std::string &sVar, const std::string &sVal, double dfTime=-1) |
bool | Notify (const std::string &sVar, const std::string &sVal, const std::string &sSrcAux, double dfTime=-1) |
bool | Notify (const std::string &sVar, double dfVal, double dfTime=-1) |
bool | Notify (const std::string &sVar, double dfVal, const std::string &sSrcAux, double dfTime=-1) |
bool | Notify (const std::string &sVar, void *pData, unsigned int nDataSize, double dfTime=-1) |
bool | Notify (const std::string &sVar, void *pData, unsigned int nDataSize, const std::string &sSrcAux, double dfTime=-1) |
bool | Register (const std::string &sVar, double dfInterval) |
bool | UnRegister (const std::string &sVar) |
bool | IsConnected () |
bool | Fetch (MOOSMSG_LIST &MsgList) |
bool | Post (CMOOSMsg &Msg) |
bool | ClientLoop () |
virtual bool | DoClientWork () |
bool | Run (const char *sServer, long lPort, const char *sMyName, unsigned int nFundamentalFreq=5) |
void | SetOnConnectCallBack (bool(*pfn)(void *pParamCaller), void *pCallerParam) |
void | SetOnDisconnectCallBack (bool(*pfn)(void *pParamCaller), void *pCallerParam) |
void | SetOnMailCallBack (bool(*pfn)(void *pParamCaller), void *pCallerParam) |
bool | HasMailCallBack () |
bool | ServerRequest (const std::string &sWhat, MOOSMSG_LIST &MsgList, double dfTimeOut=2.0, bool bContinuouslyClearBox=true) |
bool | Peek (MOOSMSG_LIST &List, int nIDRequired, bool bClearBox=true) |
std::string | GetDescription () |
bool | FakeSource (bool bFake) |
bool | Close (bool bNice=true) |
std::set< std::string > | GetPublished () |
bool | IsRegisteredFor (const std::string &sVariable) |
std::set< std::string > | GetRegistered () |
void | SetQuiet (bool bQ) |
void | DoLocalTimeCorrection (bool b) |
void | SetVerboseDebug (bool bT) |
bool | SetCommsTick (int nCommsTick) |
Static Public Member Functions | |
static bool | PeekMail (MOOSMSG_LIST &Mail, const std::string &sKey, CMOOSMsg &Msg, bool bErase=false, bool bFindYoungest=false) |
static bool | PeekAndCheckMail (MOOSMSG_LIST &Mail, const std::string &sKey, CMOOSMsg &Msg, bool bErase=false, bool bFindYoungest=false) |
static std::string | GetLocalIPAddress () |
Protected Member Functions | |
bool | ClearResources () |
void | DoBanner () |
bool | OnCloseConnection () |
bool | HandShake () |
bool | ConnectToServer () |
bool | StartThreads () |
bool | UpdateMOOSSkew (double dfRQTime, double dfTXTime, double dfRXTime) |
Protected Attributes | |
int | m_nNextMsgID |
bool | m_bConnected |
bool | m_bFakeSource |
unsigned int | m_nOutPendingLimit |
unsigned int | m_nInPendingLimit |
std::string | m_sMyName |
CMOOSLock | m_OutLock |
CMOOSLock | m_InLock |
XPCTcpSocket * | m_pSocket |
std::string | m_sDBHost |
long | m_lPort |
bool | m_bQuit |
bool | m_bMailPresent |
CMOOSThread | m_ClientThread |
MOOSMSG_LIST | m_OutBox |
MOOSMSG_LIST | m_InBox |
void * | m_pConnectCallBackParam |
bool(* | m_pfnConnectCallBack )(void *pConnectParam) |
void * | m_pDisconnectCallBackParam |
bool(* | m_pfnDisconnectCallBack )(void *pParam) |
void * | m_pMailCallBackParam |
bool(* | m_pfnMailCallBack )(void *pParam) |
unsigned int | m_nFundamentalFreq |
std::set< std::string > | m_Registered |
std::set< std::string > | m_Published |
bool | m_bQuiet |
bool | m_bVerboseDebug |
bool | m_bDoLocalTimeCorrection |
std::auto_ptr < MOOS::CMOOSSkewFilter > | m_pSkewFilter |
bool | m_bClientLoopIsRunning |
This class is the most important component of MOOS as seen from the eyes of a component developer
Definition at line 71 of file MOOSCommClient.h.
CMOOSCommClient::CMOOSCommClient | ( | ) |
default constructor
Definition at line 87 of file MOOSCommClient.cpp.
CMOOSCommClient::~CMOOSCommClient | ( | ) | [virtual] |
default destructor
Definition at line 121 of file MOOSCommClient.cpp.
bool CMOOSCommClient::ClearResources | ( | ) | [protected] |
Definition at line 995 of file MOOSCommClient.cpp.
bool CMOOSCommClient::ClientLoop | ( | ) |
internal method which runs in a seperate thread and manages the input and output of messages from the server. DO NOT CALL THIS METHOD.
Definition at line 213 of file MOOSCommClient.cpp.
make the client shut down
Definition at line 963 of file MOOSCommClient.cpp.
bool CMOOSCommClient::ConnectToServer | ( | ) | [protected] |
Connect to the server process using info supplied to Init
Definition at line 406 of file MOOSCommClient.cpp.
void CMOOSCommClient::DoBanner | ( | ) | [protected] |
send library info to stdout
Definition at line 687 of file MOOSCommClient.cpp.
bool CMOOSCommClient::DoClientWork | ( | ) | [virtual] |
called by the above to do the client mail box shuffling
Definition at line 272 of file MOOSCommClient.cpp.
void CMOOSCommClient::DoLocalTimeCorrection | ( | bool | b | ) | [inline] |
used to control whether local clock skew (used by MOOSTime()) is se via the server at the other end of this connection
Definition at line 209 of file MOOSCommClient.h.
call with "true" if you want this client to fake its own outgoing name. This is rarely used but very useful when it is
Definition at line 989 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Fetch | ( | MOOSMSG_LIST & | MsgList | ) |
Called by a user of CMOOSCommClient to retrieve mail
MsgList | a list of messages into which the newly received message will be placed |
this is called by a user of a CommClient object to retrieve mail
Definition at line 554 of file MOOSCommClient.cpp.
string CMOOSCommClient::GetDescription | ( | ) |
describe this client in a string
Definition at line 1023 of file MOOSCommClient.cpp.
string CMOOSCommClient::GetLocalIPAddress | ( | ) | [static] |
return a string of the host machines's IP adress
Definition at line 1029 of file MOOSCommClient.cpp.
std::set<std::string> CMOOSCommClient::GetPublished | ( | ) | [inline] |
return the list of messages names published
Definition at line 196 of file MOOSCommClient.h.
std::set<std::string> CMOOSCommClient::GetRegistered | ( | ) | [inline] |
return the list of messages registered
Definition at line 202 of file MOOSCommClient.h.
bool CMOOSCommClient::HandShake | ( | ) | [protected] |
performs a handshake with the server when a new connection is made. Within this function this class tells the server its name
Definition at line 587 of file MOOSCommClient.cpp.
bool CMOOSCommClient::HasMailCallBack | ( | ) |
return true if a mail callback is installed
Definition at line 192 of file MOOSCommClient.cpp.
bool CMOOSCommClient::IsConnected | ( | ) |
returns true if this obecjt is connected to the server
Definition at line 645 of file MOOSCommClient.cpp.
bool CMOOSCommClient::IsRegisteredFor | ( | const std::string & | sVariable | ) |
return true if we are registered for named variable
Definition at line 746 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
double | dfVal, | ||
const std::string & | sSrcAux, | ||
double | dfTime = -1 |
||
) |
Definition at line 763 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
const std::string & | sVal, | ||
const std::string & | sSrcAux, | ||
double | dfTime = -1 |
||
) |
Definition at line 787 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
void * | pData, | ||
unsigned int | nDataSize, | ||
double | dfTime = -1 |
||
) |
notify the MOOS community that something has changed binary data. These are experimental - don't use them until I say so
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
const std::string & | sVal, | ||
double | dfTime = -1 |
||
) |
notify the MOOS community that something has changed (string)
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
void * | pData, | ||
unsigned int | nDataSize, | ||
const std::string & | sSrcAux, | ||
double | dfTime = -1 |
||
) |
bool CMOOSCommClient::Notify | ( | const std::string & | sVar, |
double | dfVal, | ||
double | dfTime = -1 |
||
) |
notify the MOOS community that something has changed (double)
bool CMOOSCommClient::OnCloseConnection | ( | ) | [protected] |
called when connection to server is closed
Definition at line 650 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Peek | ( | MOOSMSG_LIST & | List, |
int | nIDRequired, | ||
bool | bClearBox = true |
||
) |
Have a peek at mail box and remove a particular message, by default all other messages are removed. Note this is quite different from ::PeekMail
Definition at line 865 of file MOOSCommClient.cpp.
bool CMOOSCommClient::PeekAndCheckMail | ( | MOOSMSG_LIST & | Mail, |
const std::string & | sKey, | ||
CMOOSMsg & | Msg, | ||
bool | bErase = false , |
||
bool | bFindYoungest = false |
||
) | [static] |
a static helper function that lets a user browse a mail list as for PeekMail. true is returned if mail is found and it is not more that 5 seconds old
Definition at line 955 of file MOOSCommClient.cpp.
static bool CMOOSCommClient::PeekMail | ( | MOOSMSG_LIST & | Mail, |
const std::string & | sKey, | ||
CMOOSMsg & | Msg, | ||
bool | bErase = false , |
||
bool | bFindYoungest = false |
||
) | [static] |
a static helper function that lets a user browse a mail list the message is removed if bremove is true
place a single message in the out box and return immediately. Completion of this method does not imply transmission. However transmission will occur at the next available oppurtunity. In practice the apparent speed of message transmission will be very fast indeed. This model however prevents wayward user software bring down the MOOSComms by way of denial of service. (ie hogging the network)
Msg | reference to CMOOSMsg which user wishes to send |
this is called by user of a CommClient object to send a Msg to MOOS
Definition at line 503 of file MOOSCommClient.cpp.
bool CMOOSCommClient::Register | ( | const std::string & | sVar, |
double | dfInterval | ||
) |
Register for notification in changes of named variable
sVar | name of variable of interest |
dfInterval | minimum time between notifications |
bool CMOOSCommClient::Run | ( | const char * | sServer, |
long | lPort, | ||
const char * | sMyName, | ||
unsigned int | nFundamentalFreq = 5 |
||
) |
Run the MOOSCommClient Object. This call is non blocking and begins managing process IO with the MOOSComms protocol
sServer | Name of machine on which server resides eg LOCALHOST or guru.mit.edu |
lPort | number of port on which server is listening for new connections eg 9000 |
sMyName | std::string name by which this MOOS process will be known - eg "MotionController" or "DepthSensor" |
nFundamentalFrequency | the basic tick frequency of the comms loop. Default value of 5 implies mail will be retrieved and sent from the server at 5Hz |
Definition at line 126 of file MOOSCommClient.cpp.
bool CMOOSCommClient::ServerRequest | ( | const std::string & | sWhat, |
MOOSMSG_LIST & | MsgList, | ||
double | dfTimeOut = 2.0 , |
||
bool | bContinuouslyClearBox = true |
||
) |
Directly and asynchronously make a request to the server (use this very rarely if ever. It's not meant for public consumption)
sWhat | string specifying what request to make - ALL, DB_CLEAR, PROCESS_SUMMARY or VAR_SUMMARY |
MsgList | List of messages returned by server |
dfTimeOut | TimeOut |
bContinuouslyClearBox | true if all other message returned with query are to be discarded. |
Definition at line 830 of file MOOSCommClient.cpp.
bool CMOOSCommClient::SetCommsTick | ( | int | nCommsTick | ) |
Definition at line 165 of file MOOSCommClient.cpp.
void CMOOSCommClient::SetOnConnectCallBack | ( | bool(*)(void *pParamCaller) | pfn, |
void * | pCallerParam | ||
) |
set the user supplied OnConnect call back. This callback , when set, will be invoked when a connection to the server is made. It is a good plan to register for notification of variables in this callback
pfn | pointer to static function of type bool Fn(void * pParam) |
pCallerParam | parameter passed to callback function when invoked |
Definition at line 199 of file MOOSCommClient.cpp.
void CMOOSCommClient::SetOnDisconnectCallBack | ( | bool(*)(void *pParamCaller) | pfn, |
void * | pCallerParam | ||
) |
set the user supplied OnConnect call back. This callback , when set, will be invoked when a connection to the server is lost.
pfn | pointer to static function of type bool Fn(void * pParam) |
pCallerParam | parameter passed to callback function when invoked |
void CMOOSCommClient::SetOnMailCallBack | ( | bool(*)(void *pParamCaller) | pfn, |
void * | pCallerParam | ||
) |
set the user supplied OnMail callback. This usually will not be set. Users are expected to use FetchMail from their own thread and not use this call back. This function is experimental as of release 7.2 and coders are not encouraged to use it
Definition at line 186 of file MOOSCommClient.cpp.
void CMOOSCommClient::SetQuiet | ( | bool | bQ | ) | [inline] |
used to control how verbose the connection process is
Definition at line 205 of file MOOSCommClient.h.
void CMOOSCommClient::SetVerboseDebug | ( | bool | bT | ) | [inline] |
used to control debug printing
Definition at line 212 of file MOOSCommClient.h.
bool CMOOSCommClient::StartThreads | ( | ) | [protected] |
called internally to start IO management thread
Definition at line 395 of file MOOSCommClient.cpp.
bool CMOOSCommClient::UnRegister | ( | const std::string & | sVar | ) |
UnRegister for notification in changes of named variable
sVar | name of variable of interest |
Definition at line 704 of file MOOSCommClient.cpp.
bool CMOOSCommClient::UpdateMOOSSkew | ( | double | dfRQTime, |
double | dfTXTime, | ||
double | dfRXTime | ||
) | [protected] |
Definition at line 1043 of file MOOSCommClient.cpp.
bool CMOOSCommClient::m_bClientLoopIsRunning [protected] |
Tells us whether the ClientLoop is running.
Definition at line 339 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bConnected [protected] |
true if we are connected to the server
Definition at line 228 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bDoLocalTimeCorrection [protected] |
controls whether skew is set
Definition at line 333 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bFakeSource [protected] |
true if we want to be able to fake sources of messages (used by playback)
Definition at line 231 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bMailPresent [protected] |
true if mail present (saves using a semaphore to open an empty box)
Definition at line 280 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bQuiet [protected] |
controls how verbose connectionn is
Definition at line 327 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bQuit [protected] |
IO thread will continue so long as this flag is false
Definition at line 277 of file MOOSCommClient.h.
bool CMOOSCommClient::m_bVerboseDebug [protected] |
controls verbose debugging printing
Definition at line 330 of file MOOSCommClient.h.
CMOOSThread CMOOSCommClient::m_ClientThread [protected] |
Definition at line 285 of file MOOSCommClient.h.
MOOSMSG_LIST CMOOSCommClient::m_InBox [protected] |
List of message that have been received and are ready for reading by user
Definition at line 293 of file MOOSCommClient.h.
CMOOSLock CMOOSCommClient::m_InLock [protected] |
long CMOOSCommClient::m_lPort [protected] |
port number on which server process is listening for new connections
Definition at line 274 of file MOOSCommClient.h.
unsigned int CMOOSCommClient::m_nFundamentalFreq [protected] |
funcdamental frequency with which comms with server occurs
Definition at line 318 of file MOOSCommClient.h.
unsigned int CMOOSCommClient::m_nInPendingLimit [protected] |
The number of unread incoming messages that can be tolerated
Definition at line 241 of file MOOSCommClient.h.
int CMOOSCommClient::m_nNextMsgID [protected] |
Definition at line 219 of file MOOSCommClient.h.
unsigned int CMOOSCommClient::m_nOutPendingLimit [protected] |
The number of pending unsent messages that can be tolerated
Definition at line 238 of file MOOSCommClient.h.
MOOSMSG_LIST CMOOSCommClient::m_OutBox [protected] |
List of messages that a pending to be sent
Definition at line 289 of file MOOSCommClient.h.
CMOOSLock CMOOSCommClient::m_OutLock [protected] |
void* CMOOSCommClient::m_pConnectCallBackParam [protected] |
parameter that user wants passed to him/her with connect callback
Definition at line 296 of file MOOSCommClient.h.
void* CMOOSCommClient::m_pDisconnectCallBackParam [protected] |
parameter that user wants passed to him/her with disconnect callback
Definition at line 303 of file MOOSCommClient.h.
bool(* CMOOSCommClient::m_pfnConnectCallBack)(void *pConnectParam) [protected] |
the user supplied OnConnect callback
Definition at line 299 of file MOOSCommClient.h.
bool(* CMOOSCommClient::m_pfnDisconnectCallBack)(void *pParam) [protected] |
the user supplied OnDisConnect callback
Definition at line 306 of file MOOSCommClient.h.
bool(* CMOOSCommClient::m_pfnMailCallBack)(void *pParam) [protected] |
the user supplied OnMailCallBack
Definition at line 312 of file MOOSCommClient.h.
void* CMOOSCommClient::m_pMailCallBackParam [protected] |
parameter that user wants passed to mail callback
Definition at line 309 of file MOOSCommClient.h.
std::auto_ptr< MOOS::CMOOSSkewFilter > CMOOSCommClient::m_pSkewFilter [protected] |
Skew filter keeps track of clock skew with server
Definition at line 336 of file MOOSCommClient.h.
XPCTcpSocket* CMOOSCommClient::m_pSocket [protected] |
pointer to socket connected to server
Definition at line 266 of file MOOSCommClient.h.
std::set<std::string> CMOOSCommClient::m_Published [protected] |
the set of messages names/keys that have been sent
Definition at line 324 of file MOOSCommClient.h.
std::set<std::string> CMOOSCommClient::m_Registered [protected] |
a set of strings of the resources (messages names/keys) that have been registered for
Definition at line 321 of file MOOSCommClient.h.
std::string CMOOSCommClient::m_sDBHost [protected] |
name of the host on which the server process lives
Definition at line 270 of file MOOSCommClient.h.
std::string CMOOSCommClient::m_sMyName [protected] |