src/energyplus/ForwardTranslator/ForwardTranslateMeterCustom.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/MeterCustom.hpp" | ||
| 10 | #include "../../model/MeterCustom_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../../utilities/core/Logger.hpp" | ||
| 13 | #include "../../utilities/core/Assert.hpp" | ||
| 14 | |||
| 15 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 16 | #include <utilities/idd/Meter_Custom_FieldEnums.hxx> | ||
| 17 | |||
| 18 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 19 | #include <utilities/idd/IddEnums.hxx> | ||
| 20 | #include <utilities/idd/IddFactory.hxx> | ||
| 21 | |||
| 22 | using namespace openstudio::model; | ||
| 23 | |||
| 24 | // I don't think I'm using this | ||
| 25 | //using namespace std; | ||
| 26 | |||
| 27 | // I don't know if I need this | ||
| 28 | using namespace openstudio::model; | ||
| 29 | |||
| 30 | namespace openstudio { | ||
| 31 | |||
| 32 | namespace energyplus { | ||
| 33 | |||
| 34 | ✗ | boost::optional<IdfObject> ForwardTranslator::translateMeterCustom(MeterCustom& modelObject) { | |
| 35 | |||
| 36 | ✗ | boost::optional<std::string> s; | |
| 37 | ✗ | boost::optional<double> value; | |
| 38 | |||
| 39 | ✗ | IdfObject idfObject(IddObjectType::Meter_Custom); | |
| 40 | |||
| 41 | ✗ | m_idfObjects.push_back(idfObject); | |
| 42 | |||
| 43 | ✗ | s = modelObject.name(); | |
| 44 | ✗ | if (s) { | |
| 45 | ✗ | idfObject.setName(*s); | |
| 46 | } | ||
| 47 | |||
| 48 | // FuelType | ||
| 49 | ✗ | if ((s = modelObject.fuelType())) { | |
| 50 | ✗ | idfObject.setString(Meter_CustomFields::ResourceType, s.get()); | |
| 51 | } | ||
| 52 | |||
| 53 | // Handle the (Key Name, Output Variable or Meter Name) pairs | ||
| 54 | ✗ | std::vector<std::pair<std::string, std::string>> keyVarGroups = modelObject.keyVarGroups(); | |
| 55 | |||
| 56 | ✗ | if (!keyVarGroups.empty()) { | |
| 57 | ✗ | for (const auto& keyVarGroup : keyVarGroups) { | |
| 58 | ✗ | IdfExtensibleGroup eg = idfObject.pushExtensibleGroup(); | |
| 59 | |||
| 60 | ✗ | eg.setString(Meter_CustomExtensibleFields::KeyName, keyVarGroup.first); | |
| 61 | ✗ | eg.setString(Meter_CustomExtensibleFields::OutputVariableorMeterName, keyVarGroup.second); | |
| 62 | ✗ | } | |
| 63 | } else { | ||
| 64 | ✗ | LOG(Error, modelObject.briefDescription() << ": At least one pair of (Key Name, Output Variable or Meter Name) required"); | |
| 65 | ✗ | return boost::none; | |
| 66 | } | ||
| 67 | |||
| 68 | ✗ | return boost::optional<IdfObject>(idfObject); | |
| 69 | ✗ | } | |
| 70 | |||
| 71 | } // namespace energyplus | ||
| 72 | |||
| 73 | } // namespace openstudio | ||
| 74 |