LRAUV  revA
CommandLine Class Reference

Provides a simple command line interface to the LRAUV. More...

#include <CommandLine.h>

Inheritance diagram for CommandLine:
Collaboration diagram for CommandLine:

Public Member Functions

 CommandLine (Supervisor &supervisor)
 
virtual ~CommandLine ()
 
void initialize ()
 Provide a space for initialization before being run. More...
 
void run ()
 The actual "payload" of the component. More...
 
void uninitialize ()
 Provide a space for uninitialization. More...
 
virtual bool isWritable ()
 indicates whether the stream can actually be written to. More...
 
virtual OutStreamwrite (const char *buffer, size_t num)
 writes num bytes from buffer to the output buffer/stream More...
 
void setChar (const char theChar)
 
void flush ()
 
FILE * getOutFile ()
 
void commandBang (ParsedCommand *parsedCommand)
 
void commandBurn (ParsedCommand *parsedCommand, BurnMode mode)
 
void commandConfigSet (ParsedCommand *parsedCommand, ConfigSetMode mode)
 
void commandConversation (ParsedCommand *parsedCommand, ConversationMode mode)
 
void commandDo (ParsedCommand *parsedCommand)
 
void commandFailComponent (ParsedCommand *parsedCommand, FailComponentMode mode)
 
void commandFailVariable (ParsedCommand *parsedCommand, FailVariableMode mode)
 
void commandGet (ParsedCommand *parsedCommand)
 
void commandGFscan (ParsedCommand *parsedCommand)
 
void commandHelp (ParsedCommand *parsedCommand)
 
void commandIbit (ParsedCommand *parsedCommand)
 
void commandIbitMcp3553 (ParsedCommand *parsedCommand)
 
void commandLoad (ParsedCommand *parsedCommand)
 
void commandMaintainAdd (ParsedCommand *parsedCommand, SyncComponent::CycleOrder cycleOrder)
 
void commandMaintainClear (ParsedCommand *parsedCommand)
 
void commandMaintainUnavailable (ParsedCommand *parsedCommand, SyncComponent::CycleOrder cycleOrder)
 
void commandMaintainInvalid (ParsedCommand *parsedCommand, SyncComponent::CycleOrder cycleOrder)
 
void commandMaintainList (ParsedCommand *parsedCommand)
 
void commandMaintainRemove (ParsedCommand *parsedCommand)
 
void commandQuick (ParsedCommand *parsedCommand, QuickMode mode)
 
void commandQuit (ParsedCommand *parsedCommand)
 
void commandReportAdd (ParsedCommand *parsedCommand, ReportAddMode mode)
 
void commandReportClear (ParsedCommand *parsedCommand)
 
void commandReportList (ParsedCommand *parsedCommand)
 
void commandReportRemove (ParsedCommand *parsedCommand)
 
void commandRestart (ParsedCommand *parsedCommand, RestartType mode)
 
void commandRestartApplication (ParsedCommand *parsedCommand)
 
void commandRestartHardware (ParsedCommand *parsedCommand)
 
void commandRestartLogs (ParsedCommand *parsedCommand)
 
void commandRestartSystem (ParsedCommand *parsedCommand)
 
void commandResume (ParsedCommand *parsedCommand)
 
void commandRetransmit (ParsedCommand *parsedCommand, RetransmitType retransmitType)
 
void commandRun (ParsedCommand *parsedCommand)
 
void commandSet (ParsedCommand *parsedCommand)
 
void commandSchedule (ParsedCommand *parsedCommand, ScheduleType scheduleType)
 
void commandSchedulePause (Syslog::Severity schedulePauseSeverity, Timestamp pauseTime)
 
void commandScheduleShowPaused ()
 
void commandScheduleResume ()
 
void commandShowBest (ParsedCommand *parsedCommand)
 
void commandShowComponent (ParsedCommand *parsedCommand)
 
void commandShowDependencies (ParsedCommand *parsedCommand)
 
void commandShowStack (ParsedCommand *parsedCommand)
 
void commandShowState (ParsedCommand *parsedCommand)
 
void commandShowVariable (ParsedCommand *parsedCommand)
 
void commandStop (ParsedCommand *parsedCommand)
 
- Public Member Functions inherited from AsyncComponent
bool isIdlePriority ()
 
- Public Member Functions inherited from Component
virtual ~Component ()
 Destructor cleans up readers_ and writers_. More...
 
void registerReader (DataReader *reader)
 
void unregisterReader (DataReader *reader)
 
void registerWriter (DataWriter *writer)
 
void unregisterWriter (DataWriter *writer)
 
void disableMetering (void)
 
FlexArray< DataReader * > & getReaderList (void)
 
FlexArray< DataWriter * > & getWriterList (void)
 
const ModulegetModule ()
 
virtual void configure ()
 Read (or re-read!) configuration settings. More...
 
virtual void execute (void)
 
bool isActive () const
 Indicates if the component is active. More...
 
