AURobotServers  4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ULaserSim Class Reference

#include <ulasersim.h>

Inheritance diagram for ULaserSim:
Inheritance graph

Public Member Functions

virtual bool changeMode (int scanangle, double resolution)
 
virtual bool getNewestData (ULaserData *dest, unsigned long lastSerial, int fake)
 
virtual bool isPortOpen ()
 
virtual bool logSourceData (const char *data, int dataCnt)
 
 ULaserSim ()
 
 ~ULaserSim ()
 
- Public Member Functions inherited from ULaserDevice
virtual void callGotNewDataWithObject ()
 
virtual void createBaseVars ()
 
unsigned int getBad ()
 
char * getDeviceName ()
 
int getDeviceNum ()
 
UPosition getDevicePos ()
 
UPosRot getDevicePose ()
 
URotation getDeviceRot ()
 
unsigned int getGood ()
 
char * getLogFileName (char *buffer, int bufferCnt)
 
int getLogInterval ()
 
bool getLogUsedScans ()
 
int getMaxMeasurements ()
 
bool getMirror ()
 
double getMsgRate ()
 
char * getName ()
 
int getScanAngle ()
 
double getScanAngle (int measurement)
 
double getScanResolution ()
 
unsigned long getSerial ()
 
void gotNewScan (ULaserData *gotData)
 
virtual bool isLogFileOpen ()
 
virtual bool isReplayDevice ()
 
bool isRunning ()
 
bool isSend ()
 
virtual bool isVerbose ()
 
void logFileClose ()
 
bool logFileOpen ()
 
void logThisScan (ULaserData *scan)
 
void openRequest (bool toOpen)
 
void print (char *preString)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
void send (char *msg)
 
virtual void setDeviceName (const char *device)
 
void setDeviceNum (int value)
 
void setDevicePose (UPosRot *newPose)
 
void setLogInterval (int value)
 
void setLogUsedScans (bool value)
 
void setMirror (bool value)
 
void setVarStructure (UVarPool *varStruct)
 
void setVerbose (bool value)
 
bool start ()
 
void stop (bool justClosePort)
 
void threadRunLoop ()
 
 ULaserDevice ()
 
virtual ~ULaserDevice ()
 
- Public Member Functions inherited from UServerPush
int addPushCommand (UServerInMsg *msg)
 
bool doPushCall (UServerPushElement *pe, const char *value)
 
void flushClientCmds (int clientIdx)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
bool gotCmdExe ()
 
void gotNewData (void *pData)
 
bool isUpdated (int lastCnt, int *newCnt)
 
bool needNewData ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
void servicePendingPushCmds ()
 
void setCmdExe (UServerPushImplement *executor)
 
void setImplementor (UServerPushImplement *executor)
 
bool setResource (UResBase *resource, bool remove)
 
bool setUpdated (const char *value)
 Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More...
 
 UServerPush ()
 
virtual ~UServerPush ()
 
- Public Member Functions inherited from UClientHandler
unsigned long addDataTrap (const char *key, EVENT_CALL onEvent, void *object)
 
bool addFunction (UClientFuncBase *functionHandler, bool remove=false)
 
void closeConnection ()
 
virtual void connectionChange (bool nowConnected)
 
void delDataTrap (unsigned long serial)
 
bool getNamespaceUse ()
 
const char * getServerNamespaceName ()
 
double getServerToLocalTime ()
 
bool isServerToLocalTimeValid ()
 
bool isThreadRunning ()
 
bool openConnection ()
 
void print (const char *preString)
 
void sendPing ()
 
void setHost (const char *host)
 
void setNamespace (const char *toName, const char *attributeString)
 
void setNamespaceLost ()
 
void setNamespaceUse (bool value)
 
void setPort (const int port)
 
void setVerbose (bool value)
 
const char * snprint (const char *preString, char *buff, const int buffCnt)
 
bool start ()
 
void stop (bool andWait)
 
void threadRunLoop ()
 
 UClientHandler ()
 
virtual ~UClientHandler ()
 
- Public Member Functions inherited from UClientPortSml
virtual const char * getSourceName ()
 
 UClientPortSml ()
 
- Public Member Functions inherited from UClientPort
bool blockSend (const char *buffer, int length)
 
void closeConnection ()
 
int getDataFromLine (char *buffer, int bufferSize, int pollTimeoutMs)
 
const char * getHost ()
 
const char * getHostIP ()
 
int getPort ()
 
bool isConnected ()
 
bool isVerbose ()
 
bool sendMsg (const char *message)
 
bool sendWithLock (const char *message)
 
void setHost (const char *toHost)
 
void setPort (int toPort)
 
void setVerbose (bool value)
 
bool tryConnect ()
 
 UClientPort ()
 
virtual ~UClientPort ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 
- Public Member Functions inherited from USmlSource
void allowTagAtStartOfLineOnly ()
 
