OpenStudio:utilities
Loading...
Searching...
No Matches
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) const
 Add a path to the paths searched for files.
 
boost::optional< BCLMeasureaddMeasure (const BCLMeasure &bclMeasure) const
 Add a measure to the measure dir, replaces existing measure with same id, does not add a step to the workflow.
 
bool addMeasurePath (const openstudio::path &path) const
 Add a path to the paths searched for measures.
 
bool checkForUpdates () const
 Check for updates and return true if there are any, updates value of the stored hash.
 
WorkflowJSON clone () const
 Clones this WorkflowJSON into a separate one.
 
boost::optional< DateTimecompletedAt () const
 Returns the time this WorkflowJSON was completed at.
 
boost::optional< std::string > completedStatus () const
 Returns the completion status, "Success", "Fail", "Invalid", or "Cancel".
 
std::string computeHash () const
 Compute the current hash of the workflow.
 
boost::optional< DateTimecreatedAt () const
 Returns the time this WorkflowJSON was created at.
 
boost::optional< WorkflowStepcurrentStep () const
 Get the current step.
 
unsigned currentStepIndex () const
 Get the zero based index of the current step.
 
boost::optional< std::string > eplusoutErr () const
 Returns the content of eplusout.err file.
 
std::vector< openstudio::pathfilePaths () const
 Returns the paths that will be searched in order for files, default value is '.
 
boost::optional< openstudio::pathfindFile (const openstudio::path &file) const
 Attempts to find a file by path.
 
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.
 
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.
 
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.
 
std::vector< MeasureStepgetMeasureSteps (const MeasureType &measureType) const
 Gets measure steps by measure type.
 
std::vector< std::pair< unsigned, MeasureStep > > getMeasureStepsWithIndex (const MeasureType &measureType) const
 
std::string hash () const
 Get a stored hash of the workflow.
 
bool incrementStep () const
 Increments current step, returns true if there is another step.
 
std::vector< openstudio::pathmeasurePaths () const
 Returns the paths that will be searched in order for measures, default value is '.
 
std::vector< openstudio::pathmodelicaPackages () const
 Returns additional Modelica packages to load prior to simulation.
 
openstudio::path oswDir () const
 Returns the absolute path to the directory this workflow was loaded from or saved to.
 
boost::optional< openstudio::pathoswPath () const
 Returns the absolute path this workflow was loaded from or saved to, empty for new WorkflowJSON.
 
openstudio::path outPath () const
 Returns the path to write output OSW, default value is 'out.osw'.
 
void reset () const
 Reset to re-run the workflow, does not delete steps.
 
void resetFilePaths () const
 Clear paths searched for files.
 
void resetMeasurePaths () const
 Clear paths searched for measures.
 
void resetModelicaPackages () const
 Clears any additional Modelica packages.
 
void resetRunOptions () const
 Reset RunOptions for this workflow.
 
void resetSeedFile () const
 Resets the seed file path.
 
void resetSeedModelicaFile () const
 Resets the seed Modelica file path.
 
void resetWeatherFile () const
 Resets the weather file path.
 
void resetWorkflowSteps () const
 Resets the workflow steps.
 
openstudio::path rootDir () const
 Returns the root directory, default value is '.
 
openstudio::path runDir () const
 Returns the run directory, default value is '.
 
boost::optional< RunOptionsrunOptions () const
 Get RunOptions for this workflow.
 
bool save () const
 Saves this file to the current location.
 
bool saveAs (const openstudio::path &p) const
 Saves this file to a new location.
 
boost::optional< openstudio::pathseedFile () const
 Returns the seed file path.
 
boost::optional< openstudio::pathseedModelicaFile () const
 Returns the seed Modelica file path.
 
boost::optional< std::string > seedModelicaModel () const
 Returns name of the seed Modelica model.
 
void setCompletedStatus (const std::string &status) const
 Sets the completion status, "Success", "Fail", "Invalid", or "Cancel".
 
void setEplusoutErr (const std::string &eplusoutErr) const
 Sets the content of eplusout.err file.
 
bool setMeasureSteps (const MeasureType &measureType, const std::vector< MeasureStep > &steps) const
 Sets measure steps of a given type.
 
bool setModelicaPackages (const std::vector< openstudio::path > &packages) const
 Sets additional Modelica packages to load.
 
bool setOswDir (const openstudio::path &path) const
 Sets the oswDir.
 
bool setOswPath (const openstudio::path &path) const
 Sets the absolute path for this workflow.
 
