Skip to content

Commit

Permalink
Added to command line.
Browse files Browse the repository at this point in the history
Added log port setting to the command line. Changed default setting for CUDA
device to none because nvidia likes throwing unknown exceptions otherwise.
  • Loading branch information
4ctrl-alt-del committed Oct 25, 2019
1 parent 4310891 commit d89fcf9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
28 changes: 23 additions & 5 deletions src/cli/ace_helprun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ void HelpRun::settingsSetHelp()
{
// Initialize an enumeration and string list used to determine what setting set
// command was given to get help on, if any.
enum {CUDA,OpenCL,Threads,Buffer,ChunkDir,ChunkPre,ChunkExt,Logging};
QStringList list {"cuda","opencl","threads","buffer","chunkdir","chunkpre","chunkext","logging"};
enum {CUDA,OpenCL,Threads,Buffer,ChunkDir,ChunkPre,ChunkExt,Logging,LogPort};
QStringList list {"cuda","opencl","threads","buffer","chunkdir","chunkpre","chunkext","logging","logport"};

// Create an empty command string, setting it to this run's next command argument
// is any exists.
Expand Down Expand Up @@ -637,6 +637,9 @@ void HelpRun::settingsSetHelp()
case Logging:
settingsSetLoggingHelp();
break;
case LogPort:
settingsSetLogPortHelp();
break;
default:
{
// If the setting set command was not recognized or was empty then print the basic
Expand All @@ -645,11 +648,12 @@ void HelpRun::settingsSetHelp()
stream << "Command: " << _runName << " settings set <key> <value>\n"
<< "Updates a persistent setting with the given key to the new given value.\n\n"
<< " key: The key of the setting that will be updated to a new value. Valid keys\n"
<< " are cuda, opencl, threads, buffer, chunkdir, chunkpre, chunkext, and\n"
<< " logging.\n\n"
<< " are cuda, opencl, threads, buffer, chunkdir, chunkpre, chunkext,\n"
<< " logging, and logport.\n\n"
<< "value: The new value of the given setting.\n\n"
<< "Help: " << _runName << " help settings set <key>\n"
<< "Get help about a specific setting to set with the given key.\n\n";
<< "Get help about a specific setting to set with the given key.\n\n"
<< "Valid settings set keys:\n";
break;
}
}
Expand Down Expand Up @@ -822,6 +826,20 @@ void HelpRun::settingsSetLoggingHelp()



void HelpRun::settingsSetLogPortHelp()
{
QTextStream stream(stdout);
stream << "Command: " << _runName << " settings set logport <port>\n"
<< "Updates the logging port setting. The logging port is the port number the ACE\n"
<< "logging system listens on for logging client connections.\n\n"
<< "port: The new port number.\n\n";
}






/*!
* Displays the help text for the settings list command.
*/
Expand Down
1 change: 1 addition & 0 deletions src/cli/ace_helprun.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace Ace
void settingsSetChunkPreHelp();
void settingsSetChunkExtHelp();
void settingsSetLoggingHelp();
void settingsSetLogPortHelp();
void settingsListHelp();
/*!
* The command arguments parsed out of the command line arguments of the main
Expand Down
40 changes: 38 additions & 2 deletions src/cli/ace_settingsrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void SettingsRun::execute()
stream << " Chunk Prefix: " << settings.chunkPrefix() << "\n";
stream << " Chunk Extension: " << settings.chunkExtension() << "\n";
stream << " Logging: " << ( settings.loggingEnabled() ? QStringLiteral("on") : QStringLiteral("off") ) << "\n";
stream << " Logging Port: " << settings.loggingPort() << "\n";
}

// Else call the setting parser method to determine which command was given.
Expand Down Expand Up @@ -197,8 +198,8 @@ void SettingsRun::set()
}

// Create an enumeration and string list used to determine the command given.
enum {Unknown=-1,CUDACom,OpenCLCom,Threads,Buffer,ChunkDir,ChunkPre,ChunkExt,Logging};
QStringList list {"cuda","opencl","threads","buffer","chunkdir","chunkpre","chunkext","logging"};
enum {Unknown=-1,CUDACom,OpenCLCom,Threads,Buffer,ChunkDir,ChunkPre,ChunkExt,Logging,LogPort};
QStringList list {"cuda","opencl","threads","buffer","chunkdir","chunkpre","chunkext","logging","logport"};

// Determine which setting is to be set by the command given, calling the
// appropriate method and popping this object's first command argument.
Expand Down Expand Up @@ -229,6 +230,9 @@ void SettingsRun::set()
case Logging:
setLogging();
break;
case LogPort:
setLogPort();
break;
case Unknown:
{
// The set command is not known so throw an exception informing the user.
Expand Down Expand Up @@ -565,6 +569,38 @@ void SettingsRun::setLogging()



void SettingsRun::setLogPort()
{
// Add the debug header.
EDEBUG_FUNC(this);

// Make sure there is a command argument to process.
if ( _command.size() < 1 )
{
E_MAKE_EXCEPTION(e);
e.setTitle(QObject::tr("Invalid argument"));
e.setDetails(QObject::tr("Settings set logport requires sub argument, exiting..."));
throw e;
}

bool ok;
int port {_command.first().toInt(&ok)};
if ( !ok || port < 0 || port > 65535 )
{
E_MAKE_EXCEPTION(e);
e.setTitle(QObject::tr("Invalid argument"));
e.setDetails(QObject::tr("Given logging port '%1' invalid, exiting...").arg(_command.first()));
throw e;
}

Ace::Settings::instance().setLoggingPort(port);
}






/*!
* Executes the settings list command, parsing the first argument to determine
* which specific list command is to be executed and calling the appropriate
Expand Down
1 change: 1 addition & 0 deletions src/cli/ace_settingsrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Ace
void setChunkPre();
void setChunkExt();
void setLogging();
void setLogPort();
void list();
void listCUDA();
void listOpenCL();
Expand Down
2 changes: 1 addition & 1 deletion src/core/ace_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace Ace
/*!
* The default CUDA device index value.
*/
constexpr static int _cudaDeviceDefault {0};
constexpr static int _cudaDeviceDefault {-1};
/*!
* The default OpenCL platform index value.
*/
Expand Down

0 comments on commit d89fcf9

Please sign in to comment.