const char * getErrorBuffer ()
 
virtual int getLineNumber ()
 
virtual int getNBytes (char *buffer, int n, int msTimeout=100)
 
virtual bool getNextTag (USmlTag *tag, int msTimeout=100, USmlTagIn *failEndTag=NULL, char *beforeTagBuffer=NULL, int *beforeTagCnt=NULL)
 
char * getRxDataBuffer ()
 
int getRxDataBufferCnt ()
 
bool getToEndTag (USmlTagIn *tag, char *buffer, const int bufferSize, int msTimeout=100, USmlTagIn *lastTag=NULL)
 
bool isErrorText ()
 
bool isVerbose ()
 
void setErrorBuffer (char *buf, const int bufCnt)
 
virtual void setLineNumber (int)
 
int setRxDataBufferCnt (int newMaxLength)
 
virtual bool skipNBytes (int n, int msTimeout=100)
 
virtual bool skipToEndTag (USmlTagIn *tag, int msTimeout=100)
 
virtual void syntaxError (const char *message)
 
 USmlSource ()
 
virtual ~USmlSource ()
 

Protected Member Functions

virtual void closePort ()
 
virtual const char * getNameFromDevice ()
 
virtual bool openPort ()
 
virtual bool receiveData ()
 
virtual bool sendToDevice (const char *msg, int lng)
 
virtual void setCore (UCmdExe *pCore)
 
- Protected Member Functions inherited from ULaserDevice
virtual double getDefaultDelay ()
 
void getFakeScan (ULaserData *dest, unsigned long lastSerial, int fake, double fakeDt=0.2)
 
void updateScanData (UTime scanTime)
 
- Protected Member Functions inherited from UClientHandler
virtual void interfaceAlive ()
 
virtual void interfaceAliveTag (USmlTag *)
 
virtual void interfaceTick ()
 
void sendNamespaceCloseTag ()
 
virtual void sendNamespaceOpenTag ()
 
- Protected Member Functions inherited from UClientPortSml
virtual bool doVerboseMessages ()
 
virtual int getMoreData (char *buffer, int bufferSize, int pollTimeoutMs)
 
virtual bool isSourceAvailable ()
 
virtual bool outputData (const char *message)
 
- Protected Member Functions inherited from USmlSource
void clearRxBuffer ()
 

Protected Attributes

UCmdExecore
 server core pointer More...
 
UTime dataTime
 
bool newData
 
bool repeatGetScan
 
unsigned long rxSerial
 
ULaserDatascan
 
UClientFuncSimScanscanf
 
ULogFile sourceLogFile
 potential logfile More...
 
- Protected Attributes inherited from ULaserDevice
double angleResolution
 
ULogFile datalog
 
int datalogSeq
 
bool datalogUsedScans
 
int deviceNum
 
char devName [MAX_DEVICE_NAME_LNG]
 
UTime lastScanTime
 
int loopCnt
 
double maxValidRange
 
bool mirrorData
 
int modeAngleScan
 
char name [MAX_NAME_LNG]
 
ULaserDatapushData
 
bool replayOrFake
 
bool sendNewData
 
char sendStr [MAX_SEND_MSG_LNG]
 
int sendStrCnt
 
unsigned long serial
 
unsigned int statBadCnt
 
unsigned int statGoodCnt
 
double statMsgRate
 
pthread_t threadHandle
 
bool threadRunning
 
bool threadStop
 
struct {
   UVariable *   framerate
 
   UVariable *   logData
 
   UVariable *   logDataInterval
 
   UVariable *   logSource
 
   UVariable *   maxRange
 
   UVariable *   name
 
   UVariable *   open
 
   UVariable *   pose
 
   UVariable *   scanDelay
 
   UVariable *   scanres
 
   UVariable *   scanwidth
 
   UVariable *   serial
 
   UVariable *   type
 
