src/energyplus/ReverseTranslator/ReverseTranslateElectricLoadCenterStorageSimple.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 "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/ElectricLoadCenterStorageSimple.hpp" | ||
| 9 | #include "../../model/ElectricLoadCenterStorageSimple_Impl.hpp" | ||
| 10 | |||
| 11 | #include "../../model/Schedule.hpp" | ||
| 12 | #include "../../model/Schedule_Impl.hpp" | ||
| 13 | #include "../../model/ThermalZone.hpp" | ||
| 14 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 15 | #include "../../model/Space.hpp" | ||
| 16 | #include "../../model/Space_Impl.hpp" | ||
| 17 | |||
| 18 | #include <utilities/idd/ElectricLoadCenter_Storage_Simple_FieldEnums.hxx> | ||
| 19 | |||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | |||
| 23 | using namespace openstudio::model; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | ✗ | OptionalModelObject ReverseTranslator::translateElectricLoadCenterStorageSimple(const WorkspaceObject& workspaceObject) { | |
| 30 | |||
| 31 | ✗ | OptionalDouble d; | |
| 32 | ✗ | boost::optional<WorkspaceObject> owo; | |
| 33 | ✗ | OptionalString optS; | |
| 34 | |||
| 35 | ✗ | openstudio::model::ElectricLoadCenterStorageSimple elcStorSimple(m_model); | |
| 36 | |||
| 37 | // Name | ||
| 38 | ✗ | optS = workspaceObject.name(); | |
| 39 | ✗ | if (optS) { | |
| 40 | ✗ | elcStorSimple.setName(*optS); | |
| 41 | } | ||
| 42 | |||
| 43 | // AvailabilityScheduleName | ||
| 44 | ✗ | if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_SimpleFields::AvailabilityScheduleName))) { | |
| 45 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(owo.get())) { | |
| 46 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 47 | ✗ | elcStorSimple.setAvailabilitySchedule(schedule.get()); | |
| 48 | ✗ | } | |
| 49 | ✗ | } | |
| 50 | } | ||
| 51 | |||
| 52 | // ZoneName | ||
| 53 | ✗ | if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_SimpleFields::ZoneName))) { | |
| 54 | ✗ | if (boost::optional<ModelObject> mo_ = translateAndMapWorkspaceObject(owo.get())) { | |
| 55 | // Zone is translated, and a Space is returned instead | ||
| 56 | ✗ | if (boost::optional<Space> space_ = mo_->optionalCast<Space>()) { | |
| 57 | ✗ | if (auto z_ = space_->thermalZone()) { | |
| 58 | ✗ | elcStorSimple.setThermalZone(z_.get()); | |
| 59 | ✗ | } | |
| 60 | } else { | ||
| 61 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Zone Name'"); | |
| 62 | ✗ | } | |
| 63 | ✗ | } | |
| 64 | } | ||
| 65 | |||
| 66 | // Radiative Fraction, defaults (double) | ||
| 67 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::RadiativeFractionforZoneHeatGains); | |
| 68 | ✗ | if (d) { | |
| 69 | ✗ | elcStorSimple.setRadiativeFractionforZoneHeatGains(*d); | |
| 70 | } | ||
| 71 | |||
| 72 | // nominalEnergeticEfficiencyforCharging, defaults | ||
| 73 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::NominalEnergeticEfficiencyforCharging); | |
| 74 | ✗ | if (d) { | |
| 75 | ✗ | elcStorSimple.setNominalEnergeticEfficiencyforCharging(*d); | |
| 76 | } | ||
| 77 | |||
| 78 | // nominalEnergeticEfficiencyforDischarging, defaults | ||
| 79 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::NominalDischargingEnergeticEfficiency); | |
| 80 | ✗ | if (d) { | |
| 81 | ✗ | elcStorSimple.setNominalDischargingEnergeticEfficiency(*d); | |
| 82 | } | ||
| 83 | |||
| 84 | // maximumStorageCapacity, required, assigned in ctor | ||
| 85 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::MaximumStorageCapacity); | |
| 86 | ✗ | if (d) { | |
| 87 | ✗ | elcStorSimple.setMaximumStorageCapacity(*d); | |
| 88 | } else { | ||
| 89 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have a required maximum Storage Capacity"); | |
| 90 | } | ||
| 91 | |||
| 92 | // maximumPowerforDischarging, required, assigned in ctor | ||
| 93 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::MaximumPowerforDischarging); | |
| 94 | ✗ | if (d) { | |
| 95 | ✗ | elcStorSimple.setMaximumPowerforDischarging(*d); | |
| 96 | } else { | ||
| 97 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have a required maximum power for discharging"); | |
| 98 | } | ||
| 99 | |||
| 100 | // maximumPowerforCharging, required, assigned in ctor | ||
| 101 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::MaximumPowerforCharging); | |
| 102 | ✗ | if (d) { | |
| 103 | ✗ | elcStorSimple.setMaximumPowerforCharging(*d); | |
| 104 | } else { | ||
| 105 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have a required maximum power for charging"); | |
| 106 | } | ||
| 107 | |||
| 108 | // initialStateofCharge | ||
| 109 | ✗ | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_SimpleFields::InitialStateofCharge); | |
| 110 | ✗ | if (d) { | |
| 111 | ✗ | elcStorSimple.setInitialStateofCharge(*d); | |
| 112 | } | ||
| 113 | |||
| 114 | ✗ | return elcStorSimple; | |
| 115 | ✗ | } | |
| 116 | |||
| 117 | } // namespace energyplus | ||
| 118 | |||
| 119 | } // namespace openstudio | ||
| 120 |