AURobotServers  4
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
UFuncPiCam Class Reference

#include <ufuncpicam.h>

Inheritance diagram for UFuncPiCam:
Inheritance graph

Public Member Functions

virtual void callGotNewDataWithObject ()
 
virtual void createResources ()
 
virtual bool handleCommand (UServerInMsg *msg, void *extra)
 
virtual bool methodCall (const char *name, const char *paramOrder, char **strings, const double *pars, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
virtual bool methodCallV (const char *name, const char *paramOrder, UVariable *params[], UDataBase **returnStruct, int *returnStructCnt)
 
void run ()
 
void runAlive ()
 
 UFuncPiCam ()
 
 ~UFuncPiCam ()
 
- Public Member Functions inherited from UFuncPlugBasePush
virtual bool setResource (UResBase *resource, bool remove)
 
 UFuncPlugBasePush ()
 
virtual ~UFuncPlugBasePush ()
 
- Public Member Functions inherited from UFunctionBase
bool addResource (UResBase *resource, UFunctionBase *owner)
 
void closeLogfile ()
 
virtual const char * commandList ()
 
const char * getAliasName ()
 
const char * getLoadedFileName ()
 
void * getLoadedModuleRef ()
 
virtual bool gotAllResources (char *missingThese, int missingTheseCnt)
 
bool isMine (const char *cmdName)
 
bool isStatic ()
 is the module loaded as static A module is static if the ldFilename has a length of zero. More...
 
virtual const char * name ()
 
bool newCmd (UServerInMsg *newMsg, UDataBase *extra)
 
bool newCommand (UServerInMsg *newMsg, void *extra)
 
bool openLogfile (const char *name)
 
void print (const char *preString)
 
virtual void resourceUpdated ()
 
bool sendEndTag (UServerInMsg *msg)
 
bool sendEndTag ()
 
bool sendFullTag (const char *attributes)
 
bool sendHelpDone (UServerInMsg *msg)
 
bool sendHelpDone ()
 
bool sendHelpStart (UServerInMsg *msg, const char *subject)
 
bool sendHelpStart (const char *subject)
 
bool sendHelpStart ()
 
bool sendMsg (UServerInMsg *msg, const char *message, int size)
 
bool sendMsg (const char *message)
 
bool sendMsg (UServerInMsg *msg, const char *message)
 
bool sendMsg (int clientIdx, const char *message, int size)
 
bool sendMsgInt (int clientIdx, const char *message)
 
bool sendStartTag (const char *attributes)
 
bool sendText (UServerInMsg *msg, const char *text)
 
bool sendText (const char *text)
 
virtual void setAliasName (const char *name)
 
virtual void setCommand (const char *cmdList, const char *name, const char *note)
 
void setLoadedModuleRef (void *module, const char *moduleFileName)
 
virtual void setLoadTime (UTime)
 
void setName (const char *name)
 
void setVerbose (bool value)
 
 UFunctionBase ()
 
virtual ~UFunctionBase ()
 
- Public Member Functions inherited from UCallBack
bool addOnEvent (UOnEvent *dataObject)
 
virtual bool onEvent (const char *interface, const char *dataType, void *data)
 
 UCallBack ()
 
virtual ~UCallBack ()
 
- Public Member Functions inherited from UResVarPool
int addMethod (const char *formalName, const char *paramTypes, const char *comment)
 
int addMethodV (const char *formalName, const char *paramTypes, const char *comment)
 
UVarPooladdStruct (const char *name, const char *comment, bool copy=false)
 
UVariableaddVar (const char *name, const double initialValue, const char *type, const char *comment)
 
UVariableaddVar (const char *name, const char *initialValue, const char *type, const char *comment)
 
UVariableaddVarA (const char *name, const char *initialValue, const char *type, const char *comment)
 
bool callGlobal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callGlobalV (const char *name, const char *paramOrder, UVariable **params, UDataBase **returnStruct, int *returnStructCnt)
 Call a method from the root var pool scope It may be in the structure direct (no '.') or in any sub-structure that the 'name.subname' indicate. More...
 
bool callLocal (const char *name, const char *paramOrder, char **strings, const double *doubles, double *value, UDataBase **returnStruct, int *returnStructCnt)
 
bool callVS (const char *function, const char *stringParam)
 
int callVSCD (const char *function, const char *strPar, UDataBase *data, int cooSys)
 
void createBaseVar ()
 
virtual bool createVarSpace (const int varCnt, const int structCnt, const int methCnt, const char *note, bool copy=false)
 
bool getGlobalString (const char *name, const char **value)
 
bool getGlobalValue (const char *name, double *value)
 
bool getGlobalValue (const char *name, const char **value)
 
bool getGlobalValue (const char *name, bool *value)
 
bool getGlobalValue (const char *name, UTime *value)
 
bool getLocalValue (const char *name, double *value)
 get a value in this variable tree More...
 
bool getLocalValue (const char *name, bool *value)
 
bool getLocalValue (const char *name, UTime *value)
 
double getLocalValue (int idx)
 
UPosition getLocalValue3D (int idx)
 
UPosRot getLocalValue6D (int idx)
 
bool getLocalValueBool (int idx)
 
int getLocalValueInt (int idx)
 
UTime getLocalValueTime (int idx)
 
const char * getLogFileName ()
 
const char * getVarDescription (int idx)
 
UVarCalcgetVarPool ()
 
bool isLogFileOpen ()
 
bool isLogFileOpen (const char *structName)
 
bool isVarPoolUpdated (int lastCnt, int *newCnt)
 
void logFileClose ()
 
bool logFileOpen ()
 
void logFileStart (const char *structName, bool open)
 
virtual const char * print (const char *preString, char *buff, int buffCnt)
 
bool setGlobalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar (int idx, double value, const int element)
 
bool setLocalVar (const char *name, const double value, bool mayAdd)
 Assigns a value to a variable. The variable may be a part of a structure. More...
 
bool setLocalVar3D (int idx, UPosition *value)
 
bool setLocalVar6D (int idx, UPosRot *value)
 
bool setLocalVarAdd (int idx, double value, const int element)
 
bool setLocalVarPose (int idx, UPose *value)
 
void setVarPool (UVarCalc *sharedVarPool)
 
int updateQTvars (int structIdx)
 
 UResVarPool ()
 
virtual ~UResVarPool ()
 
- Public Member Functions inherited from UResBase
void createReplayVar (UVarPool *pool)
 
UCmdExegetCorePointer ()
 
char * getLogFileName (char *fn, const int fnCnt)
 
int getResFuncIdx ()
 
const char * getResID ()
 
int getResVersion ()
 
bool isA (const char *idStr)
 
bool isAlsoA (const char *id)
 
virtual void saveSettings ()
 
void setCorePointer (UCmdExe *serverCore)
 
void setResFuncIdx (int idx)
 
virtual void setResID (const char *id, const int version)
 
virtual void updateReplayStatus ()
 
 UResBase ()
 
virtual ~UResBase ()
 
- Public Member Functions inherited from UReplay
void addChild (UReplay *child)
 
virtual bool decodeReplayLine (char *)
 
char * getLogFileName (char *fn, const int fnCnt)
 
char * getReplayFileName (char *fn, const int fnCnt)
 
int getReplayLogLine ()
 
bool isReplay ()
 
bool isReplayFileOpen ()
 
void removeChild (UReplay *child)
 
virtual void replayAdvanceTime (UTime untilTime)
 
void replaySetBaseFileName (const char *name, const char *preName="")
 
void replaySetFileName (const char *name)
 
virtual bool replayStep ()
 
int replayStep (int steps)
 
virtual bool replayToTime (UTime untilTime)
 
void setParent (UReplay *parent)
 
bool setReplay (bool value)
 
 UReplay ()
 
virtual ~UReplay ()
 
- 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 UVarMethodImplement
virtual ~UVarMethodImplement ()
 
- 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 ()
 

Private Member Functions

bool handleNormal (UServerInMsg *msg)
 
void init ()
 
void logFileTest ()
 
bool logImageToFile (UImage *imgToLog)
 
bool openCam ()
 
bool start ()
 start read thread More...
 
void stop (bool andWait)
 

Private Attributes

const char * aliasname
 
pthread_t aliveThreadHandle
 
bool aliveThreadRunning
 alive thread runnung flag More...
 
bool aliveThreadStop
 alive stop thread flag More...
 
int frameCntRgb
 number of accepted video frames (rgb or ir) More...
 
int frameLogCnt
 frame count for logging More...
 
UTime frameRateDepthTime
 variable for frame rate calculation More...
 
UTime frameRateRgbTime
 variable for frame rate calculation More...
 
UImageimgCbuf
 image buffer for color in 3d cloud More...
 
UTime lastLoopTime
 
ULLogFile logf
 
UImageLog logImage
 
UImagelogVideoImage
 pointer to video (color or IR) image to log More...
 
USemaphore newImg [PYRAMID_LEVELS_MAX]
 semaphore to indicate new image is available More...
 
int oldCamDevC
 
int oldCamDevD
 
int oldFocalLength
 last used focal length for rectified image More...
 
int oldLed
 
double oldTilt
 
ULock paramLock
 lock for parameters More...
 
CCamerapicam
 PI camera class. More...
 
pthread_t threadHandle
 
bool threadRunning
 thread runnung flag More...
 
bool threadStop
 stop thread flag More...
 
UVariablevarCamDeviceNum
 
UVariablevarExposureMeter
 
UVariablevarExposureMode
 
UVariablevarFramerate
 
UVariablevarGain
 
UVariablevarImageLogN
 
UVariablevarIsOpen
 
UVariablevarPyramidLevels
 
UVariablevarResolution
 
UVariablevarShutter
 
UVariablevarSilent
 
UVariablevarTime
 
UVariablevarUpdateCnt
 
UVariablevarWhiteBal
 
char whyString [MWL]
 

Static Private Attributes

static const int MWL = 100
 
static const int PYRAMID_LEVELS_MAX = 10
 

Additional Inherited Members

- Static Public Member Functions inherited from UResVarPool
static const char * getResClassID ()
 
- Public Attributes inherited from UFunctionBase
bool silent
 is reply to client and console to be limited More...
 
- Public Attributes inherited from UReplay
bool replayTimeAdvancePending
 
UTime replayTimeNow
 
- Static Public Attributes inherited from UFunctionBase
static const int MAX_ID_LENGTH = 30
 
static const int MAX_RESOURCE_LIST_SIZE = 250
 
- Protected Member Functions inherited from UFuncPlugBasePush
bool handlePush (UServerInMsg *msg)
 
- Protected Member Functions inherited from UFunctionBase
int getCmdIndex ()
 
UResBasegetStaticResource (const char *resName, bool mayCreate, bool staticOnly=true)
 get a pointer to a static resource. More...
 
bool isClientAlive (int clientIdx, double holdOffTime)
 
bool sendDebug (UServerInMsg *msg, const char *debugText)
 
bool sendDebug (const char *debugText)
 
bool sendError (UServerInMsg *msg, const char *errorText)
 
bool sendError (const char *errorText)
 
bool sendHelp (UServerInMsg *msg, const char *infoText)
 
bool sendHelp (const char *infoText)
 
bool sendInfo (UServerInMsg *msg, const char *infoText)
 
bool sendInfo (const char *infoText)
 
bool sendWarning (UServerInMsg *msg, const char *warningText)
 
bool sendWarning (const char *warningText)
 
UResBasesetThisResource (const char *ID, UResBase *resource, bool remove, bool *changed, UResBase *currentResPtr, bool *isLocal)
 
- Protected Member Functions inherited from UResVarPool
void setDescription (const char *note, bool copy=false)
 
- Protected Member Functions inherited from UResBase
UResBasegetStaticResource (const char *resName, bool mayCreate, bool staticOnly=true)
 get a pointer to a static resource. More...
 
- Protected Attributes inherited from UFunctionBase
char aliasName [MAX_ID_LENGTH]
 
UCmdExecmdHandler
 
char * cmdToks [20]
 
int cmdToksCnt
 
char commandsHandled [MAX_RESOURCE_LIST_SIZE]
 
UServerInMsgmsg
 
char pluginName [MAX_RESOURCE_LIST_SIZE]
 
bool verboseMessages
 
- Protected Attributes inherited from UResBase
int resFuncIdx
 
char resID [MAX_RESOURCE_ID_LENGTH]
 
char resIsAlso [MAX_RESOURCE_ISALSO_LENGTH]
 
int resVersion
 
- Protected Attributes inherited from UReplay
bool replay
 
FILE * replayFile
 
char replayFileName [REPLAY_FILE_NAME_LENGTH]
 replay filename More...
 
char replayLine [MAX_LOG_LINE_LENGTH]
 
int replayLogLine
 
UReplayreplayParent
 
UTime replayTimeNext
 
- Static Protected Attributes inherited from UReplay
static const int MAX_LOG_LINE_LENGTH = 10000
 
static const int REPLAY_FILE_NAME_LENGTH = 264
 max length of replay filename More...
 

Detailed Description

This is functions to handle camera issues

Constructor & Destructor Documentation

UFuncPiCam::UFuncPiCam ( )
inline
UFuncPiCam::~UFuncPiCam ( )

Destructor

References ULogFile::closeLog(), UImageLog::closeLogging(), imgCbuf, logf, logImage, and stop().

Referenced by UFuncPiCam().

Member Function Documentation

void UFuncPiCam::callGotNewDataWithObject ( )
virtual

Called from push implementor to get the push object. should call to 'gotNewData(object)' with the available event object. if no object is available (anymore), then call with a NULL pointer.

Reimplemented from UServerPush.

References data, UFunctionBase::getAliasName(), and UServerPush::gotNewData().

Referenced by UFuncPiCam().

void UFuncPiCam::createResources ( )
virtual

Called by server after this module is integrated into the server core structure, i.e. all core services are in place, but no commands are serviced for this module yet. Create any resources that this modules needs.

Reimplemented from UFunctionBase.

References UResVarPool::addVar(), UResVarPool::addVarA(), aliasname, UFunctionBase::getAliasName(), logf, logImage, UReplay::replaySetBaseFileName(), ULogFile::setLogName(), start(), varCamDeviceNum, varExposureMeter, varExposureMode, varFramerate, varGain, varImageLogN, varIsOpen, varPyramidLevels, varResolution, varShutter, varSilent, varTime, varUpdateCnt, and varWhiteBal.

Referenced by UFuncPiCam().

bool UFuncPiCam::handleCommand ( UServerInMsg msg,
void *  extra 
)
virtual

Handle incomming commands flagged for this module

Parameters
msgpointer to the message and the client issuing the command
Returns
true if the function is handled - otherwise the client will get a 'failed' reply

Reimplemented from UFunctionBase.

References UFunctionBase::getCmdIndex(), handleNormal(), UFuncPlugBasePush::handlePush(), and UFunctionBase::sendDebug().

Referenced by UFuncPiCam().

bool UFuncPiCam::handleNormal ( UServerInMsg msg)
private
void UFuncPiCam::init ( )
private

Decode this replay line, that is assumed to be valid - has got a time stamp.

Parameters
lineis a pointer to the line.
Returns
true if the line is valid and used (step is successful).
false if line is not a valid step. is called when it is time to update replay status (after a step in some replay file) Initialize other variables

References frameCntRgb, imgCbuf, logImage, logVideoImage, oldCamDevC, oldCamDevD, oldFocalLength, oldLed, UImageLog::setPng(), threadRunning, and threadStop.

Referenced by UFuncPiCam().

void UFuncPiCam::logFileTest ( )
private

Test for open or close logfiles using global variable

References UVariable::getInt(), ULogFile::getLogFileName(), ULogFile::isOpen(), logf, logImage, UImageLog::openLog(), UVariable::setValued(), ULogFile::toLog(), and varImageLogN.

Referenced by run(), and UFuncPiCam().

bool UFuncPiCam::logImageToFile ( UImage imgToLog)
private

Save image to imagelog and save the image itself in the imagePath. if camera device do not exist, then a default device is created..

Parameters
imgToLogis the image to be logged.

References UImage::camDevice, UCamPool::getCam(), UVariable::getInt(), UFunctionBase::getStaticResource(), UImageLog::logImage(), logImage, UCamPool::makeDevice(), ULock::tryLock(), ULock::unlock(), and varImageLogN.

Referenced by run(), and UFuncPiCam().

bool UFuncPiCam::methodCall ( const char *  name,
const char *  paramOrder,
char **  strings,
const double *  pars,
double *  value,
UDataBase **  returnStruct,
int *  returnStructCnt 
)
virtual

Function to implement a var-pool method call.

Parameters
nameis the name of the called function
paramOrderis a string with one char for each parameter in the call - d is double, s is string, c is class object.
stringsis an array of string pointers for the string type parameters (may be NULL if not used)
doublesis an array with double typed parameters (may be NULL if not used)
valueis the (direct) result of the class, either a double value, or 0.0 for false 1.0 for true 2.0 for implicit stop if a controll call.
returnStructis an array of class object pointers that can be used as parameters or return objects (may be NULL)
returnStructCntis the number of objects in the returnStruct buffer
Returns
true if the method is recognised (exists), when false is returned a invalid name or parameter list is detected.

Reimplemented from UResVarPool.

Referenced by UFuncPiCam().

bool UFuncPiCam::methodCallV ( const char *  name,
const char *  paramOrder,
UVariable params[],
UDataBase **  returnStruct,
int *  returnStructCnt 
)
virtual

Function to implement an inter plug-in method call using UVariables as parameter (and return value). Structures of the base type UDatabase (but not UVariables) may be returned in the returnStruct pointer array. The returnStructCnt should be set to returned count, if values are returned.

Parameters
nameis the name of the called function
paramOrderis a string with one char for each parameter in the call - d is double, s is string, c is class object.
paramsis an array of UVariable pointers, one pointer for each character in paramOrder. NB! params are not declared as constant, and may be used to return values.
returnStructis an array of class object pointers that can be used as parameters or return objects (may be NULL)
returnStructCntis the number of objects in the returnStruct buffer
Returns
true if the method is recognised (exists), when false is returned a invalid name or parameter list is detected.

Reimplemented from UVarMethodImplement.

Referenced by UFuncPiCam().

bool UFuncPiCam::openCam ( )
private

Open camera

Referenced by UFuncPiCam().

void UFuncPiCam::run ( )
void UFuncPiCam::runAlive ( )
bool UFuncPiCam::start ( )
private
void UFuncPiCam::stop ( bool  andWait)
privatevirtual

stop read thread

Parameters
andWaitwaits until thread is terminated, when false, then the call returns when the stop flag is set (i.e. immidiately).

Reimplemented from UResBase.

References aliveThreadHandle, aliveThreadRunning, aliveThreadStop, threadHandle, threadRunning, and threadStop.

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

Member Data Documentation

const char* UFuncPiCam::aliasname
private

Referenced by createResources().

pthread_t UFuncPiCam::aliveThreadHandle
private

alive Thread handle for frame read thread.

Referenced by start(), and stop().

bool UFuncPiCam::aliveThreadRunning
private

alive thread runnung flag

Referenced by runAlive(), start(), and stop().

bool UFuncPiCam::aliveThreadStop
private

alive stop thread flag

Referenced by runAlive(), start(), and stop().

int UFuncPiCam::frameCntRgb
private

number of accepted video frames (rgb or ir)

Referenced by init().

int UFuncPiCam::frameLogCnt
private

frame count for logging

UTime UFuncPiCam::frameRateDepthTime
private

variable for frame rate calculation

UTime UFuncPiCam::frameRateRgbTime
private

variable for frame rate calculation

UImage* UFuncPiCam::imgCbuf
private

image buffer for color in 3d cloud

Referenced by init(), and ~UFuncPiCam().

UTime UFuncPiCam::lastLoopTime
private

Kinect loop keep-alive time

Referenced by handleNormal(), and run().

ULLogFile UFuncPiCam::logf
private

General Logfile

Referenced by createResources(), handleNormal(), logFileTest(), and ~UFuncPiCam().

UImageLog UFuncPiCam::logImage
private
UImage* UFuncPiCam::logVideoImage
private

pointer to video (color or IR) image to log

Referenced by init().

const int UFuncPiCam::MWL = 100
staticprivate
USemaphore UFuncPiCam::newImg[PYRAMID_LEVELS_MAX]
private

semaphore to indicate new image is available

Referenced by run(), and runAlive().

int UFuncPiCam::oldCamDevC
private

Referenced by init(), and run().

int UFuncPiCam::oldCamDevD
private

Referenced by init(), and run().

int UFuncPiCam::oldFocalLength
private

last used focal length for rectified image

Referenced by init().

int UFuncPiCam::oldLed
private

Referenced by init().

double UFuncPiCam::oldTilt
private
ULock UFuncPiCam::paramLock
private

lock for parameters

Referenced by run(), and runAlive().

CCamera* UFuncPiCam::picam
private

PI camera class.

Referenced by run(), and runAlive().

const int UFuncPiCam::PYRAMID_LEVELS_MAX = 10
staticprivate

Referenced by run(), and runAlive().

pthread_t UFuncPiCam::threadHandle
private

Thread handle for frame read thread.

Referenced by start(), and stop().

bool UFuncPiCam::threadRunning
private

thread runnung flag

Referenced by init(), run(), start(), and stop().

bool UFuncPiCam::threadStop
private

stop thread flag

Referenced by init(), run(), start(), and stop().

UVariable* UFuncPiCam::varCamDeviceNum
private

Referenced by createResources(), and run().

UVariable* UFuncPiCam::varExposureMeter
private

Referenced by createResources(), and runAlive().

UVariable* UFuncPiCam::varExposureMode
private

Referenced by createResources(), and runAlive().

UVariable* UFuncPiCam::varFramerate
private

Referenced by createResources(), and run().

UVariable* UFuncPiCam::varGain
private

Referenced by createResources(), and runAlive().

UVariable* UFuncPiCam::varImageLogN
private
UVariable* UFuncPiCam::varIsOpen
private

Referenced by createResources(), handleNormal(), and run().

UVariable* UFuncPiCam::varPyramidLevels
private

Referenced by createResources(), run(), and runAlive().

UVariable* UFuncPiCam::varResolution
private

Referenced by createResources(), and run().

UVariable* UFuncPiCam::varShutter
private

Referenced by createResources(), and runAlive().

UVariable* UFuncPiCam::varSilent
private

processing parameters

Referenced by createResources(), handleNormal(), and run().

UVariable* UFuncPiCam::varTime
private

Referenced by createResources(), and run().

UVariable* UFuncPiCam::varUpdateCnt
private

Pointers to "own" global variables.

Referenced by createResources().

UVariable* UFuncPiCam::varWhiteBal
private

Referenced by createResources(), and runAlive().

char UFuncPiCam::whyString[MWL]
private

Short explanation to why processing failed


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