   UVariable *   versionInfo
 
var
 
UVarPoolvars
 
bool verbose
 
- Protected Attributes inherited from UClientHandler
bool binData
 is all data binary More...
 
char binTagName [MAX_BIN_NAME_LENGTH+1]
 
char namespaceAttributes [MAX_NORMAL_MESSAGE_LENGTH]
 
char namespaceName [MAX_SML_NAME_LENGTH]
 
bool namespaceUse
 
int notConnectedLoop
 
int rxTimeoutMs
 rx timeout value in ms More...
 
int serverNamespaceLevel
 
char serverNamespaceName [MAX_SML_NAME_LENGTH]
 
bool tryReConnect
 
- Protected Attributes inherited from UClientPort
enum UClientPort:: { ... }  connectionLostReason
 
UTime connectTime
 
char host [MAX_HOST_LENGTH]
 
char hostIP [MAX_HOST_LENGTH]
 
int port
 
unsigned int readCnt
 
bool verboseMessages
 
- Protected Attributes inherited from USmlSource
int dataCnt
 
char * errorBuffer
 
int errorBufferCnt
 
bool gotFirstTag
 
bool tagStartAtStartOfLineOnly
 

Additional Inherited Members

- Public Attributes inherited from UClientHandler
bool showInfo
 
bool showWarnings
 
bool tryHoldConnection
 
- Public Attributes inherited from UClientPort
int rxByteCnt
 
ULock tx
 
- Public Attributes inherited from USmlSource
const char * ifName
 
- Static Public Attributes inherited from UClientHandler
static const int MAX_DATA_TRAPS = 100
 
- Protected Types inherited from UClientPort
enum  { notLost, forReopen, rxError, txError }
 
- Static Protected Attributes inherited from UClientHandler
static const int MAX_BIN_NAME_LENGTH = 30
 binary tag name More...
 

Detailed Description

Class to connect to a simulated laserscanner

Author
Christian Andersen

Constructor & Destructor Documentation

ULaserSim::ULaserSim ( )
ULaserSim::~ULaserSim ( )

Destructor

References scan, and scanf.

Member Function Documentation

bool ULaserSim::changeMode ( int  scanangle,
double  resolution 
)
virtual

Change scanner resolution mode. (modeAngleScan and angleResolution) Returns true if new resolution is implemented. If not open, then values are just saved

Reimplemented from ULaserDevice.

References ULaserDevice::angleResolution, ULaserDevice::getDeviceName(), and ULaserDevice::modeAngleScan.

Referenced by isPortOpen().

void ULaserSim::closePort ( )
protectedvirtual
const char * ULaserSim::getNameFromDevice ( )
protectedvirtual

Get name of device

Reimplemented from ULaserDevice.

Referenced by isPortOpen().

bool ULaserSim::getNewestData ( ULaserData dest,
unsigned long  lastSerial,
int  fake 
)
virtual
virtual bool ULaserSim::isPortOpen ( )
inlinevirtual
bool ULaserSim::logSourceData ( const char *  data,
int  dataCnt 
)
virtual

is called when new data is fetched. gives the possibility to log all received data.

Parameters
datais the string received - NULL teminated, but data may hold binary 0 too!
dataCntis length of data
Returns
true if data is logged (or should return true)

Reimplemented from USmlSource.

References ULogFile::closeLog(), USmlSource::data, ULogFile::getF(), ULogFile::isOpen(), ULogFile::openLog(), sourceLogFile, and ULaserDevice::var.

Referenced by isPortOpen().

bool ULaserSim::openPort ( )
protectedvirtual
bool ULaserSim::receiveData ( )
protectedvirtual

Receive data from device – called from device loop, should return as fast as possible after dooing the job, i.e. no blocking read. Should add number of good and bad blocks of data to statBadCnt and statGootcnt. Returns true if data received.

Reimplemented from ULaserDevice.

References dataTime, ULaserDevice::deviceNum, ULaserData::getSerial(), UTime::getTimePassed(), ULaserDevice::gotNewScan(), UClientPort::isConnected(), ULaserDevice::mirrorData, newData, UTime::Now(), rxSerial, scan, sendToDevice(), ULaserData::setDeviceNum(), ULaserData::setMaxValidRange(), ULaserData::setMirror(), ULaserData::setValid(), ULaserDevice::var, and Wait().

Referenced by isPortOpen().

bool ULaserSim::sendToDevice ( const char *  msg,
int  lng 
)
protectedvirtual

Send data to device. Sends 'lng' bytes from 'msg'. Data must be a zero-terminated string.

Reimplemented from ULaserDevice.

References UClientPort::blockSend(), and mini().

Referenced by isPortOpen(), and receiveData().

virtual void ULaserSim::setCore ( UCmdExe pCore)
inlineprotectedvirtual

set server core pointer - just a debug feature - I think)

Reimplemented from ULaserDevice.

Member Data Documentation

UCmdExe* ULaserSim::core
protected

server core pointer

Referenced by ULaserSim().

UTime ULaserSim::dataTime
protected

Time of last received data

Referenced by receiveData(), and ULaserSim().

bool ULaserSim::newData
protected

New data received

Referenced by receiveData(), and ULaserSim().

bool ULaserSim::repeatGetScan
protected

Automatic repeat get scan

Referenced by getNewestData(), and ULaserSim().

unsigned long ULaserSim::rxSerial
protected

Last received serial from simulator

Referenced by receiveData(), and ULaserSim().

ULaserData* ULaserSim::scan
protected

latest data received from device

Referenced by getNewestData(), receiveData(), ULaserSim(), and ~ULaserSim().

UClientFuncSimScan* ULaserSim::scanf
protected

Client data decoder for simulated laser scanner connection

Referenced by ULaserSim(), and ~ULaserSim().

ULogFile ULaserSim::sourceLogFile
protected

potential logfile

Referenced by logSourceData(), and ULaserSim().


The documentation for this class was generated from the following files: