OpenStudio:utilities
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
openstudio::WorkflowJSON Class Reference

#include <WorkflowJSON.hpp>

Public Member Functions

std::vector< openstudio::pathabsoluteFilePaths () const
 
std::vector< openstudio::pathabsoluteMeasurePaths () const
 
openstudio::path absoluteOutPath () const
 
openstudio::path absoluteRootDir () const
 
openstudio::path absoluteRunDir () const
 
bool addFilePath (const openstudio::path &path)
 Add a path to the paths searched for files. More...
 
boost::optional< BCLMeasureaddMeasure (const BCLMeasure &bclMeasure)
 Add a measure to the measure dir, replaces existing measure with same id, does not add a step to the workflow. More...
 
bool addMeasurePath (const openstudio::path &path)
 Add a path to the paths searched for measures. More...
 
bool checkForUpdates ()
 Check for updates and return true if there are any, updates value of the stored hash. More...
 
WorkflowJSON clone () const
 Clones this WorkflowJSON into a separate one. More...
 
boost::optional< DateTimecompletedAt () const
 Returns the time this WorkflowJSON was completed at. More...
 
boost::optional< std::string > completedStatus () const
 Returns the completion status, "Success", "Fail", "Invalid", or "Cancel". More...
 
std::string computeHash () const
 Compute the current hash of the workflow. More...
 
boost::optional< DateTimecreatedAt () const
 Returns the time this WorkflowJSON was created at. More...
 
boost::optional< WorkflowStepcurrentStep () const
 Get the current step. More...
 
unsigned currentStepIndex () const
 Get the zero based index of the current step. More...
 
boost::optional< std::string > eplusoutErr () const
 Returns the content of eplusout.err file. More...
 
std::vector< openstudio::pathfilePaths () const
 Returns the paths that will be searched in order for files, default value is '. More...
 
boost::optional< openstudio::pathfindFile (const openstudio::path &file) const
 Attempts to find a file by path. More...
 
boost::optional< openstudio::pathfindFile (const std::string &fileName) const
 
boost::optional< openstudio::pathfindMeasure (const openstudio::path &measureDir) const
 Attempts to find a measure by path. More...
 
boost::optional< openstudio::pathfindMeasure (const std::string &measureDirName) const
 
boost::optional< BCLMeasuregetBCLMeasure (const MeasureStep &step) const
 Attempts to find the BCLMeasure for a given MeasureStep. More...
 
boost::optional< BCLMeasuregetBCLMeasureByUUID (const UUID &id) const
 Checks BCLMeasure for each MeasureStep attempting to find by id, does not check measures that are not in the workflow. More...
 
std::vector< MeasureStepgetMeasureSteps (const MeasureType &measureType) const
 Gets measure steps by measure type. More...
 
std::string hash () const
 Get a stored hash of the workflow. More...
 
bool incrementStep ()
 Increments current step, returns true if there is another step. More...
 
std::vector< openstudio::pathmeasurePaths () const
 Returns the paths that will be searched in order for measures, default value is '. More...
 
openstudio::path oswDir () const
 Returns the absolute path to the directory this workflow was loaded from or saved to. More...
 
boost::optional< openstudio::pathoswPath () const
 Returns the absolute path this workflow was loaded from or saved to, empty for new WorkflowJSON. More...
 
openstudio::path outPath () const
 Returns the path to write output OSW, default value is 'out.osw'. More...
 
void reset ()
 Reset to re-run the workflow, does not delete steps. More...
 
void resetFilePaths ()
 Clear paths searched for files. More...
 
void resetMeasurePaths ()
 Clear paths searched for measures. More...
 
void resetRunOptions ()
 Reset RunOptions for this workflow. More...
 
void resetSeedFile ()
 Resets the seed file path. More...
 
void resetWeatherFile ()
 Resets the weather file path. More...
 
void resetWorkflowSteps ()
 Resets the workflow steps. More...
 
openstudio::path rootDir () const
 Returns the root directory, default value is '. More...
 
openstudio::path runDir () const
 Returns the run directory, default value is '. More...
 
boost::optional< RunOptionsrunOptions () const
 Get RunOptions for this workflow. More...
 
