OpenStudioCore:ruleset
 All Classes Namespaces Functions Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
openstudio::ruleset::OSRunner Class Reference

#include <OSRunner.hpp>

Public Member Functions

void resetLastEnergyPlusSqlFilePath ()
 
void resetLastEnergyPlusWorkspace ()
 
void resetLastEnergyPlusWorkspacePath ()
 
void resetLastEpwFilePath ()
 
void resetLastOpenStudioModel ()
 
void resetLastOpenStudioModelPath ()
 
void setLastEnergyPlusSqlFilePath (const openstudio::path &lastEnergyPlusSqlFilePath)
 
void setLastEnergyPlusWorkspace (const openstudio::Workspace &lastEnergyPlusWorkspace)
 
void setLastEnergyPlusWorkspacePath (const openstudio::path &lastEnergyPlusWorkspacePath)
 
void setLastEpwFilePath (const openstudio::path &lastEpwFilePath)
 
void setLastOpenStudioModel (const openstudio::model::Model &lastOpenStudioModel)
 
void setLastOpenStudioModelPath (const openstudio::path &lastOpenStudioModelPath)
 
Constructors and Destructors
 OSRunner ()
 
virtual ~OSRunner ()
 
Getters and Queries
OSResult result () const
 Returns the OSResult for the last UserScript run by this OSRunner. More...
 
boost::optional
< openstudio::model::Model > 
lastOpenStudioModel () const
 Returns a copy of the last Model generated in the workflow if available. More...
 
boost::optional
< openstudio::Workspace > 
lastEnergyPlusWorkspace () const
 Returns a copy of the last EnergyPlus Workspace generated in the workflow if available. More...
 
boost::optional
< openstudio::SqlFile > 
lastEnergyPlusSqlFile () const
 Returns a copy of the last EnergyPlus SqlFile generated in the workflow if available. More...
 
boost::optional
< openstudio::EpwFile > 
lastEpwFile () const
 Returns a copy of the last EpwFile generated in the workflow if available. More...
 
boost::optional< openstudio::path > lastEpwFilePath () const
 Returns a path to the last EpwFile generated in the workflow if available. More...
 
virtual bool inSelection (const openstudio::model::ModelObject &modelObject) const
 Tests if the given ModelObject is in the application's current selection. More...
 
Actions
virtual std::map< std::string,
OSArgument
getUserInput (std::vector< OSArgument > &arguments) const
 Gets user input using dialog boxes, etc. More...
 
virtual void prepareForUserScriptRun (const UserScript &userScript)
 Initializes OSRunner for capturing data on a particular userScript. More...
 
virtual void registerError (const std::string &message)
 Registers error message with result, and sets result value to Fail. More...
 
virtual bool registerWarning (const std::string &message)
 Registers warning message with result. More...
 
virtual bool registerInfo (const std::string &message)
 Registers info message with result. More...
 
virtual void registerAsNotApplicable (const std::string &message)
 Sets result value to NA, and registers a corresponding info message. More...
 
virtual void registerInitialCondition (const std::string &message)
 Sets the result initial condition to message. More...
 
virtual void registerFinalCondition (const std::string &message)
 Sets the result final condition to message. More...
 
virtual void registerAttribute (Attribute &attribute)
 Saves attribute as an output result of the measure currently being run, and sets the attribute's source accordingly. More...
 
virtual void registerValue (const std::string &name, bool value)
 
virtual void registerValue (const std::string &name, const std::string &displayName, bool value)
 
virtual void registerValue (const std::string &name, double value)
 
virtual void registerValue (const std::string &name, double value, const std::string &units)
 
virtual void registerValue (const std::string &name, const std::string &displayName, double value)
 
virtual void registerValue (const std::string &name, const std::string &displayName, double value, const std::string &units)
 
virtual void registerValue (const std::string &name, int value)
 
virtual void registerValue (const std::string &name, int value, const std::string &units)
 
virtual void registerValue (const std::string &name, const std::string &displayName, int value)
 
virtual void registerValue (const std::string &name, const std::string &displayName, int value, const std::string &units)
 
virtual void registerValue (const std::string &name, const std::string &value)
 
virtual void registerValue (const std::string &name, const std::string &displayName, const std::string &value)
 
virtual void createProgressBar (const std::string &text) const
 Creates a progress bar with the text label. More...
 
virtual void updateProgress (const double &value) const
 Updates the progress bar to value (between 0 and 100). More...
 
virtual void destroyProgressBar () const
 Destroys the progress bar. More...
 
Common Error Checking Functions
bool validateUserArguments (const std::vector< OSArgument > &script_arguments, const std::map< std::string, OSArgument > &user_arguments)
 Returns true, logs no messages, and registers a value for each argument with a value or default value if all script_arguments are in user_arguments, and if all required script_arguments have been set or have defaults in user_arguments. More...
 
bool getBoolArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type boolean that is either required or has a default. More...
 
double getDoubleArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type double that is either required or has a default. More...
 
boost::optional< double > getOptionalDoubleArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type double that is optional (not required and does not have a default). More...
 
Quantity getQuantityArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type quantity that is either required or has a default. More...
 
boost::optional< Quantity > getOptionalQuantityArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type quantity that is optional (not required and does not have a default). More...
 
int getIntegerArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type integer that is either required or has a default. More...
 
boost::optional< int > getOptionalIntegerArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type integer that is optional (not required and does not have a default). More...
 
std::string getStringArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type string, choice, or path that is either required or has a default. More...
 
boost::optional< std::string > getOptionalStringArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type string, choice, or path that is optional (not required and does not have a default). More...
 
openstudio::path getPathArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type path that is either required or has a default. More...
 
boost::optional< openstudio::path > getOptionalPathArgumentValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments)
 Call this method to retrieve the value of an OSArgument of type path that is optional (not required and does not have a default). More...
 
boost::optional
< openstudio::WorkspaceObject > 
getOptionalWorkspaceObjectChoiceValue (const std::string &argument_name, const std::map< std::string, OSArgument > &user_arguments, const openstudio::Workspace &workspace)
 Call this method to retrieve the value of an OSArgument that was created by makeChoiceArgumentOfWorkspaceObjects. More...
 

Detailed Description

OSRunner is a concrete base class for application-specific classes that run UserScripts.

Constructor & Destructor Documentation

openstudio::ruleset::OSRunner::OSRunner ( )
virtual openstudio::ruleset::OSRunner::~OSRunner ( )
virtual

Member Function Documentation

virtual void openstudio::ruleset::OSRunner::createProgressBar ( const std::string &  text) const
virtual

Creates a progress bar with the text label.

Base class implementation does nothing.

virtual void openstudio::ruleset::OSRunner::destroyProgressBar ( ) const
virtual

Destroys the progress bar.

Base class implementation does nothing.

bool openstudio::ruleset::OSRunner::getBoolArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type boolean that is either required or has a default.

double openstudio::ruleset::OSRunner::getDoubleArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type double that is either required or has a default.

int openstudio::ruleset::OSRunner::getIntegerArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type integer that is either required or has a default.

boost::optional<double> openstudio::ruleset::OSRunner::getOptionalDoubleArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type double that is optional (not required and does not have a default).

boost::optional<int> openstudio::ruleset::OSRunner::getOptionalIntegerArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type integer that is optional (not required and does not have a default).

boost::optional<openstudio::path> openstudio::ruleset::OSRunner::getOptionalPathArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type path that is optional (not required and does not have a default).

boost::optional<Quantity> openstudio::ruleset::OSRunner::getOptionalQuantityArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type quantity that is optional (not required and does not have a default).

boost::optional<std::string> openstudio::ruleset::OSRunner::getOptionalStringArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type string, choice, or path that is optional (not required and does not have a default).

boost::optional<openstudio::WorkspaceObject> openstudio::ruleset::OSRunner::getOptionalWorkspaceObjectChoiceValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments,
const openstudio::Workspace &  workspace 
)

Call this method to retrieve the value of an OSArgument that was created by makeChoiceArgumentOfWorkspaceObjects.

openstudio::path openstudio::ruleset::OSRunner::getPathArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type path that is either required or has a default.

Quantity openstudio::ruleset::OSRunner::getQuantityArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type quantity that is either required or has a default.

std::string openstudio::ruleset::OSRunner::getStringArgumentValue ( const std::string &  argument_name,
const std::map< std::string, OSArgument > &  user_arguments 
)

Call this method to retrieve the value of an OSArgument of type string, choice, or path that is either required or has a default.

virtual std::map<std::string, OSArgument> openstudio::ruleset::OSRunner::getUserInput ( std::vector< OSArgument > &  arguments) const
virtual

Gets user input using dialog boxes, etc.

Result is map of name to argument. Result is empty if user cancels or user did not provide values for all required arguments. Base class implementation simply creates a map, with no information added, from arguments.

virtual bool openstudio::ruleset::OSRunner::inSelection ( const openstudio::model::ModelObject &  modelObject) const
virtual

Tests if the given ModelObject is in the application's current selection.

Base class implementation always returns true.

boost::optional<openstudio::SqlFile> openstudio::ruleset::OSRunner::lastEnergyPlusSqlFile ( ) const

Returns a copy of the last EnergyPlus SqlFile generated in the workflow if available.

boost::optional<openstudio::Workspace> openstudio::ruleset::OSRunner::lastEnergyPlusWorkspace ( ) const

Returns a copy of the last EnergyPlus Workspace generated in the workflow if available.

boost::optional<openstudio::EpwFile> openstudio::ruleset::OSRunner::lastEpwFile ( ) const

Returns a copy of the last EpwFile generated in the workflow if available.

boost::optional<openstudio::path> openstudio::ruleset::OSRunner::lastEpwFilePath ( ) const

Returns a path to the last EpwFile generated in the workflow if available.

boost::optional<openstudio::model::Model> openstudio::ruleset::OSRunner::lastOpenStudioModel ( ) const

Returns a copy of the last Model generated in the workflow if available.

virtual void openstudio::ruleset::OSRunner::prepareForUserScriptRun ( const UserScript userScript)
virtual

Initializes OSRunner for capturing data on a particular userScript.

Replaces result with a default-constructed result, and keeps the userScript name for use in log messages. Should be called at the beginning of every UserScript. Is called by the UserScript C++ classes' run methods.

virtual void openstudio::ruleset::OSRunner::registerAsNotApplicable ( const std::string &  message)
virtual

Sets result value to NA, and registers a corresponding info message.

In most circumstances, UserScripts should return true after calling this method.

virtual void openstudio::ruleset::OSRunner::registerAttribute ( Attribute &  attribute)
virtual

Saves attribute as an output result of the measure currently being run, and sets the attribute's source accordingly.

virtual void openstudio::ruleset::OSRunner::registerError ( const std::string &  message)
virtual

Registers error message with result, and sets result value to Fail.

UserScripts should return false after calling this method.

virtual void openstudio::ruleset::OSRunner::registerFinalCondition ( const std::string &  message)
virtual

Sets the result final condition to message.

virtual bool openstudio::ruleset::OSRunner::registerInfo ( const std::string &  message)
virtual

Registers info message with result.

Base class returns true. Derived classes may choose to present a prompt to the user. The UserScript should exit (return false) if false is returned.

virtual void openstudio::ruleset::OSRunner::registerInitialCondition ( const std::string &  message)
virtual

Sets the result initial condition to message.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
bool  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
bool  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
double  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
double  value,
const std::string &  units 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
double  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
double  value,
const std::string &  units 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
int  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
int  value,
const std::string &  units 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
int  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
int  value,
const std::string &  units 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual void openstudio::ruleset::OSRunner::registerValue ( const std::string &  name,
const std::string &  displayName,
const std::string &  value 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

virtual bool openstudio::ruleset::OSRunner::registerWarning ( const std::string &  message)
virtual

Registers warning message with result.

Base class returns true. Derived classes may choose to present a prompt to the user. The UserScript should exit (return false) if false is returned.

void openstudio::ruleset::OSRunner::resetLastEnergyPlusSqlFilePath ( )
void openstudio::ruleset::OSRunner::resetLastEnergyPlusWorkspace ( )
void openstudio::ruleset::OSRunner::resetLastEnergyPlusWorkspacePath ( )
void openstudio::ruleset::OSRunner::resetLastEpwFilePath ( )
void openstudio::ruleset::OSRunner::resetLastOpenStudioModel ( )
void openstudio::ruleset::OSRunner::resetLastOpenStudioModelPath ( )
OSResult openstudio::ruleset::OSRunner::result ( ) const

Returns the OSResult for the last UserScript run by this OSRunner.

(prepareForUserScriptRun should be called prior to each run to ensure that result() corresponds to a single script, and is not instead a running result over multiple scripts. One way to ensure that this happens is to call the default version of run in ModelUserScript, etc. at the beginning of any particular run method.)

void openstudio::ruleset::OSRunner::setLastEnergyPlusSqlFilePath ( const openstudio::path &  lastEnergyPlusSqlFilePath)
void openstudio::ruleset::OSRunner::setLastEnergyPlusWorkspace ( const openstudio::Workspace &  lastEnergyPlusWorkspace)
void openstudio::ruleset::OSRunner::setLastEnergyPlusWorkspacePath ( const openstudio::path &  lastEnergyPlusWorkspacePath)
void openstudio::ruleset::OSRunner::setLastEpwFilePath ( const openstudio::path &  lastEpwFilePath)
void openstudio::ruleset::OSRunner::setLastOpenStudioModel ( const openstudio::model::Model &  lastOpenStudioModel)
void openstudio::ruleset::OSRunner::setLastOpenStudioModelPath ( const openstudio::path &  lastOpenStudioModelPath)
virtual void openstudio::ruleset::OSRunner::updateProgress ( const double &  value) const
virtual

Updates the progress bar to value (between 0 and 100).

Base class implementation does nothing.

bool openstudio::ruleset::OSRunner::validateUserArguments ( const std::vector< OSArgument > &  script_arguments,
const std::map< std::string, OSArgument > &  user_arguments 
)

Returns true, logs no messages, and registers a value for each argument with a value or default value if all script_arguments are in user_arguments, and if all required script_arguments have been set or have defaults in user_arguments.

Otherwise, returns false and registers an error if there are any type mismatches, or if any required or defaulted arguments are missing (entirely, or their values are not set). All other discrepencies are logged as warnings.