#include <RubyMeasure.hpp>
Public Member Functions | |
Constructors and Destructors | |
RubyMeasure (const BCLMeasure &bclMeasure, bool isSelected=true) | |
Constructor from BCLMeasure. More... | |
RubyMeasure (const openstudio::path &perturbationScript, const FileReferenceType &inputFileType, const FileReferenceType &outputFileType, bool isUserScript=false, bool isSelected=true) | |
Constructor. More... | |
RubyMeasure (const UUID &uuid, const UUID &versionUUID, const std::string &name, const std::string &displayName, const std::string &description, bool isSelected, const FileReference &perturbationScriptOrBCLMeasureDir, const FileReferenceType &inputFileType, const FileReferenceType &outputFileType, bool isUserScript, const std::vector< ruleset::OSArgument > &arguments, bool usesBCLMeasure) | |
Constructor provided for deserialization; not for general use. More... | |
virtual | ~RubyMeasure () |
Getters and Queries | |
bool | usesBCLMeasure () const |
Temporary boolean to indicate whether this perturbation works off of a BCLMeasure or a FileReferenece. More... | |
boost::optional< BCLMeasure > | bclMeasure () const |
Returns the BCLMeasure. More... | |
boost::optional< BCLMeasure > | measure () const |
openstudio::path | bclMeasureDirectory () const |
Returns the BCLMeasure's directory. More... | |
openstudio::path | measureDirectory () const |
UUID | bclMeasureUUID () const |
Returns the BCLMeasure's UUID. More... | |
UUID | measureUUID () const |
UUID | bclMeasureVersionUUID () const |
Returns the BCLMeasure's version UUID. More... | |
UUID | measureVersionUUID () const |
FileReference | perturbationScript () const |
Returns the file reference. More... | |
std::vector< ruleset::OSArgument > | arguments () const |
Return the arguments to be passed to the perturbation ruby script as a vector of ruleset::OSArguments. More... | |
bool | isUserScript () const |
If not usesBCLMeasure(), indicates whether the file pointed to follows ruleset::UserScript syntax or not. More... | |
bool | hasIncompleteArguments () const |
Returns !incompleteArguments().empty(). More... | |
std::vector< ruleset::OSArgument > | incompleteArguments () const |
Returns any arguments() that are required but do not have a value or default value set. More... | |
Setters | |
bool | setMeasure (const BCLMeasure &measure) |
Sets measure to measure, calls clearArguments, and returns true if measure's file types are okay with the current use of this RubyMeasure. More... | |
bool | updateMeasure (const BCLMeasure &newVersion, std::vector< ruleset::OSArgument > newArguments) |
Updates measure to newVersion and merges current argument values with newArguments if newVersion has the same UUID as measure() and has compatible file types for the current use of this RubyMeasure. More... | |
bool | setPerturbationScript (const openstudio::path &script, const FileReferenceType &inputFileType, const FileReferenceType &outputFileType, bool isUserScript) |
Sets the perturbationScript to script and clears all arguments. More... | |
void | setIsUserScript (bool isUserScript) |
void | addArgument (const std::string &name) |
Add an argument to this script. More... | |
void | addArgument (const std::string &name, const std::string &value) |
Add an argument to this script. More... | |
bool | addArgument (const ruleset::OSArgument &argument) |
Add argument to this script. More... | |
void | setArgument (const ruleset::OSArgument &argument) |
Sets argument. More... | |
void | setArguments (const std::vector< ruleset::OSArgument > &arguments) |
Replaces current arguments with the provided vector. More... | |
bool | removeArgument (const std::string &argumentName) |
Removes argument named argumentName. More... | |
void | clearArguments () |
Public Member Functions inherited from openstudio::analysis::Measure | |
virtual | ~Measure () |
bool | isSelected () const |
boost::optional < FileReferenceType > | inputFileType () const |
boost::optional < FileReferenceType > | outputFileType () const |
void | setIsSelected (bool isSelected) |
runmanager::WorkItem | createWorkItem (const openstudio::path &rubyIncludeDirectory) const |
Public Member Functions inherited from openstudio::analysis::AnalysisObject | |
virtual | ~AnalysisObject () |
AnalysisObject | clone () const |
Deep copy. More... | |
std::string | name () const |
std::string | displayName () const |
std::string | description () const |
openstudio::UUID | uuid () const |
openstudio::UUID | versionUUID () const |
bool | isDirty () const |
Returns true if this object has been changed since its dirty flag was last cleared. More... | |
bool | operator== (const AnalysisObject &other) const |
Compare impls. More... | |
bool | operator!= (const AnalysisObject &other) const |
bool | uuidEqual (const AnalysisObject &other) const |
bool | uuidAndVersionEqual (const AnalysisObject &other) const |
boost::optional< AnalysisObject > | parent () const |
void | setName (const std::string &newName) |
void | setDisplayName (const std::string &newDisplayName) |
void | setDescription (const std::string &newDescription) |
bool | clearDirtyFlag () |
Call this method to reset the dirty flag of this object and all its children. More... | |
bool | connect (const char *signal, const QObject *receiver, const char *slot, Qt::ConnectionType type=Qt::AutoConnection) const |
Connect signal from this AnalysisObject to slot on receiver. More... | |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *slot=nullptr) const |
template<typename T > | |
T | cast () const |
Cast to type T. More... | |
template<typename T > | |
boost::optional< T > | optionalCast () const |
Cast to boost::optional<T>. More... | |
Related Functions | |
(Note that these are not member functions.) | |
typedef boost::optional < RubyMeasure > | OptionalRubyMeasure |
typedef boost::optional < RubyMeasure > | OptionalRubyPerturbation |
typedef std::vector< RubyMeasure > | RubyMeasureVector |
typedef RubyMeasure | RubyPerturbation |
typedef std::vector< RubyMeasure > | RubyPerturbationVector |
Related Functions inherited from openstudio::analysis::Measure | |
typedef Measure | DiscretePerturbation |
typedef std::vector< Measure > | DiscretePerturbationVector |
typedef std::vector< Measure > | MeasureVector |
typedef boost::optional< Measure > | OptionalDiscretePerturbation |
typedef boost::optional< Measure > | OptionalMeasure |
Related Functions inherited from openstudio::analysis::AnalysisObject | |
typedef std::vector < AnalysisObject > | AnalysisObjectVector |
typedef boost::optional < AnalysisObject > | OptionalAnalysisObject |
RubyMeasure is a Measure that modifies a model (OSM or IDF file) using a Ruby script.
The preferred way to create a RubyMeasure is with a BCLMeasure, see openstudio/bcl/BCLMeasure, ruleset::ModelUserScript, and ruleset::WorkspaceUserScript. In brief, a BCLMeasure is a specially structured folder, the contents of which includes a measure.rb file, which in turn contains the definition of a class that derives from ruleset::UserScript. Such scripts may be parameterized with ruleset::OSArguments, and can be run from various entry points in OpenStudio, including from this class within the analysis framework (with the help of the runmanager and analysisdriver sub-projects).
For now, RubyMeasures can also be defined by referencing a Ruby script directly (free-form or following the interface specified by the ruleset::UserScript classes). However, these features will be deprecated in time.
openstudio::analysis::RubyMeasure::RubyMeasure | ( | const BCLMeasure & | bclMeasure, |
bool | isSelected = true |
||
) |
Constructor from BCLMeasure.
openstudio::analysis::RubyMeasure::RubyMeasure | ( | const openstudio::path & | perturbationScript, |
const FileReferenceType & | inputFileType, | ||
const FileReferenceType & | outputFileType, | ||
bool | isUserScript = false , |
||
bool | isSelected = true |
||
) |
Constructor.
Measure script can be self-contained script that handles its own arguments or a file that contains a class derived from ruleset::UserScript.
If perturbationScript contains a rulset::UserScript, its type should match inputFileType and outputFileType. That is, if the UserScript is a ModelUserScript, inputFileType == outputFileType == FileReferenceType::OSM. The isUserScript boolean should also be set to true in this case.
openstudio::analysis::RubyMeasure::RubyMeasure | ( | const UUID & | uuid, |
const UUID & | versionUUID, | ||
const std::string & | name, | ||
const std::string & | displayName, | ||
const std::string & | description, | ||
bool | isSelected, | ||
const FileReference & | perturbationScriptOrBCLMeasureDir, | ||
const FileReferenceType & | inputFileType, | ||
const FileReferenceType & | outputFileType, | ||
bool | isUserScript, | ||
const std::vector< ruleset::OSArgument > & | arguments, | ||
bool | usesBCLMeasure | ||
) |
Constructor provided for deserialization; not for general use.
|
inlinevirtual |
void openstudio::analysis::RubyMeasure::addArgument | ( | const std::string & | name | ) |
Add an argument to this script.
The argument will be stored as a ruleset::OSArgument, and passed in as –#{name}.
void openstudio::analysis::RubyMeasure::addArgument | ( | const std::string & | name, |
const std::string & | value | ||
) |
Add an argument to this script.
The argument will be stored as a ruleset::OSArgument, and passed in as –#{name}=#{value}.
bool openstudio::analysis::RubyMeasure::addArgument | ( | const ruleset::OSArgument & | argument | ) |
Add argument to this script.
Returns false if !argument.hasValue() && !argument.hasDefaultValue(), but will still register the argument.
std::vector<ruleset::OSArgument> openstudio::analysis::RubyMeasure::arguments | ( | ) | const |
Return the arguments to be passed to the perturbation ruby script as a vector of ruleset::OSArguments.
If this RubyMeasure is used by one or more RubyContinuousVariables, this may be an incomplete listing from the script's perspective.
boost::optional<BCLMeasure> openstudio::analysis::RubyMeasure::bclMeasure | ( | ) | const |
Returns the BCLMeasure.
Throws if not usesBCLMeasure(). Returns boost::none if measure cannot be located on file system.
openstudio::path openstudio::analysis::RubyMeasure::bclMeasureDirectory | ( | ) | const |
Returns the BCLMeasure's directory.
Throws if not usesBCLMeasure().
UUID openstudio::analysis::RubyMeasure::bclMeasureUUID | ( | ) | const |
Returns the BCLMeasure's UUID.
Throws if not usesBCLMeasure().
UUID openstudio::analysis::RubyMeasure::bclMeasureVersionUUID | ( | ) | const |
Returns the BCLMeasure's version UUID.
Throws if not usesBCLMeasure().
void openstudio::analysis::RubyMeasure::clearArguments | ( | ) |
bool openstudio::analysis::RubyMeasure::hasIncompleteArguments | ( | ) | const |
Returns !incompleteArguments().empty().
std::vector<ruleset::OSArgument> openstudio::analysis::RubyMeasure::incompleteArguments | ( | ) | const |
Returns any arguments() that are required but do not have a value or default value set.
bool openstudio::analysis::RubyMeasure::isUserScript | ( | ) | const |
If not usesBCLMeasure(), indicates whether the file pointed to follows ruleset::UserScript syntax or not.
boost::optional<BCLMeasure> openstudio::analysis::RubyMeasure::measure | ( | ) | const |
openstudio::path openstudio::analysis::RubyMeasure::measureDirectory | ( | ) | const |
UUID openstudio::analysis::RubyMeasure::measureUUID | ( | ) | const |
UUID openstudio::analysis::RubyMeasure::measureVersionUUID | ( | ) | const |
FileReference openstudio::analysis::RubyMeasure::perturbationScript | ( | ) | const |
bool openstudio::analysis::RubyMeasure::removeArgument | ( | const std::string & | argumentName | ) |
Removes argument named argumentName.
void openstudio::analysis::RubyMeasure::setArgument | ( | const ruleset::OSArgument & | argument | ) |
Sets argument.
Replaces any existing argument with the same name, otherwise, adds it to the list.
void openstudio::analysis::RubyMeasure::setArguments | ( | const std::vector< ruleset::OSArgument > & | arguments | ) |
Replaces current arguments with the provided vector.
void openstudio::analysis::RubyMeasure::setIsUserScript | ( | bool | isUserScript | ) |
bool openstudio::analysis::RubyMeasure::setMeasure | ( | const BCLMeasure & | measure | ) |
Sets measure to measure, calls clearArguments, and returns true if measure's file types are okay with the current use of this RubyMeasure.
Does nothing and returns false otherwise.
bool openstudio::analysis::RubyMeasure::setPerturbationScript | ( | const openstudio::path & | script, |
const FileReferenceType & | inputFileType, | ||
const FileReferenceType & | outputFileType, | ||
bool | isUserScript | ||
) |
Sets the perturbationScript to script and clears all arguments.
bool openstudio::analysis::RubyMeasure::updateMeasure | ( | const BCLMeasure & | newVersion, |
std::vector< ruleset::OSArgument > | newArguments | ||
) |
Updates measure to newVersion and merges current argument values with newArguments if newVersion has the same UUID as measure() and has compatible file types for the current use of this RubyMeasure.
Does nothing and returns false otherwise. Upon successful completion, the return value of arguments() is in the same order as newArguments.
bool openstudio::analysis::RubyMeasure::usesBCLMeasure | ( | ) | const |
Temporary boolean to indicate whether this perturbation works off of a BCLMeasure or a FileReferenece.
|
related |
|
related |
|
related |
|
related |
|
related |