|
LRAUV
revA
|
The supervisor is the "main" component in the vehicle software. More...
#include <Supervisor.h>

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 Supervisor * | GetInstance () |
| 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... | |
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 Supervisor * | Instance_ |
Friends | |
| class | CommandLine |
| class | CBIT |
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.
| 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_.
|
virtual |
Destructor.
References Instance_.
|
private |
|
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().
|
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().
|
static |
|
static |
As part of orderly shutdown, delete the file at Data/running.
References Timespan::sleepFor().
Referenced by CommandLine::commandRestartSystem(), and terminate().
|
private |
Load up configuration settings.
References altConfig_, LogEngine::configAssociatedLogWriters(), Component::configure(), dataDir_, ComponentRegistry::GetEntryCount(), ComponentRegistry::GetIndexed(), Config::LoadConfigFiles(), logEngine_, and logger_.
Referenced by initialize().
|
static |
Call upon DecimationLogManager to configure automatic Logging of data.
References DecimationLogManager::configLog(), decimationLogManager_, and Instance_.
Referenced by CommandLine::commandConfigSet(), and Config::ParseLine().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_COURIER, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_COURIER, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_EXPRESS, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_EXPRESS, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
Referenced by GetLatestLogFilename(), and GetToShoreFilename().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_NORMAL, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_NORMAL, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_PRIORITY, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
|
staticprivate |
Helper function for GetToShoreFilename()
References LogWriter::SERVICE_PRIORITY, LogWriter::ServiceType2Str(), and LogWriter::ServiceType2Strlen().
Referenced by GetServiceFilter().
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().
|
inlinestaticprivate |
Returns singleton instance.
References Instance_.
|
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().
|
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().
|
staticprivate |
Helper function for GetToShoreFilename()
References FilterCourier(), FilterCourierLzma(), FilterExpress(), FilterExpressLzma(), FilterNormal(), FilterNormalLzma(), FilterPriority(), FilterPriorityLzma(), LogWriter::SERVICE_COURIER, LogWriter::SERVICE_EXPRESS, LogWriter::SERVICE_NORMAL, and LogWriter::SERVICE_PRIORITY.
Referenced by GetToShoreFilename().
|
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().
|
static |
Closes the current "toShore" file and begins a new one.
References decimationLogManager_, Instance_, DecimationLogManager::splits(), DecimationLogManager::writeFooters(), and DecimationLogManager::writeHeaders().
Referenced by LogSplitterComponent::run(), DataOverHttps::run(), and NAL9602::sendingVerify().
|
virtual |
Initialization.
Fill a little time.
Creates the logger and loads any modules. This fills the ComponentRegistry, but components aren't initialized.
References LogEngine::addAssociation(), altConfig_, argc_, argv_, CommandLine, commandLineHandler_, EventEntry::COMPONENT_ACTION, configure(), dataDir_, Syslog::DEBUG, decimationLogManager_, LogEntry::DIRECTORY_LOG_ENTRY, Syslog::ERROR, LogEntry::EVENT_LOG_ENTRY, Syslog::FAULT, KmlLogWriter::GetKmlArgs(), KmlLogWriter::GetKmlErrors(), KmlLogWriter::GetKmlUnits(), Syslog::INFO, BehaviorRegistry::Initialize(), ComponentRegistry::Initialize(), ComponentRegistry::Insert(), kmlApproximationWriter_, kmlFileWriter_, ModuleLoader::loadModules(), logEngine_, logger_, maintainer_, missionManager_, moduleLoader_, Units::NONE, Slate::ReadOnce(), reporter_, RunSimsInRealTime_, SetRestart(), StrValue::setString(), slateDirFileWriter_, slateFileWriter_, slateWriter_, EventEntry::START_CYCLE, Logger::syslog(), syslogFileWriter_, and StrValue::toString().
Referenced by run_code().
|
static |
Indicates if mission manager is failed.
References Instance_, Component::isFailed(), and missionManager_.
Referenced by VerticalControl::controlVertical().
|
static |
Indicates if a loaded mission is running.
References Instance_, MissionManager::isMissionRunning(), and missionManager_.
Referenced by ScheduledItem::DoScheduled().
|
inlinestatic |
References RunSimsInRealTime_.
Referenced by Handler::runBetween().
|
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().
|
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().
|
private |
Loads the specified mission file.
References MissionManager::loadFromFile(), and missionManager_.
Referenced by CommandLine::commandLoad().
|
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().
|
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().
|
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().
|
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().
|
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().
|
static |
Create a new directory in Logs and begin writing to it.
References dataDir_, decimationLogManager_, LinearApproximationLogWriter::forceWriteRow(), GenerateDataDir(), Instance_, kmlApproximationWriter_, kmlFileWriter_, LogEngine::lockProcessing(), LogWriter::lockWrites(), logEngine_, DecimationLogManager::resetDirectoryEntries(), SplitFileLogWriter::resetFileBase(), DecimationLogManager::resetFileBases(), FileLogWriter::resetFilename(), BinaryLogWriter::resetTimeBase(), slateDirFileWriter_, slateFileWriter_, slateWriter_, syslogFileWriter_, LogEngine::unlockProcessing(), LogWriter::unlockWrites(), LinearApproximationLogWriter::writeFooter(), DecimationLogManager::writeFooters(), LinearApproximationLogWriter::writeHeader(), and DecimationLogManager::writeHeaders().
Referenced by CommandLine::commandRestartLogs().
|
private |
Resumes a previously stopped mission.
References MissionManager::loadFromFile(), missionManager_, and MissionManager::resumeLoadedMission().
Referenced by CommandLine::commandResume().
|
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().
|
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().
|
static |
Forces an entry into the shore log.
References decimationLogManager_, DecimationLogManager::forceWrite(), and Instance_.
Referenced by SendDataComponent::run().
|
staticprivate |
References Argc_, Args_, Argv_, and ClearArgs().
Referenced by CommandLine::commandRestartApplication().
|
inlinestaticprivate |
References Restart_.
Referenced by CommandLine::commandRestartApplication(), and initialize().
|
private |
Causes the currently running mission stack to be displayed.
References MissionManager::logStack(), and missionManager_.
Referenced by CommandLine::commandShowStack().
|
private |
References commandLineHandler_, and Handler::run().
Referenced by run().
|
private |
Kills the currently running mission file.
References Component::BLOCK_COMPLETED, missionManager_, and Component::setState().
Referenced by CBIT::checkCriticals(), CBIT::checkDepth(), CBIT::checkLeak(), CommandLine::commandStop(), CBIT::monitorEnvironmentals(), and terminate().
|
private |
Terminates Supervisor run – available only to CommandLine.
References ClearRunningFile(), running_, and stopMission().
Referenced by CommandLine::run().
|
static |
If there is a file at Data/running, set WasRunning_ to true; Otherwise, just create file.
References WasRunning_.
Referenced by run_code().
|
virtual |
Uninitialization.
Spins down the threads, unloads the modules and deletes any of its own components.
References commandLineHandler_, decimationLogManager_, FlexArrayBase::isEmpty(), loadedModules_, logger_, maintainer_, FlexArray< T >::pop(), Handler::shutdown(), ComponentRegistry::ShutdownThreads(), Logger::syslog(), BehaviorRegistry::Uninitialize(), DirectoryLogWriter::Uninitialize(), Config::Uninitialize(), ComponentRegistry::Uninitialize(), and Slate::Uninitialize().
Referenced by run_code().
|
inlinestatic |
References WasRunning_.
Referenced by CBIT::initialize(), and Config::LoadPersistedConfigSets().
|
friend |
|
friend |
Referenced by initialize().
|
private |
Referenced by configure(), and initialize().
|
staticprivate |
Arguments passed to main when restarting.
Referenced by ClearArgs(), GetArgc(), and SetArgs().
|
private |
Arguments passed from main.
Referenced by initialize(), and run().
|
staticprivate |
Referenced by ClearArgs(), and SetArgs().
|
staticprivate |
Referenced by ClearArgs(), GetArgv(), and SetArgs().
|
private |
Referenced by initialize(), and run().
|
private |
Command handler.
Referenced by initialize(), startCommandLine(), and uninitialize().
|
private |
Where to write data!
Referenced by configure(), initialize(), and RestartLogs().
|
private |
Manages the "toShore" files.
Referenced by ConfigureDecimation(), IncrementShoreFile(), initialize(), RestartLogs(), SendData(), and uninitialize().
|
staticprivate |
Referenced by CBIT::checkCriticals(), CBIT::checkDepth(), CBIT::checkLeak(), ConfigureDecimation(), GetInstance(), GetQueuedSBD(), IncrementShoreFile(), IsMissionManagerFailed(), IsMissionRunning(), CBIT::monitorEnvironmentals(), QueueSBD(), RestartLogs(), SendData(), Supervisor(), and ~Supervisor().
|
private |
Referenced by initialize(), and RestartLogs().
|
private |
Referenced by initialize(), and RestartLogs().
|
private |
Module handling.
Referenced by uninitialize().
|
private |
Main LogEngine for the system.
Referenced by configure(), initialize(), and RestartLogs().
|
private |
Logger for Supervisor.
Referenced by addMaintain(), addReport(), configure(), initialize(), listMaintains(), listReports(), removeAllMaintains(), removeAllReports(), removeMaintain(), removeReport(), run(), and uninitialize().
|
private |
Maintains values specified at console.
Referenced by addMaintain(), initialize(), listMaintains(), removeAllMaintains(), removeMaintain(), and uninitialize().
|
private |
Mission handling.
Referenced by initialize(), IsMissionManagerFailed(), IsMissionRunning(), loadMission(), resumeMission(), runMission(), showStack(), and stopMission().
|
private |
Referenced by initialize().
|
private |
Reporting to console.
Referenced by addReport(), initialize(), listReports(), removeAllReports(), and removeReport().
|
staticprivate |
Flag set when it's time to restart.
Referenced by IsRestart(), and SetRestart().
|
private |
For shutdown purposes.
Referenced by run(), and terminate().
|
staticprivate |
To make simulated missions run in real-time.
Referenced by initialize(), and IsRunningSimsInRealTime().
|
private |
Queue of SBDs to re-send to shore.
Referenced by GetQueuedSBD(), and QueueSBD().
|
private |
Referenced by initialize(), and RestartLogs().
|
private |
Referenced by initialize(), and RestartLogs().
|
private |
Referenced by initialize(), and RestartLogs().
|
private |
Write logs.
Referenced by initialize(), and RestartLogs().
|
staticprivate |
Referenced by TouchRunningFile(), and WasRunning().