bool setRootDir (const openstudio::path &path) const
 Sets the rootDir.
 
bool setRunDir (const openstudio::path &path) const
 Sets the runDir.
 
bool setRunOptions (const RunOptions &options) const
 Set RunOptions for this workflow.
 
bool setSeedFile (const openstudio::path &seedFile) const
 Sets the seed file path.
 
bool setSeedModelicaFile (const openstudio::path &modelicaSeedFile) const
 Sets the seed Modelica file path.
 
bool setWeatherFile (const openstudio::path &weatherFile) const
 Sets the weather file path.
 
bool setWorkflowSteps (const std::vector< WorkflowStep > &steps) const
 Assigns the workflow steps.
 
void start () const
 Sets the started at time.
 
boost::optional< DateTimestartedAt () const
 Returns the time this WorkflowJSON was started at.
 
std::string string (bool includeHash=true) const
 Get the workflow as a string.
 
Json::Value toJSON (bool includeHash=true) const
 
boost::optional< DateTimeupdatedAt () const
 Returns the time this WorkflowJSON was updated at.
 
bool validateMeasures () const
 Checks that all measures in the Workflow can be found, and are in the correct order (ModelMeasure > EnergyPlusMeasure > ReportingMeasure)
 
boost::optional< openstudio::pathweatherFile () const
 Returns the weather file path.
 
 WorkflowJSON ()
 Create a new, empty workflow.
 
 WorkflowJSON (const openstudio::path &p)
 Constructor with path, will throw if path does not exist or file is incorrect.
 
 WorkflowJSON (const std::string &s)
 Constructor with string, will throw if string is incorrect.
 
std::vector< WorkflowStepworkflowSteps () const
 Returns the workflow steps.
 

Static Public Member Functions

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

Protected Member Functions

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

Detailed Description

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

Constructor & Destructor Documentation

◆ WorkflowJSON() [1/4]

openstudio::WorkflowJSON::WorkflowJSON ( )

Create a new, empty workflow.

◆ WorkflowJSON() [2/4]

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

Constructor with string, will throw if string is incorrect.

◆ WorkflowJSON() [3/4]

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

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

◆ WorkflowJSON() [4/4]

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

Protected constructor from impl.

Member Function Documentation

◆ absoluteFilePaths()

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

◆ absoluteMeasurePaths()

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

◆ absoluteOutPath()

openstudio::path openstudio::WorkflowJSON::absoluteOutPath ( ) const

◆ absoluteRootDir()

openstudio::path openstudio::WorkflowJSON::absoluteRootDir ( ) const

◆ absoluteRunDir()

openstudio::path openstudio::WorkflowJSON::absoluteRunDir ( ) const

◆ addFilePath()

bool openstudio::WorkflowJSON::addFilePath ( const openstudio::path & path) const

Add a path to the paths searched for files.

◆ addMeasure()

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

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

◆ addMeasurePath()

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

Add a path to the paths searched for measures.

◆ checkForUpdates()

bool openstudio::WorkflowJSON::checkForUpdates ( ) const

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

◆ clone()

WorkflowJSON openstudio::WorkflowJSON::clone ( ) const

Clones this WorkflowJSON into a separate one.

◆ completedAt()

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

Returns the time this WorkflowJSON was completed at.

◆ completedStatus()

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.

◆ computeHash()

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

Compute the current hash of the workflow.

◆ createdAt()

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

Returns the time this WorkflowJSON was created at.

◆ currentStep()

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

Get the current step.

◆ currentStepIndex()

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.

◆ eplusoutErr()

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

Returns the content of eplusout.err file.

◆ filePaths()

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.

◆ findFile() [1/2]

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.

◆ findFile() [2/2]

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

◆ findMeasure() [1/2]

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.

◆ findMeasure() [2/2]

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

◆ getBCLMeasure()

boost::optional< BCLMeasure > openstudio::WorkflowJSON::getBCLMeasure ( const MeasureStep & step) const

Attempts to find the BCLMeasure for a given MeasureStep.

◆ getBCLMeasureByUUID()

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.

◆ getMeasureSteps()

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

Gets measure steps by measure type.

◆ getMeasureStepsWithIndex()

std::vector< std::pair< unsigned, MeasureStep > > openstudio::WorkflowJSON::getMeasureStepsWithIndex ( const MeasureType & measureType) const

◆ hash()

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

Get a stored hash of the workflow.

◆ incrementStep()

bool openstudio::WorkflowJSON::incrementStep ( ) const

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

