Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdLog Class Reference

Log command. More...

Inheritance diagram for DynaShellCmdLog:
DynaShellCmd

Public Member Functions

void Exec (DynaShell &shell, int argc, char *argv[])
 Set diagnotics logging level. More...
 
virtual char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Command tab completion generator. More...
 
- Public Member Functions inherited from DynaShellCmd
 DynaShellCmd (int nArgCntMin=0, int nArgCntMax=0)
 Default constructor.
 
virtual ~DynaShellCmd ()
 Default destructor.
 
const char * GetCmdName ()
 Get dynamixel shell command name. More...
 
const char * GetCmdHelpBrief ()
 Get shell command name brief description. More...
 
virtual void PrintHelp (int indent=0, int width=80)
 Print command help with the description aligned at the given indentation. More...
 
int GetPublishedLevel () const
 
const char * GetPublishedName () const
 
int SetPublishedInfo (int nLevel, const char *sParent=NULL)
 
virtual bool ChkArgCnt (DynaShell &shell, int argc)
 Check that the argument count is within the class (min,max). More...
 
bool ChkArgCnt0 (DynaShell &shell, int argc)
 Check that the argument count is zero. More...
 
bool ChkArgCntEQ (DynaShell &shell, int argc, int eq)
 Check that the argument count is equal to the required. More...
 
bool ChkArgCntGE (DynaShell &shell, int argc, int min)
 Check argument count against minimum required. More...
 
bool ChkArgCntLE (DynaShell &shell, int argc, int max)
 Check argument count against maximum allowed. More...
 
bool ChkComm (DynaShell &shell)
 Check that Dynamixel communication exists and is open. More...
 
bool ChkChain (DynaShell &shell)
 Check that the servo chain exists. More...
 
bool ChkChainNotEmpty (DynaShell &shell)
 Check that the servo chain exists and is not empty. More...
 
bool ChkChainHasServo (DynaShell &shell, int nServoId)
 Check that the given servo is present in the chain. More...
 
bool ChkChainIsMasterServo (DynaShell &shell, int nServoId)
 Check that the given servo is a master. More...
 
bool ToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument to integer. More...
 
bool ToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument to unsigned integer. More...
 
bool ToDouble (DynaShell &shell, const char *sArg, double *pVal)
 Convert command argument to double. More...
 
bool ToBool (DynaShell &shell, const char *sArg, bool *pVal)
 Convert command argument to boolean. More...
 

Protected Attributes

int m_nTabIndex
 tab completion: keyword index
 
- Protected Attributes inherited from DynaShellCmd
const char * m_sCmdName
 command name
 
const char * m_sCmdHelpBrief
 command help brief
 
const char * m_sCmdHelpArgs
 command help arguments
 
const char * m_sCmdHelpDesc
 command help description
 
const int m_nArgCntMin
 minimum argument count
 
const int m_nArgCntMax
 maximum argument count (0 if not max)
 
int m_nPubLevel
 command's published level (depth)
 
char * m_sPubName
 command's published name
 

Additional Inherited Members

- Protected Member Functions inherited from DynaShellCmd
virtual void PrintSynopses (int indent, int width)
 Print synsopses. More...
 
virtual void PrintBlock (int col, int indent, int width, const char *sText)
 Print a block of indented text of width. More...
 
virtual void PrintDelim (int width, const char cDelim)
 
char * eow (const char *s)
 Find end of word. More...
 

Detailed Description

Log command.

Definition at line 437 of file dynashell_cmd_core.cxx.

Member Function Documentation

void DynaShellCmdLog::Exec ( DynaShell shell,
int  argc,
char *  argv[] 
)
inlinevirtual

Set diagnotics logging level.

Parameters
shellDynamixel shell.
argcCommand argument count.
argvArray of arguments.

Implements DynaShellCmd.

Definition at line 460 of file dynashell_cmd_core.cxx.

References TRY.

461  {
462  int nLevel;
463 
464  TRY( ChkArgCnt(shell, argc) );
465 
466  if( !strcmp(argv[0], "off") )
467  {
468  nLevel = 0;
469  }
470  else if( !strcmp(argv[0], "error") )
471  {
472  nLevel = 1;
473  }
474  else if( !strncmp(argv[0], "diag", 3) )
475  {
476  TRY( ToInt(shell, argv[0]+4, &nLevel) );
477  nLevel++;
478  }
479  else
480  {
481  TRY( ToInt(shell, argv[0], &nLevel) );
482  }
483 
484  LOG_SET_THRESHOLD(nLevel);
485  }
bool ToInt(DynaShell &shell, const char *sArg, int *pVal)
Convert command argument to integer.
virtual bool ChkArgCnt(DynaShell &shell, int argc)
Check that the argument count is within the class (min,max).
#define TRY(boolexpr,...)
Try boolean expression.
Definition: dynashell_cmd.h:89
virtual char* DynaShellCmdLog::TabCompletion ( DynaShell shell,
const char *  sText,
size_t  uTextLen,
int  nState,
const char *  sContext 
)
inlinevirtual

Command tab completion generator.

Completes <log_level>

Parameters
shellDynamixel shell.
sTextPartial text string to complete.
uTextLenLength of text.
nStateGenerator state. If FIRST, then initialize any statics.
sContextGenerator context (i.e. canonical command path).
Returns
If a first/next match is made, return allocated completed match.
Otherwise return NULL.

Reimplemented from DynaShellCmd.

Definition at line 502 of file dynashell_cmd_core.cxx.

References ReadLine::dupstr(), ReadLine::FIRST, and ReadLine::wc().

507  {
508  // log level symbolic names table.
509  static const char *logLevelSymTbl[] =
510  {
511  "off", "error", "diag1", "diag2", "diag3", "diag4", "diag5", "diag6"
512  };
513 
514  const char *s;
515 
516  if( (ReadLine::wc(sContext) - ReadLine::wc(m_sPubName)) != 0 )
517  {
518  return NULL;
519  }
520 
521  //
522  // New command to complete - initialize.
523  //
524  if( nState == ReadLine::FIRST )
525  {
526  m_nTabIndex = 0;
527  }
528 
529  // <log_level>
530  while( m_nTabIndex < arraysize(logLevelSymTbl) )
531  {
532  s = logLevelSymTbl[m_nTabIndex++];
533 
534  if( !strncmp(s, sText, uTextLen) )
535  {
536  return ReadLine::dupstr(s);
537  }
538  }
539 
540  // no more matches
541  return NULL;
542  }
static const int FIRST
first state
static char * dupstr(const string &str)
Duplicate string.
char * m_sPubName
command&#39;s published name
static int wc(const string &str)
Count the words in the string.
int m_nTabIndex
tab completion: keyword index

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