bool save () const
 Saves this file to the current location. More...
 
bool saveAs (const openstudio::path &p)
 Saves this file to a new location. More...
 
boost::optional< openstudio::pathseedFile () const
 Returns the seed file path. More...
 
void setCompletedStatus (const std::string &status)
 Sets the completion status, "Success", "Fail", "Invalid", or "Cancel". More...
 
void setEplusoutErr (const std::string &eplusoutErr)
 Sets the content of eplusout.err file. More...
 
bool setMeasureSteps (const MeasureType &measureType, const std::vector< MeasureStep > &steps)
 Sets measure steps of a given type. More...
 
bool setOswDir (const openstudio::path &path)
 Sets the oswDir. More...
 
bool setOswPath (const openstudio::path &path)
 Sets the absolute path for this workflow. More...
 
bool setRunOptions (const RunOptions &options)
 Set RunOptions for this workflow. More...
 
bool setSeedFile (const openstudio::path &seedFile)
 Sets the seed file path. More...
 
bool setWeatherFile (const openstudio::path &weatherFile)
 Sets the weather file path. More...
 
bool setWorkflowSteps (const std::vector< WorkflowStep > &steps)
 Assigns the workflow steps. More...
 
void start ()
 Sets the started at time. More...
 
boost::optional< DateTimestartedAt () const
 Returns the time this WorkflowJSON was started at. More...
 
std::string string (bool includeHash=true) const
 Get the workflow as a string. More...
 
boost::optional< DateTimeupdatedAt () const
 Returns the time this WorkflowJSON was updated at. More...
 
boost::optional< openstudio::pathweatherFile () const
 Returns the weather file path. More...
 
 WorkflowJSON ()
 Create a new, empty workflow. More...
 
 WorkflowJSON (const std::string &s)
 Constructor with string, will throw if string is incorrect. More...
 
 WorkflowJSON (const openstudio::path &p)
 Constructor with path, will throw if path does not exist or file is incorrect. More...
 
std::vector< WorkflowStepworkflowSteps () const
 Returns the workflow steps. More...
 

Static Public Member Functions

static boost::optional
< WorkflowJSON
load (const std::string &s)
 Attempt to load a WorkflowJSON from string. More...
 
static boost::optional
< WorkflowJSON
load (const openstudio::path &p)
 Attempt to load a WorkflowJSON from path. More...
 

Protected Member Functions

 WorkflowJSON (std::shared_ptr< detail::WorkflowJSON_Impl > impl)
 Protected constructor from impl. More...
 

Detailed Description

Class for accessing the OpenStudio Workflow (OSW) JSON format.

Constructor & Destructor Documentation

openstudio::WorkflowJSON::WorkflowJSON ( )

Create a new, empty workflow.

openstudio::WorkflowJSON::WorkflowJSON ( const std::string &  s)

Constructor with string, will throw if string is incorrect.

openstudio::WorkflowJSON::WorkflowJSON ( const openstudio::path p)

Constructor with path, will throw if path does not exist or file is incorrect.

openstudio::WorkflowJSON::WorkflowJSON ( std::shared_ptr< detail::WorkflowJSON_Impl >  impl)
protected

Protected constructor from impl.

Member Function Documentation

std::vector<openstudio::path> openstudio::WorkflowJSON::absoluteFilePaths ( ) const
std::vector<openstudio::path> openstudio::WorkflowJSON::absoluteMeasurePaths ( ) const
openstudio::path openstudio::WorkflowJSON::absoluteOutPath ( ) const
openstudio::path openstudio::WorkflowJSON::absoluteRootDir ( ) const
openstudio::path openstudio::WorkflowJSON::absoluteRunDir ( ) const
bool openstudio::WorkflowJSON::addFilePath ( const openstudio::path path)

Add a path to the paths searched for files.

boost::optional<BCLMeasure> openstudio::WorkflowJSON::addMeasure ( const BCLMeasure bclMeasure)

Add a measure to the measure dir, replaces existing measure with same id, does not add a step to the workflow.

bool openstudio::WorkflowJSON::addMeasurePath ( const openstudio::path path)

Add a path to the paths searched for measures.