const CodedStrgetName (void) const
 Returns the name. More...
 
const TimestampgetTimeOfLastRun (void) const
 
ComponentState getState (void)
 Return the component's current state. More...
 
void setState (ComponentState state)
 
RunState getRunState (void)
 Return the component's run state. More...
 
bool isUsingRunState ()
 Return true if using runState. More...
 
void requestData (bool requestingData)
 Tell the component to start (or stop) sending data. More...
 
void requestStart ()
 Tell the component to start runnning. More...
 
void requestPause (const Timespan expectedPauseTime)
 Tell the component to pause runnning. More...
 
void requestResume ()
 Tell the component resume from pause. More...
 
void requestStop ()
 Tell the component to stop runnning. More...
 
virtual RunState start ()
 Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence. More...
 
virtual RunState starting ()
 Might follow a STOP...START sequence Subseqent. More...
 
virtual RunState runnable ()
 Should eventually follow a START request or RESETTING. More...
 
virtual RunState satisfied ()
 Possible return value of a Behavior. More...
 
virtual RunState pause ()
 Pause for a short period (indicated by pauseTime) More...
 
virtual RunState pausing ()
 Might follow a PAUSE request. More...
 
virtual RunState paused ()
 Should eventually follow a PAUSE request: should set continueTime. More...
 
virtual RunState resume ()
 Resume from PAUSE. More...
 
virtual RunState resuming ()
 Might follow a PAUSE...RESUME sequence. More...
 
virtual RunState resetting ()
 Might occur in case of Error. More...
 
virtual RunState stop ()
 Initial state – can be later followed by START. More...
 
virtual RunState stopping ()
 Might follow a STOP request. More...
 
virtual RunState stopped ()
 Should eventually follow a STOP request. More...
 
void setCriticalFailureReported (bool boolVal)
 
void setRecoveringFromCritical (bool boolVal)
 
void setFailureReported (bool boolVal)
 
bool isFailureUninitialized ()
 
void setFailureUninitialized (bool boolVal)
 
void setRetryTimeout (const Timespan &timeout)
 
virtual bool isCompleted (void)
 Query if this component is completed. More...
 
void setPeriod (const Timespan &period)
 Set the period of this component... used if it is periodic. More...
 
const TimespangetPeriod (void)
 Returns the component's period (regardless of whether it is periodic) More...
 
ComponentType getComponentType ()
 Getter function for ComponentType. More...
 
virtual bool isFailed (void) const
 
virtual FailureMode::FailType getFailureType (void) const
 
virtual bool getCriticalFailureReported (void) const
 
virtual bool getFailureReported (void) const
 
virtual Timespan getRetryTimeout (void) const
 
virtual FailureMode::FailType setFailure (FailureMode::FailType failureType)
 
virtual int getFailCount (void) const
 
virtual bool isFailureMissionCritical ()
 
virtual int getAllowableFailures (void) const
 
virtual void setAllowableFailures (int fails)
 
LoggergetLogger (void)
 
virtual int incrementFailCount (void)
 
virtual void resetFailCount (void)
 
virtual int getSkippedRunsSinceFail (void) const
 
virtual int incrementSkippedRunsSinceFail (void)
 
virtual void logVoltage (float voltage, float averageVoltage)
 
virtual void logCurrent (float current, float averageCurrent)
 
const TimestampgetWriteTimestamp (void)
 
void setWriteTimestamp (const Timestamp &writeTimestamp)
 
BlobReadernewBlobReader (const BlobURI &blobURI)
 
BlobReadernewBlobReaderFromUniversal (const Str &componentName, const UniversalBlobURI &blobURI)
 