◆ load() [1/2]

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

Attempt to load a WorkflowJSON from path.

◆ load() [2/2]

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

Attempt to load a WorkflowJSON from string.

◆ measurePaths()

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.

◆ modelicaPackages()

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

Returns additional Modelica packages to load prior to simulation.

Each entry is evaluated relative to filePaths if not absolute.

◆ oswDir()

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.

◆ oswPath()

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

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

◆ outPath()

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.

◆ reset()

void openstudio::WorkflowJSON::reset ( ) const

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

◆ resetFilePaths()

void openstudio::WorkflowJSON::resetFilePaths ( ) const

Clear paths searched for files.

◆ resetMeasurePaths()

void openstudio::WorkflowJSON::resetMeasurePaths ( ) const

Clear paths searched for measures.

◆ resetModelicaPackages()

void openstudio::WorkflowJSON::resetModelicaPackages ( ) const

Clears any additional Modelica packages.

◆ resetRunOptions()

void openstudio::WorkflowJSON::resetRunOptions ( ) const

Reset RunOptions for this workflow.

◆ resetSeedFile()

void openstudio::WorkflowJSON::resetSeedFile ( ) const

Resets the seed file path.

◆ resetSeedModelicaFile()

void openstudio::WorkflowJSON::resetSeedModelicaFile ( ) const

Resets the seed Modelica file path.

◆ resetWeatherFile()

void openstudio::WorkflowJSON::resetWeatherFile ( ) const

Resets the weather file path.

◆ resetWorkflowSteps()

void openstudio::WorkflowJSON::resetWorkflowSteps ( ) const

Resets the workflow steps.

◆ rootDir()

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

Returns the root directory, default value is '.

'. Evaluated relative to oswDir if not absolute.

◆ runDir()

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

Returns the run directory, default value is '.

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

◆ runOptions()

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

Get RunOptions for this workflow.

◆ save()

bool openstudio::WorkflowJSON::save ( ) const

Saves this file to the current location.

◆ saveAs()

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

Saves this file to a new location.

Updates the OSW path.

◆ seedFile()

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

Returns the seed file path.

Evaluated relative to filePaths if not absolute.

◆ seedModelicaFile()

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

Returns the seed Modelica file path.

Evaluated relative to filePaths if not absolute. This can be a single .mo file or a package.mo.

◆ seedModelicaModel()

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

Returns name of the seed Modelica model.

This will be the model that is simulated.

◆ setCompletedStatus()

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

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.

◆ setEplusoutErr()

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

Sets the content of eplusout.err file.

◆ setMeasureSteps()

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

Sets measure steps of a given type.

Does not change other measure steps.

◆ setModelicaPackages()

bool openstudio::WorkflowJSON::setModelicaPackages ( const std::vector< openstudio::path > & packages) const

Sets additional Modelica packages to load.

◆ setOswDir()

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

Sets the oswDir.

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

◆ setOswPath()

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

Sets the absolute path for this workflow.

◆ setRootDir()

bool openstudio::WorkflowJSON::setRootDir ( const openstudio::path & path) const

Sets the rootDir.

◆ setRunDir()

bool openstudio::WorkflowJSON::setRunDir ( const openstudio::path & path) const

Sets the runDir.

◆ setRunOptions()

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

Set RunOptions for this workflow.

◆ setSeedFile()

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

Sets the seed file path.

◆ setSeedModelicaFile()

bool openstudio::WorkflowJSON::setSeedModelicaFile ( const openstudio::path & modelicaSeedFile) const

Sets the seed Modelica file path.

◆ setWeatherFile()

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

Sets the weather file path.

◆ setWorkflowSteps()

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

Assigns the workflow steps.

◆ start()

void openstudio::WorkflowJSON::start ( ) const

Sets the started at time.

◆ startedAt()

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

Returns the time this WorkflowJSON was started at.

◆ string()

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

Get the workflow as a string.

◆ toJSON()

Json::Value openstudio::WorkflowJSON::toJSON ( bool includeHash = true) const

◆ updatedAt()

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

Returns the time this WorkflowJSON was updated at.

◆ validateMeasures()

bool openstudio::WorkflowJSON::validateMeasures ( ) const

Checks that all measures in the Workflow can be found, and are in the correct order (ModelMeasure > EnergyPlusMeasure > ReportingMeasure)

◆ weatherFile()

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

Returns the weather file path.

Evaluated relative to filePaths if not absolute.

◆ workflowSteps()

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

Returns the workflow steps.