bool openstudio::WorkflowJSON::checkForUpdates ( )

Check for updates and return true if there are any, updates value of the stored hash.

WorkflowJSON openstudio::WorkflowJSON::clone ( ) const

Clones this WorkflowJSON into a separate one.

boost::optional<DateTime> openstudio::WorkflowJSON::completedAt ( ) const

Returns the time this WorkflowJSON was completed at.

boost::optional<std::string> openstudio::WorkflowJSON::completedStatus ( ) const

Returns the completion status, "Success", "Fail", "Invalid", or "Cancel".

"Success" will be set automatically if all steps in the workflow complete successfully. "Fail" will be set automatically if any step in the workflow reports an error. "Invalid" can be set by a measure if the workflow requests parameter combinations that are not valid. "Cancel" will be set automatically if a workflow is cancelled externally during execution.

std::string openstudio::WorkflowJSON::computeHash ( ) const

Compute the current hash of the workflow.

boost::optional<DateTime> openstudio::WorkflowJSON::createdAt ( ) const

Returns the time this WorkflowJSON was created at.

boost::optional<WorkflowStep> openstudio::WorkflowJSON::currentStep ( ) const

Get the current step.

unsigned openstudio::WorkflowJSON::currentStepIndex ( ) const

Get the zero based index of the current step.

If a simulation completes normally, current step index will be one higher than index of the last step. If a simulation is halted, current step index will point to the step after the last run step.

boost::optional<std::string> openstudio::WorkflowJSON::eplusoutErr ( ) const

Returns the content of eplusout.err file.

std::vector<openstudio::path> openstudio::WorkflowJSON::filePaths ( ) const

Returns the paths that will be searched in order for files, default value is '.

/files/'. Evaluated relative to rootDir if not absolute.

boost::optional<openstudio::path> openstudio::WorkflowJSON::findFile ( const openstudio::path file) const

Attempts to find a file by path.

If file is relative, searches through filePaths in order and returns first match that exists. If file is absolute, does not search for file in filePaths, only returns true it file exists.

boost::optional<openstudio::path> openstudio::WorkflowJSON::findFile ( const std::string &  fileName) const
boost::optional<openstudio::path> openstudio::WorkflowJSON::findMeasure ( const openstudio::path measureDir) const

Attempts to find a measure by path.

If measureDir is relative, searches through measurePaths in order and returns first match that exists. If measureDir is absolute, does not search for measureDir in measurePaths, only returns true it measureDir exists.

boost::optional<openstudio::path> openstudio::WorkflowJSON::findMeasure ( const std::string &  measureDirName) const
boost::optional<BCLMeasure> openstudio::WorkflowJSON::getBCLMeasure ( const MeasureStep step) const

Attempts to find the BCLMeasure for a given MeasureStep.

boost::optional<BCLMeasure> openstudio::WorkflowJSON::getBCLMeasureByUUID ( const UUID id) const

Checks BCLMeasure for each MeasureStep attempting to find by id, does not check measures that are not in the workflow.

std::vector<MeasureStep> openstudio::WorkflowJSON::getMeasureSteps ( const MeasureType measureType) const

Gets measure steps by measure type.

std::string openstudio::WorkflowJSON::hash ( ) const

Get a stored hash of the workflow.

bool openstudio::WorkflowJSON::incrementStep ( )

Increments current step, returns true if there is another step.

static boost::optional<WorkflowJSON> openstudio::WorkflowJSON::load ( const std::string &  s)
static

Attempt to load a WorkflowJSON from string.

static boost::optional<WorkflowJSON> openstudio::WorkflowJSON::load ( const openstudio::path p)
static

Attempt to load a WorkflowJSON from path.

std::vector<openstudio::path> openstudio::WorkflowJSON::measurePaths ( ) const

Returns the paths that will be searched in order for measures, default value is '.

/measures/'. Evaluated relative to rootDir if not absolute.

openstudio::path openstudio::WorkflowJSON::oswDir ( ) const

Returns the absolute path to the directory this workflow was loaded from or saved to.

Returns current working dir for new WorkflowJSON.

boost::optional<openstudio::path> openstudio::WorkflowJSON::oswPath ( ) const

