LRAUV  revA
Supervisor Class Reference

The supervisor is the "main" component in the vehicle software. More...

#include <Supervisor.h>

Collaboration diagram for Supervisor:

Public Member Functions

 Supervisor (int argc, char **argv, Str &dataDir)
 Constructor: To meet requirement The vehicle control loop (start time) must be accurate to within 10 ms, this constructor sets the process priority to -20. More...
 
virtual ~Supervisor ()
 Destructor. More...
 
virtual void initialize ()
 Initialization. More...
 
virtual void run ()
 The run() function. More...
 
virtual void uninitialize ()
 Uninitialization. More...
 

Static Public Member Functions

static Str GenerateDataDir (const Str &logSymlinkSubdir="")
 Generates a new data directory and returns its name. More...
 
static Str RestartLogs ()
 Create a new directory in Logs and begin writing to it. More...
 
static void IncrementShoreFile ()
 Closes the current "toShore" file and begins a new one. More...
 
static Str GetToShoreFilename (LogWriter::ServiceType serviceType)
 Gets the name of the latest "toShore" file May be from a previous run of the software. More...
 
static Str GetLatestLogFilename (FileFilterType fileFilter)
 Gets the name of the latest Log file that matches the filter May be from a previous run of the software. More...
 
static bool IsRestart ()
 
static int GetArgc ()
 
static char ** GetArgv ()
 
static void ClearArgs ()
 
static void SendData (DataEntry *dataEntry, LogWriter::ServiceType serviceType)
 Forces an entry into the shore log. More...
 
static bool IsMissionManagerFailed ()
 Indicates if mission manager is failed. More...
 
static bool IsMissionRunning ()
 Indicates if a loaded mission is running. More...
 
static void TouchRunningFile ()
 If there is a file at Data/running, set WasRunning_ to true; Otherwise, just create file. More...
 
static void ClearRunningFile ()
 As part of orderly shutdown, delete the file at Data/running. More...
 
static bool WasRunning ()
 
static bool IsRunningSimsInRealTime ()
 
static void QueueSBD (const char *path)
 Queue up the sbd at the indicated address to be resent. More...
 
static char * GetQueuedSBD ()
 Get the path to next SBD to be resent, if any Delete the pointer after use! More...
 
static void ConfigureDecimation (LogWriter::ServiceType serviceType, DecimationLogWriter::DecimationType decimationType, const Str &name, DataValue *parameter, Logger &logger)
 Call upon DecimationLogManager to configure automatic Logging of data. More...
 

Private Member Functions

 Supervisor (const Supervisor &old)
 
void configure ()
 Load up configuration settings. More...
 
bool loadMission (const char *missionName)
 Loads the specified mission file. More...
 
bool resumeMission (const char *missionName)
 Resumes a previously stopped mission. More...
 
bool runMission (const char *missionName, bool quitAtEnd)
 Loads the specified mission file if non-null Runs that mission or previously loaded one. More...
 
void showStack ()
 Causes the currently running mission stack to be displayed. More...
 
void stopMission ()
 Kills the currently running mission file. More...
 
void terminate ()
 Terminates Supervisor run – available only to CommandLine. More...
 
void addMaintain (unsigned short int uriCode, DataValue *dataValue, SyncComponent::CycleOrder cycleOrder, bool unavailable=false, bool invalid=false)
 Add a uriCode and value to be maintained – available only to CommandLine function prototype mirrored from Maintainer.h. More...
 
void removeMaintain (unsigned short int uriCode)
 Remove the maintaining of an uriCode from the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h. More...
 
void removeAllMaintains ()
 Remove the maintaining of all uriCodes from the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h. More...
 
void listMaintains ()
 List the uriCodes being maintained by the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h. More...
 
void addReport (unsigned short int uriCode, Reporter::ReportType type=Reporter::REPORT_CHANGE, const Timespan *timespan=NULL)
 Add the reporting of an uriCode to the Reporter – available only to CommandLine function prototype mirrored from Reporter.h. More...
 
