src/energyplus/ForwardTranslator/ForwardTranslateSite.cpp
| 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 | #include "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/Site.hpp" | ||
| 10 | #include "../../model/Site_Impl.hpp" | ||
| 11 | #include "../../model/ShadingSurfaceGroup.hpp" | ||
| 12 | |||
| 13 | #include <utilities/idd/Site_Location_FieldEnums.hxx> | ||
| 14 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 15 | #include <utilities/idd/IddEnums.hxx> | ||
| 16 | |||
| 17 | using namespace openstudio::model; | ||
| 18 | |||
| 19 | using namespace std; | ||
| 20 | |||
| 21 | namespace openstudio { | ||
| 22 | |||
| 23 | namespace energyplus { | ||
| 24 | |||
| 25 | 51 | boost::optional<IdfObject> ForwardTranslator::translateSite(Site& modelObject) { | |
| 26 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | IdfObject site = createAndRegisterIdfObject(openstudio::IddObjectType::Site_Location, modelObject); |
| 27 | |||
| 28 |
1/1✓ Branch 1 taken 51 times.
|
51 | OptionalString optS = modelObject.name(); |
| 29 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (optS) { |
| 30 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | site.setName(*optS); |
| 31 | } | ||
| 32 | |||
| 33 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | OptionalDouble od = modelObject.latitude(); |
| 34 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (od) { |
| 35 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | site.setDouble(Site_LocationFields::Latitude, *od); |
| 36 | } | ||
| 37 | |||
| 38 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | od = modelObject.longitude(); |
| 39 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (od) { |
| 40 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | site.setDouble(Site_LocationFields::Longitude, *od); |
| 41 | } | ||
| 42 | |||
| 43 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | od = modelObject.timeZone(); |
| 44 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (od) { |
| 45 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | site.setDouble(Site_LocationFields::TimeZone, *od); |
| 46 | } | ||
| 47 | |||
| 48 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | od = modelObject.elevation(); |
| 49 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (od) { |
| 50 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | site.setDouble(Site_LocationFields::Elevation, *od); |
| 51 | } | ||
| 52 | |||
| 53 |
3/3✓ Branch 1 taken 51 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 50 times.
|
51 | if (!modelObject.isKeepSiteLocationInformationDefaulted()) { |
| 54 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (modelObject.keepSiteLocationInformation()) { |
| 55 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | site.setString(Site_LocationFields::KeepSiteLocationInformation, "Yes"); |
| 56 | } else { | ||
| 57 | ✗ | site.setString(Site_LocationFields::KeepSiteLocationInformation, "No"); | |
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | // translate shading groups | ||
| 62 |
1/1✓ Branch 1 taken 51 times.
|
51 | ShadingSurfaceGroupVector shadingSurfaceGroups = modelObject.shadingSurfaceGroups(); |
| 63 |
1/1✓ Branch 3 taken 51 times.
|
51 | std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess()); |
| 64 |
2/2✓ Branch 4 taken 35 times.
✓ Branch 5 taken 51 times.
|
86 | for (ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups) { |
| 65 |
1/1✓ Branch 1 taken 35 times.
|
35 | translateAndMapModelObject(shadingSurfaceGroup); |
| 66 | } | ||
| 67 | |||
| 68 |
1/1✓ Branch 1 taken 51 times.
|
102 | return boost::optional<IdfObject>(site); |
| 69 | 51 | } | |
| 70 | |||
| 71 | } // namespace energyplus | ||
| 72 | |||
| 73 | } // namespace openstudio | ||
| 74 |