Returns the absolute path this workflow was loaded from or saved to, empty for new WorkflowJSON.

openstudio::path openstudio::WorkflowJSON::outPath ( ) const

Returns the path to write output OSW, default value is 'out.osw'.

Evaluated relative to oswDir to ensure relative paths remain valid.

void openstudio::WorkflowJSON::reset ( )

Reset to re-run the workflow, does not delete steps.

void openstudio::WorkflowJSON::resetFilePaths ( )

Clear paths searched for files.

void openstudio::WorkflowJSON::resetMeasurePaths ( )

Clear paths searched for measures.

void openstudio::WorkflowJSON::resetRunOptions ( )

Reset RunOptions for this workflow.

void openstudio::WorkflowJSON::resetSeedFile ( )

Resets the seed file path.

void openstudio::WorkflowJSON::resetWeatherFile ( )

Resets the weather file path.

void openstudio::WorkflowJSON::resetWorkflowSteps ( )

Resets the workflow steps.

openstudio::path openstudio::WorkflowJSON::rootDir ( ) const

Returns the root directory, default value is '.

'. Evaluated relative to oswDir if not absolute.

openstudio::path openstudio::WorkflowJSON::runDir ( ) const

Returns the run directory, default value is '.

/run'. Evaluated relative to rootDir if not absolute.

boost::optional<RunOptions> openstudio::WorkflowJSON::runOptions ( ) const

Get RunOptions for this workflow.

bool openstudio::WorkflowJSON::save ( ) const

Saves this file to the current location.

bool openstudio::WorkflowJSON::saveAs ( const openstudio::path p)

Saves this file to a new location.

Updates the OSW path.

boost::optional<openstudio::path> openstudio::WorkflowJSON::seedFile ( ) const

Returns the seed file path.

Evaluated relative to filePaths if not absolute.

void openstudio::WorkflowJSON::setCompletedStatus ( const std::string &  status)

Sets the completion status, "Success", "Fail", "Invalid", or "Cancel".

Measure writers can call this with "Success" if all required results have been generated. Measure writers should not call this with "Fail", runner.registerError should be used instead. Measure writers can call this with "Invalid" if the workflow requests parameter combinations that are not valid. Measure writers should not call this with "Cancel", this is reserved for external cancel operations.

void openstudio::WorkflowJSON::setEplusoutErr ( const std::string &  eplusoutErr)

Sets the content of eplusout.err file.

bool openstudio::WorkflowJSON::setMeasureSteps ( const MeasureType measureType,
const std::vector< MeasureStep > &  steps 
)

Sets measure steps of a given type.

Does not change other measure steps.

bool openstudio::WorkflowJSON::setOswDir ( const openstudio::path path)

Sets the oswDir.

If oswPath is empty this does not set it. If oswPath is set, this changes directories but preserves file name.

bool openstudio::WorkflowJSON::setOswPath ( const openstudio::path path)

Sets the absolute path for this workflow.

bool openstudio::WorkflowJSON::setRunOptions ( const RunOptions options)

Set RunOptions for this workflow.

bool openstudio::WorkflowJSON::setSeedFile ( const openstudio::path seedFile)

Sets the seed file path.

bool openstudio::WorkflowJSON::setWeatherFile ( const openstudio::path weatherFile)

Sets the weather file path.

bool openstudio::WorkflowJSON::setWorkflowSteps ( const std::vector< WorkflowStep > &  steps)

Assigns the workflow steps.

void openstudio::WorkflowJSON::start ( )

Sets the started at time.

boost::optional<DateTime> openstudio::WorkflowJSON::startedAt ( ) const

Returns the time this WorkflowJSON was started at.

std::string openstudio::WorkflowJSON::string ( bool  includeHash = true) const

Get the workflow as a string.

boost::optional<DateTime> openstudio::WorkflowJSON::updatedAt ( ) const

Returns the time this WorkflowJSON was updated at.

boost::optional<openstudio::path> openstudio::WorkflowJSON::weatherFile ( ) const

Returns the weather file path.

Evaluated relative to filePaths if not absolute.

std::vector<WorkflowStep> openstudio::WorkflowJSON::workflowSteps ( ) const

Returns the workflow steps.