void removeReport (unsigned short int uriCode)
 Remove the reporting of an uriCode from the Reporter – available only to CommandLine function prototype mirrored from Reporter.h. More...
 
void removeAllReports ()
 Remove the reporting of all uriCodes from the Reporter – available only to CommandLine function prototype mirrored from Reporter.h. More...
 
void listReports ()
 List the uriCodes being reported by the Reporter – available only to CommandLine function prototype mirrored from Reporter.h. More...
 
void startCommandLine ()
 

Static Private Member Functions

static void SetArgs (const char *args)
 
static void SetRestart (bool restart)
 
static SupervisorGetInstance ()
 Returns singleton instance. More...
 
static int FilterLogDir (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static FileFilterType GetServiceFilter (LogWriter::ServiceType serviceType, bool lzma)
 Helper function for GetToShoreFilename() More...
 
static int FilterCourier (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterCourierLzma (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterExpress (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterExpressLzma (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterPriority (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterPriorityLzma (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterNormal (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 
static int FilterNormalLzma (DIRENT_CONST struct dirent *dirEntry)
 Helper function for GetToShoreFilename() More...
 

Private Attributes

LogEnginelogEngine_
 Main LogEngine for the system. More...
 
Logger logger_
 Logger for Supervisor. More...
 
int argc_
 Arguments passed from main. More...
 
char ** argv_
 
Str altConfig_
 
ListOfLoadedModulePtrs loadedModules_
 Module handling. More...
 
ModuleLoader moduleLoader_
 
HandlercommandLineHandler_
 Command handler. More...
 
MissionManagermissionManager_
 Mission handling. More...
 
Maintainermaintainer_
 Maintains values specified at console. More...
 
Reporterreporter_
 Reporting to console. More...
 
bool running_
 For shutdown purposes. More...
 
StrdataDir_
 Where to write data! More...
 
FlexArray< char * > sbdQueue_
 Queue of SBDs to re-send to shore. More...
 
DecimationLogManagerdecimationLogManager_
 Manages the "toShore" files. More...
 
FileLogWritersyslogFileWriter_
 Write logs. More...
 
BinaryLogWriterslateWriter_
 
SplitFileLogWriterslateFileWriter_
 
FileLogWriterslateDirFileWriter_
 
FileLogWriterkmlFileWriter_
 
LinearApproximationLogWriterkmlApproximationWriter_
 

Static Private Attributes

static bool Restart_
 Flag set when it's time to restart. More...
 
static int Argc_
 Arguments passed to main when restarting. More...
 
static char ** Argv_
 
static char * Args_
 
static bool WasRunning_
 
static bool RunSimsInRealTime_
 To make simulated missions run in real-time. More...
 
static SupervisorInstance_
 

Friends

class CommandLine
 
class CBIT
 

Detailed Description

The supervisor is the "main" component in the vehicle software.

It is the first to start (from the real "main()") function, and handles the loading of other modules, the instantiation of components and the spinning off of threads. Once the vehicle is up and running it can host other infrequently-running (lower priority) components, as well as its own overhead processes.

The supervisor is the "owner" of all other system Components and is responsible for instantiation and uninstantiation.

Constructor & Destructor Documentation

Supervisor::Supervisor ( int  argc,
char **  argv,
Str dataDir 
)

Constructor: To meet requirement The vehicle control loop (start time) must be accurate to within 10 ms, this constructor sets the process priority to -20.

Constructor.

References Instance_.

Supervisor::~Supervisor ( )
virtual

Destructor.

References Instance_.

Supervisor::Supervisor ( const Supervisor old)
private

Member Function Documentation

void Supervisor::addMaintain ( unsigned short int  uriCode,
DataValue dataValue,
SyncComponent::CycleOrder  cycleOrder,
bool  unavailable = false,
bool  invalid = false 
)
private

Add a uriCode and value to be maintained – available only to CommandLine function prototype mirrored from Maintainer.h.

Add the maintaining of an uriCode to the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h.

References Maintainer::addMaintain(), Syslog::ERROR, logger_, maintainer_, and Logger::syslog().

Referenced by CommandLine::commandMaintainAdd(), CommandLine::commandMaintainInvalid(), and CommandLine::commandMaintainUnavailable().

void Supervisor::addReport ( unsigned short int  uriCode,
Reporter::ReportType  type = Reporter::REPORT_CHANGE,
const Timespan timespan = NULL 
)
private

Add the reporting of an uriCode to the Reporter – available only to CommandLine function prototype mirrored from Reporter.h.

References Reporter::addReport(), Syslog::ERROR, logger_, ElementURI::NO_CODE, reporter_, and Logger::syslog().

Referenced by CommandLine::commandReportAdd().

void Supervisor::ClearArgs ( )
static

References Argc_, Args_, and Argv_.

Referenced by main(), and SetArgs().

void Supervisor::ClearRunningFile ( )
static

As part of orderly shutdown, delete the file at Data/running.

References Timespan::sleepFor().

Referenced by CommandLine::commandRestartSystem(), and terminate().

void Supervisor::ConfigureDecimation ( LogWriter::ServiceType  serviceType,
DecimationLogWriter::DecimationType  decimationType,
const Str name,
DataValue parameter,
Logger logger 
)
static

Call upon DecimationLogManager to configure automatic Logging of data.

References DecimationLogManager::configLog(), decimationLogManager_, and Instance_.

Referenced by CommandLine::commandConfigSet(), and Config::ParseLine().

int Supervisor::FilterCourier ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterCourierLzma ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterExpress ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterExpressLzma ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterLogDir ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate

Helper function for GetToShoreFilename()

Referenced by GetLatestLogFilename(), and GetToShoreFilename().

int Supervisor::FilterNormal ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterNormalLzma ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterPriority ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
int Supervisor::FilterPriorityLzma ( DIRENT_CONST struct dirent *  dirEntry)
staticprivate
Str Supervisor::GenerateDataDir ( const Str logSymlinkSubdir = "")
static

Generates a new data directory and returns its name.

References Str::cStr(), Str::length(), Timestamp::Now(), and Timestamp::toSmallString().

Referenced by RestartLogs(), and run_code().

static int Supervisor::GetArgc ( )
inlinestatic

References Argc_.

Referenced by main().

static char** Supervisor::GetArgv ( )
inlinestatic

References Argv_.

Referenced by main().

static Supervisor* Supervisor::GetInstance ( )
inlinestaticprivate

Returns singleton instance.

References Instance_.

Str Supervisor::GetLatestLogFilename ( FileFilterType  fileFilter)
static

Gets the name of the latest Log file that matches the filter May be from a previous run of the software.

Gets the name of the latest Log file that matches the filter.

References Str::cStr(), Str::EMPTY_STR, and FilterLogDir().

Referenced by MissionStateLogger::NewResume().

char * Supervisor::GetQueuedSBD ( )
static

Get the path to next SBD to be resent, if any Delete the pointer after use!

References Instance_, FlexArray< T >::pop(), and sbdQueue_.

Referenced by NAL9602::sendingFillBuffer().

Str Supervisor::GetToShoreFilename ( LogWriter::ServiceType  serviceType)
static

Gets the name of the latest "toShore" file May be from a previous run of the software.

Gets the name of the latest "toShore" file.

References Str::cStr(), Str::EMPTY_STR, LzmaEncoder::encode(), FilterLogDir(), and GetServiceFilter().

Referenced by DataOverHttps::run(), and NAL9602::sendingFillBuffer().

void Supervisor::IncrementShoreFile ( )
static
bool Supervisor::IsMissionManagerFailed ( )
static

Indicates if mission manager is failed.

References Instance_, Component::isFailed(), and missionManager_.

Referenced by VerticalControl::controlVertical().

bool Supervisor::IsMissionRunning ( )
static

Indicates if a loaded mission is running.

References Instance_, MissionManager::isMissionRunning(), and missionManager_.

Referenced by ScheduledItem::DoScheduled().

static bool Supervisor::IsRestart ( )
inlinestatic

References Restart_.

Referenced by main().

static bool Supervisor::IsRunningSimsInRealTime ( )
inlinestatic

References RunSimsInRealTime_.

Referenced by Handler::runBetween().

void Supervisor::listMaintains ( )
private

List the uriCodes being maintained by the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h.

References Syslog::ERROR, Maintainer::listMaintains(), logger_, maintainer_, and Logger::syslog().

Referenced by CommandLine::commandMaintainList().

void Supervisor::listReports ( )
private

List the uriCodes being reported by the Reporter – available only to CommandLine function prototype mirrored from Reporter.h.

References Syslog::ERROR, Reporter::listReports(), logger_, reporter_, and Logger::syslog().

Referenced by CommandLine::commandReportList().

bool Supervisor::loadMission ( const char *  missionName)
private

Loads the specified mission file.

References MissionManager::loadFromFile(), and missionManager_.

Referenced by CommandLine::commandLoad().

void Supervisor::QueueSBD ( const char *  path)
static

Queue up the sbd at the indicated address to be resent.

References Instance_, FlexArray< T >::push(), sbdQueue_, and FlexArray< T >::setDoArrayDelete().

Referenced by CommandLine::commandRetransmit().

void Supervisor::removeAllMaintains ( )
private

Remove the maintaining of all uriCodes from the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h.

References Syslog::ERROR, logger_, maintainer_, Maintainer::removeAllMaintains(), and Logger::syslog().

Referenced by CommandLine::commandMaintainClear().

void Supervisor::removeAllReports ( )
private

Remove the reporting of all uriCodes from the Reporter – available only to CommandLine function prototype mirrored from Reporter.h.

References Syslog::ERROR, logger_, Reporter::removeAllReports(), reporter_, and Logger::syslog().

Referenced by CommandLine::commandReportClear().

void Supervisor::removeMaintain ( unsigned short int  uriCode)
private

Remove the maintaining of an uriCode from the Maintainer – available only to CommandLine function prototype mirrored from Maintainer.h.

References Syslog::ERROR, logger_, maintainer_, Maintainer::removeMaintain(), and Logger::syslog().

Referenced by CommandLine::commandMaintainRemove().

void Supervisor::removeReport ( unsigned short int  uriCode)
private

Remove the reporting of an uriCode from the Reporter – available only to CommandLine function prototype mirrored from Reporter.h.

References Syslog::ERROR, logger_, ElementURI::NO_CODE, Reporter::removeReport(), reporter_, and Logger::syslog().

Referenced by CommandLine::commandReportRemove().

bool Supervisor::resumeMission ( const char *  missionName)
private

Resumes a previously stopped mission.

References MissionManager::loadFromFile(), missionManager_, and MissionManager::resumeLoadedMission().

Referenced by CommandLine::commandResume().

void Supervisor::run ( void  )
virtual

The run() function.

This is the guts of the supervisor.

Best to think of this as main() for the vehicle software. Kicks off all the child threads (through the ComponentRegistry), then sits back and watches the software run.

We run this only once.

References argc_, argv_, CommandLine::DoCommand(), CommandLine::DoScheduled(), logger_, running_, Timespan::Seconds(), Timespan::sleepFor(), startCommandLine(), ComponentRegistry::StartThreads(), and Logger::syslog().

Referenced by run_code().

bool Supervisor::runMission ( const char *  missionName,
bool  quitAtEnd 
)
private

Loads the specified mission file if non-null Runs that mission or previously loaded one.

References MissionManager::loadFromFile(), missionManager_, and MissionManager::runLoadedMission().

Referenced by CommandLine::commandRun().

void Supervisor::SendData ( DataEntry dataEntry,
LogWriter::ServiceType  serviceType 
)
static

Forces an entry into the shore log.

References decimationLogManager_, DecimationLogManager::forceWrite(), and Instance_.

Referenced by SendDataComponent::run().

void Supervisor::SetArgs ( const char *  args)
staticprivate
static void Supervisor::SetRestart ( bool  restart)
inlinestaticprivate
void Supervisor::showStack ( )
private

Causes the currently running mission stack to be displayed.

References MissionManager::logStack(), and missionManager_.

Referenced by CommandLine::commandShowStack().

void Supervisor::startCommandLine ( )
private

References commandLineHandler_, and Handler::run().

Referenced by run().

void Supervisor::stopMission ( )
private
void Supervisor::terminate ( )
private

Terminates Supervisor run – available only to CommandLine.

References ClearRunningFile(), running_, and stopMission().

Referenced by CommandLine::run().

void Supervisor::TouchRunningFile ( )
static

If there is a file at Data/running, set WasRunning_ to true; Otherwise, just create file.

References WasRunning_.

Referenced by run_code().

static bool Supervisor::WasRunning ( )
inlinestatic

Friends And Related Function Documentation

friend class CBIT
friend
friend class CommandLine
friend

Referenced by initialize().

Member Data Documentation

Str Supervisor::altConfig_
private

Referenced by configure(), and initialize().

int Supervisor::Argc_
staticprivate

Arguments passed to main when restarting.

Referenced by ClearArgs(), GetArgc(), and SetArgs().

int Supervisor::argc_
private

Arguments passed from main.

Referenced by initialize(), and run().

char * Supervisor::Args_
staticprivate

Referenced by ClearArgs(), and SetArgs().

char ** Supervisor::Argv_
staticprivate

Referenced by ClearArgs(), GetArgv(), and SetArgs().

char** Supervisor::argv_
private

Referenced by initialize(), and run().

Handler* Supervisor::commandLineHandler_
private

Command handler.

Referenced by initialize(), startCommandLine(), and uninitialize().

Str& Supervisor::dataDir_
private

Where to write data!

Referenced by configure(), initialize(), and RestartLogs().

DecimationLogManager* Supervisor::decimationLogManager_
private

Manages the "toShore" files.

Referenced by ConfigureDecimation(), IncrementShoreFile(), initialize(), RestartLogs(), SendData(), and uninitialize().

LinearApproximationLogWriter* Supervisor::kmlApproximationWriter_
private

Referenced by initialize(), and RestartLogs().

FileLogWriter* Supervisor::kmlFileWriter_
private

Referenced by initialize(), and RestartLogs().

ListOfLoadedModulePtrs Supervisor::loadedModules_
private

Module handling.

Referenced by uninitialize().

LogEngine* Supervisor::logEngine_
private

Main LogEngine for the system.

Referenced by configure(), initialize(), and RestartLogs().

Maintainer* Supervisor::maintainer_
private

Maintains values specified at console.

Referenced by addMaintain(), initialize(), listMaintains(), removeAllMaintains(), removeMaintain(), and uninitialize().

MissionManager* Supervisor::missionManager_
private
ModuleLoader Supervisor::moduleLoader_
private

Referenced by initialize().

Reporter* Supervisor::reporter_
private

Reporting to console.

Referenced by addReport(), initialize(), listReports(), removeAllReports(), and removeReport().

bool Supervisor::Restart_
staticprivate

Flag set when it's time to restart.

Referenced by IsRestart(), and SetRestart().

bool Supervisor::running_
private

For shutdown purposes.

Referenced by run(), and terminate().

bool Supervisor::RunSimsInRealTime_
staticprivate

To make simulated missions run in real-time.

Referenced by initialize(), and IsRunningSimsInRealTime().

FlexArray<char*> Supervisor::sbdQueue_
private

Queue of SBDs to re-send to shore.

Referenced by GetQueuedSBD(), and QueueSBD().

FileLogWriter* Supervisor::slateDirFileWriter_
private

Referenced by initialize(), and RestartLogs().

SplitFileLogWriter* Supervisor::slateFileWriter_
private

Referenced by initialize(), and RestartLogs().

BinaryLogWriter* Supervisor::slateWriter_
private

Referenced by initialize(), and RestartLogs().

FileLogWriter* Supervisor::syslogFileWriter_
private

Write logs.

Referenced by initialize(), and RestartLogs().

bool Supervisor::WasRunning_
staticprivate

Referenced by TouchRunningFile(), and WasRunning().


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