BlobWriternewBlobWriter (const BlobURI &blobURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
ConfigReadernewConfigReader (const ConfigURI &configURI)
 
DataReadernewDataReader (const DataURI &dataURI)
 
DataReadernewDataReaderFromUniversal (const Str &componentName, const UniversalURI &universalURI)
 
DataWriternewDataWriter (const DataURI &dataURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalBlobReadernewUniversalBlobReader (const UniversalBlobURI &universalURI)
 
UniversalBlobWriternewUniversalBlobWriter (const UniversalBlobURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalDataReadernewUniversalReader (const UniversalURI &universalURI)
 
UniversalDataWriternewUniversalWriter (const UniversalURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
- Public Member Functions inherited from OutStream
virtual ~OutStream ()
 Destructor. More...
 
virtual OutStreamwriteHex (const char *buffer, size_t num)
 writes num bytes from buffer to the output buffer/stream as hex chars More...
 
virtual OutStreamwrite (const char *buffer)
 writes zero-terminated buffer to the output buffer/stream More...
 
virtual OutStreamwriteHex (const char *buffer)
 writes zero-terminated buffer to the output buffer/stream More...
 
OutStreamoperator<< (const Str buffer)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const char buffer[])
 write a Str, using stream operator More...
 
OutStreamoperator<< (const char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const signed char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const unsigned char byte)
 write a Str, using stream operator More...
 
OutStreamoperator<< (const int number)
 write a Str, using stream operator More...
 
OutStreamwriteChar (const signed char value)
 writes a single byte to the output buffer/stream More...
 
OutStreamwriteCharHex (const signed char byte)
 writes a single signed char to the output buffer/stream as 2 hex chars More...
 
OutStreamwriteUCharHex (const unsigned char byte)
 writes a single unsigned char to the output buffer/stream as 2 hex chars More...
 
OutStreamwriteInteger (const int number, const unsigned int radix=10)
 writes an integer as a base-radix string More...
 
OutStreamwriteNumber (const double number, const unsigned int radix=10)
 
OutStreamwriteShort (const short value)
 writes a single short to the output buffer/stream More...
 
OutStreamwriteShortHex (const short word)
 writes a single short to the output buffer/stream as 4 hex chars More...
 
OutStreamwriteUShortHex (const unsigned short word)
 writes a single unsigned short to the output buffer/stream as 4 hex chars More...
 
OutStreamwriteUShortCompact (const unsigned short &value)
 writes an unsigned short integer as 1 to 3 bytes, encoded as follows: xxxxxxx0 - 7 bit value, encoded in 1 byte xxxxxx01+1byte - 14 bit value, encoded in 2 bytes xxxxx011+2bytes - 16 bit value, encoded in 3 bytes More...
 
OutStreamwriteInt24 (const int medInt)
 writes a 3-byte integer to the output buffer/stream only works on little-endian machines! More...
 
OutStreamwriteInt (const int value)
 writes a 4-byte integer to the output buffer/stream More...
 
OutStreamwriteLongLong (const long long value)
 writes a 8-byte integer to the output buffer/stream More...
 
OutStreamwriteLongLongCompact (const long long &value)
 writes a signed long long integer as 1 to 9 bytes, encoded as follows: 0xxxxxxx - 7 bit value, encoded in 1 byte 10xxxxxx+1byte - 14 bit value, encoded in 2 bytes 110xxxxx+2bytes - 21 bit value, encoded in 3 bytes 1110xxxx+3bytes - 28 bit value, encoded in 4 bytes 11110xxx+4bytes - 35 bit value, encoded in 5 bytes 111110xx+5bytes - 42 bit value, encoded in 6 bytes 1111110x+6bytes - 49 bit value, encoded in 7 bytes 11111110+7bytes - 56 bit value, encoded in 8 bytes 11111111+8bytes - 64 bit value, encoded in 9 bytes More...
 
OutStreamwriteFloat (const float value)
 writes a 4-byte float to the output buffer/stream More...
 
OutStreamwriteFloat2 (const float value)
 writes a 2-byte float to the output buffer/stream More...
 
OutStreamwriteFloat3 (const float value)
 writes a 3-byte float to the output buffer/stream More...
 
OutStreamwriteDouble (const double value)
 writes a 8-byte double to the output buffer/stream More...
 
OutStreamwriteDouble6 (const double value)
 
size_t bytesWritten ()
 

Static Public Member Functions

static void DoCommand (const char *command, bool forceRun)
 
static void DoScheduled ()
 
static void DoScheduleList ()
 
static void DoScheduleResume ()
 
static void DoSchedulePause (Syslog::Severity schedulePauseSeverity, Timestamp pauseTime)
 
static bool IsCommandQueued ()
 
static void CommandBang (ParsedCommand *parsedCommand, int mode)
 
static void CommandBurn (ParsedCommand *parsedCommand, int mode)
 
static void CommandConfigSet (ParsedCommand *parsedCommand, int mode)
 
static void CommandConversation (ParsedCommand *parsedCommand, int mode)
 
static void CommandDo (ParsedCommand *parsedCommand, int mode)
 
static void CommandFailComponent (ParsedCommand *parsedCommand, int mode)
 
static void CommandFailVariable (ParsedCommand *parsedCommand, int mode)
 
static void CommandGet (ParsedCommand *parsedCommand, int mode)
 
static void CommandGFscan (ParsedCommand *parsedCommand, int mode)
 
static void CommandHelp (ParsedCommand *parsedCommand, int mode)
 
static void CommandIbit (ParsedCommand *parsedCommand, int mode)
 
static void CommandIbitMcp3553 (ParsedCommand *parsedCommand, int mode)
 
static void CommandLoad (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainAdd (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainClear (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainUnavailable (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainInvalid (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainList (ParsedCommand *parsedCommand, int mode)
 
static void CommandMaintainRemove (ParsedCommand *parsedCommand, int mode)
 
static void CommandQuick (ParsedCommand *parsedCommand, int mode)
 
static void CommandQuit (ParsedCommand *parsedCommand, int mode)
 
static void CommandReportAdd (ParsedCommand *parsedCommand, int mode)
 
static void CommandReportClear (ParsedCommand *parsedCommand, int mode)
 
static void CommandReportList (ParsedCommand *parsedCommand, int mode)
 
static void CommandReportRemove (ParsedCommand *parsedCommand, int mode)
 
static void CommandRestart (ParsedCommand *parsedCommand, int mode)
 
static void CommandResume (ParsedCommand *parsedCommand, int mode)
 
static void CommandRetransmit (ParsedCommand *parsedCommand, int mode)
 
static void CommandRun (ParsedCommand *parsedCommand, int mode)
 
static void CommandSet (ParsedCommand *parsedCommand, int mode)
 
static void CommandSchedule (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowBest (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowComponent (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowDependencies (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowStack (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowState (ParsedCommand *parsedCommand, int mode)
 
static void CommandShowVariable (ParsedCommand *parsedCommand, int mode)
 
static void CommandStop (ParsedCommand *parsedCommand, int mode)
 

Protected Types

enum  BurnMode { BURN_OFF, BURN_ON, BURN_SECONDS }
 
enum  ConversationMode { CONVERSATION_SHOW, CONVERSATION_START, CONVERSATION_STOP }
 
enum  ConfigSetMode { CONFIG_SET_LIST, CONFIG_SET_RELOAD, CONFIG_SET_CONFIG, CONFIG_SET_LOGGING }
 
enum  FailComponentMode {
  FAIL_COMPONENT_LIST, FAIL_COMPONENT_SHOW, FAIL_COMPONENT_NONE, FAIL_COMPONENT_HARD,
  FAIL_COMPONENT_SOFT, FAIL_COMPONENT_SEGFAULT
}
 
enum  FailVariableMode {
  FAIL_VARIABLE_LIST, FAIL_VARIABLE_SHOW, FAIL_VARIABLE_UNAVAILABLE, FAIL_VARIABLE_AVAILABLE,
  FAIL_VARIABLE_INVALID, FAIL_VARIABLE_VALID
}
 
enum  QuickMode { QUICK_SHOW, QUICK_ON, QUICK_OFF }
 
enum  ReportAddMode { REPORT_ADD_MOD, REPORT_ADD_TOUCH, REPORT_ADD_PERIODIC }
 
enum  RestartType { RESTART_APPLICATION, RESTART_HARDWARE, RESTART_LOGS, RESTART_SYSTEM }
 
enum  RetransmitType { RETRANSMIT_SBD }
 
enum  ScheduleType {
  SCHEDULE_ASAP, SCHEDULE_CLEAR, SCHEDULE_LIST, SCHEDULE_NEXT,
  SCHEDULE_PAUSE, SCHEDULE_REMOVE, SCHEDULE_RESUME, SCHEDULE_TIME
}
 
- Protected Types inherited from Component
enum  ConfigOption { CONFIG_SIMULATE_HARDWARE, CONFIG_POWER, CONFIG_FREQUENCY, CONFIG_LATENCY }
 

Protected Member Functions

CommandaddCommand (const char *keyword, const char *description, bool advanced=false)
 
void clearParsed ()
 
bool findUniqueArg (char *buffer, int len)
 Return true if a unique arg matches the supplied arg. More...
 
bool parseBufferEnd ()
 If the last word in buffer is a valid arg, deal with it. More...
 
void completeArg (char *buffer, int len)
 Normally called in response to a tab keypress. More...
 
CommandSyntaxfindUniqueSyntax (char *buffer, int len, bool &anyMatch)
 Return unique syntax that buffer matches unique keyword. More...
 
bool findSyntax (char *buffer, int len)
 If the buffer equals a unique syntax keyword, set parsedSyntax_ to that syntax. More...
 
void completeSyntax (char *buffer, int len)
 Normally called in response to a tab keypress. More...
 
void clearLine ()
 
void backspace ()
 
void setLine (const char *line, bool allowExec)
 
void execLine ()
 
void getLines ()
 
unsigned char kbGetc ()
 
char * nextWord (char **line)
 
- Protected Member Functions inherited from AsyncComponent
 AsyncComponent (const Str &name, const Module *module, const Timespan period, bool idlePriority=false)
 Protected constructor for components that run in periodic asynchronous threads. More...
 
 AsyncComponent (const Str &name, const Module *module, bool idlePriority=false)
 Protected constructor for components that run in continuous asynchronous threads. More...
 
- Protected Member Functions inherited from Component
virtual ConfigURI getConfigURI (ConfigOption configOption) const
 Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc. More...
 
virtual ConfigURI getConfigURI (ConfigOption configOption, ElementURI forElement) const
 Should return [myNamespace]::POWER_[forElement], [myNamespace]::LATENCY_[forElement], etc. More...
 
virtual void setDurationOfLastRun (const Timespan &span)
 
virtual void setTimeOfRun (const Timestamp &time)
 
virtual void setTimeOfLastRun (const Timestamp &time)
 
virtual void setDt (const Timespan &dt)
 
virtual bool setEnabled (bool enabled=true)
 
void setRunState (const RunState runState)
 
const Timespan getPauseTime () const
 
virtual void setFailureMissionCritical (bool failureMissionCritical)
 
bool simulateHardware ()
 
- Protected Member Functions inherited from OutStream
 OutStream ()
 Protected Constructor for abstract class. More...
 

Protected Attributes

FlexArray< Command * > commands_
 
ParsedCommand parsedCommands_ [MAX_CMDS]
 
int parsedCommandCount_
 
bool haveTermios_
 
struct termios originalTermios_
 
struct termios newTermios_
 
Supervisorsupervisor_
 
FILE * in_
 
FILE * out_
 
const char * prompt_
 
char hostname_ [MAX_HOST_NAME_SIZE]
 
FlexArray< Str * > cmdHistory_
 
size_t cmdHistoryIndex_
 
Mutex scheduleMutex_
 
bool gettingLines_
 
bool cmdQueued_
 
StrValue keyText_
 
Timestamp burnStopTime_
 
char doBuffer_ [1024]
 
size_t doBytes_
 
Str doSbd_
 
DataReaderibitRunningReader_
 
DataReaderscanRunningReader_
 
UniversalDataReaderplatformConversationReader_
 
UniversalDataWriterplatformConversationWriter_
 
- Protected Attributes inherited from AsyncComponent
bool idlePriority_
 
- Protected Attributes inherited from Component
Logger logger_
 
Syslog::Severity debugLevel_
 
ComponentState state_
 Keep track of whether the component has "completed" or should be run again. More...
 
Timespan desiredPeriod_
 
CodedStrname_
 Store the component's name (used for logging purposes) More...
 
Timestamp timeOfRun_
 
Timestamp timeOfLastRun_
 
Timespan durationOfLastRun_
 
Timespan dt_
 
Timespan retryTimeout_
 
bool enabled_
 
bool failureReported_
 Indicates if the failure has been reported – cuts down on syslog. More...
 
bool criticalFailureReported_
 Indicates if a "Critical" failure has been reported – cuts down on syslog. More...
 
bool recoveringFromCritical_
 Indicates that a component had a previous critical failure that has been cleared temporarily awaiting final word from the component itself. More...
 
bool failureUninitialized_
 Indicates if the failure has resulted in an uninitialize call. More...
 
int failCount_
 Number of failures logged by PCaller. More...
 
bool failureMissionCritical_
 If true (default), complete failure ends mission. More...
 
int allowableFailures_
 Number of failures allowed to occur. More...
 
int skippedRunsSinceFail_
 Number of skipped runs since failureMode_ set by failCount_. More...
 
FailureMode::FailType failureType_
 Failed status. If failCount_ > 0, then this may be reset. More...
 
Timestamp timeOfFailure_
 Time of last failure. Relevant only if failed=true. More...
 
Timestamp writeTimestamp_
 Time of last write. More...
 
FlexArray< DataReader * > readers_
 
FlexArray< DataWriter * > writers_
 
const Modulemodule_
 
Timespan pauseTime_
 
bool meteringEnabled_
 If true, metering is enabled. More...
 
DataWriterdurationOfLastRunWriter_
 Writer for durationOfLastRun. More...
 
DataWritervoltageWriter_
 
DataWriteravgVoltageWriter_
 
DataWritercurrentWriter_
 
DataWriteravgCurrentWriter_
 
bool persistentPause_
 True if data is persistent while component is paused. More...
 
- Protected Attributes inherited from OutStream
size_t lastWritten_
 

Static Protected Attributes

static const int BUFF_SIZE = 1024
 
static char ConsoleBuffer_ [BUFF_SIZE]
 
static int InputIndex_
 
static char OutputBuffer_ [BUFF_SIZE]
 
static int OutputIndex_
 
static const int HISTORY_SIZE = 50
 
static bool AtMode_
 
static const Timespan BANG_TIMEOUT
 
static const size_t MAX_HOST_NAME_SIZE = 128
 
static char QueuedCommand_ [BUFF_SIZE]
 
static Mutex QueueCommandMutex_
 
static CommandLineInstance_
 
- Static Protected Attributes inherited from OutStream
static const unsigned char HEX_CHARS [] = "0123456789ABCDEF"
 

Private Member Functions

 CommandLine (const CommandLine &old)
 

Friends

class CommandLine_Test
 

Additional Inherited Members

- Public Types inherited from Component
enum  ComponentState {
  BLOCK_CONTINUOUS, BLOCK_PERIODIC, BLOCK_NORMAL, BLOCK_COMPLETED,
  BLOCK_UNKNOWN
}
 In this model, the component has basically two states: wanting to run, and completed (no longer needing to run). More...
 
enum  ComponentType { COMPONENT_ASYNC, COMPONENT_CONFIG, COMPONENT_BEHAVIOR, COMPONENT_SYNC }
 Components can indicate how they want to be handled by their type. More...
 
enum  RunState {
  NO_RUN_STATE = 0, START, STARTING, RUNNABLE,
  SATISFIED, PAUSE, PAUSING, PAUSED,
  RESUME, RESUMING, RESETTING, STOP,
  STOPPING, STOPPED
}
 

Detailed Description

Provides a simple command line interface to the LRAUV.

The command line is available from the console while the application runs, and is intended to take commands sent over the satellite radio.

Constructor & Destructor Documentation

CommandLine::CommandLine ( Supervisor supervisor)

References Command::addArg(), addCommand(), Command::addSyntax(), ARG_COMMAND, ARG_COMPONENT, ARG_CONFIG_DIR, ARG_CONFIG_VARIABLE, ARG_DECIMATION_TYPE, ARG_FLOAT, ARG_INT, ARG_MISSION, ARG_QUOTED_STRING, ARG_REGEX, ARG_SECONDS, ARG_SERVICE_TYPE, ARG_STRING, ARG_TIMESTAMP, ARG_TOKEN, ARG_UNIT, ARG_UNIVERSAL, ARG_VARIABLE, Units::BOOL, BURN_OFF, BURN_ON, BURN_SECONDS, CommandBang(), CommandBurn(), CommandConfigSet(), CommandConversation(), CommandDo(), CommandFailComponent(), CommandFailVariable(), CommandGet(), CommandGFscan(), CommandHelp(), CommandIbit(), CommandIbitMcp3553(), CommandLoad(), CommandMaintainAdd(), CommandMaintainClear(), CommandMaintainInvalid(), CommandMaintainList(), CommandMaintainRemove(), CommandMaintainUnavailable(), CommandQuick(), CommandQuit(), CommandReportAdd(), CommandReportClear(), CommandReportList(), CommandReportRemove(), CommandRestart(), CommandResume(), CommandRetransmit(), CommandRun(), CommandSchedule(), CommandSet(), CommandShowBest(), CommandShowComponent(), CommandShowDependencies(), CommandShowStack(), CommandShowState(), CommandShowVariable(), CommandStop(), CONFIG_SET_CONFIG, CONFIG_SET_LIST, CONFIG_SET_LOGGING, CONFIG_SET_RELOAD, CONVERSATION_SHOW, CONVERSATION_START, CONVERSATION_STOP, SyncComponent::CYCLE_CONTROL, SyncComponent::CYCLE_DERIVATION, SyncComponent::CYCLE_MISSION, SyncComponent::CYCLE_SENSOR, SyncComponent::CYCLE_SERVO, SyncComponent::CYCLE_SIMULATOR, doBuffer_, FAIL_COMPONENT_HARD, FAIL_COMPONENT_LIST, FAIL_COMPONENT_NONE, FAIL_COMPONENT_SEGFAULT, FAIL_COMPONENT_SHOW, FAIL_COMPONENT_SOFT, FAIL_VARIABLE_AVAILABLE, FAIL_VARIABLE_INVALID, FAIL_VARIABLE_LIST, FAIL_VARIABLE_SHOW, FAIL_VARIABLE_UNAVAILABLE, FAIL_VARIABLE_VALID, haveTermios_, hostname_, ibitRunningReader_, in_, Instance_, MAX_HOST_NAME_SIZE, Component::newDataReader(), newTermios_, Component::newUniversalReader(), Component::newUniversalWriter(), NOT_REQUIRED, originalTermios_, UniversalURI::PLATFORM_CONVERSATION, platformConversationReader_, platformConversationWriter_, prompt_, QueuedCommand_, QUICK_OFF, QUICK_ON, QUICK_SHOW, REPORT_ADD_MOD, REPORT_ADD_PERIODIC, REPORT_ADD_TOUCH, REQUIRED, REQUIRED_AFTER_PREVIOUS, RESTART_APPLICATION, RESTART_HARDWARE, RESTART_LOGS, RESTART_SYSTEM, RETRANSMIT_SBD, scanRunningReader_, SCHEDULE_ASAP, SCHEDULE_CLEAR, SCHEDULE_LIST, SCHEDULE_NEXT, SCHEDULE_PAUSE, SCHEDULE_REMOVE, SCHEDULE_RESUME, SCHEDULE_TIME, Component::setAllowableFailures(), and Component::setRetryTimeout().

CommandLine::~CommandLine ( )
virtual
CommandLine::CommandLine ( const CommandLine old)
private

Member Function Documentation

Command& CommandLine::addCommand ( const char *  keyword,
const char *  description,
bool  advanced = false 
)
inlineprotected

References FlexArray< T >::push().

Referenced by CommandLine().

void CommandLine::backspace ( )
protected

References ConsoleBuffer_, InputIndex_, and out_.

Referenced by clearLine(), and getLines().

void CommandLine::clearLine ( )
protected

References backspace(), and InputIndex_.

Referenced by getLines(), and setLine().

void CommandLine::clearParsed ( )
protected
void CommandLine::CommandBang ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandBang(), and Instance_.

Referenced by CommandLine(), and DataReceiver::Receive().

void CommandLine::CommandBurn ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandBurn(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandConfigSet ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandConfigSet(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandConversation ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandConversation(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandDo ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandDo(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandFailComponent ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandFailComponent(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandFailVariable ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandFailVariable(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandGet ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandGet(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandGFscan ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandGFscan(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandGFscan ( ParsedCommand parsedCommand)
void CommandLine::CommandHelp ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandHelp(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandHelp ( ParsedCommand parsedCommand)
void CommandLine::CommandIbit ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandIbit(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandIbit ( ParsedCommand parsedCommand)
void CommandLine::CommandIbitMcp3553 ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandIbit(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandLoad ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandLoad(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandMaintainAdd ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainAdd(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandMaintainClear ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainClear(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandMaintainClear ( ParsedCommand parsedCommand)
void CommandLine::CommandMaintainInvalid ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainInvalid(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandMaintainList ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainList(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandMaintainList ( ParsedCommand parsedCommand)
void CommandLine::CommandMaintainRemove ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainRemove(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandMaintainUnavailable ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandMaintainUnavailable(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandQuick ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandQuick(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandQuick ( ParsedCommand parsedCommand,
QuickMode  mode 
)
void CommandLine::CommandQuit ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandQuit(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandQuit ( ParsedCommand parsedCommand)
void CommandLine::CommandReportAdd ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandReportAdd(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandReportClear ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandReportClear(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandReportClear ( ParsedCommand parsedCommand)
void CommandLine::CommandReportList ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandReportList(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandReportList ( ParsedCommand parsedCommand)
void CommandLine::CommandReportRemove ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandReportRemove(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandRestart ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandRestart(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandRestartHardware ( ParsedCommand parsedCommand)
void CommandLine::commandRestartLogs ( ParsedCommand parsedCommand)

References Supervisor::RestartLogs().

Referenced by commandRestart().

void CommandLine::CommandResume ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandResume(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandRetransmit ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandRetransmit(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandRun ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandRun(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandSchedule ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandSchedule(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandSchedulePause ( Syslog::Severity  schedulePauseSeverity,
Timestamp  pauseTime 
)
void CommandLine::commandScheduleResume ( )
void CommandLine::commandScheduleShowPaused ( )
void CommandLine::CommandSet ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandSet(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandShowBest ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowBest(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandShowComponent ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowComponent(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandShowDependencies ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowDependencies(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandShowStack ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowStack(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandShowStack ( ParsedCommand parsedCommand)
void CommandLine::CommandShowState ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowState(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandShowState ( ParsedCommand parsedCommand)
void CommandLine::CommandShowVariable ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandShowVariable(), and Instance_.

Referenced by CommandLine().

void CommandLine::CommandStop ( ParsedCommand parsedCommand,
int  mode 
)
static

References commandStop(), and Instance_.

Referenced by CommandLine().

void CommandLine::commandStop ( ParsedCommand parsedCommand)
void CommandLine::completeArg ( char *  buffer,
int  len 
)
protected

Normally called in response to a tab keypress.

If there's a parsedCommand_, expand it. Otherwise expand all options and start a new line.

References commands_, ParsedCommand::completeArg(), ConsoleBuffer_, flush(), FlexArray< T >::get(), Command::getKeyword(), ParsedCommand::getStart(), InputIndex_, out_, parsedCommandCount_, parsedCommands_, and FlexArrayBase::size().

Referenced by getLines().

void CommandLine::completeSyntax ( char *  buffer,
int  len 
)
protected

Normally called in response to a tab keypress.

If there's a parsedSyntax_, expand it. Otherwise expand all options and start a new line.

void CommandLine::DoScheduled ( )
static
void CommandLine::DoScheduleList ( )
static
void CommandLine::DoSchedulePause ( Syslog::Severity  schedulePauseSeverity,
Timestamp  pauseTime 
)
static
void CommandLine::DoScheduleResume ( )
static
bool CommandLine::findSyntax ( char *  buffer,
int  len 
)
protected

If the buffer equals a unique syntax keyword, set parsedSyntax_ to that syntax.

Return true if buffer equals start of any syntax keyword.

bool CommandLine::findUniqueArg ( char *  buffer,
int  len 
)
protected

Return true if a unique arg matches the supplied arg.

CommandSyntax* CommandLine::findUniqueSyntax ( char *  buffer,
int  len,
bool &  anyMatch 
)
protected

Return unique syntax that buffer matches unique keyword.

void CommandLine::flush ( )
FILE* CommandLine::getOutFile ( )
inline

References out_.

Referenced by ParsedCommand::completeCommand().

void CommandLine::initialize ( void  )
virtual

Provide a space for initialization before being run.

Reimplemented from Component.

References Units::BOOL, keyText_, Component::logger_, platformConversationWriter_, Slate::ReadOnce(), and DataWriter::write().

bool CommandLine::IsCommandQueued ( )
static
bool CommandLine::isWritable ( )
virtual

indicates whether the stream can actually be written to.

Implements OutStream.

References Component::BLOCK_COMPLETED, Component::enabled_, and Component::state_.

unsigned char CommandLine::kbGetc ( )
protected

References AtMode_, haveTermios_, in_, and Timespan::sleepFor().

Referenced by getLines().

char * CommandLine::nextWord ( char **  line)
protected
bool CommandLine::parseBufferEnd ( )
protected

If the last word in buffer is a valid arg, deal with it.

Report if a valid arg matches the supplied arg.

Return false if the end of the buffer is invalid.

If so, deal with it. If the last word in buffer is a valid arg, deal with it. If we need to toss the last character, return false.

References ARG_NONE, ARG_STRING, ParsedCommand::clearAll(), commands_, ConsoleBuffer_, ParsedCommand::getCurrentArgType(), ParsedCommand::getStart(), InputIndex_, ParsedCommand::isInQuotedString(), ParsedCommand::parseBufferEnd(), parsedCommandCount_, parsedCommands_, and ParsedCommand::setStart().

Referenced by getLines(), setChar(), and CommandLine_Test::testParse().

void CommandLine::run ( void  )
virtual

The actual "payload" of the component.

Reimplemented from Component.

References Component::enabled_, getLines(), supervisor_, and Supervisor::terminate().

void CommandLine::setChar ( const char  theChar)
void CommandLine::setLine ( const char *  line,
bool  allowExec 
)
protected

References clearLine(), clearParsed(), execLine(), and setChar().

Referenced by DoCommand(), and getLines().

void CommandLine::uninitialize ( void  )
virtual

Provide a space for uninitialization.

Reimplemented from Component.

OutStream & CommandLine::write ( const char *  buffer,
size_t  num 
)
virtual

writes num bytes from buffer to the output buffer/stream

Implements OutStream.

References BUFF_SIZE, flush(), OutputBuffer_, and OutputIndex_.

Friends And Related Function Documentation

friend class CommandLine_Test
friend

Member Data Documentation

bool CommandLine::AtMode_
staticprotected

Referenced by commandRestartSystem(), and kbGetc().

const Timespan CommandLine::BANG_TIMEOUT
staticprotected

Referenced by commandBang().

const int CommandLine::BUFF_SIZE = 1024
staticprotected
Timestamp CommandLine::burnStopTime_
protected

Referenced by commandBurn(), and getLines().

FlexArray<Str*> CommandLine::cmdHistory_
protected

Referenced by execLine(), and getLines().

size_t CommandLine::cmdHistoryIndex_
protected

Referenced by execLine(), and getLines().

bool CommandLine::cmdQueued_
protected
FlexArray<Command*> CommandLine::commands_
protected
char CommandLine::ConsoleBuffer_
staticprotected
char CommandLine::doBuffer_[1024]
protected

Referenced by commandDo(), CommandLine(), and getLines().

size_t CommandLine::doBytes_
protected

Referenced by commandDo(), and getLines().

Str CommandLine::doSbd_
protected

Referenced by commandDo(), and getLines().

bool CommandLine::gettingLines_
protected

Referenced by DoCommand(), and getLines().

bool CommandLine::haveTermios_
protected
const int CommandLine::HISTORY_SIZE = 50
staticprotected

Referenced by execLine().

char CommandLine::hostname_[MAX_HOST_NAME_SIZE]
protected

Referenced by CommandLine(), and getLines().

DataReader* CommandLine::ibitRunningReader_
protected

Referenced by commandIbit(), CommandLine(), and getLines().

FILE* CommandLine::in_
protected
int CommandLine::InputIndex_
staticprotected
StrValue CommandLine::keyText_
protected

Referenced by getLines(), and initialize().

const size_t CommandLine::MAX_HOST_NAME_SIZE = 128
staticprotected

Referenced by CommandLine().

struct termios CommandLine::newTermios_
protected
struct termios CommandLine::originalTermios_
protected
char CommandLine::OutputBuffer_
staticprotected

Referenced by flush(), and write().

int CommandLine::OutputIndex_
staticprotected

Referenced by flush(), and write().

int CommandLine::parsedCommandCount_
protected
ParsedCommand CommandLine::parsedCommands_[MAX_CMDS]
protected
UniversalDataReader* CommandLine::platformConversationReader_
protected

Referenced by commandConversation(), and CommandLine().

UniversalDataWriter* CommandLine::platformConversationWriter_
protected
const char* CommandLine::prompt_
protected

Referenced by CommandLine(), flush(), and getLines().

Mutex CommandLine::QueueCommandMutex_
staticprotected
char CommandLine::QueuedCommand_
staticprotected

Referenced by CommandLine().

DataReader* CommandLine::scanRunningReader_
protected
Mutex CommandLine::scheduleMutex_
protected

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