src/model/WeatherFile.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef MODEL_WEATHERFILE_HPP | ||
| 7 | #define MODEL_WEATHERFILE_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ModelObject.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/core/Path.hpp" | ||
| 13 | |||
| 14 | namespace openstudio { | ||
| 15 | |||
| 16 | class EpwFile; | ||
| 17 | class DayOfWeek; | ||
| 18 | |||
| 19 | namespace model { | ||
| 20 | |||
| 21 | class Site; | ||
| 22 | |||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | class WeatherFile_Impl; | ||
| 26 | |||
| 27 | } // namespace detail | ||
| 28 | |||
| 29 | /** WeatherFile derives from ModelObject and is an interface to the OpenStudio IDD object named "OS:WeatherFile". | ||
| 30 | * | ||
| 31 | * WeatherFile is a unique object which references an EPW format weather file to use for EnergyPlus simulation. | ||
| 32 | * EnergyPlus requires the weather file for simulation be named in.epw and located in the same directory as the input IDF file. | ||
| 33 | * The WeatherFile object provides a mechanism for an OpenStudio Model to reference a weather file in a more permanent way. | ||
| 34 | * The RunManager is able to locate the actual weather file needed and place it in the EnergyPlus run directory at simulation time. | ||
| 35 | * WeatherFile does not have a public constructor because it is a unique ModelObject. | ||
| 36 | * To get the WeatherFile object for a Model or create one if it does not yet exist use model.getUniqueObject<WeatherFile>(). | ||
| 37 | * To get the WeatherFile object for a Model but not create one if it does not yet exist use model.getOptionalUniqueObject<WeatherFile>(). | ||
| 38 | */ | ||
| 39 | class MODEL_API WeatherFile : public ModelObject | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | /** @name Constructors and Destructors */ | ||
| 43 | //@{ | ||
| 44 | 540 | virtual ~WeatherFile() override = default; | |
| 45 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 46 | 340 | WeatherFile(const WeatherFile& other) = default; | |
| 47 | 107 | WeatherFile(WeatherFile&& other) = default; | |
| 48 | ✗ | WeatherFile& operator=(const WeatherFile&) = default; | |
| 49 | ✗ | WeatherFile& operator=(WeatherFile&&) = default; | |
| 50 | |||
| 51 | //@} | ||
| 52 | /** @name Static Methods */ | ||
| 53 | //@{ | ||
| 54 | |||
| 55 | static IddObjectType iddObjectType(); | ||
| 56 | |||
| 57 | /// Sets WeatherFile in the Model based on EpwFile input. | ||
| 58 | static boost::optional<WeatherFile> setWeatherFile(Model& model, const openstudio::EpwFile& epwFile); | ||
| 59 | |||
| 60 | //@} | ||
| 61 | /** @name Getters */ | ||
| 62 | //@{ | ||
| 63 | |||
| 64 | std::string city() const; | ||
| 65 | |||
| 66 | std::string stateProvinceRegion() const; | ||
| 67 | |||
| 68 | std::string country() const; | ||
| 69 | |||
| 70 | std::string dataSource() const; | ||
| 71 | |||
| 72 | std::string wMONumber() const; | ||
| 73 | |||
| 74 | double latitude() const; | ||
| 75 | |||
| 76 | double longitude() const; | ||
| 77 | |||
| 78 | double timeZone() const; | ||
| 79 | |||
| 80 | double elevation() const; | ||
| 81 | |||
| 82 | bool isElevationDefaulted() const; | ||
| 83 | |||
| 84 | boost::optional<std::string> url() const; | ||
| 85 | |||
| 86 | boost::optional<openstudio::path> path() const; | ||
| 87 | |||
| 88 | boost::optional<std::string> checksum() const; | ||
| 89 | |||
| 90 | boost::optional<int> startDateActualYear() const; | ||
| 91 | |||
| 92 | boost::optional<DayOfWeek> startDayOfWeek() const; | ||
| 93 | |||
| 94 | //@} | ||
| 95 | /** @name Setters */ | ||
| 96 | //@{ | ||
| 97 | |||
| 98 | bool setCity(const std::string& city); | ||
| 99 | |||
| 100 | bool setStateProvinceRegion(const std::string& stateProvinceRegion); | ||
| 101 | |||
| 102 | bool setCountry(const std::string& country); | ||
| 103 | |||
| 104 | bool setDataSource(const std::string& dataSource); | ||
| 105 | |||
| 106 | bool setWMONumber(const std::string& wMONumber); | ||
| 107 | |||
| 108 | bool setLatitude(double latitude); | ||
| 109 | |||
| 110 | bool setLongitude(double longitude); | ||
| 111 | |||
| 112 | bool setTimeZone(double timeZone); | ||
| 113 | |||
| 114 | bool setElevation(double elevation); | ||
| 115 | |||
| 116 | void resetElevation(); | ||
| 117 | |||
| 118 | //bool setUrl(boost::optional<std::string> url); | ||
| 119 | |||
| 120 | //bool setUrl(const std::string& url); | ||
| 121 | |||
| 122 | //void resetUrl(); | ||
| 123 | |||
| 124 | //bool setChecksum(boost::optional<std::string> checksum); | ||
| 125 | |||
| 126 | //bool setChecksum(const std::string& checksum); | ||
| 127 | |||
| 128 | //void resetChecksum(); | ||
| 129 | |||
| 130 | //@} | ||
| 131 | |||
| 132 | // Returns the parent Site. | ||
| 133 | boost::optional<Site> site() const; | ||
| 134 | |||
| 135 | /** Load and return the EpwFile. Optional argument dir can be used as a base path | ||
| 136 | if url field is relative. */ | ||
| 137 | boost::optional<EpwFile> file(const openstudio::path& dir = openstudio::path()) const; | ||
| 138 | |||
| 139 | /** Save the url as relative to basePath, or just keep the file name and extension if | ||
| 140 | * basePath.empty(). */ | ||
| 141 | bool makeUrlRelative(const openstudio::path& basePath = openstudio::path()); | ||
| 142 | |||
| 143 | /** Search for file and save the absolute url if successful. */ | ||
| 144 | bool makeUrlAbsolute(const openstudio::path& searchDirectory); | ||
| 145 | |||
| 146 | // Returns the environment name used if the RunPeriod object has no name, | ||
| 147 | // environmentName = "City StateProvinceRegion Country DataSource WMO#=WMONumber" | ||
| 148 | boost::optional<std::string> environmentName() const; | ||
| 149 | |||
| 150 | protected: | ||
| 151 | explicit WeatherFile(Model& model); | ||
| 152 | |||
| 153 | /// @cond | ||
| 154 | using ImplType = detail::WeatherFile_Impl; | ||
| 155 | |||
| 156 | friend class Model; | ||
| 157 | friend class openstudio::IdfObject; | ||
| 158 | |||
| 159 | explicit WeatherFile(std::shared_ptr<detail::WeatherFile_Impl> impl); | ||
| 160 | |||
| 161 | /// @endcond | ||
| 162 | private: | ||
| 163 | REGISTER_LOGGER("openstudio.model.WeatherFile"); | ||
| 164 | }; | ||
| 165 | |||
| 166 | /** \relates WeatherFile*/ | ||
| 167 | using OptionalWeatherFile = boost::optional<WeatherFile>; | ||
| 168 | |||
| 169 | /** \relates WeatherFile*/ | ||
| 170 | using WeatherFileVector = std::vector<WeatherFile>; | ||
| 171 | |||
| 172 | } // namespace model | ||
| 173 | } // namespace openstudio | ||
| 174 | |||
| 175 | #endif // MODEL_WEATHERFILE_HPP | ||
| 176 |